private void left_click_Handler()
        {
            if (MouseUtilities.GetAsyncKeyState(MouseUtilities.VK_LEFTBUTTON) != 0)
            {
                #region
                if (minimap_move_mode == true)
                {
                    Point p  = MouseUtilities.CorrectGetPosition(minimap_image);
                    int   mx = (int)p.X;
                    int   my = (int)p.Y;
                    int   x  = mx / pixel_size - (int)view_rect.Width / 2;
                    int   y  = my / pixel_size - (int)view_rect.Height / 2;

                    int size_zoomCell = (int)(32 * Gl.main.uiScaleSlider.Value);

                    Gl.main.move_scrols_to(x * size_zoomCell, y * size_zoomCell);
                }
                #endregion
            }
            else
            {
                #region
                on_left_click_Timer.AutoReset = false;
                on_left_click_Timer.Stop();

                minimap_move_mode = false;
                #endregion
            }
        }
        void listView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.IsMouseOverScrollbar)
            {
                // 4/13/2007 - Set the flag to false when cursor is over scrollbar.
                this.canInitiateDrag = false;
                return;
            }

            int index = this.IndexUnderDragCursor;

            this.canInitiateDrag = index > -1;

            if (this.canInitiateDrag)
            {
                // Remember the location and index of the ListViewItem the user clicked on for later.
                this.ptMouseDown   = MouseUtilities.GetMousePosition(this.listView);
                this.indexToSelect = index;
            }
            else
            {
                this.ptMouseDown   = new Point(-10000, -10000);
                this.indexToSelect = -1;
            }
        }
        bool IsMouseOver(Visual target)
        {
            Rect  bounds   = VisualTreeHelper.GetDescendantBounds(target);
            Point mousePos = MouseUtilities.GetMousePosition(target);

            return(bounds.Contains(mousePos));
        }
Exemple #4
0
        void mouseZone_MouseMove(object sender, MouseEventArgs e)
        {
            if (IsActive)
            {
                _viewport.Cursor = Cursors.None;

                var centerOfViewport  = _viewport.PointToScreen(new Point(_viewport.ActualWidth / 2, _viewport.ActualHeight / 2));
                var relativePos       = e.MouseDevice.GetPosition(_viewport);
                var actualRelativePos = new Point(relativePos.X - _viewport.ActualWidth / 2, _viewport.ActualHeight / 2 - relativePos.Y);
                var dx = actualRelativePos.X;
                var dy = actualRelativePos.Y;
                _yaw   += dx;
                _pitch += dy;

                // Rotate
                RawRotation = QuaternionHelper.EulerAnglesInDegToQuaternion(_pitch * Sensitivity * 0.1, _yaw * Sensitivity * 0.1, 0);
                UpdatePositionAndRotation();

                // Set mouse position back to the center of the viewport in screen coordinates
                MouseUtilities.SetPosition(centerOfViewport);
            }
            else
            {
                _viewport.Cursor = Cursors.Arrow;
            }
        }
        private void OnPreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (movingPokemon)
            {
                Point ptCursor = new Point();
                if (hoverIndex != -1)
                {
                    if (IsViewingParty)
                    {
                        ptCursor = partyClickAreas[hoverIndex].TranslatePoint(new Point(16, 9), adornerContainer);
                    }
                    else
                    {
                        ptCursor = boxClickAreas[hoverIndex].TranslatePoint(new Point(12, 8), adornerContainer);
                    }
                }
                else
                {
                    ptCursor = MouseUtilities.GetMousePosition(adornerContainer);
                }


                double left = ptCursor.X - 16;
                double top  = ptCursor.Y - 24;

                this.pickupDragAdorner.SetOffsets(left, top);
            }
        }
Exemple #6
0
        public void OnMouseMove(MouseEventArgs e)
        {
            if (!_needsRestore)
            {
                return;
            }

            _needsRestore = false;

            var position = e.GetPosition(_window);
            var bounds   = _window.RestoreBounds;

            var percentHorizontal = position.X / _window.ActualWidth;
            var targetHorizontal  = bounds.Width * percentHorizontal;

            var percentVertical = position.Y / _window.ActualHeight;
            var targetVertical  = bounds.Height * percentVertical;

            var screenPosition = MouseUtilities.GetScreenPosition();

            _window.Left = screenPosition.X - targetHorizontal;
            _window.Top  = screenPosition.Y - targetVertical;

            _window.WindowState = WindowState.Normal;

            _window.DragMove();
        }
Exemple #7
0
 void Update()
 {
     if (MouseUtilities.TouchingUI(rt) && Input.GetMouseButtonDown(0))
     {
         action.Invoke(layer);
     }
 }
Exemple #8
0
        private void OnLocationChanged(object sender, EventArgs e)
        {
            var win = (HostWindow)sender;

            if (!win.IsLoaded || !TabControl.IsTabDragging || TabControl.Items.Count > 1)
            {
                return;
            }

            var absolutePoint = MouseUtilities.GetScreenPosition();

            var windowUnder = win.FindWindowUnderAt(absolutePoint);

            if (windowUnder == null)
            {
                return;
            }

            // The screen position relative to the main window
            var relativePoint = windowUnder.PointFromScreen(absolutePoint);

            if (TryDockToWindow(windowUnder, relativePoint, TabControl.SelectedItem as TabViewModelBase))
            {
                win.Close();
            }
        }
        internal void StartTabDrag(Point p, ChromeTabItem tab = null, bool isTabGrab = false)
        {
            this._lastMouseDown = DateTime.UtcNow;
            if (tab == null)
            {
                HitTestResult result = VisualTreeHelper.HitTest(this, this.downPoint);
                if (result == null)
                {
                    return;
                }
                DependencyObject source = result.VisualHit;
                while (source != null && !this.Children.Contains(source as UIElement))
                {
                    source = VisualTreeHelper.GetParent(source);
                }
                if (source == null)
                {
                    //The mouse is not over a tab item, so just return.
                    return;
                }
                this.draggedTab = source as ChromeTabItem;
            }
            else if (tab != null)
            {
                this.draggedTab = tab;
            }
            else
            {
                return;
            }

            if (this.draggedTab != null)
            {
                if (this.Children.Count == 1 &&
                    ParentTabControl.DragWindowWithOneTab &&
                    Mouse.LeftButton == MouseButtonState.Pressed &&
                    !isTabGrab)
                {
                    this.draggingWindow = true;
                    Window.GetWindow(this).DragMove();
                }
                else
                {
                    this.downTabBoundsPoint = MouseUtilities.CorrectGetPosition(this.draggedTab);
                    Canvas.SetZIndex(this.draggedTab, 1000);
                    ParentTabControl.ChangeSelectedItem(this.draggedTab);
                    if (isTabGrab)
                    {
                        for (int i = 0; i < this.Children.Count; i++)
                        {
                            ProcessMouseMove(new Point(p.X + 0.1, p.Y));
                        }
                    }
                    else
                    {
                        ProcessMouseMove(new Point(p.X + 0.1, p.Y));
                    }
                }
            }
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method executes the new command.</summary>
        ///
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Event arguments.</param>
        ///--------------------------------------------------------------------------------
        private void NewExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            DiagramViewModel view = DataContext as DiagramViewModel;

            if (view != null)
            {
                Point currentPosition = MouseUtilities.GetMousePosition(this);
                dialog         = new Window();
                dialog.Height  = 350 * UserSettingsHelper.Instance.ControlSize;
                dialog.Width   = 300 * UserSettingsHelper.Instance.ControlSize;
                dialog.Left    = Math.Max(currentPosition.X, 20);
                dialog.Top     = Math.Max(currentPosition.Y, 20);
                dialog.Content = new EntityDialogControl();
                Entity newEntity = new Entity();
                newEntity.EntityID = Guid.NewGuid();
                newEntity.Solution = view.Solution;
                EntityViewModel newEntityView = new EntityViewModel(newEntity, view.Solution);
                dialog.DataContext          = newEntityView;
                dialog.Title                = newEntityView.Title;
                newEntityView.RequestClose += new EventHandler(newEntityView_RequestClose);

                dialog.ShowDialog();
                if (newEntityView.IsOK == true)
                {
                    // TODO: investigate why this workflow needs to be different than other elements in the model
                    newEntityView.Entity.TransformDataFromObject(newEntityView.EditEntity, null, false);
                    newEntityView.EditEntity = null;
                    view.AddEntity(newEntityView, currentPosition, true);
                }
            }
        }
        private void TickDragScroll(object sender, EventArgs e)
        {
            bool isDone = true;

            if (this.IsLoaded)
            {
                Rect  bounds = new Rect(RenderSize);
                Point p      = MouseUtilities.GetMousePosition(this);
                if (bounds.Contains(p))
                {
                    if (p.Y < DRAG_MARGIN)
                    {
                        DragScroll(DragDirection.Up);
                        isDone = false;
                    }
                    else if (p.Y > RenderSize.Height - DRAG_MARGIN)
                    {
                        DragScroll(DragDirection.Down);
                        isDone = false;
                    }
                }
            }

            if (isDone)
            {
                CancelDrag();
            }
        }
Exemple #12
0
        private void myRelationshipTree_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var dragAction = DragDropEffects.None;

            if ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None)
            {
                dragAction = DragDropEffects.Move;
            }
            else if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.None)
            {
                dragAction = DragDropEffects.Copy;
            }

            if (dragAction == DragDropEffects.None)
            {
                return;
            }

            var draggedItem = myTree.GetItemAtLocation <TreeViewItem>(MouseUtilities.GetMousePosition(myTree));

            if (draggedItem == null)
            {
                return;
            }

            var dragInfo = new TreeDragInfo(draggedItem);

            dragInfo.Action = dragAction;

            DragDrop.DoDragDrop(myTree, dragInfo.ToDataObject(), dragInfo.Action);
            e.Handled = true;
        }
Exemple #13
0
        protected override void OnQueryContinueDrag(QueryContinueDragEventArgs e)
        {
            base.OnQueryContinueDrag(e);

            if (e.Action == DragAction.Cancel || e.Action == DragAction.Drop)
            {
                StopAutoScrolling();
            }
            else if (e.Action == DragAction.Continue)
            {
                Point  pt     = MouseUtilities.GetMousePosition(this);
                double height = this.RenderSize.Height;
                if (pt.Y < AutoScrollMargin)
                {
                    // start scrolling scroll up
                    StartAutoScrolling(pt.Y - AutoScrollMargin);
                }
                else if (pt.Y > height - AutoScrollMargin)
                {
                    // start scrolling scroll down.
                    StartAutoScrolling(pt.Y - (height - AutoScrollMargin));
                }
                else
                {
                    // stop autoscrolling.
                    StopAutoScrolling();
                }
            }
        }
Exemple #14
0
 private void HandleShooting()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         Vector3 shootDirection = MouseUtilities.GetMouseWorldPosition() - transform.position;
         shootingBehaviour.Shoot(shootDirection);
     }
 }
Exemple #15
0
 protected override void OnGiveFeedback(GiveFeedbackEventArgs e)
 {
     base.OnGiveFeedback(e);
     if (CurrentAdorner != null)
     {
         CurrentAdorner.DrawArc(MouseUtilities.GetMousePosition(ParentCanvas));
     }
 }
Exemple #16
0
 void Update()
 {
     if ((Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) && !PlayManager.GetIsPlay() &&
         !paletteMenuManager.IsPaletteMenuActive() && currentPalette != -1)
     {
         if (currentTool == Tools.Draw)
         {
             currMousePos = MouseUtilities.GridSpace(buildCam);
             prevMousePos = currMousePos;
         }
         else if (currentTool == Tools.Rect)
         {
             prevMousePos = MouseUtilities.GridSpace(buildCam);
         }
     }
     if ((Input.GetMouseButton(0) || Input.GetMouseButton(1)) && !PlayManager.GetIsPlay() &&
         !paletteMenuManager.IsPaletteMenuActive() && currentPalette != -1)
     {
         bool draw;
         draw = Input.GetMouseButton(0);
         if (currentTool == Tools.Draw)
         {
             currMousePos = MouseUtilities.GridSpace(buildCam);
             DrawTileLine(tileTypes[currentPalette], currMousePos, prevMousePos, draw);
             prevMousePos = MouseUtilities.GridSpace(buildCam);
         }
         else if (currentTool == Tools.Rect)
         {
             currMousePos = MouseUtilities.GridSpace(buildCam);
             rect.SetActive(true);
             rect.GetComponent <RectDraw>().Draw(currMousePos, prevMousePos);
         }
     }
     else
     {
         rect.SetActive(false);
     }
     if ((Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) && !PlayManager.GetIsPlay() &&
         !paletteMenuManager.IsPaletteMenuActive() && currentPalette != -1)
     {
         bool draw;
         draw = Input.GetMouseButtonUp(0);
         if (currentTool == Tools.Rect)
         {
             DrawTileRect(tileTypes[currentPalette], currMousePos, prevMousePos, draw);
         }
     }
     if (PlayManager.GetIsPlay())
     {
         camBoundsRect.SetActive(false);
     }
     else
     {
         camBoundsRect.SetActive(true);
     }
 }
Exemple #17
0
        bool IsMouseOver(Visual target)
        {
            // We need to use MouseUtilities to figure out the cursor
            // coordinates because, during a drag-drop operation, the WPF
            // mechanisms for getting the coordinates behave strangely.

            Rect  bounds   = VisualTreeHelper.GetDescendantBounds(target);
            Point mousePos = MouseUtilities.GetMousePosition(target);

            return(bounds.Contains(mousePos));
        }
 void Update()
 {
     if (valuesSet)
     {
         if (MouseUtilities.TouchingUI(rt) && Input.GetMouseButtonDown(0))
         {
             action.Invoke(palette);
         }
         im.color = typeColors[draw.GetPalette(palette) - 1];
     }
 }
Exemple #19
0
    void Update()
    {
        worldPoint  = MouseUtilities.GridSpace(cam);
        screenPoint = RectTransformUtility.WorldToScreenPoint(cam, worldPoint);

        cursorSize          = (Screen.height / 100f) / (cam.orthographicSize * 2);
        rt.localScale       = new Vector3(cursorSize, cursorSize, 0);
        rt.sizeDelta        = draw.GetCurrentPaletteSize();
        rt.anchoredPosition = screenPoint - canvasRt.sizeDelta / 2f + new Vector2(
            (rt.sizeDelta.x % 200 == 0) ? (50f * rt.localScale.x) : 0, (rt.sizeDelta.y % 200 == 0) ? (50f * rt.localScale.y) : 0);
    }
        AdornerLayer InitializeAdornerLayer(ListViewItem itemToDrag)
        {
            VisualBrush brush = new VisualBrush(itemToDrag);

            this.dragAdorner         = new DragAdorner(this.listView, itemToDrag.RenderSize, brush);
            this.dragAdorner.Opacity = this.DragAdornerOpacity;
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(this.listView);

            layer.Add(dragAdorner);
            this.ptMouseDown = MouseUtilities.GetMousePosition(this.listView);

            return(layer);
        }
Exemple #21
0
        public static object GetItemAtMousePoint(this ItemsControl parent)
        {
            // Dan - this is a fix to fix a null reference exception caused when switching
            // tabs in tab control - the parent item here can end up not being in the visual
            // tree
            PresentationSource inputSource = PresentationSource.FromVisual(parent);

            if (inputSource != null)
            {
                return(parent.GetItemAtPoint(MouseUtilities.CorrectGetPosition(parent)));
            }
            return(null);
        }
 void CheckMouseOver()
 {
     if (collider.bounds.Contains(MouseUtilities.getMouseWorldPosition()))
     {
         blockState = BlockState.MOUSEOVER;
         doMouseOverState();
     }
     else
     {
         blockState = BlockState.IDLE;
         doIdleState();
     }
 }
Exemple #23
0
 void Update()
 {
     if (PlayManager.GetIsPlay() || !isSelected)
     {
         lineRenderer.enabled = false;
         for (int i = 0; i < nodes.Length; i++)
         {
             nodes[i].SetActive(false);
         }
     }
     else
     {
         lineRenderer.enabled = true;
         for (int i = 0; i < nodes.Length; i++)
         {
             nodes[i].SetActive(true);
         }
     }
     isSelected = gameObject.name.Equals(draw.GetLayer());
     if (Input.GetMouseButtonDown(0) && isSelected)
     {
         mousePositionBuffer = MouseUtilities.WorldSpace(cam);
     }
     if (Input.GetMouseButton(0) && isSelected)
     {
         Vector3 positionChange = MouseUtilities.WorldSpace(cam) - mousePositionBuffer;
         for (int i = 0; i < nodes.Length; i++)
         {
             Vector3 normalizedPosition = new Vector3(nodes[i].transform.position.x, nodes[i].transform.position.y, 0);
             if ((Vector3.Distance(MouseUtilities.WorldSpace(cam), normalizedPosition) < 0.5f && currentlyDragged == -1) ||
                 currentlyDragged == i)
             {
                 nodes[i].transform.position += positionChange;
                 lineRenderer.SetPosition(i, nodes[i].transform.position + Vector3.forward);
                 currentlyDragged = i;
                 break;
             }
         }
         mousePositionBuffer = MouseUtilities.WorldSpace(cam);
     }
     if (Input.GetMouseButtonUp(0) && isSelected)
     {
         for (int i = 0; i < nodes.Length; i++)
         {
             Vector3 pos = nodes[i].transform.position;
             nodes[i].transform.position = new Vector3(Mathf.Round(pos.x), Mathf.Round(pos.y), pos.z);
             lineRenderer.SetPosition(i, nodes[i].transform.position + Vector3.forward);
         }
         currentlyDragged = -1;
     }
 }
        void UpdateDragAdornerLocation()
        {
            if (this.dragAdorner != null)
            {
                Point ptCursor = MouseUtilities.GetMousePosition(this.ListView);

                double       left             = ptCursor.X - this.ptMouseDown.X;
                ListViewItem itemBeingDragged = this.GetListViewItem(this.indexToSelect);
                Point        itemLoc          = itemBeingDragged.TranslatePoint(new Point(0, 0), this.ListView);
                double       top = itemLoc.Y + ptCursor.Y - this.ptMouseDown.Y;

                this.dragAdorner.SetOffsets(left, top);
            }
        }
Exemple #25
0
        private void UpdateDragAdornerLocation()
        {
            if (dragAdorner != null)
            {
                Point ptCursor = MouseUtilities.GetMousePosition(ListView);

                double left = ptCursor.X - ptMouseDown.X;

                // The top offset is relative to the item being dragged.
                ListViewItem itemBeingDragged = GetListViewItem(indexToSelect);
                Point        itemLoc          = itemBeingDragged.TranslatePoint(new Point(0, 0), ListView);
                double       top = itemLoc.Y + ptCursor.Y - ptMouseDown.Y;

                dragAdorner.SetOffsets(left, top);
            }
        }
Exemple #26
0
    public virtual void checkDrag()
    {
        if (isSnapped() || isDropping())
        {
            return;
        }

        if (isMouseOver())
        {
            if (Input.GetMouseButton(0))
            {
                if (GameManager.GetCurrentItem() == null)
                {
                    if (isInConveyor())
                    {
                        GridManager.getConveyor().removeFromList(this);
                    }

                    setDragging();
                    sprite.color = dragColor;
                    GameManager.setCurrentItem(this);
                    AudioManager.playSfx(pickupItem);
                }
            }
        }

        if (isDragging())
        {
            transform.parent.position = MouseUtilities.getMouseWorldPosition();
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (GridManager.isInsideConveyer(transform.parent.position) && GameManager.GetCurrentItem() == this)
            {
                GridManager.getConveyor().addToConveyor(this);
            }
            else
            {
                setDropped();
                if (!isInConveyor())
                {
                    setDragIdle();
                }
            }
        }
    }
Exemple #27
0
        private void UpdateDragAdornerLocation()
        {
            if (this.dragAdorner != null)
            {
                Point ptCursor = MouseUtilities.GetMousePosition(this.ListView);

                //double left = ptCursor.X - this.ptMouseDown.X;
                double left = ptCursor.X - 18; // borderÀÇ Àý¹Ý // wheo

                // 4/13/2007 - Made the top offset relative to the item being dragged.
                ListViewItem itemBeingDragged = this.GetListViewItem(this.indexToSelect);
                Point        itemLoc          = itemBeingDragged.TranslatePoint(new Point(0, 0), this.ListView);
                double       top = itemLoc.Y + ptCursor.Y - this.ptMouseDown.Y;

                this.dragAdorner.SetOffsets(left, top);
            }
        }
Exemple #28
0
        public void ChildrenRemoveAndCloseIfNeed(Popup child)
        {
            var pc = child.Tag as PopupContainer;

            if (pc != null)
            {
                if (pc.IsChildrenExists)
                {
                    return;
                }
            }

            Children.Remove(child);
            if (Children.Count != 0)
            {
                return;
            }

            var visual = Popup.Child as FrameworkElement;

            if (visual == null)
            {
                return;
            }

            var mousePnt = MouseUtilities.GetMousePosition(visual);

            if (!(visual.ActualWidth <= (mousePnt.X + 2)) && !(visual.ActualHeight <= (mousePnt.Y + 2)) && !(mousePnt.X < 2) && !(mousePnt.Y < 2))
            {
                return;
            }

            Popup.IsOpen = false;
            Popup removed;

            _openedPopups.TryRemove(PopupBase, out removed);

            if (Parent != null)
            {
                pc = Parent.Tag as PopupContainer;
                if (pc != null)
                {
                    pc.ChildrenRemoveAndCloseIfNeed(Popup);
                }
            }
        }
Exemple #29
0
        private void MoveWindow(Window window)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                window.BringToFront();

                var objectivePoint = PointToScreen(MouseUtilities.CorrectGetPosition(this));
                window.Top         = objectivePoint.Y - TabControl.TabPanelHeight / 2;

                Debug.WriteLine(DateTime.Now.ToShortTimeString() + " dragging window");

                if (Mouse.LeftButton == MouseButtonState.Pressed)
                {
                    window.DragMove();
                }
            }));
        }
        internal void StartTabDrag(ChromeTabItem tab = null, bool isTabGrab = false)
        {
            Point downPoint = MouseUtilities.CorrectGetPosition(this);

            if (tab != null)
            {
                this.UpdateLayout();
                double xPos = ((this.currentTabWidth - overlap) * tab.Index) + (this.currentTabWidth / 2);
                this.downPoint = new Point(xPos, downPoint.Y);
            }
            else
            {
                this.downPoint = downPoint;
            }

            StartTabDrag(downPoint, tab, isTabGrab);
        }