随笔分类 -  Programming

.Net(C#, WPF), OpenGL
摘要:对于enum类型:使用foreach遍历enum类型的元素并填充comboxforeach ( HatchStyle hs1 in Enum.GetValues(typeof(HatchStyle))) { comboBox1.Items.Add(hs1.ToString()); }From... 阅读全文
posted @ 2014-06-10 16:16 马语者 阅读(792) 评论(0) 推荐(0) 编辑
摘要:我现在是这么画的,class A { private GeometryGroup _lines; private Path _path; public A() { _path.Data = _lines; } public Draw() { LineGeometry line = new LineGeometr... 阅读全文
posted @ 2014-06-06 11:09 马语者 阅读(903) 评论(0) 推荐(0) 编辑
摘要:WPF的XAML提供了一系列功能强大、用法复杂的 mini-language 来描述可扩展应用程序标记语言 (XAML) 中的几何路径。如下所示: XAML Command Name Description F i FillRule i=0:EvenOdd. i=1:NonZero. M x y Move Moveto (x, y). m x y R... 阅读全文
posted @ 2014-05-30 18:26 马语者 阅读(2059) 评论(0) 推荐(0) 编辑
摘要:当Thumb跟随Grid旋转90度后,拖拽控件时会飞掉。 private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragD... 阅读全文
posted @ 2014-05-30 15:41 马语者 阅读(1916) 评论(1) 推荐(1) 编辑
摘要:最近项目中在用Linq Distinct想要将重复的资料去除时,发现它跟Any之类的方法有点不太一样,不能很直觉的在呼叫时直接带入重复数据判断的处理逻辑,所以当我们要用某个成员属性做重复数据的判断时,就必需绕一下路,这边稍微将处理的方法做个整理并记录一下。 首先为了方便接下去说明,我们必须先来准备后面会用到的数据类别,这边一样用笔者最常用来示范的Person类别,内含两个成员属性ID与Name... 阅读全文
posted @ 2014-05-23 18:39 马语者 阅读(2149) 评论(0) 推荐(0) 编辑
摘要:如果是在代码中添加的形状,获取Shape.RenderedGeometry会出错。 这是由于WPF没有更新形状的原因,调用Shape.Arrange()后问题解决。 阅读全文
posted @ 2014-05-22 11:31 马语者 阅读(318) 评论(0) 推荐(0) 编辑
摘要:First off, we can use our Line-Point Distance code to test for the "BOUNDARY" case. If the distance from any segment to the test point is 0, then return "BOUNDARY". If you didn't have that code pre-wr... 阅读全文
posted @ 2014-05-20 10:27 马语者 阅读(376) 评论(0) 推荐(0) 编辑
摘要:In the previous section we saw how to use vectors to solve geometry problems. Now we are going to learn how to use some basic linear algebra to do line intersection, and then apply line intersection t... 阅读全文
posted @ 2014-05-20 10:26 马语者 阅读(262) 评论(0) 推荐(0) 编辑
摘要:Introduction Many TopCoders seem to be mortally afraid of geometry problems. I think it's safe to say that the majority of them would be in favor of a ban on TopCoder geometry problems. However, geo... 阅读全文
posted @ 2014-05-20 10:25 马语者 阅读(402) 评论(0) 推荐(0) 编辑
摘要:It is not possible using the .NET BCL. However if you really want it you can use native SetCursorPos inUser32.dll. [DllImport("User32.dll")]private static extern bool SetCursorPos(int x, int y);As ot... 阅读全文
posted @ 2014-05-19 19:27 马语者 阅读(1459) 评论(0) 推荐(0) 编辑
摘要:have tested this, it worked, at least for me var x1 = Canvas.GetLeft(e1);var y1 = Canvas.GetTop(e1);Rect r1 = new Rect(x1, y1, e1.ActualWidth, e1.ActualHeight);var x2 = Canvas.GetLeft(e2);var y2 = ... 阅读全文
posted @ 2014-05-19 11:27 马语者 阅读(1432) 评论(0) 推荐(0) 编辑
摘要:have a Canvas with a couple of elements on it like Line, Path and Text Box. In the MouseOver event of the Canvas there's a HitTest for all of them like: bool HitTest( Point p ){ return VisualTreeHel... 阅读全文
posted @ 2014-05-15 16:23 马语者 阅读(921) 评论(0) 推荐(0) 编辑
摘要:The .NET framework comes with a variety of different serializers. Hopefully, my overview of these serializers will have provided some insight into the differences between them and the various advantag... 阅读全文
posted @ 2014-05-14 16:18 马语者 阅读(263) 评论(0) 推荐(0) 编辑
摘要:string test = "Testing 1-2-3";// convert string to streambyte[] byteArray = Encoding.ASCII.GetBytes(test); MemoryStream stream = new MemoryStream(byteArray);// convert stream to stringStreamReader rea... 阅读全文
posted @ 2014-05-14 16:16 马语者 阅读(217) 评论(0) 推荐(0) 编辑
摘要:序列化又称串行化,是.NET运行时环境用来支持用户定义类型的流化的机制。其目的是以某种存储形成使自定义对象持久化,或者将这种对象从一个地方传输到另一个地方。 .NET框架提供了两种种串行化的方式:1、是使用BinaryFormatter进行串行化;2、使用XmlSerializer进行串行化。第一种方式提供了一个简单的二进制数据流以及某些附加的类型信息,而第二种将数据流格式化为XML存储。... 阅读全文
posted @ 2014-05-14 08:52 马语者 阅读(11075) 评论(0) 推荐(0) 编辑
摘要:您拖动的一个或多个类将显示在关系图上。 它们依赖的类将显示在“UML 模型资源管理器”中。 参见 模型表示类型的方式。 将程序代码中的类添加到 UML 模型 打开一个 C# 项目。 将一个 UML 类图。解决方案: 在“体系结构”菜单上,选择“新建关系图”。 在“添加新关系图”对话框中选择“UML 类图”。 如果您还没有,将建模项目创建。 ... 阅读全文
posted @ 2014-05-12 17:35 马语者 阅读(3770) 评论(0) 推荐(0) 编辑
摘要:public Point TranslatePoint( Point point, UIElement relativeTo)private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e){ // Retrieve the coordinate of the mouse position. Point ... 阅读全文
posted @ 2014-05-09 16:54 马语者 阅读(269) 评论(0) 推荐(0) 编辑
摘要:1、“.”为通配符,表示任何一个字符,例如:“a.c”可以匹配“anc”、“abc”、“acc”; 2、“[]”,在[]内可以指定要求匹配的字符,例如:“a[nbc]c”可以匹配“anc”、“abc”、“acc” ;但不可以匹配“ancc”,a到z可以写成[a-z],0到9可以写成[0-9]; 3、数量限定符号,表示匹配次数(或者叫做长度)的符号: 包括:“*”——0次或者多次 ... 阅读全文
posted @ 2014-05-08 16:20 马语者 阅读(522) 评论(0) 推荐(0) 编辑
摘要:首先,千万不要觉得Adorner离你很远,因为最简单的WPF界面也会用到Adorner。在WPF中,下面的几个很常见的功能,都是用Adorner实现的。 1. 光标(caret) 2. 焦点(focus) 3. 高亮(highlight) 4. 拖拽预览(drag and drop) 5. 拼写错误提示 6. 数据绑定中用来提示错误的Er... 阅读全文
posted @ 2014-04-28 09:04 马语者 阅读(1938) 评论(0) 推荐(2) 编辑
摘要:1. 继承属性: DataContext is a property on FrameworkElement (base class for all WPF Controls) and is implemented as a DependencyProperty. DataContext是一个财产上的FrameworkElement的(所有WPF控件的基类),作为DependencyProper... 阅读全文
posted @ 2014-04-25 18:09 马语者 阅读(2493) 评论(0) 推荐(0) 编辑