private void timer_Tick(object sender, EventArgs e)
        {
            currentPosition            = CaptureHelpers.GetCursorPosition();
            PreviousSelectionRectangle = SelectionRectangle;
            SelectionRectangle         = CaptureHelpers.CreateRectangle(positionOnClick.X, positionOnClick.Y, currentPosition.X, currentPosition.Y);

            try
            {
                UpdateBackgroundImage();
            }
            catch
            {
            }
        }
        private void timer_Tick(object sender, EventArgs e)
        {
            if (isMouseDown)
            {
                positionOld     = positionCurrent;
                positionCurrent = CaptureHelpers.GetZeroBasedMousePosition();

                if (positionCurrent != positionOld)
                {
                    SelectionRectangle = CaptureHelpers.CreateRectangle(positionOnClick.X, positionOnClick.Y, positionCurrent.X, positionCurrent.Y);
                    Refresh();
                }
            }
        }
Пример #3
0
        private Point SnapPosition(Point posOnClick, Point posCurrent)
        {
            Rectangle currentRect = CaptureHelpers.CreateRectangle(posOnClick, posCurrent);
            Point     newPosition = posCurrent;

            foreach (Size size in surface.Config.SnapSizes)
            {
                if (currentRect.Width.IsBetween(size.Width - surface.Config.SnapDistance, size.Width + surface.Config.SnapDistance) ||
                    currentRect.Height.IsBetween(size.Height - surface.Config.SnapDistance, size.Height + surface.Config.SnapDistance))
                {
                    if (posCurrent.X > posOnClick.X)
                    {
                        if (posCurrent.Y > posOnClick.Y)
                        {
                            newPosition = new Point(posOnClick.X + size.Width - 1, posOnClick.Y + size.Height - 1);
                            break;
                        }
                        else
                        {
                            newPosition = new Point(posOnClick.X + size.Width - 1, posOnClick.Y - size.Height + 1);
                            break;
                        }
                    }
                    else
                    {
                        if (posCurrent.Y > posOnClick.Y)
                        {
                            newPosition = new Point(posOnClick.X - size.Width + 1, posOnClick.Y + size.Height - 1);
                            break;
                        }
                        else
                        {
                            newPosition = new Point(posOnClick.X - size.Width + 1, posOnClick.Y - size.Height + 1);
                            break;
                        }
                    }
                }
            }

            Rectangle newRect = CaptureHelpers.CreateRectangle(posOnClick, newPosition);

            if (surface.ScreenRectangle0Based.Contains(newRect))
            {
                return(newPosition);
            }

            return(posCurrent);
        }
Пример #4
0
        protected Rectangle CalculateAreaFromNodes()
        {
            IEnumerable <NodeObject> nodes = drawableObjects.OfType <NodeObject>().Where(x => x.Visible);

            if (nodes.Count() > 1)
            {
                int left   = (int)nodes.Min(x => x.Position.X);
                int top    = (int)nodes.Min(x => x.Position.Y);
                int right  = (int)nodes.Max(x => x.Position.X);
                int bottom = (int)nodes.Max(x => x.Position.Y);

                return(CaptureHelpers.CreateRectangle(new Point(left, top), new Point(right, bottom)));
            }

            return(Rectangle.Empty);
        }
Пример #5
0
        private void timer_Tick(object sender, EventArgs e)
        {
            currentPosition            = CaptureHelpers.GetCursorPosition();
            PreviousSelectionRectangle = SelectionRectangle;
            SelectionRectangle         = CaptureHelpers.CreateRectangle(positionOnClick.X, positionOnClick.Y, currentPosition.X, currentPosition.Y);

            try
            {
                RefreshSurface();
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show(ex.ToString());
#endif
            }
        }
        public void Update()
        {
            if (IsMoving)
            {
                Rectangle rect = CurrentArea;
                rect.X     += InputManager.MouseVelocity.X;
                rect.Y     += InputManager.MouseVelocity.Y;
                CurrentArea = rect;
            }

            if (IsCreating && !CurrentArea.IsEmpty)
            {
                currentPosition = InputManager.MousePosition0Based;
                CurrentArea     = CaptureHelpers.CreateRectangle(positionOnClick, currentPosition);
            }

            CheckHover();

            ResizeManager.Update();
        }
Пример #7
0
        private Point SnapPosition(Point posOnClick, Point posCurrent)
        {
            Rectangle currentRect = CaptureHelpers.CreateRectangle(posOnClick, posCurrent);
            Point     newPosition = posCurrent;

            foreach (SnapSize size in surface.Config.SnapSizes)
            {
                if (currentRect.Width.IsBetween(size.Width - surface.Config.SnapDistance, size.Width + surface.Config.SnapDistance) ||
                    currentRect.Height.IsBetween(size.Height - surface.Config.SnapDistance, size.Height + surface.Config.SnapDistance))
                {
                    newPosition = CaptureHelpers.CalculateNewPosition(posOnClick, posCurrent, size);
                    break;
                }
            }

            Rectangle newRect = CaptureHelpers.CreateRectangle(posOnClick, newPosition);

            if (surface.ScreenRectangle0Based.Contains(newRect))
            {
                return(newPosition);
            }

            return(posCurrent);
        }
Пример #8
0
 private void timer_Tick(object sender, EventArgs e)
 {
     CurrentMousePosition = CaptureHelpers.GetCursorPosition();
     SelectionRectangle   = CaptureHelpers.CreateRectangle(positionOnClick.X, positionOnClick.Y, CurrentMousePosition.X, CurrentMousePosition.Y);
     Refresh();
 }
Пример #9
0
        public virtual void OnNodeUpdate()
        {
            for (int i = 0; i < 8; i++)
            {
                ResizeNode node = Manager.ResizeNodes[i];

                if (node.IsDragging)
                {
                    Manager.IsResizing = true;

                    if (!InputManager.IsBeforeMouseDown(MouseButtons.Left))
                    {
                        tempNodePos  = node.Position;
                        tempStartPos = Rectangle.Location;
                        tempEndPos   = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1);
                    }

                    Point pos      = InputManager.MousePosition0Based;
                    Point startPos = tempStartPos;
                    Point endPos   = tempEndPos;

                    NodePosition nodePosition = (NodePosition)i;

                    int x = pos.X - tempNodePos.X;

                    switch (nodePosition)
                    {
                    case NodePosition.TopLeft:
                    case NodePosition.Left:
                    case NodePosition.BottomLeft:
                        startPos.X += x;
                        break;

                    case NodePosition.TopRight:
                    case NodePosition.Right:
                    case NodePosition.BottomRight:
                        endPos.X += x;
                        break;
                    }

                    int y = pos.Y - tempNodePos.Y;

                    switch (nodePosition)
                    {
                    case NodePosition.TopLeft:
                    case NodePosition.Top:
                    case NodePosition.TopRight:
                        startPos.Y += y;
                        break;

                    case NodePosition.BottomLeft:
                    case NodePosition.Bottom:
                    case NodePosition.BottomRight:
                        endPos.Y += y;
                        break;
                    }

                    Rectangle = CaptureHelpers.CreateRectangle(startPos, endPos);
                }
            }
        }