예제 #1
0
 private void splitContainer1_Panel2_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         Win32ImageList.ImageList_EndDrag();
         mouseDownPoint = Point.Empty;
     }
 }
예제 #2
0
        private void splitContainer1_Panel2_DragEnter(object sender, DragEventArgs e)
        {
            // ImageList_DragEnterにはクライアント領域における相対座標ではなく
            // タイトルバーなどの非クライアント領域を含むWindowにおける相対座標を指定する
            Point p = this.PointToClient(Cursor.Position);
            int   x = Cursor.Position.X - this.Left;
            int   y = Cursor.Position.Y - this.Top;

            // ドラッグ中は半透明イメージを表示し続けたいのでImageList_DragEnterには
            // ListBoxのHandleを渡すのでなく、FormのHandleを渡す
            Win32ImageList.ImageList_DragEnter(this.Handle, x, y);
        }
예제 #3
0
        private void splitContainer1_Panel2_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                var image = avatarlist[0].image;
                mouseDownPoint = new Point(e.X - this.Bounds.X - image.Width / 2, e.Y - this.Bounds.Y - image.Height / 2);

                // Imageの初期化
                imageList.Images.Clear();
                imageList.ImageSize = new Size(image.Width, image.Height);

                // 半透明イメージの元画像を作成、ImageListに追加
                imageList.Images.Add(image);

                // ImageList_BeginDragにはドラッグする
                // イメージの中における相対座標を指定する
                Win32ImageList.ImageList_BeginDrag(imageList.Handle, 0, e.X, e.Y);
                int x = Cursor.Position.X + mouseDownPoint.X;
                int y = Cursor.Position.Y + mouseDownPoint.Y;
                Win32ImageList.ImageList_DragEnter(this.Handle, x, y);
            }
        }
예제 #4
0
        private void splitContainer1_Panel2_MouseMove(object sender, MouseEventArgs e)
        {
            if (mouseDownPoint != Point.Empty)
            {
                int x = Cursor.Position.X + mouseDownPoint.X;
                int y = Cursor.Position.Y + mouseDownPoint.Y;
                Win32ImageList.ImageList_DragMove(x, y);

                /*
                 * Rectangle dragRegion = new Rectangle(
                 *  mouseDownPoint.X - SystemInformation.DragSize.Width / 2,
                 *  mouseDownPoint.Y - SystemInformation.DragSize.Height / 2,
                 *  SystemInformation.DragSize.Width,
                 *  SystemInformation.DragSize.Height);
                 * if (!dragRegion.Contains(e.X, e.Y))
                 * {
                 *
                 *  Win32ImageList.ImageList_DragMove(e.X, e.Y);
                 *  mouseDownPoint = Point.Empty;
                 * }
                 */
            }
        }
예제 #5
0
 private void splitContainer1_Panel2_DragLeave(object sender, EventArgs e)
 {
     Win32ImageList.ImageList_DragLeave(this.Handle);
 }