2012年1月7日 星期六

C# 皮克丘霸克斯的移動

繼上次我"意思到了"做出龍抓手游標之後

"我期待"能移動pictureBox了

今次終於動了

而且簡單到匪夷所思


http://www.youtube.com/watch?v=o0Wvn-9BXVc

截圖老半天游標都無法入鏡 而且也沒法表現出真的能"動" 只好祭出HTC的蒐證功能


 private MouseEventArgs MouseStartPos = null;
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e) {
            if (e.Button == MouseButtons.Left) {
                MouseStartPos = e;
                pictureBox1.Cursor = new Cursor(new Bitmap(Resources.Catch).GetHicon());
            }
        }

        private void pictureBox1_MouseUp(object sender, MouseEventArgs e) {
            pictureBox1.Cursor = new Cursor(new Bitmap(Resources.Palm).GetHicon());
        }

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e) {                
            if (pictureBox1.Capture && e.Button == MouseButtons.Left) {
                pictureBox1.Top = e.Y + pictureBox1.Location.Y - MouseStartPos.Y;
                pictureBox1.Left = e.X + pictureBox1.Location.X - MouseStartPos.X;
                pictureBox1.Cursor = new Cursor(new Bitmap(Resources.Catch).GetHicon());
            }
        }


pictureBox1.Cursor = new Cursor(new Bitmap(Resources.Catch).GetHicon())

是將資源裡的圖片轉換成滑鼠遊標的意思

沒有留言:

張貼留言