public void Update(Input input) { collage.AspectRatio = drawRectangle.AspectRatio; imageUnderMouse = null; for (int i = collage.Images.Count - 1; i >= 0; i--) { Rectangle rec = collage.Images[i].GetRectangleInBoundary(drawRectangle.Rectangle); if (Utils.IsVectorInRotatedRectangle(input.MousePositionVector, rec, collage.Images[i].Rotation)) { imageUnderMouse = collage.Images[i]; break; } } }
public bool Update() { bool areFilesChoosed = !dataAccess.GuiThread.IsBlockedByDialog; if (areFilesChoosed) { string[] fileNames = ofw.SelectedFiles; ofw.Destroy(); if (fileNames != null) { // make a list of all new images. List<Image> images = new List<Image>(); for (int i = 0; i < fileNames.Length; i++) { // check if the image needs a new Source or if another one can be reused ImageSource imageSource = null; foreach (Image img in editData.Collage.Images) { if (img.Source.FileName == fileNames[i]) { imageSource = img.Source; break; } } Image image; if (imageSource == null) image = new Image(dataAccess, fileNames[i]); else image = new Image(imageSource); // set a random position image.Center = new Vector2((float)dataAccess.Random.NextDouble(), (float)dataAccess.Random.NextDouble()); images.Add(image); } // make a command that can load all images at once Command command = new Command(ExecuteAddImages, ExecuteRemoveImages, images, "Add new images"); editData.UndoManager.ExecuteAndAddCommand(command); } } return !areFilesChoosed; }