public override void Undo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote row = document.FindOutlinerNoteById(__NodeId); MainWindow window = DragDropHelper.GetMainWindow(treeListView); window.DoHoist(row); }
void Start() { var allTargets = GetComponentsInChildren <DragDropTarget>(); var allItems = GetComponentsInChildren <DragDropItem>(); foreach (var target in allTargets) { target.AddCallback(DragDropEventTriggerType.ItemEnter, targetsOnEnter); target.AddCallback(DragDropEventTriggerType.ItemExit, targetsOnExit); target.AddCallback(DragDropEventTriggerType.ItemAttach, targetOnAttach); target.AddCallback(DragDropEventTriggerType.ItemDetach, targetOnDetach); } foreach (var item in allItems) { item.SetTargetsByRootObject(gameObject); item.AddCallback(DragDropEventTriggerType.ItemAttach, itemsOnAttach); item.AddCallback(DragDropEventTriggerType.ItemDetach, itemsOnDetach); item.AddCallback(DragDropEventTriggerType.ItemEnter, itemsOnEnter); item.AddCallback(DragDropEventTriggerType.ItemExit, itemsOnExit); item.AddCallback(DragDropEventTriggerType.ItemSetFree, itemsOnSetFree); item.AddCallback(DragDropEventTriggerType.ItemClick, itemsOnClick); DragDropTarget target = DragDropHelper.FindComponentUpward <DragDropTarget>(item.transform); if (target != null) { DragDropHelper.InitializePair(item, target); } } }
private void OnWIPPreviewDragEnter(object sender, DragEventArgs e) { // We want to disable hover-to-expand for WIPs when dragging from the designer surface. // This is because after hover-to-expand, the transition designer will be unloaded. // As a result, 1) there is no way to update other transitions if the shared trigger is updated, and // 2) The ReorderableListEditor will be cleared and there is no way to update the source container // for actions if actions are updated. WorkflowItemPresenter presenter = (WorkflowItemPresenter)sender; if (presenter.Item != null && DragDropHelper.GetDraggedModelItems(e).Count <ModelItem>() > 0) { WorkflowViewElement topmostWFViewElement = this.FindTopmostWorkflowViewelementByHitTest( presenter, e.GetPosition(presenter)); bool isAlreadyExpanded = topmostWFViewElement != null ? topmostWFViewElement.ShowExpanded : false; if (!isAlreadyExpanded) { // Handling the DragEnter would not only disable Auot-expand but also Auto-surround UI gesture (Bug 202880). // To circumvent this problem, a new method (ShowSpacerHelperOnDraggedItems) is used to show // the spacer directly. presenter.ShowSpacerHelperOnDraggedItems(e); e.Handled = true; } } }
private void BeginDragOperation(Point mousePosition) { // If the mouse moved mostly horizontally, then we'll begin a timeline scroll // operation, otherwise we'll begin a Visualization Panel reorder operation if (this.IsHorizontalDrag(mousePosition)) { // Only drag the timeline of the navigator is currently paused if (PsiStudioContext.Instance.VisualizationContainer.Navigator.CursorMode == CursorMode.Manual) { this.currentDragOperation = DragOperation.TimelineScroll; this.DoDragTimeline(mousePosition); this.Cursor = Cursors.Hand; } } else { if (!DragDropHelper.MouseNearPanelBottomEdge(mousePosition, this.ActualHeight)) { this.currentDragOperation = DragOperation.PanelReorder; DataObject data = new DataObject(); data.SetData(DragDropDataName.DragDropOperation, DragDropOperation.ReorderPanel); data.SetData(DragDropDataName.VisualizationPanel, this.VisualizationPanel); data.SetData(DragDropDataName.VisualizationPanelView, this); data.SetData(DragDropDataName.MouseOffsetFromTop, mousePosition.Y); data.SetData(DragDropDataName.PanelSize, new Size?(new Size(this.ActualWidth, this.ActualHeight))); RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap((int)this.ActualWidth, (int)this.ActualHeight, 96, 96, PixelFormats.Pbgra32); renderTargetBitmap.Render(this); data.SetImage(renderTargetBitmap); DragDrop.DoDragDrop(this, data, DragDropEffects.Move); this.Cursor = Cursors.Hand; } } }
public MainWindow() { System.Threading.Thread.CurrentThread.CurrentCulture = defaultCultureInfo; System.Threading.Thread.CurrentThread.CurrentUICulture = defaultCultureInfo; Utils.cultureInfo = defaultCultureInfo; // View models: for controls, dialog boxes and the main window model SchemaList = new ObservableCollection <DcTable>(); TableList = new ObservableCollection <DcTable>(); ColumnList = new ObservableCollection <DcColumn>(); // Model: business object being shown/edited Space = new Space(); DragDropHelper = new DragDropHelper(); InitializeComponent(); // Views: dialog boxes, controls and other visual elements columnBox = new ColumnBox(this); // Create new empty mashup Operation_NewSpace(); }
protected override void OnDragEnter(DragEventArgs e) { if (DragDropHelper.AllowDrop( e.Data, Context, typeof(Activity))) { e.Effects = (DragDropEffects.Move & e.AllowedEffects); e.Handled = true; } else { var data = e.Data.GetData(Constants.DATA_FORMAT) as XElement; if (Utilities.CheckValidDrop(data, Constants.SCRIPT)) { e.Effects = (DragDropEffects.Move & e.AllowedEffects); e.Handled = true; } else { e.Effects = DragDropEffects.None; e.Handled = true; } } base.OnDragEnter(e); }
public MainPage() { InitializeComponent(); dragHelper = new DragDropHelper(); State = Persistence.GlobalState.Load(); State.Translations.ChangeLocale(Options.Locale); DataContext = State; SetWindowTitle(); // TODO: move this block to XAML, see http://www.galasoft.ch/mydotnet/articles/article-2007081301.aspx itemCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(LiftItems); itemCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("Category")); itemCollectionView.SortDescriptions.Add(new SortDescription("Category", ListSortDirection.Descending)); itemCollectionView.SortDescriptions.Add(new SortDescription("Title", ListSortDirection.Ascending)); LiftItems.CollectionChanged += (sender, e) => { Console.WriteLine(DateTime.Now + " LiftItems.CollectionChanged/2 triggered"); //UpdateLiftItems(); }; lbLiftItems.SelectedIndex = 0; lbLiftItems.Focus(); // set jumplist items in case they were changed outside of the program Helpers.JumpListHelper.Update(itemCollectionView.Cast <Data.LiftItem>()); //lbLiftItems.DragEnter += new DragEventHandler(lbLiftItems_DragEnter); //lbLiftItems.DragOver += new DragEventHandler(lbLiftItems_DragOver); }
void IDataObject.GetData(FORMATETC[] fmt, STGMEDIUM[] m) { STGMEDIUM retMedium = new STGMEDIUM(); if (fmt == null || fmt.Length < 1) { return; } foreach (DataCacheEntry e in this.entries) { if (e.Format.cfFormat == fmt[0].cfFormat /*|| fmt[0].cfFormat == InternalNativeMethods.CF_HDROP*/) { retMedium.tymed = e.Format.tymed; // Caller must delete the memory. retMedium.unionmember = DragDropHelper.CopyHGlobal(new IntPtr(e.Data)); break; } } if (m != null && m.Length > 0) { m[0] = retMedium; } }
internal void OnPreviewDragOverPanel(DragEventArgs e) { // Do not do auto-connect if we are currently auto-splitting. if (this.panel.CurrentAutoSplitTarget != null) { return; } DependencyObject currentTarget = this.CurrentTarget; if (currentTarget != null) { Rect rect = GetAutoConnectHitRect(currentTarget); if (rect.Contains(e.GetPosition(this.panel))) { // Do not update the adorner if the cursor is still in the hit region of the current target return; } } ModelItem draggedModelItem = DragDropHelper.GetDraggedModelItemInternal(e); DependencyObject draggedView = draggedModelItem != null ? draggedModelItem.View : null; AutoConnectDirections direction; UIElement target = this.FindTarget(e.GetPosition(this.panel), draggedView, out direction) as UIElement; this.RemoveDropTargets(); if (target != null && (direction & this.panel.AutoConnectContainer.GetDirectionsAllowed(e, target)) != AutoConnectDirections.None) { this.AddDropTargets(e, target, direction); } }
/// <summary> /// ドラッグ&ドロップ操作の開始 /// </summary> /// <param name="sender">イベント発行元</param> /// <param name="e">ドラッグイベント情報</param> private void OnDragEnter(object sender, DragEventArgs e) { if (IsDropFromTextBox(e)) { return; } bool canExecute = this.Command?.CanExecute(e.Data) ?? false; var effect = canExecute ? (e.AllowedEffects & this.AllowEffects) : DragDropEffects.None; if (this.SetDescription) { if (this.UseDescriptionIcon) { DragDropHelper.SetDescription(e.Data, this.DescriptionIcon, this.DescriptionMessage, this.DescriptionInsertion); } else { DragDropHelper.SetDescription(e.Data, effect, this.DescriptionMessage, this.DescriptionInsertion); } } var position = e.GetPosition(this.AssociatedObject); this._dragDropHelper.DragEnter(e.Data, position, effect); e.Effects = effect; e.Handled = true; }
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; }
public ActionEditor() { this.InitializeComponent(); container.DataContext = this; DDH = new DragDropHelper<CortanaCommand>(ActionSequence, ActionPicker); }
public ActionEditor() { this.InitializeComponent(); container.DataContext = this; DDH = new DragDropHelper <CortanaCommand>(ActionSequence, ActionPicker); }
private void CheckMainWindow() { if (__MainWindow == null) { __MainWindow = DragDropHelper.GetMainWindow(this); } }
public static string GetSourceProjectPath(Microsoft.VisualStudio.OLE.Interop.IDataObject dataObject) { string projectPath = null; FORMATETC fmtetc = CreateFormatEtc(CF_VSPROJECTCLIPDESCRIPTOR); if (QueryGetData(dataObject, ref fmtetc) == VSConstants.S_OK) { STGMEDIUM stgmedium = DragDropHelper.GetData(dataObject, ref fmtetc); if (stgmedium.tymed == (uint)TYMED.TYMED_HGLOBAL) { // We are releasing the cloned hglobal here. IntPtr dropInfoHandle = stgmedium.unionmember; if (dropInfoHandle != IntPtr.Zero) { try { string path = GetData(dropInfoHandle); // Clone the path that we can release our memory. if (!String.IsNullOrEmpty(path)) { projectPath = String.Copy(path); } } finally { Marshal.FreeHGlobal(dropInfoHandle); } } } } return(projectPath); }
private void BeginDragOperation(Point mousePosition) { // If the mouse moved mostly horizontally, then we'll begin a timeline scroll // operation, otherwise we'll begin a Visualization Panel reorder operation if (this.IsHorizontalDrag(mousePosition)) { this.currentDragOperation = DragOperation.TimelineScroll; this.DoDragTimeline(mousePosition); this.Cursor = Cursors.Hand; } else { if (!DragDropHelper.MouseNearPanelBottomEdge(mousePosition, this.ActualHeight)) { this.currentDragOperation = DragOperation.PanelReorder; DataObject data = new DataObject(); data.SetData("DragOperation", "ReorderPanels"); data.SetData("VisualizationPanel", this.VisualizationPanel); data.SetData("VisualizationPanelView", this); data.SetData("MouseOffsetFromTop", mousePosition.Y); data.SetData("PanelSize", new Size?(new Size(this.ActualWidth, this.ActualHeight))); RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap((int)this.ActualWidth, (int)this.ActualHeight, 96, 96, PixelFormats.Pbgra32); renderTargetBitmap.Render(this); data.SetImage(renderTargetBitmap); DragDrop.DoDragDrop(this, data, DragDropEffects.Move); this.Cursor = Cursors.Hand; } } }
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; }
protected virtual void Dispose(bool disposing) { Logging.Debug("LibraryCatalogOverviewControl::Dispose({0}) @{1}", disposing, dispose_count); WPFDoEvents.InvokeInUIThread(() => { WPFDoEvents.SafeExec(() => { if (dispose_count == 0) { // Get rid of managed resources / get rid of cyclic references: library_index_hover_popup?.Dispose(); } }); WPFDoEvents.SafeExec(() => { WPFDoEvents.AssertThisCodeIsRunningInTheUIThread(); if (dispose_count == 0) { WizardDPs.ClearPointOfInterest(PanelSearchScore); } }); WPFDoEvents.SafeExec(() => { if (dispose_count == 0) { WizardDPs.ClearPointOfInterest(ObjLookInsidePanel); } }); WPFDoEvents.SafeExec(() => { TextTitle.MouseLeftButtonUp -= TextTitle_MouseLeftButtonUp; ButtonOpen.ToolTipOpening -= HyperlinkPreview_ToolTipOpening; ButtonOpen.ToolTipClosing -= HyperlinkPreview_ToolTipClosing; ListSearchDetails.SearchClicked -= ListSearchDetails_SearchSelectionChanged; DataContextChanged -= LibraryCatalogOverviewControl_DataContextChanged; }); WPFDoEvents.SafeExec(() => { DataContext = null; }); WPFDoEvents.SafeExec(() => { // Clear the references for sanity's sake library_index_hover_popup = null; drag_drop_helper = null; }); ++dispose_count; }); }
private int GetViewLastEditorColumnId() { if (__MainWindow == null) { __MainWindow = DragDropHelper.GetMainWindow(this); } return(__MainWindow.GetViewColumnId(GetLastEditorColumnId())); }
protected DragDropHelper ddHelper; // It is used to check what is possible and to execute actions public SubsetTreeControl() { if (App.Current != null && App.Current.MainWindow != null) // Note: If we do not do it, then this control will raise exception at design time (at run time everything is ok) { ddHelper = ((MainWindow)App.Current.MainWindow).DragDropHelper; } InitializeComponent(); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote row = document.FindOutlinerNoteById(__NodeId); MainWindow window = DragDropHelper.GetMainWindow(treeListView); if (document.HostNode == row && row != null) { window.DoUnhoist(row); } }
public List <ModelItem> SortSelectedItems(List <ModelItem> selectedItems) { if (selectedItems == null) { throw FxTrace.Exception.ArgumentNull("selectedItems"); } DragDropHelper.ValidateItemsAreOnView(selectedItems, this.ModelItem.Properties[StateMachineDesigner.StatesPropertyName].Collection); return(selectedItems); }
public void OnItemsMoved(List <ModelItem> movedItems) { if (movedItems == null) { throw FxTrace.Exception.ArgumentNull("movedItems"); } DragDropHelper.ValidateItemsAreOnView(movedItems, this.ModelItem.Properties[StateMachineDesigner.StatesPropertyName].Collection); this.DoDeleteItems(movedItems, false); }
public List <ModelItem> SortSelectedItems(List <ModelItem> selectedItems) { if (selectedItems == null) { throw FxTrace.Exception.ArgumentNull("selectedItems"); } DragDropHelper.ValidateItemsAreOnView(selectedItems, this.modelElement.Keys); return(selectedItems); }
private void SourceListView_DragItemsStarting(object sender, DragItemsStartingEventArgs e) { ListView source = sender as ListView; if (source.Equals(ActionSequence)) { DDH = new DragDropHelper<CortanaCommand>(ActionSequence, ActionPicker); } else { DDH = new DragDropHelper<CortanaCommand>(ActionPicker, ActionSequence); } DDH.SourceListView_DragItemsStarting(sender, e); }
protected override void OnDragEnter(DragEventArgs e) { if (this.AutoSplitEnabled && this.AutoSplitContainer != null && DragDropHelper.GetDraggedObjectCount(e) == 1 && this.AutoSplitContainer.CanAutoSplit(e)) { this.HighlightForAutoSplit(); this.Panel.RemoveAutoConnectAdorner(); this.Panel.CurrentAutoSplitTarget = this; } base.OnDragEnter(e); }
private static void OnEnableDragDropPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs) { var newValue = (bool)eventArgs.NewValue; if (newValue) { var pickerList = (PickerList)dependencyObject; DragDropHelper.SetIsDragSource(pickerList.listBox, true); DragDropHelper.SetIsDropTarget(pickerList.listBox, true); } }
protected override void OnPreviewDragOver(DragEventArgs e) { if (this.IsOutmostPanel()) { if (this.AutoConnectEnabled && DragDropHelper.GetDraggedObjectCount(e) == 1) { this.autoConnectHelper.OnPreviewDragOverPanel(e); } } base.OnPreviewDragOver(e); }
void FileDrop(object sender, DragEventArgs e) { string[] fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[]; foreach (var fileName in fileNames) { DragDropHelper.UploadFile(fileName); } e.Handled = true; }
public static int GetFocusedColumnIdx(TreeListView outlinerTree, OutlinerNote note) { MainWindow mainWindow = DragDropHelper.GetMainWindow(outlinerTree); if (mainWindow.IsEditorSelected == true) { return(mainWindow.LastColumn); } return(-1); }
void FileDrop(object sender, DragEventArgs e) { ClientStats.LogEvent("Drop document in images view"); string[] fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[]; foreach (var fileName in fileNames) { DragDropHelper.UploadFile(fileName); } e.Handled = true; }
public WorkflowViewElement GetViewElement(ModelItem modelItem, ICompositeView sourceContainer) { WorkflowViewElement itemView = (WorkflowViewElement)this.ViewService.GetView(modelItem); if (null != sourceContainer) { DragDropHelper.SetCompositeView(itemView, (UIElement)sourceContainer); } itemView.Loaded += this.OnViewLoaded; itemView.Unloaded += this.OnViewUnloaded; return(itemView); }
internal void BeginDragShadowTracking(DragDropHelper.ViewElementDragShadow dragShadow) { // Returns the first adorner layer in the visual tree above a specified Visual. AdornerLayer layer = this.GetAdornerLayerForDragShadow(); if (null != layer) { layer.Add(dragShadow); this.viewElementDragShadow = dragShadow; //register for window messages notification this.Context.Services.GetService<WindowHelperService>().RegisterWindowMessageHandler(new WindowMessage(OnMessage)); } }
internal void EndDragShadowTracking(DragDropHelper.ViewElementDragShadow dragShadow) { AdornerLayer layer = this.GetAdornerLayerForDragShadow(); if (null != layer) { //unregister from window message notification this.Context.Services.GetService<WindowHelperService>().UnregisterWindowMessageHandler(new WindowMessage(OnMessage)); layer.Remove(dragShadow); this.viewElementDragShadow = null; } }