コード例 #1
0
        void newt_DragEnter(object sender, DragEventArgs e)
        {
            e.Handled = true;
            var tabItem = e.Source as CloseableTabItem;

            if (tabItem == null)
                return;

            //if (Mouse.PrimaryDevice.LeftButton == MouseButtonState.Pressed)
            //{
            //    DragDrop.DoDragDrop(tabItem, tabItem, DragDropEffects.All);
            //}
            //if (e.Data.GetDataPresent(DataFormats.FileDrop))
            //{
                if ((sender as CloseableTabItem).Path.IsFileSystemObject)
                {
                    if ((e.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey)
                    {
                        e.Effects = DragDropEffects.Copy;

                    }
                    else
                    {
                        //if (Path.GetPathRoot((sender as CloseableTabItem).Path.ParsingName) ==
                        //    Path.GetPathRoot(Explorer.NavigationLog.CurrentLocation.ParsingName))
                        //{
                        //    e.Effects = DragDropEffects.Move;


                        //}
                        //else
                        //{
                        //    e.Effects = DragDropEffects.Copy;

                        //}

                        // I decided just to have it do a move because it will avoid errors with special shell folders.
                        // Besides, if a person wants to copy something, they should know how to press Ctrl to copy.
                        e.Effects = DragDropEffects.Move;
                    }
                }
                else
                {
                    e.Effects = DragDropEffects.None;
                }


                Win32Point ptw = new Win32Point();
                GetCursorPos(ref ptw);
                e.Effects = DragDropEffects.None;
                var tabItemSource = e.Data.GetData(typeof(CloseableTabItem)) as CloseableTabItem;
                if (tabItemSource == null)
                    DropTargetHelper.DragEnter(this, e.Data, new System.Windows.Point(ptw.X, ptw.Y), e.Effects);
            //}
            //else
            //{
            //    if (e.Data.GetDataPresent(typeof(CloseableTabItem)))
            //    {
            //        e.Effects = DragDropEffects.Move;
            //    }
            //}

        }
コード例 #2
0
 public static System.Drawing.Point GetMousePosition()
 {
     Win32Point w32Mouse = new Win32Point();
     GetCursorPos(ref w32Mouse);
     return new System.Drawing.Point(w32Mouse.X, w32Mouse.Y);
 }
コード例 #3
0
        void newt_DragOver(object sender, DragEventArgs e)
        {
            e.Handled = true;

            if ((sender as CloseableTabItem).Path.IsFileSystemObject)
            {
                if ((e.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey)
                {
                    e.Effects = DragDropEffects.Copy;

                }
                else
                {
                    //if (Path.GetPathRoot((sender as CloseableTabItem).Path.ParsingName) ==
                    //    Path.GetPathRoot(Explorer.NavigationLog.CurrentLocation.ParsingName))
                    //{
                    //    e.Effects = DragDropEffects.Move;


                    //}
                    //else
                    //{
                    //    e.Effects = DragDropEffects.Copy;

                    //}

                    // I decided just to have it do a move because it will avoid errors with special shell folders.
                    // Besides, if a person wants to copy something, they should know how to press Ctrl to copy.
                    e.Effects = DragDropEffects.Move;
                }
            }
            else
            {
                e.Effects = DragDropEffects.None;
            }

            Win32Point ptw = new Win32Point();
            GetCursorPos(ref ptw);
            //e.Handled = true;
            if (e.Data.GetType() != typeof(CloseableTabItem))
                DropTargetHelper.DragOver(new System.Windows.Point(ptw.X, ptw.Y), e.Effects);
        }
コード例 #4
0
 internal static extern bool GetCursorPos(ref Win32Point pt);