본문 바로가기

c#16

C# 더블버퍼링 사용하기 컨트롤에 더블버퍼링 사용 방법 this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); this.UpdateStyles(); 2010. 9. 11.
C# Form간의 Data 공유.. //GraphicForm 생성자 private Form1 wnd = null; public GraphicForm(Form1 wnd) { InitializeComponent(); this.wnd = wnd; } public GraphicForm m_graphic = null; private GraphicForm_Show() { if (!m_graphic.Created) { m_graphic = new GraphicForm(this); m_graphic.MdiParent = this; m_graphic.Show(); } } 2010. 8. 9.
C# Thread 사용하기 Thread _thread=null; private void Thread_APC() { if (!(_thread== null)) _thread.Abort(); //TiroShow Thread 리소스 해제 _thread= new Thread(Thread_Proc); _thread.Start(); } private void Thread_Proc() { } 2010. 6. 26.
C# Thread 에서 UI 또는 Control 접근하기 Visual Studio 2008 Sp1 개발환경이다.. Visual Studio 2005 까지만해도 Thread에서 Control을 접근하면 Warring 은 있었지만 Error는 없었다.. 하지만 2008 Sp1 부터 바뀐듯하다.. Realse 로는 Error가 나지 않지만 디버깅을 하면 Error 가 생긴다. 해결방법 -> this.Invoke(new MethodInvoker(delegate() { 여기서 컨트롤을 사용하면된다~~ })); 2010. 5. 27.
C# TextBox Auto Scroll txtDebug.Select(txtDebug.TextLength, 0); txtDebug.ScrollToCaret(); 2009. 12. 16.
C# 투명 PictureBox 만들기 GIF 같은 형식의 투명색이 존재하는 그림을 사용해야한다.. pictureBox2.BackColor = Color.Transparent; BackColor 칼라를 투명으로 해주면~~ 투명으로~~ 2009. 11. 5.
WiiMote 자동연결.. 구조 블로솔레일 사용함.. -> 블루솔레일로 위리모컨 아이콘을 만든후.. 단축키로 지정함.. 프로그램상에서 계속 단축키를 눌러줌.. WiiMoteAuto 원래는 FindWindows 로 handle값을 찾았지만... 메모리가 싸이므로.. 프로그램을 껏다 켰다 해야한다... WiiMote프로그램이 TRobot 프로그램보다 늦게 켜지면 TRobot 프로그램의 Handle 값을 찾을수가 없다. 그래서 HsleeCom 은 WiiMote 프로그램이 Init 될때.. TRobot의 핸들값을 ini로 저장하여 WiiMote는 핸들값이 들어있는 ini파일을 Read시켜. Handle값 얻어왔다. 2009. 9. 8.
C# 키보드 후킹 첨부파일 다운로드하고.. 솔루션에 추가시켜야함... using System.Runtime.InteropServices; using Utilities; //첨부cs파일 네임스페이스 namespace key_preview { public partial class Form1 : Form { globalKeyboardHook gkh = new globalKeyboardHook(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { gkh.HookedKeys.Add(Keys.Decimal);//후킹할 키 등록 gkh.KeyDown += new KeyEventHandler(gkh_KeyDown).. 2009. 5. 28.
C# PDA Serial통신 우선 제일먼저 해줘야할일은 당연히 Serial Control추가... Program 생성자에 아래코드를 추가해준다.. this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived); dataReciveHandler = new EventHandler(dataRecive); 시리얼 수신 이벤트핸들러함수를 아래와같이 추가한다. protected void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs args) { try { Invoke(dataReciveHandler.. 2009. 5. 15.
C# Txt Log 만들기 public void TXTLog(String strMsg) { try { string m_strLogPrefix = AppDomain.CurrentDomain.BaseDirectory + @"LOG\"; string m_strLogExt = @".LOG"; DateTime dtNow = DateTime.Now; string strDate = dtNow.ToString("yyyy-MM-dd"); string strPath = String.Format("{0}{1}{2}", m_strLogPrefix, strDate, m_strLogExt); string strDir = Path.GetDirectoryName(strPath); DirectoryInfo diDir = new DirectoryInfo(strD.. 2009. 4. 28.
C# Ping Test using System.Net.NetworkInformation; private Ping ping = new Ping(); private PingOptions pingOption = new PingOptions(); private bool PingTest(string strIP) { byte[] byteSendData = Encoding.ASCII.GetBytes(strSendData); PingReply pingReply = ping.Send(strIP, 120, byteSendData, pingOption); if (pingReply.Status == IPStatus.Success) { Debug.WriteLine("핑성공!"); return true; } else { Debug.WriteLine(".. 2009. 4. 28.
C# Target 빌드 이벤트 로봇쪽 어플리케이션은 PC에서 프로그래밍 하고.. Bin 파일을 Robot에 저장해야되는데.. 빌트 Output을 로봇쪽으로 해놓으면... 난감한 상황이 발생한다... 로봇과 연결이 않되있을때에는 프로젝트를 불러오기 힘들다는거... 그래서.. 빌드 이벤트를 사용~~~ 로컬컴퓨터에 빌드후 Bin파일만 로봇쪽으로 Copy.. copy "$(TargetDir)\$(TargetFileName)" "\\192.168.1.171\로컬 디스크 (d)\0. UCity BIN\$(TargetFileName)" copy "$(TargetDir)\$(TargetFileName)" "※위치※\$(TargetFileName)" 2009. 3. 28.
C# 안정화 과정 오류가 많지 않기로 소문난 C# 가비지 컬렉터라고하죠? C++의 메모리 관리를 프로그래머가 직접 해줘야하는 힘든과정을.. 자동으로 해주는것이 C#의 가비지 컬렉터... 정말 좋지만.. 세부메모리를 건드릴려면 힘들다는 단점. C# 안정화 과장. Form기반. 1. Form클래스에 사용하고자하는 기능을 올림... -> 작동이 잘되는지 확인.. 2. 그 기능을 독작하게하는 클래스를 생성후 Form을 부모클래스로 연결해 사용.. -> 안정화 완료.. 3. DLL화.. 음 내 경험상 바로 DLL을 만들어서 하니까 잘 않되는게 많음.. Form기반에 올려 성능검증을 마친후 클래스화시켜 마지막 DLL DLL로 만드는 이유는 나중에 다른 솔루션에서 가따 쓰기가 참 편리하다~ 2009. 3. 23.
C# CPU사용율 알아내기 private ManagementPath cpuPath = null; private ManagementObject cpuObject = null; private ManagementScope scope = null; private ulong oldCpuValue, oldNanoValue; public void SetWMIObject() { this.cpuPath = new ManagementPath(); this.cpuPath.RelativePath = "Win32_PerfRawData_PerfOS_Processor.Name='_Total'"; this.cpuObject = new ManagementObject(this.scope, cpuPath, null); } public decimal ObtainCp.. 2009. 3. 19.
C# Thread 편리하게 사용하기. C#의 Thread는 3종류가 있다.. 일반적으로 Thread, ThreadPOOL, TimerThread Thread는 일반적인 Thread이고 ThreadPOOL은.. Thread가도는데 또 콜이들어오면 기다리고있다가 Thread가 종료되면 시작되는 Thread TimerThread는 타이머와같이 정해진시간에 한번씩 뜨는 Thread이다... 일반 Timer와 TimerThread의 차이점은 Timer에서 Sleep 현상이 일어나면 프로세서가 멈추지만.. TimerThread는 Sleep이 걸려도 프로세서가 멈추지 않는다는점이다.. Thread의 경우 한번이라도 돌았을경우 프로세서가 죽을때 if (!(Algoritms == null)) Algoritms.Abort(); 라는 문구를 넣어줘야 프로세서가.. 2009. 3. 19.