随笔分类 -  Programming

上一页 1 ··· 4 5 6 7 8
.Net(C#, WPF), OpenGL
摘要:获取各种路径//应用程序的当前工作目录。 System.IO.Directory.GetCurrentDirectory(); //获取程序的基目录。System.AppDomain.CurrentDomain.BaseDirectory; //获取和设置包括该应用程序的目录的名称。System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。 System.Windows.Forms.Application.StartupPath; //获取启动了应用程序的可 阅读全文
posted @ 2013-01-04 15:27 马语者 阅读(2081) 评论(0) 推荐(1) 编辑
摘要:需要添加引用System.DiagnosticProcess process = new Process(); //创建进程对象process.StartInfo.FileName = "cmd.exe"; //要执行的程序名process.StartInfo.UseShellExecute = false; ////不使用系统外壳程序启动进程process.StartInfo.CreateNoWindow = true; //不显示dos程序窗口//重新定向标准输入,输入,错误输出process.StartInfo.RedirectStandardInput = true 阅读全文
posted @ 2013-01-04 14:22 马语者 阅读(2489) 评论(0) 推荐(0) 编辑
摘要:使用@的意思是不转义\按说要在字符串里表示c:\windows\notepad.exe得写成c:\\windows\\notepad.exe但是前面加@以后就不用两个\了 阅读全文
posted @ 2013-01-04 13:55 马语者 阅读(4983) 评论(0) 推荐(1) 编辑
摘要:List<T> 被声明为class, 所以它是地址型变量。而值型变量会被声明为struct。在赋值时需要注意,比如:List<int> listA = new List<int>(){1, 2, 3};List<int> listB = new List<int>();List<int> listC = new List<int>();listB = listA;listC = listA;for(int i = 0; i< listB.Count; i++){ listB[i] =listC[i] *2 阅读全文
posted @ 2012-12-31 13:27 马语者 阅读(1180) 评论(0) 推荐(0) 编辑
摘要:前面补0的数字字串String.Format("{0:0000}", 157); // 输出 0157 前后都补0的数字字串String.Format("{0:0000.0000}", 157.42); // 输出 0157.4200 每3位数(千)加逗号(String.Format("{0:0,0}", 38560); // 输出 38,5600:0 这样表示会把前面补0 ,例如本来是6,会显示06,所以不要有0: 就不会变成06格式化电话号码(String.Format("{0:(###) ###-####}" 阅读全文
posted @ 2012-12-26 17:00 马语者 阅读(3104) 评论(0) 推荐(0) 编辑
摘要:double dValue = 99.123456;int iValue = 9999;string strValue = "99.123456";string result = "";result = dValue.ToString("0.00");//99.12result = Convert.ToDouble(iValue).ToString("0.00");//9999.00 result = Convert.ToDouble(strValue).ToString("0.00"); // 阅读全文
posted @ 2012-12-26 16:29 马语者 阅读(6155) 评论(0) 推荐(0) 编辑
摘要:经常会遇到要在Canvas里将各类控件居中的问题,下面以TextBlock为例说明。//在将TextBlock添加到Canvas前获取它的实际尺寸TextBlock label = new TextBlock;label.Text = "It is a test";label.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));Size labelSize = label.DesiredSize;Canvas canvas = new Canvas();canvas.Width = 100; 阅读全文
posted @ 2012-12-22 18:59 马语者 阅读(7646) 评论(0) 推荐(0) 编辑
摘要:经常使用System.Drawing.Color, 本篇介绍一下颜色与名称及RGB值的对应关系。 阅读全文
posted @ 2012-12-17 14:24 马语者 阅读(48065) 评论(1) 推荐(1) 编辑
摘要:的 阅读全文
posted @ 2012-12-15 21:13 马语者 阅读(482) 评论(0) 推荐(0) 编辑
摘要:本文介绍一下OpenGL下绘制三维物体的基本方法。编译环境:OpenTK, c#。以下是OpenGL的基本绘图函数:1. 绘制正方体View Code//draw a cube: solid void DrawCube(Color color, Vector3d refMarker, Vector3d size) { List<Vector3d> points = new List<Vector3d>(); //points //back points (anti-clockwise) ... 阅读全文
posted @ 2012-12-15 20:48 马语者 阅读(4754) 评论(2) 推荐(1) 编辑
摘要:OpenGL是针对Windows Forms开发,下面是在WPF环境下的集成方法。(P.S. 如果只在windows下使用,其实WPF 3D或DirectX是更好的选择)。1.新建一个WPF项目。2.添加以下references到项目中:System.Windows.FormsWindowsFormsIntegrationOpenTKOpenTK.GLControl3.在xaml中加入如下内容:<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/wi 阅读全文
posted @ 2012-12-13 10:24 马语者 阅读(7688) 评论(0) 推荐(1) 编辑
摘要://1. 将int型list转为string型list:List<int> intList =newList<int>(new int[]{1,2,3});List<string> strList = intList.ConvertAll<string>(x => x.ToString());//2. 字符串,整型,浮点型等类型直接的转换(Convert):string str = "2";int num = Convert.ToInt32(str);//3. 分割换行符,去除空行string[] lines = con 阅读全文
posted @ 2012-12-11 16:07 马语者 阅读(311) 评论(0) 推荐(0) 编辑
摘要:1. 单行注释://Console.WriteLine("单行注释");2. 多行注释:/*Console.WriteLine("多行注释");*/3. 解释型注释,当调用该函数时,会显示summary中的内容。/// <summary>/// 我是第一行注释/// 我是第二行注释/// </summary>public void Proc(){} 阅读全文
posted @ 2012-12-11 14:15 马语者 阅读(224) 评论(0) 推荐(0) 编辑

上一页 1 ··· 4 5 6 7 8