小编Abd*_*usa的帖子

在哪里放试试

考虑这种情况:我有3层应用程序,当用户点击按钮时,按钮事件处理程序调用biz层中的方法,该方法对我的按钮事件处理程序提供的数据执行任何操作,然后将该数据传递给发送的数据Access层他们到后端数据库.问题是在哪里放试试?在数据层,在商业层,在表示层或可能把它放在所有这些?在这种情况下,表示异常处理的最佳策略是什么?

.net c#

19
推荐指数
3
解决办法
8354
查看次数

在c#中从右到左打印

根据msdn:http: //www.microsoft.com/middleeast/msdn/arabicsupp.aspx

GDI +如何支持阿拉伯语?

GDI +支持阿拉伯文本操作,包括输出设备,屏幕和打印机的RTL读取顺序的打印文本.Graphics.DrawString方法使用指定的StringFormat对象的格式属性,使用指定的Brush和Font对象在指定的x,y位置或矩形(根据其重载)绘制指定的文本字符串.StringFormat对象包括文本布局信息,例如文本阅读顺序.

因此,您可以轻松地将图形对象的原点移动到Right-Top而不是Left-Top,以便平滑地在屏幕上的指定位置打印出阿拉伯文本,而无需显式计算位置.

虽然将(X,Y)坐标设置为(0,0)时也是如此,但如果我想增加X坐标以在纸张上的特定区域打印,则X协调将增加到纸张的右侧而不是在从右到左打印时应该保持原样; 这意味着在纸张外打印.看这个演示:

static void Main(string[] args)
{
    PrintDocument p = new PrintDocument();
    p.PrintPage += new PrintPageEventHandler(PrintPage);
    p.Print();
}

static void PrintPage(object sender, PrintPageEventArgs e)
{
    string drawString = "?????? ?????";
    SolidBrush drawBrush = new SolidBrush(Color.Black);
    Font drawFont = new System.Drawing.Font("Arail", 16);
    RectangleF recAtZero = new RectangleF(0, 0, e.PageBounds.Width, e.PageBounds.Height);
    StringFormat drawFormat = new StringFormat();

    drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft;

    e.Graphics.DrawString(drawString, drawFont, drawBrush, recAtZero, drawFormat);
    RectangleF recAtGreaterThantZero = new RectangleF(300, 0, e.PageBounds.Width, e.PageBounds.Height);
    e.Graphics.DrawString(drawString, …
Run Code Online (Sandbox Code Playgroud)

.net c# printing graphics

18
推荐指数
2
解决办法
1万
查看次数

由于DelegateCommand导致WPF应用程序中的内存泄漏

我刚刚使用MVVM模式完成了用WPF和c#编写的桌面应用程序.在这个应用程序中,我使用Delegate Command实现来包装我的ModelView中公开的ICommands属性.问题是这些DelegateCommands阻止我的ModelView和View在关闭视图后被垃圾收集.因此,在我终止整个应用程序之前,它一直保持冷静.我分析了应用程序,我发现它是关于将模型视图保存在内存中的委托命令.我怎么能避免这种情况,这是mvvm模式的本质,还是我的模式的植入?谢谢.

编辑:这是我实现MVVM模式的小但完整的部分

第一:CommandDelegte类

class DelegateCommand:ICommand
{
    private Action<object> execute;
    private Predicate<object> canExcute;
    public DelegateCommand(Action<object> execute, Predicate<object> canExecute)
    {
        if (execute == null)
        {
            throw new ArgumentNullException("execute");
        }
        this.execute = execute;
        this.canExcute = canExecute;
    }
    public bool CanExecute(object parameter)
    {
        if (this.canExcute != null)
        {
            return canExcute(parameter);
        }
        return true;
    }

    public event EventHandler CanExecuteChanged
    {
        add { CommandManager.RequerySuggested += value; }
        remove { CommandManager.RequerySuggested -= value; }
    }


    public void Execute(object parameter)
    {
        this.execute(parameter);
    }
}
Run Code Online (Sandbox Code Playgroud)

第二:ModelView类

public class …
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm delegatecommand

9
推荐指数
1
解决办法
6908
查看次数

什么是代码优化?

当说这段代码需要一些优化,或者可能是一些如何优化时,这是什么意思?哪种代码需要优化?如何对c#中的代码进行优化?有什么好处?

c# optimization

7
推荐指数
2
解决办法
1万
查看次数

标签 统计

c# ×4

.net ×2

delegatecommand ×1

graphics ×1

mvvm ×1

optimization ×1

printing ×1

wpf ×1