public TilesetPropertiesViewModel(IConstants constants, IAmeSession session, IScrollModel scrollModel) { this.session = session ?? throw new ArgumentNullException("session"); this.scrollModel = scrollModel ?? throw new ArgumentNullException("scrollModel"); this.WindowTitle.Value = "New Map"; this.drawingGroup = new DrawingGroup(); this.tilesetImage = new DrawingGroup(); this.gridLines = new DrawingGroup(); this.extendedBorder = new DrawingGroup(); this.drawingGroup.Children.Add(this.extendedBorder); this.drawingGroup.Children.Add(this.tilesetImage); this.drawingGroup.Children.Add(this.gridLines); this.TileImage.Value = new DrawingImage(this.drawingGroup); this.ZoomLevels = this.scrollModel.ZoomLevels; this.ZoomIndex.Value = this.scrollModel.ZoomIndex; this.maxGridThickness = constants.MaxGridThickness; this.updatePositionLabelMsDelay = constants.DefaultUpdatePositionLabelMsDelay; this.updatePositionLabelStopWatch = Stopwatch.StartNew(); this.IsTransparent.PropertyChanged += TransparencyChanged; this.TransparentColor.PropertyChanged += TransparencyChanged; this.ZoomIndex.PropertyChanged += UpdateZoomIndex; this.GridPen.PropertyChanged += UpdateGridPen; this.BackgroundBrush.PropertyChanged += UpdateBackground; this.BackgroundPen.PropertyChanged += UpdateBackground; this.SelectedMetadata.PropertyChanged += SelectedMetadataChanged; this.IsSelectingTransparency.PropertyChanged += IsSelectingTransparencyChanged; this.HandleLeftClickDownCommand = new DelegateCommand <object>((point) => HandleLeftClickDown((Point)point)); this.HandleLeftClickUpCommand = new DelegateCommand <object>((point) => HandleLeftClickUp((Point)point)); this.HandleMouseMoveCommand = new DelegateCommand <object>((point) => HandleMouseMove((Point)point)); this.SetTilesetCommand = new DelegateCommand(() => SetTileset()); this.CloseWindowCommand = new DelegateCommand(() => CloseWindow()); this.AddCustomMetaDataCommand = new DelegateCommand(() => AddCustomProperty()); this.RemoveCustomMetadataCommand = new DelegateCommand(() => RemoveCustomProperty()); this.MoveMetadataUpCommand = new DelegateCommand(() => MoveMetadataUp()); this.MoveMetadataDownCommand = new DelegateCommand(() => MoveMetadataDown()); this.BrowseSourceCommand = new DelegateCommand(() => BrowseSource()); this.ShowGridCommand = new DelegateCommand(() => RedrawGrid()); this.ShowRulerCommand = new DelegateCommand(() => RefreshRuler()); this.ZoomInCommand = new DelegateCommand(() => ZoomIn()); this.ZoomOutCommand = new DelegateCommand(() => ZoomOut()); this.SetZoomCommand = new DelegateCommand <ZoomLevel>((zoomLevel) => SetZoom(zoomLevel)); }
public ItemEditorViewModel(IEventAggregator eventAggregator, IConstants constants, IAmeSession session, TilesetModel tilesetModel, IScrollModel scrollModel) { this.eventAggregator = eventAggregator ?? throw new ArgumentNullException("eventAggregator is null"); this.Session = session ?? throw new ArgumentNullException("session is null"); this.ScrollModel = scrollModel ?? throw new ArgumentNullException("scrollModel is null"); this.Title.Value = "Item"; this.drawingGroup = new DrawingGroup(); this.extendedBorder = new DrawingGroup(); this.tilesetImage = new DrawingGroup(); this.gridLines = new DrawingGroup(); this.selectLines = new DrawingGroup(); this.drawingGroup.Children.Add(this.extendedBorder); this.drawingGroup.Children.Add(this.tilesetImage); this.drawingGroup.Children.Add(this.gridLines); this.drawingGroup.Children.Add(this.selectLines); this.TileImage.Value = new DrawingImage(this.drawingGroup); this.Scale.Value = ScaleType.Tile; this.PositionText.Value = "0, 0"; this.IsGridOn.Value = true; this.GridPen.Value = new Pen(Brushes.Orange, 1); this.BackgroundBrush.Value = (SolidColorBrush)(new BrushConverter().ConvertFrom("#b8e5ed")); this.BackgroundPen.Value = new Pen(Brushes.Transparent, 0); this.maxGridThickness = constants.MaxGridThickness; this.TilesetModels = new ObservableCollection <TilesetModel>(); foreach (TilesetModel model in this.Session.CurrentTilesets.Value) { this.TilesetModels.Add(model); } if (tilesetModel != null) { ChangeItemModel(tilesetModel); } this.updatePositionLabelMsDelay = constants.DefaultUpdatePositionLabelMsDelay; this.updateSelectLineMsDelay = constants.DefaultUpdatePositionLabelMsDelay; this.updateTransparentColorMsDelay = constants.DefaultUpdatePositionLabelMsDelay; this.updatePositionLabelStopWatch = Stopwatch.StartNew(); this.updateSelectLineStopWatch = Stopwatch.StartNew(); this.updateTransparentColorStopWatch = Stopwatch.StartNew(); this.TilesetModel.PropertyChanged += TilesetModelChanged; this.ItemImage.PropertyChanged += ItemImageChanged; this.ScrollModel.PropertyChanged += ScrollModelPropertyChanged; this.GridPen.PropertyChanged += GridPenChanged; this.BackgroundBrush.PropertyChanged += BackgroundChanged; this.BackgroundPen.PropertyChanged += BackgroundChanged; this.Session.CurrentTilesets.Value.CollectionChanged += TilesetsChanged; this.HandleLeftClickDownCommand = new DelegateCommand <object>((point) => HandleLeftClickDown((Point)point)); this.HandleLeftClickUpCommand = new DelegateCommand <object>((point) => HandleLeftClickUp((Point)point)); this.HandleMouseMoveCommand = new DelegateCommand <object>((point) => HandleMouseMove((Point)point)); this.AddTilesetCommand = new DelegateCommand(() => AddTileset()); this.AddImageCommand = new DelegateCommand(() => AddImage()); this.RemoveItemCommand = new DelegateCommand(() => RemoveItem()); this.ViewPropertiesCommand = new DelegateCommand(() => ViewProperties()); this.EditCollisionsCommand = new DelegateCommand(() => EditCollisions()); this.CropCommand = new DelegateCommand(() => Crop()); this.ChangeItemCommand = new DelegateCommand <object>((entry) => ChangeItemModel(entry as TilesetModel)); this.UpdateModelCommand = new DelegateCommand(() => UpdateTilesetModel()); this.ShowGridCommand = new DelegateCommand(() => RedrawGrid()); this.ShowRulerCommand = new DelegateCommand(() => RefreshRuler()); this.ZoomInCommand = new DelegateCommand(() => ZoomIn()); this.ZoomOutCommand = new DelegateCommand(() => ZoomOut()); this.SetZoomCommand = new DelegateCommand <ZoomLevel>((zoomLevel) => SetZoom(zoomLevel)); this.eventAggregator.GetEvent <UpdatePaddedBrushEvent>().Subscribe((brushModel) => { UpdatePaddedBrushModel(brushModel); }, ThreadOption.PublisherThread); }
public ItemEditorViewModel(IEventAggregator eventAggregator, IConstants constants, IAmeSession session, IScrollModel scrollModel) : this(eventAggregator, constants, session, session.CurrentTileset.Value, scrollModel) { }
public MapEditorViewModel(IEventAggregator eventAggregator, IConstants constants, IAmeSession session, Map map, IScrollModel scrollModel) { this.eventAggregator = eventAggregator ?? throw new ArgumentNullException("eventAggregator is null"); this.session = session ?? throw new ArgumentNullException("session is null"); this.Map.Value = map ?? throw new ArgumentNullException("map is null"); this.ScrollModel = scrollModel ?? throw new ArgumentNullException("scrollModel is null"); this.Title.Value = map.Name.Value; this.orderer = new LayerOrderRenderer(this.session); this.imageTransform = new CoordinateTransform(); this.imageTransform.SetPixelToTile(map.TileWidth.Value, map.TileHeight.Value); this.imageTransform.SetSelectionToPixel(map.TileWidth.Value / 2, map.TileHeight.Value / 2); this.drawingGroup = new DrawingGroup(); this.mapBackground = new DrawingGroup(); this.layerItems = new DrawingGroup(); this.hoverSample = new DrawingGroup(); this.gridLines = new DrawingGroup(); this.layerBoundaries = new DrawingGroup(); RenderOptions.SetEdgeMode(this.hoverSample, EdgeMode.Aliased); this.drawingGroup.Children.Add(this.mapBackground); this.drawingGroup.Children.Add(this.layerItems); this.drawingGroup.Children.Add(this.hoverSample); this.drawingGroup.Children.Add(this.gridLines); this.drawingGroup.Children.Add(this.layerBoundaries); this.DrawingCanvas = new DrawingImage(this.drawingGroup); this.BackgroundBrush.Value = new SolidColorBrush(map.BackgroundColor.Value); this.BackgroundPen.Value = new Pen(Brushes.Transparent, 0); this.Scale.Value = ScaleType.Tile; this.PositionText.Value = "0, 0"; this.HoverSampleOpacity.Value = hoverSampleOpacity; this.hoverSample.Opacity = hoverSampleOpacity; this.maxGridThickness = constants.MaxGridThickness; this.updatePositionLabelMsDelay = constants.DefaultUpdatePositionLabelMsDelay; this.updatePositionLabelStopWatch = Stopwatch.StartNew(); SetMapLayers(map); ChangeCurrentLayer(this.Map.Value.CurrentLayer.Value); RedrawBackground(); UpdateMapRecentlySaved(); this.Map.Value.CurrentLayer.PropertyChanged += CurrentLayerChanged; this.Map.Value.Name.PropertyChanged += MapNameChanged; this.Map.Value.Layers.CollectionChanged += LayersChanged; this.Map.Value.IsRecentlySaved.PropertyChanged += MapRecentlySavedChanged; this.ScrollModel.PropertyChanged += ScrollModelPropertyChanged; this.BackgroundBrush.PropertyChanged += BackgroundChanged; this.BackgroundPen.PropertyChanged += BackgroundChanged; this.HoverSampleOpacity.PropertyChanged += HoverSampleOpacityChanged; this.HandleLeftClickDownCommand = new DelegateCommand <object>((point) => HandleLeftClickDown((Point)point)); this.HandleLeftClickUpCommand = new DelegateCommand <object>((point) => HandleLeftClickUp((Point)point)); this.ShowGridCommand = new DelegateCommand(() => DrawGrid(this.IsGridOn.Value)); this.HandleMouseMoveCommand = new DelegateCommand <object>((point) => HandleMouseMove((Point)point)); this.UndoCommand = new DelegateCommand(() => this.Undo()); this.RedoCommand = new DelegateCommand(() => this.Redo()); this.ZoomInCommand = new DelegateCommand(() => this.ScrollModel.ZoomIn()); this.ZoomOutCommand = new DelegateCommand(() => this.ScrollModel.ZoomOut()); this.SetZoomCommand = new DelegateCommand <ZoomLevel>((zoomLevel) => this.ScrollModel.SetZoom(zoomLevel)); this.eventAggregator.GetEvent <NewPaddedBrushEvent>().Subscribe((brushEvent) => { UpdateBrushImage(brushEvent); }, ThreadOption.PublisherThread); }
public SelectedBrushViewModel(IEventAggregator eventAggregator, IConstants constants, IScrollModel scrollModel) { this.eventAggregator = eventAggregator ?? throw new ArgumentNullException("eventAggregator is null"); this.ScrollModel = scrollModel ?? throw new ArgumentNullException("scrollModel is null"); this.Title.Value = "Selected Brush"; this.imageTransform = new CoordinateTransform(); this.drawingGroup = new DrawingGroup(); this.extendedBackground = new DrawingGroup(); this.selectedBrushImage = new DrawingGroup(); this.gridLines = new DrawingGroup(); this.drawingGroup.Children.Add(this.selectedBrushImage); this.drawingGroup.Children.Add(this.extendedBackground); this.drawingGroup.Children.Add(this.gridLines); this.BrushImage.Value = new DrawingImage(this.drawingGroup); RenderOptions.SetEdgeMode(this.selectedBrushImage, EdgeMode.Aliased); this.gridModel = new PaddedGridRenderable(); this.Scale.Value = ScaleType.Pixel; this.PositionText.Value = "0, 0"; this.maxGridThickness = constants.MaxGridThickness; this.updatePositionLabelMsDelay = constants.DefaultUpdatePositionLabelMsDelay; this.updatePositionLabelStopWatch = Stopwatch.StartNew(); this.ScrollModel.PropertyChanged += ScrollModelPropertyChanged; this.ShowGridCommand = new DelegateCommand(() => DrawGrid(this.IsGridOn.Value)); this.HandleMouseMoveCommand = new DelegateCommand <object>((point) => HandleMouseMove((Point)point)); this.ZoomInCommand = new DelegateCommand(() => this.ScrollModel.ZoomIn()); this.ZoomOutCommand = new DelegateCommand(() => this.ScrollModel.ZoomOut()); this.SetZoomCommand = new DelegateCommand <ZoomLevel>((zoomLevel) => this.ScrollModel.SetZoom(zoomLevel)); this.eventAggregator.GetEvent <NewPaddedBrushEvent>().Subscribe((brushEvent) => { UpdateBrushImage(brushEvent); }, ThreadOption.UIThread); }
public MinimapViewModel(IEventAggregator eventAggregator, IAmeSession session, IScrollModel scrollModel) { this.eventAggregator = eventAggregator ?? throw new ArgumentNullException("eventAggregator"); this.session = session ?? throw new ArgumentNullException("session"); this.ScrollModel = scrollModel ?? throw new ArgumentNullException("scrollModel"); this.Title.Value = "Minimap"; this.Scale.Value = ScaleType.Tile; this.PositionText.Value = "0, 0"; // TODO ensure this works for non-square maps this.minimapLayers = new DrawingGroup(); if (this.session.CurrentMap != null) { Map currentMap = this.session.CurrentMap.Value; DrawingGroup filled = new DrawingGroup(); using (DrawingContext context = filled.Open()) { Rect drawingRect = new Rect(0, 0, currentMap.PixelWidth.Value, currentMap.PixelHeight.Value); context.DrawRectangle(Brushes.Transparent, new Pen(Brushes.Transparent, 0), drawingRect); } this.minimapLayers.Children.Add(filled); foreach (ILayer layer in this.session.CurrentLayers.Value) { this.minimapLayers.Children.Add(layer.Group); } } this.minimapPreview = new DrawingImage(this.minimapLayers); this.session.CurrentMap.PropertyChanged += CurrentMapChanged; this.FitMinimapCommand = new DelegateCommand(() => FitMinimap()); this.ToggleGridCommand = new DelegateCommand(() => ToggleGrid()); this.ToggleCollisionsCommand = new DelegateCommand(() => ToggleCollisions()); this.CenterOnPointCommand = new DelegateCommand(() => CenterOnPoint()); this.ZoomInCommand = new DelegateCommand(() => this.ScrollModel.ZoomIn()); this.ZoomOutCommand = new DelegateCommand(() => this.ScrollModel.ZoomOut()); this.SetZoomCommand = new DelegateCommand <ZoomLevel>((zoomLevel) => this.ScrollModel.SetZoom(zoomLevel)); this.UpdatePositionCommand = new DelegateCommand <object>((point) => UpdatePosition((Point)point)); this.SetRatioCommand = new DelegateCommand <object>((ratio) => UpdateRatio(Convert.ToDouble(ratio))); }