public bool Update()
        {
            if (colorChooser == null && !dataAccess.GuiThread.WaitsToInvoke) dataAccess.GuiThread.Invoke(OpenColorDialog);
            if (colorChooser != null)
            {
                editData.Collage.BackgroundColor = colorChooser.SelectedColor;
                if (colorChooser.Response != Gtk.ResponseType.None && colorChooser.Response != Gtk.ResponseType.Ok)
                {
                    editData.Collage.BackgroundColor = startColor;
                    colorChooser.Destroy();
                    colorChooser = null;
                    return false;
                }
                if (colorChooser.Response == Gtk.ResponseType.Ok)
                {
                    Command command = new Command(ExecuteColorChange, ExecuteColorChange, colorChooser.SelectedColor, "Change Background Color");
                    command.SetUndoData(startColor);
                    editData.UndoManager.AddCommand(command);

                    colorChooser.Destroy();
                    colorChooser = null;
                    return false;
                }
            }
            return true;
        }
示例#2
0
        public bool Update()
        {
            if (dataAccess.Input.ScrollWheelDifference != 0) startTime = DateTime.Now;
            foreach (Image image in editData.SelectedImages)
            {
                image.Width *= (dataAccess.Input.ScrollWheelDifference / 2000f) + 1;
                image.Width = Math.Max(image.Width, 0.01f);
            }

            bool continueScale = (DateTime.Now - startTime).Milliseconds < 300          // stop when the time is up
                && !dataAccess.Input.IsStrg                                             // stop when the user wants to zoom instead of scale
                && !(dataAccess.Input.IsLeftButtonDown && (!editData.SelectedImages.Contains(editData.ImageUnderMouse) || editData.ImageUnderMouse == null)); // stop when the user clicks somewhere, where no selection is

            if (!continueScale)
            {
                float[] newWidth = new float[editData.SelectedImages.Count];
                for (int i = 0; i < editData.SelectedImages.Count; i++)
                {
                    newWidth[i] = editData.SelectedImages[i].Width;
                }
                Command command = new Command(ExecuteScale, ExecuteScale, newWidth, "Scale Selected Images");
                command.SetUndoData(startWidth);
                editData.UndoManager.AddCommand(command);
            }
            return continueScale;
        }
示例#3
0
 public bool Update()
 {
     bool continueMove = dataAccess.Input.IsLeftButtonDown;
     if (continueMove)
     {
         foreach (Image image in editData.SelectedImages)
         {
             image.SetCenterInBoundary(editData.DrawRectangle.Rectangle, image.GetCenterInBoundary(editData.DrawRectangle.Rectangle) + dataAccess.Input.MouseDifferenceVector);
         }
         totalMove += dataAccess.Input.MouseDifferenceVector;
     }
     else
     {
         Command command = new Command(ExecuteMove, ExecuteMove, totalMove, "Move Selected Images");
         command.SetUndoData(-totalMove);
         editData.UndoManager.AddCommand(command);
     }
     return continueMove;
 }
        public bool Start()
        {
            if (editData.SelectedImages.Count > 0)
            {
                Image newBackgroundImage = editData.SelectedImages.First();

                ImageData newImageData = new ImageData();
                newImageData.Center = new Vector2(0.5f);
                newImageData.Rotation = 0f;
                newImageData.Width = 1f;

                int oldIndex = editData.Collage.Images.IndexOf(newBackgroundImage);

                Command command = new Command(ExecuteSetAsBackground, UndoSetAsBackground, new List<object>() { oldIndex, newImageData }, "Set To Front");
                command.SetUndoData(new List<object>() { oldIndex, newBackgroundImage.Data });
                editData.UndoManager.ExecuteAndAddCommand(command);
            }
            return false;
        }
示例#5
0
        public bool Update()
        {
            foreach(Image image in editData.SelectedImages)
            {
                Vector2 difference = dataAccess.Input.MousePositionVector - image.GetCenterInBoundary(editData.DrawRectangle.Rectangle);
                image.Rotation = (float)Math.Atan2(difference.Y, difference.X) + rotationOffset[editData.SelectedImages.IndexOf(image)];
            }

            bool continueRotation = dataAccess.Input.IsRightButtonDown;
            if(!continueRotation)
            {
                float[] newRotation = new float[editData.SelectedImages.Count];
                for (int i = 0; i < editData.SelectedImages.Count; i++)
            {
                newRotation[i] = editData.SelectedImages[i].Rotation;
            }
                Command command = new Command(ExecuteScale, ExecuteScale, newRotation, "Scale Selected Images");
                command.SetUndoData(startRotation);
                editData.UndoManager.AddCommand(command);
            }
            return continueRotation;
        }
        public bool Update()
        {
            // allow to zoom and move the view
            editData.DrawRectangle.Zoom(-dataAccess.Input.ScrollWheelDifference / 10f, dataAccess.Input.MousePositionVector);
            if (dataAccess.Input.IsMiddleButtonDown) editData.DrawRectangle.Move(dataAccess.Input.MouseDifferenceVector);

            UpdateButtons();

            if(IsCanceled())
            {
                editData.DrawRectangle.AspectRatio = startAspectRatio;
                return false;
            }

            if (IsConfirmed())
            {
                Command command = new Command(ExecuteAspectRatioChange, ExecuteAspectRatioChange, editData.Collage.AspectRatio, "Change Aspect Ratio");
                command.SetUndoData(startAspectRatio);
                editData.UndoManager.AddCommand(command);
                return false;
            }
            else
            {
                Rectangle newDrawPosition = editData.DrawRectangle.Rectangle;

                // change size
                if (rightMoveButton.IsDown) newDrawPosition.Width += dataAccess.Input.MouseDifferencePoint.X;
                if (downMoveButton.IsDown) newDrawPosition.Height += dataAccess.Input.MouseDifferencePoint.Y;
                // set minimum size
                if (newDrawPosition.Width < 50) newDrawPosition.Width = 50;
                if (newDrawPosition.Height < 50) newDrawPosition.Height = 50;

                editData.DrawRectangle.SetRectangle(newDrawPosition);

                SetButtonPositions();
                return true;
            }
        }
        public bool Update()
        {
            if(dataAccess.Input.IsKeyPressed(Keys.Escape))
            {
                editData.SelectedImages.Clear();
                editData.SelectedImages.AddRange(selectionBefore);
                return false;
            }

            if (dataAccess.Input.IsLeftButtonReleased || dataAccess.Input.AreKeysPressed(Keys.Enter))
            {
                Command command = new Command(ExecuteSelectionChange, ExecuteSelectionChange, new List<Image>(editData.SelectedImages), "Random Selection");
                command.SetUndoData(selectionBefore);
                editData.UndoManager.AddCommand(command);
                return false;
            }
            else
            {
                selectionFraction = dataAccess.Input.MousePositionVector.X / (float)dataAccess.GraphicsDevice.Viewport.Width;
                selectionFraction = MathHelper.Clamp(selectionFraction, 0, 1);

                editData.SelectedImages.Clear();
                editData.SelectedImages.AddRange(randomOrder.GetRange(0, (int)Math.Floor(randomOrder.Count * selectionFraction)));
                return true;
            }
        }
        public bool Start()
        {
            List<object> currentData = GetCurrentData();
            List<object> calculationData = CalculateAutoPosition();

            Command command = new Command(ExecuteAutoPosition, ExecuteAutoPosition, calculationData, "Auto Position");
            command.SetUndoData(currentData);
            editData.UndoManager.ExecuteAndAddCommand(command);

            return false;
        }