Exemple #1
0
 internal void SwitchWindows(Window target, bool toModal = false)
 {
     if (!toModal)
     {
         target.Show();
         SourceWindow.Close();
     }
     else
     {
         target.ShowDialog();
     }
 }
Exemple #2
0
        void PosBaseWindow_DeleteEvent(object o, DeleteEventArgs args)
        {
            Hide();

            //Pos
            if (SourceWindow != null)
            {
                SourceWindow.ShowAll();
            }
            //Startup Window
            else
            {
                LogicPos.Quit(this);
            };

            //Prevent Window Destroy, When user Uses Close
            args.RetVal = true;
        }
        private void HandleDrop(BaseDraggableView xView)
        {
            Vector2 xGridPosition = xView.Centre;

            xGridPosition.x = Mathf.FloorToInt(xGridPosition.x / NodeGridSpacingX);
            xGridPosition.y = Mathf.FloorToInt(xGridPosition.y / NodeGridSpacingY);

            xGridPosition.x = Mathf.Max(xGridPosition.x, 1);
            xGridPosition.y = Mathf.Max(xGridPosition.y, 1);


            Node xOtherNode = GetNodeAtGridPosition(xGridPosition);

            if (xOtherNode == null)
            {
                Vector2 xNewCentre = xGridPosition;
                xNewCentre.x *= NodeGridSpacingX;
                xNewCentre.y *= NodeGridSpacingY;

                xView.Centre = xNewCentre;
                SourceWindow.Repaint();
            }
        }
        public override void Draw()
        {
            Event xCurrentEvent = Event.current;

            if (xCurrentEvent != null)
            {
                EventType xCurrentEventType = xCurrentEvent.type;

                if (xCurrentEvent.isMouse)
                {
                    Vector3 xMousePosition = xCurrentEvent.mousePosition;
                    bool    bWithinBounds  = CursorIsWithinBounds(xMousePosition);
                    switch (xCurrentEventType)
                    {
                    case EventType.MouseDown:
                    {
                        //TODO: Raycast to hit topmost BaseDraggableView...?
                        if (bWithinBounds)
                        {
                            m_bIsBeingDragged = true;

                            float fXOffset = ViewBounds.x - xMousePosition.x;
                            float fYOffset = ViewBounds.y - xMousePosition.y;
                            m_pxCursorOffsetFromCentre = new Vector2(fXOffset, fYOffset);

                            if (DragBegan != null)
                            {
                                DragBegan(this);
                            }
                        }
                        break;
                    }

                    case EventType.MouseDrag:
                    {
                        if (m_bIsBeingDragged)
                        {
                            float   fBoundOriginX   = xMousePosition.x + m_pxCursorOffsetFromCentre.x;
                            float   fBoundOriginY   = xMousePosition.y + m_pxCursorOffsetFromCentre.y;
                            Vector2 xNewBoundCentre = new Vector2(fBoundOriginX, fBoundOriginY);

                            Rect NewBounds = new Rect();
                            NewBounds.x      = xNewBoundCentre.x;
                            NewBounds.y      = xNewBoundCentre.y;
                            NewBounds.width  = ViewBounds.width;
                            NewBounds.height = ViewBounds.height;

                            ViewBounds = NewBounds;

                            SourceWindow.Repaint();

                            if (DragChanged != null)
                            {
                                DragChanged(this);
                            }
                        }
                        break;
                    }

                    case EventType.MouseUp:
                    {
                        if (DragEnded != null && m_bIsBeingDragged)
                        {
                            DragEnded(this);
                        }

                        m_bIsBeingDragged          = false;
                        m_pxCursorOffsetFromCentre = Vector2.zero;

                        break;
                    }
                    }
                }
            }
        }
 public void Dispose()
 {
     SourceWindow.Close();
 }