Exemple #1
0
        protected override void OnSelectedItem(CommandsViewModel item)
        {
            base.OnSelectedItem(item);

            PaletteAnimator.ResetPalette();
            PaletteAnimator.PlayAction(item?.Action?.Commands);
            OnPropertyChanged(nameof(DuplicateCommand));
        }
Exemple #2
0
        public MainViewModel()
        {
            Actions = new ActionsViewModel();

            PlayActionCommand = new RelayCommand(x =>
            {
                PaletteAnimator.ResetPalette();
                PaletteAnimator.PlayAction(Actions?.SelectedItem.Action);
            }, x => true);

            PlayCommandCommand = new RelayCommand(x =>
            {
                PaletteAnimator.ResetPalette();
                PaletteAnimator.PlayCommand(Actions?.SelectedItem?.SelectedItem?.Command);
            }, x => true);

            StopCommand = new RelayCommand(x =>
            {
                PaletteAnimator.ResetPalette();
                PaletteAnimator.PlayAction((PalAction)null);
            }, x => true);

            LoadImageCommand = new RelayCommand(x =>
            {
                var fd = FileDialog.Factory(null, FileDialog.Behavior.Open, FileDialog.Type.ImagePng);
                if (fd.ShowDialog() == true)
                {
                    var bitmap = new BitmapImage(new System.Uri(fd.FileName));
                    if (bitmap.Format == PixelFormats.Indexed8)
                    {
                        PaletteAnimator.LoadPalette(bitmap);
                        Spritesheet = bitmap;
                    }
                    else
                    {
                        MessageBox.Show("The selected image does not contain any palette.",
                                        "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }, x => true);
        }