internal void SelectBrush(MultiTileBrush multiTileBrush) { Tool = new TileBrushToolBehavior(multiTileBrush); ToolCursor = new MultiTileCursor(multiTileBrush); if (ToolChanged != null) { ToolChanged(this, new ToolChangedEventArgs(Tool)); } }
protected void SetBrush(MultiTileBrush s) { _brush = s; foreach (var i in _images) { this.Children.Remove(i); } var width = _brush.Cells.Length; var height = _brush.Cells[0].Length; var cellWidth = _brush.Cells[0][0].tile.Width * Zoom; var cellHeight = _brush.Cells[0][0].tile.Height * Zoom; this.Width = cellWidth * width; this.Height = cellHeight * height; this.ColumnDefinitions.Clear(); this.RowDefinitions.Clear(); for (var x = 0; x < width; x++) { var col = new ColumnDefinition(); col.Width = new GridLength(cellWidth); this.ColumnDefinitions.Add(col); for (var y = 0; y < height; y++) { if (x == 0) { var row = new RowDefinition(); row.Height = new GridLength(cellHeight); this.RowDefinitions.Add(row); } var cell = _brush.Cells[x][y]; var image = new Image(); image.Width = cellWidth; image.Height = cellHeight; Grid.SetColumn(image, x); Grid.SetRow(image, y); this._images.Add(image); } } foreach (var i in _images) { this.Children.Add(i); } }
public void AddBrush(MultiTileBrush brush) { _brushes.Add(brush); }
private void LoadBrushes() { var path = GetBrushFilePath(); if (!System.IO.File.Exists(path)) return; using (var stream = new System.IO.StreamReader(path)) { while (!stream.EndOfStream) { string line = stream.ReadLine(); if (line == null) break; string[] info = line.Split(' '); var brush = new MultiTileBrush(int.Parse(info[0]), int.Parse(info[1])); int x = 0; int y = 0; for (int i = 2; i < info.Length; i++) { int id = int.Parse(info[i]); if (id >= 0) brush.AddTile(Tileset[id], x, y); y++; if (y >= brush.Height) { y = 0; x++; } } _brushes.Add(brush); } } }
public MultiTileCursor(MultiTileBrush brush) { _brush = brush; var image = new WriteableBitmap((int)Width, (int)Height, 96, 96, PixelFormats.Pbgra32, null); }
internal void SelectBrush(MultiTileBrush multiTileBrush) { var args = new TileBrushSelectedEventArgs() { TileBrush = multiTileBrush }; ViewModelMediator.Current.GetEvent<TileBrushSelectedEventArgs>().Raise(this, args); SelectedBrush = multiTileBrush; OnPropertyChanged("SelectedBrush"); }
private void CreateSelectionBrush(object obj) { if (_selection == null) return; var s = _selection.Value; var brush = new MultiTileBrush(s.Width, s.Height); for (var x = 0; x < s.Width; x++) { for (var y = 0; y < s.Height; y++) { brush.AddTile(_selectionScreen.TileAt(x + s.X, y + s.Y), x, y); } } _tileset.AddBrush(brush); _observedBrushes.Add(brush); }