我正在WPF中将视觉效果打印到收据打印机(Star TSP 700II).当视觉很小时,它很好,它打印好.
然而,当视觉增长时,它将剪切图像并在星形打印机的卷筒上打印到一定大小,然后它只是切割而不打印图像的其余部分.
PrintDialog.PrintVisual(Grid1, "Test");
Run Code Online (Sandbox Code Playgroud)
我已经尝试调整PageMediaSize,但这并没有改变打印输出上的任何内容.
有趣的是,当我打印到Microsoft XPS Document Writer时,保存的文件具有完整图像.

我也注意到它打印的尺寸总是最大高度= A4页面的高度.问题是如何让它打印超过A4的高度(当我从打印机首选项打印测试文档时,它能够执行此操作).
我已将一些Blob上传到azure。当我登录时,它们显示在浏览器中,但是当我尝试下载它们时,出现以下消息:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>BlobNotFound</Code>
<Message>
The specified blob does not exist. RequestId:d3cd1a18-1e48-47bd-9985-4ab7e655eed2 Time:2013-09-19T15:02:16.4158548Z
</Message>
</Error>
Run Code Online (Sandbox Code Playgroud)
屏幕截图浏览(显示斑点)
屏幕截图显示了我单击下载后发生的情况

我有一个文本框KeyUp事件触发器连接到WPF中的命令.我需要传递作为命令参数按下的实际键.
该命令执行正常,但处理它的代码需要知道按下的实际键(记住这可能是一个输入键或任何不仅仅是一个字母,所以我无法从TextBox.text获取它).
无法弄清楚如何做到这一点.XAML:
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Run Code Online (Sandbox Code Playgroud)
XAML:
<TextBox Height="23" Name="TextBoxSelectionSearch" Width="148" Tag="Enter Selection Name" Text="{Binding Path=SelectionEditorFilter.SelectionNameFilter,UpdateSourceTrigger=PropertyChanged}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyUp">
<i:InvokeCommandAction Command="{Binding SelectionEditorSelectionNameFilterKeyUpCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
Run Code Online (Sandbox Code Playgroud) 我将一些A4图像和较小的图像保存到文件中.
我想知道什么是最好的格式.它们仅从灰度扫描中返回.然而,一些图像的尺寸非常大(与我们预期的相比).
我们已经尝试将它们保存为具有不同质量的JPEG,但仍然无法将它们视为我们想要的那么小,JPEG不是最有效的格式.
A4保存质量8保存为196KB较小图像保存质量8保存为28KB
因为这个图像的大部分都是空白区域,所以我们期望文件大小要小得多.文件大小比图像质量更重要.我们做错了吗?
这是A4图像样本

这是样本较小的图像

我们的代码是用c#编写的
// Get a bitmap.
Bitmap bmp1 = new Bitmap(@"c:\TestImageFromScanner.jpg");
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
// Create an Encoder object based on the GUID
// for the Quality parameter category.
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Quality;
// Create an EncoderParameters object.
// An EncoderParameters object has an array of EncoderParameter
// objects. In this case, there is only one
// EncoderParameter object in the array.
EncoderParameters myEncoderParameters = new EncoderParameters(1);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder,8L);
myEncoderParameters.Param[0] …Run Code Online (Sandbox Code Playgroud) 我有一个打开端口 5555 的 powershell 脚本,但它默认为 profile = private,当我希望它全部为(私有、公共、域)时。如何修改脚本以实现此目的?
$port = New-Object -ComObject HNetCfg.FWOpenPort
$port.Port = 5555
$port.Name = 'MyPort'
$port.Enabled = $true
$fwMgr = New-Object -ComObject HNetCfg.FwMgr
$profile = $fwMgr.LocalPolicy.CurrentProfile
$profile.GloballyOpenPorts.Add($port)
$port = New-Object -ComObject HNetCfg.FWOpenPort
$port.Port = 6521
$port.Name = 'ArkleSQL'
$port.Enabled = $true
$fwMgr = New-Object -ComObject HNetCfg.FwMgr
$profile = $fwMgr.LocalPolicy.CurrentProfile
$profile.GloballyOpenPorts.Add($port)
Run Code Online (Sandbox Code Playgroud) Visual Studio 2012 不断提示我进行 SQL Server 连接(反复),这很烦人。当我打开我的解决方案时(甚至在我运行它之前)就会发生这种情况。
我的同事没有从 TFS 源代码控制中获得相同的解决方案。
我已经尝试搜索显示的服务器/数据库的所有文件,但没有任何返回。
这阻碍了我做任何工作的努力。

我想检查一个实体对象是否已更改(包括它的任何子对象是否已被修改)。我正在使用实体框架 4.4
我的代码基本上从数据库加载对象并将值应用于某些属性(但它们可能与原始属性相同)。
我知道我可以检查entityObject.EntityState,但是如果孩子有变化,它会更新,还是我需要遍历对象中的所有孩子?
这是因为如果它有我需要运行一大堆其他代码(例如向用户发送电子邮件警报和说值已更新的内容,但如果它们尚未更新,我不想运行该代码更新)。
我有一些c#代码在Vista和Windows 7上正常工作但在Windows XP上抛出了GDI +错误(安装了Service Pack 3).
在XP上抛出错误
System.Runtime.INteropServices.ExternalException(0x80004005):在System.Drawing.Graphics.DrawImage(Image image,Int32 x,Int32 y)的System.Drawing.Graphics.CheckErrorStatus(Int32Status)中的GDI +中发生一般错误.在System.Drawing .Graphics.DrawImageUnscaled(Image image,Int32 x,Int 32 y)at mysolution.Core.ImageTools.ConvertToBitonal(Bitmap orginal,Int32 threshold)
此行代码中断:
using (var g = Graphics.FromImage(source))
{
g.DrawImageUnscaled(original, 0, 0); // Error Is Thrown Here
}
Run Code Online (Sandbox Code Playgroud)
WpFAppTestingConvertToBitonalCS
....
以下是我正在调用的全部功能.
public static Bitmap ConvertToBitonal(Bitmap original, int threshold)
{
Bitmap source;
// If original bitmap is not already in 32 BPP, ARGB format, then convert
if (original.PixelFormat != PixelFormat.Format32bppArgb)
{
source = new Bitmap(original.Width, original.Height, PixelFormat.Format32bppArgb);
source.SetResolution(original.HorizontalResolution, original.VerticalResolution);
using (var g = …Run Code Online (Sandbox Code Playgroud) 我正在使用ac#memory cache(System.Runtime.Caching)并且它正在填满,并使用比预期更多的ram.无论如何都要列出缓存中每个对象占用缓存的大小
我想编写与此类似的代码,以便我可以确定哪个特定项目导致了问题?
private void ListSizeOfEachItemInCache()
{
foreach {var item in Cache.Items}
{
Console.WriteLine(string.Format(item.Key, item.CacheSize));
}
}
Run Code Online (Sandbox Code Playgroud)
我的项通常是包含其中集合的类,并且具有大对象图.但是,如果我将它们序列化到磁盘,使用数据协定序列化程序,它们似乎不会填充磁盘上的空间,因为它们似乎在RAM中.这导致我认为文件缓存可能更好(因为从远程数据库中检索项目 - 甚至不在本地).
private static readonly MemoryCache Cache = MemoryCache.Default;
Run Code Online (Sandbox Code Playgroud)
我已经看到有关在内存中列出对象大小的其他问题,但这是不同的,因为我想要它在内存缓存中占用的确切大小(我不能假设它会完全相同,也许它有一些其他开销,因为缓存需要知道一些其他数据,例如何时添加,它的到期策略等).
我有两个WPF单元格样式,我想基于转换器应用它们.我是我的样本下面我试图改变背景颜色(在实际应用中我会改变更多,但这不是问题的重点,所以我只是简化).
<Style TargetType="{x:Type DataGridCell}" x:Key="WinCellStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border x:Name="border"
Background="LightGreen"
BorderBrush="Transparent"
BorderThickness="1"
SnapsToDevicePixels="True">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type DataGridCell}" x:Key="LossCellStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border x:Name="border"
Background="LightSalmon"
BorderBrush="Transparent"
BorderThickness="1"
SnapsToDevicePixels="True">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
然后我有一个转换器:
public class AmountToCellStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var valueAsDecimal = (decimal?) value;
if (valueAsDecimal > 0)
{
return …Run Code Online (Sandbox Code Playgroud)