Ejemplo n.º 1
0
        private void FormImageList_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ListViewItem[])))
            {
                //この処理が無いと、ドラッグ&ドロップ開始早々絵が表示されない
                IntPtr pinDesktopWindow = ClsWin32.GetDesktopWindow();
                ClsWin32.ImageList_DragEnter(pinDesktopWindow, Cursor.Position.X, Cursor.Position.Y);

                e.Effect = DragDropEffects.None;
            }
            else if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                bool     isSuccess   = false;
                string[] pclAllPaths = (string[])e.Data.GetData(DataFormats.FileDrop);
                foreach (string clPathTmp1 in pclAllPaths)
                {
                    if (Directory.Exists(clPathTmp1))
                    {
                        string[] pclFilePaths = System.IO.Directory.GetFiles(clPathTmp1, "*.*", SearchOption.AllDirectories);
                        foreach (string clPathTmp2 in pclFilePaths)
                        {
                            bool isChk = this.ChkImageFile(clPathTmp2);
                            if (!isChk)
                            {
                                continue;
                            }

                            isSuccess = true;
                        }
                    }
                    else if (File.Exists(clPathTmp1))
                    {
                        bool isChk = this.ChkImageFile(clPathTmp1);
                        if (!isChk)
                        {
                            continue;
                        }

                        isSuccess = true;
                    }
                }

                if (isSuccess)
                {
                    e.Effect = DragDropEffects.Copy;
                }
                else
                {
                    e.Effect = DragDropEffects.None;
                }
            }
        }
Ejemplo n.º 2
0
        private void listView_MouseUp(object sender, MouseEventArgs e)
        {
            m_isMouseLDown = false;
            if (this.mMouseDownPoint == Point.Empty)
            {
                return;
            }

            IntPtr pinDesktopWindow = ClsWin32.GetDesktopWindow();

            ClsWin32.ImageList_DragLeave(pinDesktopWindow);
            ClsWin32.ImageList_EndDrag();

            this.mMouseDownPoint = Point.Empty;

            Console.WriteLine("MouseUp");
        }