« Previous : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : ... 114 : Next »

[C#] 마우스 드래그로 패널 이동하기

사용자 삽입 이미지

마우스 드래그로 패널(그림에서 보이시는 일본어 입력기가 패널로 그려저 있습니다.)을 폼상에서 이동하는 소스 코드 입니다.

private Point mCurrentPosition = new Point(0, 0);
현재 패널에 위치를 저장하는 Point형 mCurrentPosition 을 생성합니다.

패널에서 MouseMove이벤트를 생성후 다음코드와 같이 작성합니다.
private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                p_japan_KeyInput.Location = new Point(p_japan_KeyInput.Location.X + (mCurrentPosition.X + e.X), p_japan_KeyInput.Location.Y + (mCurrentPosition.Y + e.Y));
            }
        }
그리고 MouseDown 이벤트로 생성후 다음코드와 같이 작성합니다.
private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button == MouseButtons.Left)
            {
                mCurrentPosition = new Point(-e.X, -e.Y);
            }
        }
마지막으로 DragEnter 이벤트를 생성후 다음과 같이 코드를 작성합니다.
private void panel1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.All;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

Posted by 블루네군

2010/01/13 13:30 2010/01/13 13:30
Response
No Trackback , No Comment
RSS :
http://bluene.net/blog/rss/response/523

C# HashTable

C# HashTable을 이용하여 국가를 검색하면 그 국가에 해당하는 꽃 이름이
꽃 이름을 통하여 검색하면 해당되는 국가가 나타나도록...
 
flower.cs
 class flower
    {
        private string fl;
        public string Flower
        {
            get
            {
                return fl;
            }
            set
            {
                fl = value;
            }
        }
    }

world.cs
 class world
    {
        private string wl;
        public string World
        {
            get
            {
                return wl;
            }
            set
            {
                wl = value;
            }
        }
    }

form.cs
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        flower fl = new flower();
        world wl = new world();
        
        Hashtable flower = new Hashtable();
        Hashtable world = new Hashtable();

        private void button1_Click(object sender, EventArgs e)
        {
            object o = textBox1.Text;
            textBox2.Text = flower[textBox1.Text].ToString();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            fl.Flower = textBox1.Text;
            wl.World = textBox2.Text;

            flower.Add(fl.Flower, wl.World);
            world.Add(wl.World, fl.Flower);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            object o = textBox2.Text;
            textBox1.Text = world[textBox2.Text].ToString();
        }
    }

Posted by 블루네군

2010/01/03 20:52 2010/01/03 20:52
Response
No Trackback , No Comment
RSS :
http://bluene.net/blog/rss/response/522

C# 시리얼 통신 소스입니다.

C# 시리얼 통신 소스입니다.
소스가 너무 허접하여(?) 공개하기가 뭐시기 하여 올리지 않았는데...

 찾으시는 분이 많아서.. 
뭐, 혼자 하드에 썩어두면 뭐하나 싶기도 하고..
사실적으로, 따지면 귀차니즘도 있고 해서

그냥 블로그에 올립니다.
필요 하린 분은 다운로드 해 가세요..!!

Posted by 블루네군

2009/12/30 22:48 2009/12/30 22:48
Response
No Trackback , 2 Comments
RSS :
http://bluene.net/blog/rss/response/521

« Previous : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : ... 114 : Next »

Archives

Calendar

«   2010/09   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Site Stats

Total hits:
407774
Today:
139
Yesterday:
144