心如止水

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2016年7月7日

摘要: mutex有一个名字,如果这个exe已经打开了,createNew返回的就是false,程序就退出了。 这是个wpf application的例子 protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); b 阅读全文
posted @ 2016-07-07 16:34 cutebear 阅读(662) 评论(0) 推荐(0) 编辑

2012年5月31日

摘要: 首先介绍CommandManager类,它有一个重要的静态事件:RequerySuggested: Occurs when the CommandManager detects conditions that might change the ability of a command to execute.当CommandManager认为当前的某个改变或动作有可能会改变command的能否执行的状态时,就触发该事件。例如焦点改变,所以这个事件会多次被触发。另外有一个重要的静态方法:InvalidateRequerySuggested(): Forces the CommandManager 阅读全文
posted @ 2012-05-31 15:27 cutebear 阅读(5361) 评论(0) 推荐(1) 编辑

2012年5月30日

摘要: LabelTool有一个SmallImage属性,是一个ImageSource类型,试图去旋转这个ImageSource没有成功。有个类TransformedBitmap可以用来旋转ImageSource,但它只支持90度旋转,所以不能用。于是通过更改它的Template实现。xaml:View Code <Window x:Class="RotatingImageInLabelTool.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml 阅读全文
posted @ 2012-05-30 14:55 cutebear 阅读(373) 评论(0) 推荐(0) 编辑

2012年5月15日

摘要: http://files.cnblogs.com/bear831204/XPathTest.zip部分代码:WriteElements("The root bookstore, this is the whole document:", "./bookstore"); WriteElements("All <first-name> elements:", ".//first-name"); WriteElements("First <author> inside each < 阅读全文
posted @ 2012-05-15 15:11 cutebear 阅读(258) 评论(0) 推荐(0) 编辑

2012年5月3日

摘要: class Program { static void Main(string[] args) { var numbers = new int[] { 6, 4, 3, 10, 2, 21, 15, 1, 8, 9, 24, 64, 43, 767, 7, 3, 8, 22, 87, 28, 56, 76, 23, 88, 13, 554, 775, 20 }; QuickSort(numbers, 0, numbers.Length - 1); foreach (var n in numbers) Console.Write(n + " "); Console.Read( 阅读全文
posted @ 2012-05-03 14:51 cutebear 阅读(231) 评论(0) 推荐(0) 编辑

2012年4月26日

摘要: /// <summary> /// Uses letterCount array to record each letter's cout, count of letter 'a' stored in letterCount[0], /// count of letter 'b' stored in letterCount[1], count of letter 'c' sto... 阅读全文
posted @ 2012-04-26 16:30 cutebear 阅读(465) 评论(0) 推荐(0) 编辑

2012年4月24日

摘要: 1. The following sample uses threads and lock. As long as the lock statement is present, the statement block is a critical section and balance will never become a negative number. // using System.Threading; class Account { private Object thisLock = new Object(); int balance; ... 阅读全文
posted @ 2012-04-24 16:58 cutebear 阅读(621) 评论(0) 推荐(0) 编辑

2012年4月23日

摘要: 主窗口:namespace WindowsFormsApplication17{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } public event EventHandler Form1Te... 阅读全文
posted @ 2012-04-23 17:00 cutebear 阅读(375) 评论(0) 推荐(0) 编辑

2012年4月22日

摘要: 1. 规则:允许 Dispose 方法被调用多次而不引发异常。 此方法在首次调用后应该什么也不做。2. using 语句允许程序员指定使用资源的对象应当何时释放资源。为 using 语句提供的对象必须实现 IDisposable 接口,此接口提供了 Dispose 方法,该方法将释放此对象的资源。3. Close和DisposeIn most .NET framework classes, there is no difference between Close() and Dispose(). For example, these methods do the same thing in t 阅读全文
posted @ 2012-04-22 22:57 cutebear 阅读(297) 评论(0) 推荐(0) 编辑

2012年4月20日

摘要: 原文:http://www.cnblogs.com/artech/archive/2007/05/06/737130.html深入理解string和如何高效地使用string 无论你所使用的是哪种编程语言,我们都不得不承认这样一个共识:string是我们使用最为频繁的一种对象。但是string的常用性并不意味着它的简单性,而且我认为,正是由于string的频繁使用才会促使其设计人员在string的设计上花大量的功夫。所以正是这种你天天见面的string,蕴含了很多精妙的设计思想。一个月以前我写了一篇讨论字符串的驻留(string interning)的文章,我今天将会以字符串的驻留为基础,进一 阅读全文
posted @ 2012-04-20 15:45 cutebear 阅读(262) 评论(0) 推荐(0) 编辑

摘要: 原文:http://www.cnblogs.com/artech/archive/2007/03/04/663728.aspx关于字符串的驻留的机制,对于那些了解它的人肯定会认为很简单,但是我相信会有很大一部分人对它存在迷惑。在开始关于字符串的驻留之前,先给出一个有趣的Sample:Code Snip:staticvoidMain(string[]args){stringstr1="ABCD1234";stringstr2="ABCD1234";stringstr3="ABCD";stringstr4="1234" 阅读全文
posted @ 2012-04-20 15:41 cutebear 阅读(215) 评论(0) 推荐(0) 编辑

摘要: 参考自:http://www.cnblogs.com/fox23/archive/2008/07/26/understanding-immutable-in-csharp.html有一种很简单也很受用的编程(不仅仅是C#)宗旨,就是所谓的"Immutability"(不可变性质)。如果一个类的实例是immutable的,那么我们把这个类也称作immutable class。这样说来,似乎immutable的确是一个相当简单的东西,不过从以下几个问题中你可以找到使用immutable对象的便利之处。我们可以想一下,为什么编写一个多线程的应用程序要相对困难一些?那是因为在访问某 阅读全文
posted @ 2012-04-20 15:20 cutebear 阅读(858) 评论(0) 推荐(0) 编辑

2012年4月18日

摘要: 对访问修饰关键字public, protected, internal and private的说明1.msdn: Internal types or members are accessible only within files in the same assembly.只要在同一个assembly中就能访问,而不是命名空间。如下面的例子,在同一个assembly ClassLibrary2.dll中:namespace ClassLibrary2{ public class Class1 { protected string TestString1 { get; set; } inter 阅读全文
posted @ 2012-04-18 16:07 cutebear 阅读(1808) 评论(1) 推荐(2) 编辑

2012年4月14日

摘要: 原文:http://www.cnblogs.com/tedzhao/archive/2011/11/08/WPF_FrameworkElement_LoadedAndInitialized.html在WPF中FrameworkElement类定义了两个事件:Loaded和Initialized事件。当控件被加载到页面上的 时候,这两个事件会相继发生, 那么这两个事件的差别是什么哪?在进行自定义控件开发的时候,应该如何使用这两个事件那? 小结:Initialized事件:该事件表明Frameworkelement已经被创建, 而且它的所有属性已经被设置。通常情况下子Element的事件会先于父E 阅读全文
posted @ 2012-04-14 17:54 cutebear 阅读(657) 评论(0) 推荐(1) 编辑

摘要: 原文:http://www.c-sharpcorner.com/uploadfile/37db1d/understanding-wpf-application-lifecycle/1. What is the Application Class: When we run any WPF application, it is represented by an instance of the System.Windows.Application class. The job of this class is to track all open windows in our application 阅读全文
posted @ 2012-04-14 16:48 cutebear 阅读(339) 评论(0) 推荐(0) 编辑