摘要:
1.自定义控件, 和接口 interface IModify { bool IsModified { get; } } class TextBoxEx : TextBox, IModify { private bool isModified = false; public bool IsModified { get { return isModified; } } protected override void OnTextChanged(EventArgs ... 阅读全文
摘要:
protected override void WndProc(ref Message m) { base.WndProc(ref m); switch (m.Msg) { case WinUser.WM_CREATE: break; case WinUser.WM_PAINT: break; case WinUser.WM_LBUTT... 阅读全文
摘要:
Semaphore 信号量, 用来限制可同时访问某一资源或资源池的线程数。信号量维护了一个计数器, 计数器的值可以在0到指定的最大值之间。当一个线程完成了对信号量的等待后, 信号量计数器值减少。当一个线程稀放信号量时, 信号量计数器值增加。当计数器值达到零后,信号量是"未标志的",当计数器值大于零时, 信号量是"标志的"。任何线程都无法等待信号量变为"标志的", 因此信号量对限制可以共享数据的线程数量很有用处。using System;using System.Collections.Generic;using System.Text 阅读全文
摘要:
// 根据RGB,计算灰度值private int GetGrayColor(System.Drawing.Color color){ int i = (int)(0.299 * color.R + 0.587 * color.G + 0.114 * color.B); int i2 = (color.R * 19595 + color.G * 38469 + color.B * 7472) >> 16; return i;}private void SetBitmap(Bitmap img){ BitmapData bmData = img.LockBits(new ... 阅读全文
摘要:
using System;using System.Collections.Generic;using System.Text;using System.Net.Sockets;using System.Net;using System.Threading;using System.Runtime.InteropServices;namespace ConsoleApplication2{ class Program { static Socket m_sListen; static void Main(string[] args) { ... 阅读全文
摘要:
服务端和客户是通过这样一个结构体进行通信的using System;using System.IO;using System.Runtime.InteropServices;namespace AUS.Common{ /// <summary> /// 通信结构体 /// </summary> [Serializable] [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct Packet { public cmd cmd; public int len;... 阅读全文
摘要:
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e){ if (e.Action != TreeViewAction.ByMouse) return; SetParentNode(e.Node); SetChildNode(e.Node);}private void SetParentNode(TreeNode node){ if (node.Level > 0) { node.Parent.Checked = true; SetParentNode(node.Parent); }}private vo 阅读全文
摘要:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication3{ public partial class Form3 : Form { public Form3() { InitializeComponent(); } public struct ComboBoxItem&l 阅读全文
摘要:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication3{ public partial class Form2 : Form { public Form2() { InitializeComponent(); this.comboBox1.DropDownStyle = 阅读全文
摘要:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication3{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } class User { public int id { 阅读全文