代码改变世界

Wpf和WinForm在窗体中处理用户自定义消息的不同方式

2013-01-08 15:19 by panmin, 1350 阅读, 0 推荐, 收藏,
摘要:WPF:在Visual的句柄创建后(如OnLoad、OnSourceInitialized代码里),使用下面方法:方法一:HwndSource source =PresentationSource.FromVisual(this) as HwndSource; //添加命名空间System.Windows.Interopif(source != null) source.AddHook(WndProc);方法二:HwndSource source =HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);if(source != nu 阅读全文

C# 中的奇进偶舍

2013-01-08 14:51 by panmin, 474 阅读, 0 推荐, 收藏,
摘要:float f = -123.567F; int i = (int)f;//-123int i1 = Convert.ToInt32(f);//-124注:奇进偶舍:http://baike.baidu.com/view/4337461.htm 阅读全文

应用程序域的使用 AppDomain

2013-01-08 12:53 by panmin, 302 阅读, 0 推荐, 收藏,
摘要:1、加载和卸载域static void Main(){ // Create an Application Domain: System.AppDomain newDomain = System.AppDomain.CreateDomain("NewApplicationDomain");// Load and execute an assembly: newDomain.ExecuteAssembly(@"c:\HelloWorld.exe");// Unload the application domain: System.AppDomain.Unlo 阅读全文

wpf与winForm界面控件遍历

2013-01-08 12:11 by panmin, 811 阅读, 1 推荐, 收藏,
摘要:WinForm: public void 遍历(Control c, ref List<Control> list ) { foreach (Control item in c.Controls) { list.Add(item); if (item.Controls != null && item.Controls.Count != 0) { 遍历(item, ref list); } } } public void... 阅读全文

Wpf 实现拖拽效果

2013-01-06 15:21 by panmin, 4513 阅读, 0 推荐, 收藏,
摘要:1、设置源控件和目标控件的AllowDrop=truelistBox1.AllowDrop = true;<Style TargetType="ListBoxItem"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <StackPanel Name="grid"> <Image Source="{Binding}"/> <TextBlock Text= 阅读全文

WPF ListView实现DataGrid同样的效果

2013-01-06 10:21 by panmin, 765 阅读, 0 推荐, 收藏,
摘要:<ListView><ListView.View><GridView><!--表示一种视图模式,该模式以列的形式显示ListView控件的数据项源文档 <http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=ZH-CN&k=k(SYSTEM.WINDOWS.CONTROLS.GRIDVIEW);k(VS.XAMLEDITOR);k(SOLUTIONITEMSPROJECT);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2 阅读全文

Wpf实现打印Xaml文件功能

2013-01-05 09:23 by panmin, 2003 阅读, 1 推荐, 收藏,
摘要:功能点:1、读取XAML文件显示在界面上; 2、将XAML文件中的布局在DocumentViewer中显示,从而实现打印预览。一、读取指定的XAML文件XmlReader xr = new XmlTextReader(filePath);object ob = XamlReader.Load(xr);注:其中XAML文件是FixedPage为根节点的结构。二、将读取的文件转换成页 并绑定数据FixedPage fp = (FixedPage)ob; fp.DataContext = 数据源;三、将页加载到PageContent中PageContent pc = new PageContent( 阅读全文

2013 新的一年 新的开始

2013-01-01 20:13 by panmin, 197 阅读, 0 推荐, 收藏,
摘要:时间总是在不知不觉中飞逝,眨眼之间2013年就到来了,2012年发生了不少事情,但是过去的都过去了,新的一年新的开始。这也是我在博客园的第一篇博文,希望以后能够通过博客记录自己在技术上成长的点点滴滴,也希望能够在博客园认识一些志趣相投的朋友,大家一起交流、进步。 阅读全文