Ejemplo n.º 1
0
        private new void Update()
        {
            if (!timerStart.IsRunning)
            {
                timerStart.Start();
                timerFPS.Start();
            }

            InputManager.Update();

            DrawableObject[] objects = DrawableObjects.OrderByDescending(x => x.Order).ToArray();

            if (objects.All(x => !x.IsDragging))
            {
                for (int i = 0; i < objects.Count(); i++)
                {
                    DrawableObject obj = objects[i];

                    if (obj.Visible)
                    {
                        obj.IsCursorHover = obj.Rectangle.Contains(InputManager.MousePosition0Based);

                        if (obj.IsCursorHover)
                        {
                            if (InputManager.IsMousePressed(MouseButtons.Left))
                            {
                                obj.IsDragging = true;
                            }

                            for (int y = i + 1; y < objects.Count(); y++)
                            {
                                objects[y].IsCursorHover = false;
                            }

                            break;
                        }
                    }
                }
            }
            else
            {
                if (InputManager.IsMouseReleased(MouseButtons.Left))
                {
                    foreach (DrawableObject obj in objects)
                    {
                        obj.IsDragging = false;
                    }
                }
            }

            borderDotPen.DashOffset = (float)timerStart.Elapsed.TotalSeconds * -15;

            ShapeManager.Update();
        }
Ejemplo n.º 2
0
        protected override void Update()
        {
            base.Update();

            if (InputManager.IsMousePressed(MouseButtons.Right))
            {
                if (isAreaCreated)
                {
                    isAreaCreated = false;
                    regionFillPath.Reset();
                    HideNodes();
                    points.Clear();
                }
                else
                {
                    Close(SurfaceResult.Close);
                }
            }

            if (Config.QuickCrop && isAreaCreated && InputManager.IsMouseReleased(MouseButtons.Left))
            {
                Close(SurfaceResult.Region);
            }

            if (!isAreaCreated && InputManager.IsMouseDown(MouseButtons.Left))
            {
                lastNode.Visible = true;
                isAreaCreated    = true;
            }

            if (lastNode.Visible && InputManager.IsMouseDown(MouseButtons.Left))
            {
                if (points.Count == 0 || points.Last() != InputManager.MousePosition0Based)
                {
                    points.Add(InputManager.MousePosition0Based);

                    if (points.Count > 1)
                    {
                        regionFillPath.AddLine(points.Last(1), points.Last());
                    }

                    lastNode.Position = InputManager.MousePosition0Based;
                }
            }

            if (points.Count > 2)
            {
                RectangleF rect = regionFillPath.GetBounds();

                currentArea = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width + 1, (int)rect.Height + 1);
            }
        }
Ejemplo n.º 3
0
        internal void UpdateObjects()
        {
            DrawableObject[] objects = DrawableObjects.OrderByDescending(x => x.Order).ToArray();

            Point position = InputManager.ClientMousePosition;

            if (objects.All(x => !x.IsDragging))
            {
                for (int i = 0; i < objects.Length; i++)
                {
                    DrawableObject obj = objects[i];

                    if (obj.Visible)
                    {
                        obj.IsCursorHover = obj.Rectangle.Contains(position);

                        if (obj.IsCursorHover)
                        {
                            if (InputManager.IsMousePressed(MouseButtons.Left))
                            {
                                obj.OnMousePressed(position);
                            }

                            for (int j = i + 1; j < objects.Length; j++)
                            {
                                objects[j].IsCursorHover = false;
                            }

                            break;
                        }
                    }
                }
            }
            else
            {
                if (InputManager.IsMouseReleased(MouseButtons.Left))
                {
                    foreach (DrawableObject obj in objects)
                    {
                        if (obj.IsDragging)
                        {
                            obj.OnMouseReleased(position);
                        }
                    }
                }
            }
        }