private void ImportImage(object sender, RoutedEventArgs e) { var dialog = new Microsoft.Win32.OpenFileDialog(); dialog.Filter = "Image Files (*.jpg; *.jpeg; *.gif; *.bmp; *.png)|*.jpg; *.jpeg; *.gif; *.bmp; *.png"; if ((bool)dialog.ShowDialog()) { var new_entity = new ImageEntity(dialog.FileName); MainWindowStackPanelEntities.Children.Add(new_entity.original_image); new_entity.original_image.MouseMove += ImageMouseMove; new_entity.original_image.Name = "image_" + (entitiesController.CountCanvasEntities() + 1); new_entity.Name = dialog.SafeFileName; entitiesController.AddPrefabsEntity(new_entity.original_image.Name, new_entity); } }
public void CanvasMouseWheel(object sender, MouseWheelEventArgs e) { if (!Keyboard.IsKeyDown(Key.LeftCtrl) && !Keyboard.IsKeyDown(Key.RightCtrl) && entitiesController.CountCanvasEntities() > 0) { return; } ScaleTransform scaleTr = mainWindowCanvas.LayoutTransform as ScaleTransform; if (e.Delta >= 5 && scaleTr.ScaleY < maxYScale && scaleTr.ScaleX < maxXScale) { scaleTr.ScaleY += zoomValue; scaleTr.ScaleX += zoomValue; } else if (e.Delta <= -5 && scaleTr.ScaleY > minYScale && scaleTr.ScaleX > minXScale) { scaleTr.ScaleY -= zoomValue; scaleTr.ScaleX -= zoomValue; } }