Skip to content

Instantly share code, notes, and snippets.

@abc126
abc126 / startexe
Created March 9, 2018 04:05
Start an exe file in C#
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "WindowsFormsApplication1.exe"; //启动的应用程序名称
startInfo.Arguments = "我是由控制台程序传过来的参数,如果传多个参数用空格隔开"+" 第二个参数";
startInfo.WindowStyle = ProcessWindowStyle.Normal;
Process.Start(startInfo);
}
catch (Exception ex)
{
@abc126
abc126 / SendACommandToAutoCAD.cs
Created March 9, 2018 04:14
SendACommandToAutoCAD
public static void SendACommandToAutoCAD(string command)
{
if (MgdApplication.DocumentManager.Count == 0)
{
MessageBox.Show("无活动文档,请新建文档后再执行命令", "新建文档", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
}
// 根据是否有命令运行决定esc的数量
string esc = "";
string cmds = (string)MgdApplication.GetSystemVariable("CMDNAMES");
@abc126
abc126 / GetCurrentDllPath.cs
Created March 9, 2018 04:26
GetCurrentDllPath
private string GetDllPath()
{
string strDLLPath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
strDLLPath = strDLLPath.Substring(8);
return strDLLPath.Substring(0, strDLLPath.LastIndexOf("/") + 1);
}
@abc126
abc126 / SystemPlatform.cs
Created March 12, 2018 15:08
Get System Platform at .net 3.5
[DllImport("kernel32", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
public extern static IntPtr LoadLibrary(string libraryName);
[DllImport("kernel32", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
public extern static IntPtr GetProcAddress(IntPtr hwnd, string procedureName);
private delegate bool IsWow64ProcessDelegate([In] IntPtr handle, [Out] out bool isWow64Process);
public static bool IsOS64Bit()
{
@abc126
abc126 / SystemPlatform.cs
Created March 12, 2018 15:09
Get System platform at .net 3.5
public static class Wow
{
public static bool Is64BitProcess
{
get { return IntPtr.Size == 8; }
}
public static bool Is64BitOperatingSystem
{
get
@abc126
abc126 / ACM学习计划
Created March 30, 2018 15:54 — forked from dodola/ACM学习计划
ACM学习计划
ACM大量习题题库
ACM大量习题题库
现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge。除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库。
USACO
http://ace.delos.com/usacogate
美国著名在线题库,专门为信息学竞赛选手准备

C#编码规范

概述

规范制定原则

  • 方便代码的交流和维护。
  • 不影响编码的效率,不与大众习惯冲突。
  • 使代码更美观、阅读更方便。
  • 使代码的逻辑更清晰、更易于理解。
@abc126
abc126 / PeekingStreamReader
Created May 23, 2018 15:03
PeekingStreamReader
public class PeekingStreamReader : StreamReader
{
private Queue<string> _peeks;
public PeekingStreamReader(Stream stream) : base(stream)
{
_peeks = new Queue<string>();
}
public PeekingStreamReader(string path) : base(path)
{
_peeks = new Queue<string>();
@abc126
abc126 / PresenterBindingAttribute
Created October 8, 2018 01:44
PresenterBindingAttribute
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MVP
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class PresenterBindingAttribute : Attribute
{
@abc126
abc126 / EnumLabel.cs
Created October 8, 2018 05:10 — forked from gabehesse/EnumLabel.cs
C# attribute that allows string representation of enum members & an extension method to get that string representation from an enum member.
public class EnumLabelAttribute : Attribute
{
public string Label { get; private set; }
public EnumLabelAttribute(string label) { Label = label; }
}
public static class EnumLabelExtension
{
public static string GetLabel(this Enum @enum)
{