Example #1
0
        public ShellWindow(SingleInstanceManager singleInstanceManager, ShellViewModel shellViewModel, IAppEvents appEvents, IAppSettingsService appSettingsService)
        {
            DataContext = shellViewModel;
            InitializeComponent();

            singleInstanceManager.OnNewInstance += SingleInstanceManager_OnNewInstance;
            appEvents.OnDragDropModeChanged     += AppEvents_OnDragDropModeChanged;

            dragDropHelper = new DragDropHelper(tabControl, new List <DragDropPair>
            {
                new DragDropPair(typeof(ListViewItem)),
                new DragDropPair(typeof(ListViewItem), typeof(TabItem)),
                new DragDropPair(typeof(ListViewItem), typeof(ListView)),
                new DragDropPair(typeof(TabItem)),
                new DragDropPair(typeof(TabItem), typeof(TabPanel))
            });

            fileDragDropHelper = new FileDragDropHelper(tabControl, new List <Type>
            {
                typeof(ListViewItem),
                typeof(TabItem)
            }, new List <Type>
            {
                typeof(TabControl)
            });
            AppEvents_OnDragDropModeChanged(appSettingsService.DragDropMode);

            KeyDownHandlerEnabled = true;
        }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();
            tbLogs.TextChanged += TbLogs_TextChanged;

            DataContext = new MainViewModel();
            var dragDropHelper = new DragDropHelper(tabControl, new List <DragDropPair>
            {
                new DragDropPair(typeof(ListViewItem)),
                new DragDropPair(typeof(ListViewItem), typeof(TabItem)),
                new DragDropPair(typeof(ListViewItem), typeof(ListView)),
                new DragDropPair(typeof(TabItem)),
                new DragDropPair(typeof(TabItem), typeof(TabPanel))
            });

            dragDropHelper.OnDrag += DragDropHelper_OnDrag;
            dragDropHelper.OnDrop += DragDropHelper_OnDrop;

            var fileDragDropHelper = new FileDragDropHelper(listView, new List <Type> {
                typeof(ListViewItem)
            }, new List <Type> {
                typeof(ListView)
            });

            fileDragDropHelper.OnFileDrag += FileDragDropHelper_OnFileDrag;
            fileDragDropHelper.OnFileDrop += FileDragDropHelper_OnFileDrop;
        }
Example #3
0
        public static void RegisterDragAndDrop <FI, DI, FSI>(this ExplorerViewModel <FI, DI, FSI> explorervm, DirectoryTree2 dtree)
            where FI : FSI
            where DI : FSI
        {
            FileDragDropHelper <EntryViewModel <FI, DI, FSI> > .SetEnableDrag(dtree, true);

            FileDragDropHelper <EntryViewModel <FI, DI, FSI> > .SetEnableDrop(dtree, true);

            RegisterConstructMethod(explorervm);
        }
Example #4
0
        public static void RegisterDragAndDrop <FI, DI, FSI>(this ExplorerViewModel <FI, DI, FSI> explorervm, FileList2 fileList)
            where FI : FSI
            where DI : FSI
        {
            FileDragDropHelper <EntryViewModel <FI, DI, FSI> > .SetEnableDrag(fileList, true);

            FileDragDropHelper <EntryViewModel <FI, DI, FSI> > .SetEnableDrop(fileList, true);

            RegisterConstructMethod(explorervm);
        }
        private void myDataGrid_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed && !IsDragging)
            {
                Point position = e.GetPosition(null);

                if (Math.Abs(position.X - _startPoint.X) > SystemParameters.MinimumHorizontalDragDistance ||
                    Math.Abs(position.Y - _startPoint.Y) > SystemParameters.MinimumVerticalDragDistance)
                {
                    //Start DragDrop Action!
                    {
                        var row = UIHelpers.TryFindFromPoint <DataGridRow>((UIElement)sender, e.GetPosition(myDataGrid));
                        if (row != null)
                        {
                            DataObject dragData = new DataObject("dataRow", row);
                            dragData.SetData("ProjectBlockInfo", myDataGrid.SelectedItem);
                            if (myDataGrid.SelectedItem is S7ProjectBlockInfo)
                            {
                                S7ProjectBlockInfo blkInfo = (S7ProjectBlockInfo)myDataGrid.SelectedItem;
                                string             awlblk  = blkInfo.GetSourceBlock();

                                dragData.SetData(FileDragDropHelper.CFSTR_FILEDESCRIPTORW, FileDragDropHelper.GetFileDescriptor(blkInfo.BlockName + ".awl", awlblk));
                                dragData.SetData(FileDragDropHelper.CFSTR_FILECONTENTS, FileDragDropHelper.GetFileContents(awlblk));

                                byte[] unicodeText = Encoding.Unicode.GetBytes(awlblk); // UTF-16
                                byte[] utf8Text    = Encoding.UTF8.GetBytes(awlblk);
                                byte[] utf32Text   = Encoding.UTF32.GetBytes(awlblk);
                                dragData.SetData(DataFormats.Text, awlblk);
                                dragData.SetData(DataFormats.UnicodeText, unicodeText);
                                dragData.SetData("UTF-8", utf8Text);
                                dragData.SetData("UTF-32", utf32Text);
                            }
                            //dragData = new DataObject(DataFormats.Text,row.ToString());
                            Mouse.OverrideCursor = dragDropCursor = new GhostCursor(row).Cursor;

                            DragDrop.DoDragDrop((DependencyObject)sender, dragData, DragDropEffects.Copy);
                            Mouse.OverrideCursor = null;
                        }
                    }
                }
            }
        }
Example #6
0
 public static void RegisterDragTemplate <FI, DI, FSI>(this ExplorerViewModel <FI, DI, FSI> explorervm, System.Windows.UIElement control, System.Windows.DataTemplate itemTemplate)
     where FI : FSI
     where DI : FSI
 {
     FileDragDropHelper <EntryViewModel <FI, DI, FSI> > .SetDragItemTemplate(control, itemTemplate);
 }