public MainWindowViewModel() { TextureFiles = new BulkChangeObservableCollection <TextureSetFile>(); TextureFiles.Add(CreateSample()); UserPreferences = new UserPreferences(); InitializeCommand = ReactiveCommand.CreateFromTask(OnInitialized); ShutDownCommand = ReactiveCommand.CreateFromTask(OnShutDown); TestCommand = ReactiveCommand.CreateFromTask(OnTest); ZoomInCommand = ReactiveCommand.Create(OnZoomIn, this.BindProperty(e => e.CanZoomIn)); ZoomOutCommand = ReactiveCommand.Create(OnZoomOut, this.BindProperty(e => e.CanZoomOut)); CreateNewCommand = ReactiveCommand.Create(OnCreateNew); QuitCommand = ReactiveCommand.Create(OnQuit); var selectedItemBinding = this.BindProperty(e => e.SelectedItem); AddCollectionCommand = ReactiveCommand.Create(OnAddCollection, selectedItemBinding.Select(HasAnySelection)); AddGridCommand = ReactiveCommand.Create(OnAddGrid, selectedItemBinding.Select(CanAddGrid)); AddTileCommand = ReactiveCommand.Create(OnAddTile, selectedItemBinding.Select(CanAddTile)); DeleteCommand = ReactiveCommand.Create(OnDelete, selectedItemBinding.Select(HasAnySelection)); DuplicateCommand = ReactiveCommand.Create(OnDuplicate, selectedItemBinding.Select(HasAnySelection)); ArrangeTilesCommand = ReactiveCommand.Create(OnArrangeTiles, selectedItemBinding.Select(HasAnySelection)); GenerateTilesCommand = ReactiveCommand.Create(OnGenerateTiles, selectedItemBinding.Select(HasAnySelection)); var uri = new Uri("avares://Steropes.Tiles.TemplateGen/Assets/Icons/New-Document.png", UriKind.RelativeOrAbsolute); var assets = AvaloniaLocator.Current.GetService <IAssetLoader>(); PreviewImage = new Bitmap(assets.Open(uri)); }
public GeneratorPreferences() { TileColors = new BulkChangeObservableCollection <Color> { Colors.Aquamarine, Colors.CornflowerBlue, Colors.Coral, Colors.Gold, Colors.MediumOrchid, Colors.Lavender }; TileColors.CollectionChanged += (_, _) => OnPropertyChanged(nameof(TileColors)); RecentFiles = new BulkChangeObservableCollection <string>(); RecentFiles.CollectionChanged += (_, _) => OnPropertyChanged(nameof(RecentFiles)); DefaultTileType = TileType.Isometric; DefaultWidth = 96; DefaultHeight = 48; DefaultBorderColor = Colors.DarkGray; DefaultTileColor = Colors.DarkGray; DefaultTileAnchorColor = Colors.Chocolate; DefaultTileHighlightColor = Colors.DimGray; DefaultTextColor = Colors.Black; TextSpacing = 5; DefaultFont = new Font(SKTypeface.Default.FamilyName, 8); DefaultCellPadding = 1; DefaultCollectionBorder = 1; DefaultCollectionMargin = 1; DefaultCollectionPadding = 2; DefaultGridBorder = 1; DefaultGridMargin = 1; DefaultGridPadding = 2; }