private void OnMouseDown(Event e) { Image comp = e.Target as Image; if (null == comp) { return; } // check if dragged item is child of _pnlSource or _pnlDest if (_pnlSource.ContentContains(comp) || _pnlDest.ContentContains(comp)) { DragSource dataSource = new DragSource(); //dataSource.AddData(comp.Text, "text"); // add text for COPY_TEXT mode //dataSource.AddData(comp.StyleName, "style"); // add text for COPY_STYLE mode //dataSource.AddData(comp, "control"); // add reference to control for Move mode Image proxy = new Image { Texture = comp.Texture, // reference the same texture ScaleMode = ImageScaleMode.ScaleToFit //// TEMP: handles the DragDropManager missing bounds clonning //Bounds = (Rectangle) comp.GlobalBounds.Clone(), //// TEMP: handles the DragDropManager missing MouseEnabled enabled turning off on the proxy //MouseEnabled = false }; DragDropManager.DoDrag(comp, dataSource, (MouseEvent)e, proxy, 0, 0, 0.5f, false); /*new DragOption(DragOptionType.ProxyVisible, false), * new DragOption(DragOptionType.FeedbackVisible, false)*/ } }
/// <summary> /// Creates adornment. /// </summary> /// <param name="ordersAndStops">Collection of orders and stops.</param> /// <param name="source">Source where orders are dragged from.</param> /// <returns>Adornment.</returns> public static IAdornment CreateAdornment(IList<object> ordersAndStops, DragSource source) { Debug.Assert(ordersAndStops != null); Debug.Assert(ordersAndStops.Count > 0); IAdornment adornment = null; switch (source) { case DragSource.FindView: case DragSource.OrdersView: adornment = _CreateOrdersViewAdornment(ordersAndStops); break; case DragSource.RoutesView: adornment = _CreateRoutesViewAdornment(ordersAndStops); break; case DragSource.MapView: adornment = _CreateMapViewAdornment(ordersAndStops); break; case DragSource.TimeView: adornment = _CreateGanttViewAdornment(ordersAndStops); break; default: Debug.Assert(false); break; } return adornment; }
public static void FinalizeDrag() { _isDragging = false; _dragSource = null; _dragContextInfo = null; DragContext = null; }
private void EndDrag(bool abort) { if (abort) { return; } if (!Outline.FloatWindowBounds.IsEmpty) { DragSource.FloatAt(Outline.FloatWindowBounds); } else if (Outline.DockTo is DockPane) { DockPane pane = Outline.DockTo as DockPane; DragSource.DockTo(pane, Outline.Dock, Outline.ContentIndex); } else if (Outline.DockTo is DockPanel) { DockPanel panel = Outline.DockTo as DockPanel; panel.UpdateDockWindowZOrder(Outline.Dock, Outline.FlagFullEdge); DragSource.DockTo(panel, Outline.Dock); } if (DragSource is DockContentHandler && ((DockContentHandler)DragSource).Content is ITabbedDocument) { ((DockContentHandler)DragSource).Content.DockHandler.Activate(); } }
// Start is called before the first frame update void Start() { //Mouse events should only interact with robots, not with other elements Physics.queriesHitTriggers = false; if (Levels != null) { Scene scene = SceneManager.GetActiveScene(); int index = Array.IndexOf(Levels, scene.name); if (index >= 0) { // Set up the next level that we'll load into when the user wins if (index == Levels.Length - 1) { // We're on the final level now nextLevel = null; } else { nextLevel = Levels[index + 1]; } } } if (nextLevelButton) { nextLevelButton.gameObject.SetActive(nextLevel != null); } DragSource.EnablePopups(); }
protected override void OnMouseDoubleClick(MouseButtonEventArgs e) { base.OnMouseDoubleClick(e); if (_isDragging) { return; } // Double-click ends any manipulation which may be in progress. // Otherwise bugs may happen (e.g. if the default action moves the card) if (IsMouseCaptured) { ReleaseMouseCapture(); } _dragSource = DragSource.None; if (e.ChangedButton != MouseButton.Left) { return; } e.Handled = true; if (GroupControl != null) { GroupControl.ExecuteDefaultAction(Card); } }
private bool InitDrag(Control c, DragSource source) { if (!base.BeginDrag(c)) { return(false); } m_source = source; if (Source == DragSource.Content || Source == DragSource.Pane || Source == DragSource.FloatWindow) { m_dockOutline = new DockOutline(); m_dockIndicator = new DockIndicator(this); DockIndicator.Show(false); } else if (Source == DragSource.AutoHideWindowSplitter || Source == DragSource.DockWindowSplitter || Source == DragSource.PaneSplitter) { m_splitterOutline = new SplitterOutline(); } else { return(false); } return(true); }
/// <inheritdoc /> public override void OnDragPerform(DragPerformEvent e) { var dropElements = DragSource.GetSelection(); var contentViewContainer = (e.target as GraphView)?.ContentViewContainer ?? e.target as VisualElement; var variablesToCreate = dropElements .OfType <IVariableDeclarationModel>() .Select((e1, i) => ( e1, GUID.Generate().ToSerializableGUID(), contentViewContainer.WorldToLocal(e.mousePosition) + i * DragDropSpacer * Vector2.down)) .ToList(); var droppedNodes = dropElements.OfType <INodeModel>(); if (droppedNodes.Any(e2 => !(e2 is IVariableNodeModel)) && variablesToCreate.Any()) { // no way to handle this ATM throw new ArgumentException("Unhandled case, dropping blackboard/variables fields and nodes at the same time"); } if (variablesToCreate.Any()) { Stencil.OnDragAndDropVariableDeclarations(Dispatcher, variablesToCreate); } }
/// <summary> /// Creates adornment. /// </summary> /// <param name="ordersAndStops">Collection of orders and stops.</param> /// <param name="source">Source where orders are dragged from.</param> /// <returns>Adornment.</returns> public static IAdornment CreateAdornment(IList <object> ordersAndStops, DragSource source) { Debug.Assert(ordersAndStops != null); Debug.Assert(ordersAndStops.Count > 0); IAdornment adornment = null; switch (source) { case DragSource.FindView: case DragSource.OrdersView: adornment = _CreateOrdersViewAdornment(ordersAndStops); break; case DragSource.RoutesView: adornment = _CreateRoutesViewAdornment(ordersAndStops); break; case DragSource.MapView: adornment = _CreateMapViewAdornment(ordersAndStops); break; case DragSource.TimeView: adornment = _CreateGanttViewAdornment(ordersAndStops); break; default: Debug.Assert(false); break; } return(adornment); }
private void EndDrag(bool abort) { if (abort) { return; } if (!Outline.FloatWindowBounds.IsEmpty) { if (!(DragSource is FloatWindow) && !((DragSource as DockPane)?.IsFloat ?? false)) { DockPanel.OnBeforeDocumentDragged(); } DragSource.FloatAt(Outline.FloatWindowBounds); } else if (Outline.DockTo is DockPane) { DockPanel.OnBeforeDocumentDragged(); DockPane pane = Outline.DockTo as DockPane; DragSource.DockTo(pane, Outline.Dock, Outline.ContentIndex); } else if (Outline.DockTo is DockPanel) { DockPanel.OnBeforeDocumentDragged(); DockPanel panel = Outline.DockTo as DockPanel; panel.UpdateDockWindowZOrder(Outline.Dock, Outline.FlagFullEdge); DragSource.DockTo(panel, Outline.Dock); } }
protected void LeftButtonDownOverImage(object sender, MouseEventArgs e) { e.Handled = true; if (_isDragging) { return; } _isOverCount = false; if (Card == null) { return; } if (!Card.Selected) { Selection.Clear(); } _mousePt = e.GetPosition(this); Window window = Window.GetWindow(this); if (window != null) { _mouseWindowPt = TranslatePoint(_mousePt, (UIElement)window.Content); } _dragSource = Keyboard.Modifiers == ModifierKeys.Shift ? DragSource.Target : DragSource.Card; CaptureMouse(); }
private GameObject CreateCardDisplay(Card cardData) { Transform cardHolder = GetNextAvailableCardHolder(); GameObject cardObject = Instantiate(cardPrefab, cardHolder); CardUI cardUI = cardObject.GetComponent <CardUI>(); cardUI.cardData = cardData; DragSource dragSource = cardObject.GetComponent <DragSource>(); if (dragSource != null) { dragSource.enabled = cardDraggable; } HoverCardOverlay cardHover = cardObject.GetComponent <HoverCardOverlay>(); if (cardHover != null) { cardHover.hoverParent = hoverParent; } return(cardObject); }
protected override void OnMouseUp(MouseButtonEventArgs e) { base.OnMouseUp(e); switch (e.ChangedButton) { case MouseButton.Left: if (IsMouseCaptured) { ReleaseMouseCapture(); } if (_dragSource == DragSource.Card) { e.Handled = true; _dragSource = DragSource.None; if (_isDragging) { _isDragging = false; DragCardCompleted(); } break; } if (_dragSource == DragSource.Target) { e.Handled = true; _dragSource = DragSource.None; if (_draggedArrow != null) { _draggedArrow.RemoveFromLayer(); _draggedArrow = null; } if (_isDragging) { _isDragging = false; } var dependencyObject = Mouse.DirectlyOver as DependencyObject; while (dependencyObject != null && !(dependencyObject is CardControl)) { DependencyObject parent = LogicalTreeHelper.GetParent(dependencyObject) ?? VisualTreeHelper.GetParent(dependencyObject); dependencyObject = parent; } if (dependencyObject == this) { Card.ToggleTarget(); } else if (dependencyObject != null && ((CardControl)dependencyObject).Card.Group is Table) { Card.Target(((CardControl)dependencyObject).Card); } } break; } }
private void TestDrop() { if (Outline == null || Indicator == null || Indicator.IsDisposed) { return; } Outline.FlagTestDrop = false; Indicator.FullPanelEdge = ((Control.ModifierKeys & Keys.Shift) != 0); if ((Control.ModifierKeys & Keys.Control) == 0) { Indicator.TestDrop(); if (!Outline.FlagTestDrop) { DockPane pane = DockHelper.PaneAtPoint(Control.MousePosition, DockPanel); if (pane != null && DragSource.IsDockStateValid(pane.DockState)) { pane.TestDrop(DragSource, Outline); } } if (!Outline.FlagTestDrop && DragSource.IsDockStateValid(DockState.Float)) { FloatWindow floatWindow = DockHelper.FloatWindowAtPoint(Control.MousePosition, DockPanel); if (floatWindow != null) { floatWindow.TestDrop(DragSource, Outline); } } } else { Indicator.DockPane = DockHelper.PaneAtPoint(Control.MousePosition, DockPanel); } if (!Outline.FlagTestDrop) { if (DragSource.IsDockStateValid(DockState.Float)) { Rectangle rect = FloatOutlineBounds; rect.Offset(Control.MousePosition.X - StartMousePosition.X, Control.MousePosition.Y - StartMousePosition.Y); Outline.Show(rect); } } if (!Outline.FlagTestDrop) { Cursor.Current = Cursors.No; Outline.Show(); } else { Cursor.Current = DragControl.Cursor; } }
/// <summary> /// Method initialize drag operation /// </summary> /// <param name="draggingOrders"></param> public void StartDragOrders(Collection <object> draggingOrdersAndStops, DragSource dragSource) { // Get orders from stops and orders. Collection <Order> draggingOrders = GetOrdersFromObjectsCollection(draggingOrdersAndStops); if (draggingOrders.Count == 0) { return; } // Decline dragging if orders and stops not belongs to the same date. bool isSameDate = _CheckOrdersAndStopsIsFromSameDate(draggingOrdersAndStops); if (!isSameDate) { string message = (string)App.Current.FindResource(DRAGGING_ORDERS_WITH_DIFFERENT_DAYS_PROHIBITED_RESOURCE_NAME); App.Current.Messenger.AddWarning(message); return; } // Create data object for drag and drop. IDataObject draggingObject = _CreateDraggingObject(draggingOrders); if (draggingObject == null) { return; } try { // Create adornment. IAdornment adornment = AdornmentFactory.CreateAdornment(draggingOrdersAndStops, dragSource); // Create feedbacker. using (DragDropFeedbacker feedbacker = new DragDropFeedbacker(adornment)) { if (DragStarted != null) { DragStarted(this, EventArgs.Empty); } DragDropEffects effect = DragDrop.DoDragDrop(feedbacker, draggingObject, DragDropEffects.None | DragDropEffects.Move); } } catch (Exception ex) { Logger.Error(ex); } finally { if (DragEnded != null) { DragEnded(this, EventArgs.Empty); } } }
private bool InitDrag(Control c, DragSource dragSource) { if (!base.BeginDrag(c)) { return(false); } m_dragSource = dragSource; DropTarget.Clear(); return(true); }
protected override void OnEndDrag(bool abort) { DockPanel.SuspendLayout(true); Outline.Close(); if (!abort) { DragSource.MoveSplitter(GetMovingOffset(Control.MousePosition)); } DragSource.EndDrag(); DockPanel.ResumeLayout(true, true); }
public static void InitializeDrag(FrameworkElement source, Point startPoint) { if (_dragSources.ContainsKey(source)) { _dragSource = _dragSources[source]; FrameworkElement sourceElement = _dragSource.SourceElement; _dragContextInfo = FindDragContext(source); DragContext = _dragContextInfo.Context; DragStartPosition = source.TranslatePoint(startPoint, DragContext); } }
public void OnDragSourceDropped(DragSource source) { if (enabled && source.gameObject != gameObject) { if (onDropSound) { audioSource.PlayOneShot(onDropSound, 2f); } onDrop.Invoke(this, source); } }
/// <summary> /// Updates the drag drop allowed properties. /// </summary> protected virtual void UpdateIsDragDropPossible() { CanonicSelection CanonicSelectedItemList = new CanonicSelection(CreateItemList()); if (GetCanonicSelectedItemList(CanonicSelectedItemList)) { DragSource.SetIsDragPossible(CanonicSelectedItemList); } else { DragSource.ClearIsDragPossible(); DragSource.ClearFlatDraggedItemList(); } }
/// <summary> /// Performs a drag after the mouse has moved. /// </summary> /// <param name="e">The event data.</param> protected virtual void DragAfterMouseMove(MouseEventArgs e) { if (AllowDragDrop && e.LeftButton == MouseButtonState.Pressed && (Keyboard.FocusedElement is ExtendedTreeViewItemBase)) { if (IsCopyPossible) { ExtendedTreeViewItemBase?ItemContainer = GetEventSourceItem(e); if (ItemContainer != null) { DebugMessage("Drag Started"); DragSource.DragAfterMouseMove(e); } } } }
/// <summary> /// Occurs when activity of the current drag drop operation has changed. /// </summary> /// <param name="sender">The event source.</param> /// <param name="e">The event data.</param> protected virtual void OnDragActivityChanged(object?sender, EventArgs e) { Contract.RequireNotNull(sender, out IDragSourceControl Ctrl); bool IsHandled = false; switch (Ctrl.DragActivity) { case DragActivity.Idle: IsHandled = true; break; case DragActivity.Starting: bool IsDragPossible = DragSource.IsDragPossible(out _, out IList ItemList); Debug.Assert(IsDragPossible); SetDragItemList(DragSource, ItemList); CancellationToken cancellation = new CancellationToken(); NotifyDragStarting(cancellation); if (cancellation.IsCanceled) { Ctrl.CancelDrag(); } IsHandled = true; break; case DragActivity.Started: DataObject Data = new DataObject(DragSource.GetType(), DragSource); DragDropEffects AllowedEffects = DragDropEffects.Move; if (DragSource.AllowDropCopy) { AllowedEffects |= DragDropEffects.Copy; } DragDrop.DoDragDrop(this, Data, AllowedEffects); ClearCurrentDropTarget(); IsHandled = true; break; default: break; } Debug.Assert(IsHandled); }
/// <summary> /// Gets the drag source from arguments of a drag drop event. /// </summary> /// <param name="e">The event data.</param> /// <param name="dragSource">The drag source upon return.</param> /// <returns>True if successful.</returns> protected virtual bool GetValidDragSourceFromArgs(DragEventArgs e, out IDragSourceControl dragSource) { if (e.Data.GetDataPresent(DragSource.GetType())) { if (e.Data.GetData(DragSource.GetType()) is IDragSourceControl AsDragSource) { if (AsDragSource.HasDragItemList(out object RootItem, out IList _) && IsSameTypeAsContent(RootItem)) { dragSource = AsDragSource; return(true); } } } Contract.Unused(out dragSource); return(false); }
public void OnCardDrop(DragSource source) { CardUI sourceCardUI = source.GetComponent <CardUI>(); InstantiateUnit(sourceCardUI.cardData as UnitCard); playAction = CreatePlayCardAction(sourceCardUI.cardData as UnitCard); handManager.AddPlayAction(playAction); Destroy(source.gameObject); UIManager.instance.ValidateDropCost(); foreach (DropTarget target in GetComponents <DropTarget>()) { target.enabled = false; } }
protected override void OnEndDrag(bool abort) { DockPanel.SuspendLayout(true); Outline.Close(); Indicator.Close(); EndDrag(abort); // Queue a request to layout all children controls DockPanel.PerformMdiClientLayout(); DockPanel.ResumeLayout(true, true); DragSource.EndDrag(); DragSource = null; }
public void OnUnitDrop(DragSource source) { UnitHolder originalHolder = source.originalParent.GetComponent <UnitHolder>(); RemovePlayAction(originalHolder.playAction); originalHolder.playAction = null; GameObject cardObject = CreateCardDisplay(source.GetComponent <UnitUI>().cardData); cardObject.transform.position = cardObject.transform.parent.position; foreach (DropTarget target in originalHolder.GetComponents <DropTarget>()) { target.enabled = true; } Destroy(source.gameObject); UIManager.instance.ValidateDropCost(); }
private void EndDrag(bool abort) { if (abort) return; if (!Outline.FloatWindowBounds.IsEmpty) DragSource.FloatAt(Outline.FloatWindowBounds); else if (Outline.DockTo is DockPane) { DockPane pane = Outline.DockTo as DockPane; DragSource.DockTo(pane, Outline.Dock, Outline.ContentIndex); } else if (Outline.DockTo is DockPanel) { DockPanel panel = Outline.DockTo as DockPanel; panel.UpdateDockWindowZOrder(Outline.Dock, Outline.FlagFullEdge); DragSource.DockTo(panel, Outline.Dock); } }
private void OnRecordPresenterLoaded(object sender, RoutedEventArgs e) { var recordPresenter = sender as DataRecordPresenter; if (DragDropManager.GetDragSource(recordPresenter) != null) { return; } var dragSource = new DragSource { IsDraggable = true }; dragSource.DragStart += new System.EventHandler <DragDropStartEventArgs>(dragSource_DragStart); dragSource.Drop += OnRecordDragDrop; dragSource.DragTemplate = ((Window)Utilities.GetAncestorFromType(this.dataPresenter, typeof(Window), true)).Resources["dragTemplate"] as DataTemplate; DragDropManager.SetDragSource(recordPresenter, dragSource); }
private bool CanAccept(GameObject drag, out DragSource source) { source = null; if (!enabled) { return(false); } if (drag == null) { return(false); } source = drag.GetComponent <DragSource>(); if (source == null) { return(false); } return(source.type == type); }
public void OnUnitDrop(DragSource source) { UnitHolder originalHolder = source.originalParent.GetComponent <UnitHolder>(); source.transform.SetParent(transform); source.transform.position = transform.position; handManager.RemovePlayAction(originalHolder.playAction); originalHolder.playAction = null; playAction = CreatePlayCardAction(source.GetComponent <UnitUI>().cardData); handManager.AddPlayAction(playAction); foreach (DropTarget target in GetComponents <DropTarget>()) { target.enabled = false; } foreach (DropTarget target in originalHolder.GetComponents <DropTarget>()) { target.enabled = true; } }
private void EndDrag(bool abort) { if (abort) { return; } if (!Outline.FloatWindowBounds.IsEmpty) { DragSource.FloatAt(Outline.FloatWindowBounds); } else if (Outline.DockTo is DockPane) { var pane = (DockPane)Outline.DockTo; DragSource.DockTo(pane, Outline.Dock, Outline.ContentIndex); } else if (Outline.DockTo is DockPanel) { var panel = (DockPanel)Outline.DockTo; panel.UpdateDockWindowZOrder(Outline.Dock, Outline.FlagFullEdge); DragSource.DockTo(panel, Outline.Dock); } }
protected void LeftButtonDownOverImage(object sender, MouseEventArgs e) { e.Handled = true; if (_isDragging) return; _isOverCount = false; if (Card == null) return; if (!Card.Selected) Selection.Clear(); _mousePt = e.GetPosition(this); Window window = Window.GetWindow(this); if (window != null) _mouseWindowPt = TranslatePoint(_mousePt, (UIElement) window.Content); _dragSource = Keyboard.Modifiers == ModifierKeys.Shift ? DragSource.Target : DragSource.Card; CaptureMouse(); }
private void grdNotes_PreviewMouseMove(object sender, MouseEventArgs e) { try { if (e.LeftButton != MouseButtonState.Pressed) return; if (!grdNotes.IsMouseCaptured) return; var ef = DragDropEffects.Move | DragDropEffects.Scroll; var gr = getSelectedGroup(); if (gr == null) { ef = DragDropEffects.None; _DragSource = DragSource.None; } else if (gr.ID <= (int)SpecialGroups.AllGroups) { if (gr.ID != (int)SpecialGroups.Incoming) { ef = DragDropEffects.None; _DragSource = DragSource.None; } else { _DragSource = DragSource.ListIncoming; } } else { _DragSource = DragSource.ListGroup; } e.Handled = true; var pt = e.GetPosition(null); if (Math.Abs(pt.X - _StartPoint.X) <= SystemParameters.MinimumHorizontalDragDistance && Math.Abs(pt.Y - _StartPoint.Y) <= SystemParameters.MinimumVerticalDragDistance) return; grdNotes.ReleaseMouseCapture(); startDragListView(ef); } catch (Exception ex) { PNStatic.LogException(ex); } }
/// <summary> /// Method initialize drag operation /// </summary> /// <param name="draggingOrders"></param> public void StartDragOrders(Collection<object> draggingOrdersAndStops, DragSource dragSource) { // Get orders from stops and orders. Collection<Order> draggingOrders = GetOrdersFromObjectsCollection(draggingOrdersAndStops); if (draggingOrders.Count == 0) return; // Decline dragging if orders and stops not belongs to the same date. bool isSameDate = _CheckOrdersAndStopsIsFromSameDate(draggingOrdersAndStops); if (!isSameDate) { string message = (string)App.Current.FindResource(DRAGGING_ORDERS_WITH_DIFFERENT_DAYS_PROHIBITED_RESOURCE_NAME); App.Current.Messenger.AddWarning(message); return; } // Create data object for drag and drop. IDataObject draggingObject = _CreateDraggingObject(draggingOrders); if (draggingObject == null) return; try { // Create adornment. IAdornment adornment = AdornmentFactory.CreateAdornment(draggingOrdersAndStops, dragSource); // Create feedbacker. using (DragDropFeedbacker feedbacker = new DragDropFeedbacker(adornment)) { if (DragStarted != null) DragStarted(this, EventArgs.Empty); DragDropEffects effect = DragDrop.DoDragDrop(feedbacker, draggingObject, DragDropEffects.None | DragDropEffects.Move); } } catch (Exception ex) { Logger.Error(ex); } finally { if (DragEnded != null) DragEnded(this, EventArgs.Empty); } }
private void MouseButtonDoubleClickAction(MouseButtonEventArgs e) { base.OnMouseDoubleClick(e); // Double-click ends any manipulation which may be in progress. // Otherwise bugs may happen (e.g. if the default action moves the card) if (IsMouseCaptured) ReleaseMouseCapture(); _dragSource = DragSource.None; Program.GameEngine.EventProxy.OnCardDoubleClick(Card, (int)e.ChangedButton, downKeys); if (e.ChangedButton == MouseButton.Left) { e.Handled = true; if (GroupControl != null) GroupControl.ExecuteDefaultAction(Card); } }
private void MouseButtonUpAction(MouseButtonEventArgs e) { base.OnMouseUp(e); var shouldFireEvent = true; switch (e.ChangedButton) { case MouseButton.Left: if (IsMouseCaptured) ReleaseMouseCapture(); if (_dragSource == DragSource.Card) { shouldFireEvent = false; e.Handled = true; _dragSource = DragSource.None; if (!_isDragging) { Program.GameEngine.EventProxy.OnCardClick(Card, (int)e.ChangedButton, downKeys); } DragCardCompleted(); break; } if (_dragSource == DragSource.Target) { shouldFireEvent = false; e.Handled = true; _dragSource = DragSource.None; if (_draggedArrow != null) { _draggedArrow.RemoveFromLayer(); _draggedArrow = null; } if (_isDragging) { _isDragging = false; } var dependencyObject = Mouse.DirectlyOver as DependencyObject; while (dependencyObject != null && !(dependencyObject is CardControl)) { DependencyObject parent = LogicalTreeHelper.GetParent(dependencyObject) ?? VisualTreeHelper.GetParent(dependencyObject); dependencyObject = parent; } if (dependencyObject == this) Card.ToggleTarget(); else if (dependencyObject != null && ((CardControl)dependencyObject).Card.Group is Table) Card.Target(((CardControl)dependencyObject).Card); } break; } if (shouldFireEvent) Program.GameEngine.EventProxy.OnCardClick(Card, (int)e.ChangedButton, downKeys); }
private bool InitDrag(Control c, DragSource dragSource) { if (!base.BeginDrag(c)) return false; m_dragSource = dragSource; DropTarget.Clear(); return true; }
private void initializeUI() { try { this.Width = Globals.ThisAddIn.iTempWidth; this.Height = Globals.ThisAddIn.iTempHeight; BrightIdeasSoftware.TextOverlay textOverlay = this.listItems.EmptyListMsgOverlay as BrightIdeasSoftware.TextOverlay; textOverlay.TextColor = Color.FromArgb(255, 96, 96, 96); textOverlay.BackColor = System.Drawing.Color.White; textOverlay.BorderWidth = 0; textOverlay.InsetY = 0; textOverlay.Font = new System.Drawing.Font("Serif", 9); rbd = new BrightIdeasSoftware.RowBorderDecoration(); rbd.BorderPen = new Pen(Color.FromArgb(170, Color.DarkGray), 1); rbd.FillBrush = new SolidBrush(Color.FromArgb(40, Color.Black)); rbd.BoundsPadding = new Size(-2, -2); rbd.CornerRounding = 6.0f; this.listItems.SelectedRowDecoration = rbd; this.listItems.CellToolTip.ReshowDelay = 0; alternateRBD = new BrightIdeasSoftware.RowBorderDecoration(); alternateRBD.BorderPen = new Pen(Color.LightGray, 1); alternateRBD.FillBrush = null; alternateRBD.BoundsPadding = new Size(2, 0); alternateRBD.CornerRounding = 0; this.menuitemSortBy.DropDownItems.AddRange(getSortByMenuItems()); this.menuitemSortBy.DropDownItems.Add(new ToolStripSeparator()); this.menuitemSortBy.DropDownItems.AddRange(getSortByDirectionMenuItems()); ((ToolStripMenuItem)this.menuitemSortBy.DropDownItems[Properties.Settings.Default.DEFAULT_SORTBY + ""]).CheckState = CheckState.Indeterminate; ((ToolStripMenuItem)this.menuitemSortBy.DropDownItems[Properties.Settings.Default.DEFAULT_SORTBY + ""]).Checked = true; this.contextmenuSortBy.Items.AddRange(getSortByMenuItems()); this.contextmenuSortBy.Items.Add(new ToolStripSeparator()); this.contextmenuSortBy.Items.AddRange(getSortByDirectionMenuItems()); ((ToolStripMenuItem)this.contextmenuSortBy.Items[Properties.Settings.Default.DEFAULT_SORTBY + ""]).CheckState = CheckState.Indeterminate; ((ToolStripMenuItem)this.contextmenuSortBy.Items[Properties.Settings.Default.DEFAULT_SORTBY + ""]).Checked = true; currentSortBy = (SortByType)Properties.Settings.Default.DEFAULT_SORTBY; DragSource dragSource = new DragSource(); this.listItems.DragSource = dragSource; dragSource.endDragEvent +=new EndDragDelegate(dragSource_endDragEvent); this.treeFolders.ShowNodeToolTips = true; this.treeFolders.ShowLines = true; this.btnMore.Enabled = false; this.btnSearch.BackgroundImageLayout = ImageLayout.Center; buildSearchOptionsContextMenu(); buildFilterFieldsContextMenu(); buildImageList(); prepareLayout(); positionSplitter(); //將來可能需要加上開關QuickStart的checkbox by Gene if (this.chkQuickStartTip.Checked) { Properties.Settings.Default.DEFAULT_SHOWQUICKSTART = true; } try { disableClickSounds(); } catch { } if (Properties.Settings.Default.DEFAULT_SHOWQUICKSTART) { QuickStart quickstart = new QuickStart(Properties.Settings.Default.URL_QUICKSTART); quickstart.Show(); } btnTemplate.PerformClick(); } catch (Exception ex) { this.log.WriteLine(LogType.Error, "MasterControl::initializeUI", ex.ToString()); } }
protected override void OnMouseUp(MouseButtonEventArgs e) { base.OnMouseUp(e); switch (e.ChangedButton) { case MouseButton.Left: if (IsMouseCaptured) ReleaseMouseCapture(); if (_dragSource == DragSource.Card) { e.Handled = true; _dragSource = DragSource.None; if (_isDragging) { _isDragging = false; DragCardCompleted(); } break; } if (_dragSource == DragSource.Target) { e.Handled = true; _dragSource = DragSource.None; if (_draggedArrow != null) { _draggedArrow.RemoveFromLayer(); _draggedArrow = null; } if (_isDragging) { _isDragging = false; } var dependencyObject = Mouse.DirectlyOver as DependencyObject; while (dependencyObject != null && !(dependencyObject is CardControl)) { DependencyObject parent = LogicalTreeHelper.GetParent(dependencyObject) ?? VisualTreeHelper.GetParent(dependencyObject); dependencyObject = parent; } if (dependencyObject == this) Card.ToggleTarget(); else if (dependencyObject != null && ((CardControl) dependencyObject).Card.Group is Table) Card.Target(((CardControl) dependencyObject).Card); } break; } }
private void startDragListView(DragDropEffects e) { try { DataObject dob; if (e != DragDropEffects.None) { dob = new DataObject("notes_list", Tuple.Create(getSelectedGroup(), grdNotes.SelectedItems.OfType<CPNote>().ToList())); } else { dob = new DataObject("empty_list", ""); } DragDrop.DoDragDrop(grdNotes, dob, e); } catch (Exception ex) { PNStatic.LogException(ex); } finally { _DragSource = DragSource.None; if (_HighLightedItem != null) { PNUtils.SetIsHighlighted(_HighLightedItem, false); _HighLightedItem = null; } } }
private bool InitDrag(Control c, DragSource source) { if (!base.BeginDrag(c)) return false; m_source = source; if (Source == DragSource.Content || Source == DragSource.Pane || Source == DragSource.FloatWindow) { m_dockOutline = new DockOutline(); m_dockIndicator = new DockIndicator(this); DockIndicator.Show(false); } else if (Source == DragSource.AutoHideWindowSplitter || Source == DragSource.DockWindowSplitter || Source == DragSource.PaneSplitter) m_splitterOutline = new SplitterOutline(); else return false; return true; }
protected void LeftButtonDownOverImage(object sender, MouseEventArgs e) { e.Handled = true; if (!isDragging) { isOverCount = false; if (!Card.Selected) Selection.Clear(); mousePt = e.GetPosition(this); mouseWindowPt = TranslatePoint(mousePt, (UIElement)Window.GetWindow(this).Content); dragSource = Keyboard.Modifiers == ModifierKeys.Shift ? DragSource.Target : DragSource.Card; cardDragPeacedOut = false; CaptureMouse(); } }
protected override void OnMouseDoubleClick(MouseButtonEventArgs e) { base.OnMouseDoubleClick(e); if (_isDragging) return; // Double-click ends any manipulation which may be in progress. // Otherwise bugs may happen (e.g. if the default action moves the card) if (IsMouseCaptured) ReleaseMouseCapture(); _dragSource = DragSource.None; if (e.ChangedButton != MouseButton.Left) return; e.Handled = true; GroupControl.ExecuteDefaultAction(Card); }
private void startDragTreeView() { try { _InDrag = true; var gr = getSelectedGroup(); if (gr == null || gr.ID <= (int)SpecialGroups.AllGroups) return; _DragSource = DragSource.Tree; DragDrop.DoDragDrop(tvwGroups, tvwGroups.SelectedItem, DragDropEffects.Move | DragDropEffects.Scroll); } catch (Exception ex) { PNStatic.LogException(ex); } finally { _DragReady = false; _InDrag = false; _DragSource = DragSource.None; if (_HighLightedItem != null) { PNUtils.SetIsHighlighted(_HighLightedItem, false); _HighLightedItem = null; } } }