public void Undo()
        {
            _item.IsSelected = false;

            _item.RenamedFromAction = true;
            _item.DisplayName       = _oldName;

            SignalManager.Get <DropElementSignal>().Dispatch(_origin, _item);
            SignalManager.Get <MoveElementSignal>().Dispatch(_origin, _item);
        }
Exemplo n.º 2
0
        public ColorPaletteDialog(PaletteIndex paletteIndex, int colorPosition)
        {
            InitializeComponent();

            _paletteIndex  = paletteIndex;
            _colorPosition = colorPosition;

            SignalManager.Get <ColorPaletteSelectSignal>().Listener += OnColorPaletteSelect;
            SignalManager.Get <CloseDialogSignal>().Listener        += OnCloseDialog;
        }
        public void Redo()
        {
            _item.IsSelected = false;

            _item.RenamedFromAction = true;
            _item.DisplayName       = _newName;

            SignalManager.Get <DropElementSignal>().Dispatch(_dropTarget, _item);
            SignalManager.Get <MoveElementSignal>().Dispatch(_dropTarget, _item);
        }
Exemplo n.º 4
0
        private void SelectTile(MapViewModel viewModel)
        {
            if (viewModel.SelectedAttributeTile == -1)
            {
                return;
            }

            viewModel.RectangleVisibility = Visibility.Visible;

            SignalManager.Get <SelectPaletteIndexSignal>().Dispatch(viewModel.SpritePaletteIndices[viewModel.SelectedAttributeTile]);
        }
Exemplo n.º 5
0
        public override void Execute(object parameter)
        {
            ProjectModel model = ModelManager.Get <ProjectModel>();

            if (model != null && !string.IsNullOrEmpty(model.Name))
            {
                model.Reset();

                SignalManager.Get <CloseProjectSuccessSignal>().Dispatch();
            }
        }
Exemplo n.º 6
0
        public void Save()
        {
            if (string.IsNullOrEmpty(ProjectFilePath))
            {
                return;
            }

            Toml.WriteFile(this, ProjectFilePath);

            SignalManager.Get <ProjectConfigurationSavedSignal>().Dispatch();
        }
Exemplo n.º 7
0
        public void CleanUp()
        {
            ColorPaletteCleanup();

            bankViewer.OnDeactivate();

            #region Signals
            SignalManager.Get <OutputSelectedQuadrantSignal>().Listener      -= OnOutputSelectedQuadrant;
            SignalManager.Get <ColorPaletteControlSelectedSignal>().Listener -= OnColorPaletteControlSelected;
            #endregion
        }
Exemplo n.º 8
0
        public ProjectPropertiesDialogViewModel()
        {
            MappersModel mappers = ModelManager.Get <MappersModel>();

            Mappers = mappers.Mappers;

            ReadProjectData();

            SignalManager.Get <CloseDialogSignal>().Listener += OnCloseDialog;

            _changed = false;
        }
        public override void Execute(object parameter)
        {
            SelectionChangedEventArgs changedEvent = parameter as SelectionChangedEventArgs;

            if (changedEvent.AddedItems.Count > 0)
            {
                if (changedEvent.AddedItems[0] is FileModelVO fileModel)
                {
                    SignalManager.Get <FileModelVOSelectionChangedSignal>().Dispatch(fileModel);
                }
            }
        }
        public override void Execute(object parameter)
        {
            SelectionChangedEventArgs changedEvent = parameter as SelectionChangedEventArgs;

            if (changedEvent.AddedItems.Count > 0)
            {
                if (changedEvent.AddedItems[0] is CharacterAnimationVO animationVO)
                {
                    SignalManager.Get <CharacterAnimationVOSelectionChangedSignal>().Dispatch(animationVO);
                }
            }
        }
Exemplo n.º 11
0
        public override void Execute(object parameter)
        {
            SelectionChangedEventArgs changedEvent = parameter as SelectionChangedEventArgs;

            if (changedEvent.AddedItems.Count > 0)
            {
                if (changedEvent.AddedItems[0] is EntitySource entitySource)
                {
                    SignalManager.Get <EntitySourceSelectionChangedSignal>().Dispatch(entitySource);
                }
            }
        }
        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
        {
            bankViewer.OnDeactivate();
            frameView.OnDeactivate();

            #region Signals
            SignalManager.Get <FileModelVOSelectionChangedSignal>().Listener -= OnFileModelVOSelectionChanged;
            SignalManager.Get <PaintTileSignal>().Listener            -= OnPaintTile;
            SignalManager.Get <EraseTileSignal>().Listener            -= OnEraseTile;
            SignalManager.Get <SavePropertySignal>().Listener         -= OnSaveProperty;
            SignalManager.Get <UpdateCharacterImageSignal>().Listener -= OnUpdateCharacterImage;
            #endregion
        }
Exemplo n.º 13
0
        public override void Execute(object parameter)
        {
            QueryContinueDragEventArgs dragEvent = parameter as QueryContinueDragEventArgs;

            if (dragEvent.EscapePressed)
            {
                dragEvent.Action = DragAction.Cancel;

                SignalManager.Get <DetachAdornersSignal>().Dispatch();

                dragEvent.Handled = true;
            }
        }
Exemplo n.º 14
0
        public Map()
        {
            InitializeComponent();

            bankViewer.OnActivate();

            #region Signals
            SignalManager.Get <OutputSelectedQuadrantSignal>().Listener      += OnOutputSelectedQuadrant;
            SignalManager.Get <ColorPaletteControlSelectedSignal>().Listener += OnColorPaletteControlSelected;
            #endregion

            LoadBankImage();
        }
Exemplo n.º 15
0
        public override void Execute(object parameter)
        {
            MouseWheelEventArgs wheelEvent = parameter as MouseWheelEventArgs;

            MouseWheelVO vo = new MouseWheelVO
            {
                Delta          = wheelEvent.Delta,
                OriginalSource = wheelEvent.OriginalSource,
                Sender         = wheelEvent.Source
            };

            SignalManager.Get <MouseWheelSignal>().Dispatch(vo);
        }
Exemplo n.º 16
0
        private static async void OnRegisterFileHandler(ProjectItem item, string path)
        {
            FileHandler fileHandler = new FileHandler()
            {
                Name = item.DisplayName, Path = path
            };

            item.FileHandler = fileHandler;

            if (item.IsFolder)
            {
                return;
            }

            AFileModel model = Util.FileModelFactory(item.Type);

            if (model == null)
            {
                return;
            }

            string itemPath = Path.Combine(fileHandler.Path, fileHandler.Name + model.FileExtension);

            if (!File.Exists(itemPath))
            {
                return;
            }

            fileHandler.FileModel = await ReadFileAndLoadModelAsync(itemPath, item.Type);

            if (string.IsNullOrEmpty(fileHandler.FileModel.GUID))
            {
                fileHandler.FileModel.GUID = Guid.NewGuid().ToString();
            }

            if (ProjectFiles.Handlers.ContainsKey(fileHandler.FileModel.GUID))
            {
                return;
            }

            ProjectFiles.Handlers.Add(fileHandler.FileModel.GUID, fileHandler);

            SignalManager.Get <ProjectItemLoadedSignal>().Dispatch(fileHandler.FileModel.GUID);

            ProjectFiles.ObjectsLoading--;

            if (ProjectFiles.ObjectsLoading <= 0)
            {
                SignalManager.Get <HideLoadingDialogSignal>().Dispatch();
            }
        }
Exemplo n.º 17
0
        private void BuildPalettes()
        {
            SignalManager.Get <WriteBuildOutputSignal>().Dispatch("Building palettes", OutputMessageType.Information);

            ProjectModel projectModel = ModelManager.Get <ProjectModel>();

            string fullPath = Path.Combine(Path.GetFullPath(projectModel.Build.OutputFilePath), "palettes.s");

            using (StreamWriter outputFile = new StreamWriter(fullPath))
            {
                List <FileModelVO> paletteModelVOs = ProjectFiles.GetModels <PaletteModel>();

                outputFile.WriteLine("; This file is autogenerated!");

                SortedDictionary <string, StringWriter> pals = new SortedDictionary <string, StringWriter>();

                foreach (FileModelVO vo in paletteModelVOs)
                {
                    PaletteModel model = vo.Model as PaletteModel;

                    string name = "palette_" + vo.Name.Replace(' ', '_').ToLower();

                    Color color0 = Util.GetColorFromInt(model.Color0);
                    Color color1 = Util.GetColorFromInt(model.Color1);
                    Color color2 = Util.GetColorFromInt(model.Color2);
                    Color color3 = Util.GetColorFromInt(model.Color3);

                    StringWriter stringWriter = new StringWriter();

                    stringWriter.Write($"    .byte ");
                    stringWriter.Write($"${Util.ColorToColorHex(color0)},");
                    stringWriter.Write($"${Util.ColorToColorHex(color1)},");
                    stringWriter.Write($"${Util.ColorToColorHex(color2)},");
                    stringWriter.Write($"${Util.ColorToColorHex(color3)}");

                    pals.Add(name, stringWriter);
                }

                foreach (var item in pals)
                {
                    outputFile.WriteLine("");
                    outputFile.WriteLine($"{item.Key}:");

                    outputFile.Write(item.Value.ToString());
                    outputFile.Write(Environment.NewLine);
                }
            }

            SignalManager.Get <WriteBuildOutputSignal>().Dispatch("Finished building palettes", OutputMessageType.Information);
        }
Exemplo n.º 18
0
        public override void Execute(object parameter)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete the animation tab?", "Delete", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                MouseButtonEventArgs args = parameter as MouseButtonEventArgs;

                FrameworkElement source  = (FrameworkElement)args.OriginalSource;
                ActionTabItem    tabItem = source.DataContext as ActionTabItem;

                SignalManager.Get <AnimationTabDeletedSignal>().Dispatch(tabItem);
            }
        }
        private void ProcessImage(Image image, Point point)
        {
            WriteableBitmap writeableBmp = BitmapFactory.New((int)Math.Ceiling(image.ActualWidth), (int)Math.Ceiling(image.ActualHeight));

            using (writeableBmp.GetBitmapContext())
            {
                writeableBmp = BitmapFactory.ConvertToPbgra32Format(image.Source as BitmapSource);

                int x = (int)Math.Floor(point.X / 8);
                int y = (int)Math.Floor(point.Y / 8);

                SignalManager.Get <SelectedPixelSignal>().Dispatch(writeableBmp.Clone(), new Point(x, y));
            }
        }
Exemplo n.º 20
0
        public override void Execute(object parameter)
        {
            DragEventArgs dragEvent = parameter as DragEventArgs;

            TreeViewItem treeViewItem = Util.FindAncestor <TreeViewItem>((DependencyObject)dragEvent.OriginalSource);

            if (treeViewItem != null)
            {
                dragEvent.Effects = DragDropEffects.Move;

                SignalManager.Get <InitializeAdornersSignal>().Dispatch(treeViewItem, dragEvent);
            }

            dragEvent.Handled = true;
        }
Exemplo n.º 21
0
        public override bool CanExecute(object parameter)
        {
            SignalManager.Get <DetachAdornersSignal>().Dispatch();

            DragEventArgs dragEvent = parameter as DragEventArgs;

            ProjectItem item = dragEvent.Data.GetData(typeof(ProjectItem)) as ProjectItem;

            if (item.IsRoot)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 22
0
        public override void Execute(object parameter)
        {
            object[] values = (object[])parameter;
            string   path   = (string)values[0];

            string[] filters = null;
            bool     newFile = (bool)values[2];

            if (values.Length > 1)
            {
                filters = (string[])values[1];
            }

            if (!string.IsNullOrEmpty(path))
            {
                path = Path.GetFullPath(path);
                path = Path.GetDirectoryName(path);
            }

            CommonOpenFileDialog dialog = new CommonOpenFileDialog
            {
                Title                     = "Select File",
                IsFolderPicker            = false,
                InitialDirectory          = path,
                AddToMostRecentlyUsedList = false,
                AllowNonFileSystemItems   = false,
                DefaultDirectory          = path,
                EnsureFileExists          = true,
                EnsurePathExists          = true,
                EnsureReadOnly            = false,
                EnsureValidNames          = true,
                Multiselect               = false,
                ShowPlacesList            = true
            };

            if (filters != null && filters.Length > 0)
            {
                for (int i = 0; i < filters.Length; i += 2)
                {
                    dialog.Filters.Add(new CommonFileDialogFilter(filters[i], filters[i + 1]));
                }
            }

            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                SignalManager.Get <BrowseFileSuccessSignal>().Dispatch(dialog.FileName, newFile);
            }
        }
Exemplo n.º 23
0
        public override void Execute(object parameter)
        {
            if (parameter == null)
            {
                return;
            }

            object[]        values       = (object[])parameter;
            string          imagePath    = (string)values[1];
            WriteableBitmap wp           = (WriteableBitmap)values[2];
            Point           croppedPoint = (Point)values[3];
            BitmapSource    imgSource    = (BitmapSource)values[4];

            Merge(wp, imgSource, croppedPoint, imagePath);

            SignalManager.Get <SavedPixelChangesSignal>().Dispatch();
        }
Exemplo n.º 24
0
        private void UpdateConfigurations(string projectFullPath)
        {
            NESToolConfigurationModel model = ModelManager.Get <NESToolConfigurationModel>();

            if (model.DefaultProjectPath != projectFullPath)
            {
                // Update the recent projects also with the new project path
                model.InsertToRecentProjects(projectFullPath);

                // Make this new project the default project
                model.DefaultProjectPath = projectFullPath;

                model.Save();
            }

            SignalManager.Get <UpdateRecentProjectsSignal>().Dispatch(model.RecentProjects);
        }
Exemplo n.º 25
0
        public override void Execute(object parameter)
        {
            object[] values      = (object[])parameter;
            string   path        = (string)values[0];
            string   projectName = (string)values[1];

            int prgSize  = (int)values[2];
            int chrSize  = (int)values[3];
            int mapperId = (int)values[4];

            string projectFullPath = Path.Combine(path, projectName);

            CreateProject(projectFullPath, prgSize, chrSize, mapperId);

            SignalManager.Get <CloseProjectSuccessSignal>().Dispatch();
            SignalManager.Get <CreateProjectSuccessSignal>().Dispatch(projectFullPath);
        }
Exemplo n.º 26
0
        public override void Execute(object parameter)
        {
            if (ItemSelected == null)
            {
                return;
            }

            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this element?", "Delete", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                SignalManager.Get <RegisterHistoryActionSignal>().Dispatch(new DeleteProjectItemHitoryAction(ItemSelected));

                ProjectItemFileSystem.DeteElement(ItemSelected);

                SignalManager.Get <DeleteElementSignal>().Dispatch(ItemSelected);
            }
        }
Exemplo n.º 27
0
        public override void Execute(object parameter)
        {
            MouseEventArgs mouseEvent = parameter as MouseEventArgs;

            if (mouseEvent.LeftButton == MouseButtonState.Pressed)
            {
                TreeViewItem treeViewItem = Util.FindAncestor <TreeViewItem>((DependencyObject)mouseEvent.OriginalSource);

                MouseMoveVO vo = new MouseMoveVO
                {
                    Position       = mouseEvent.GetPosition(treeViewItem),
                    OriginalSource = mouseEvent.OriginalSource,
                    Sender         = mouseEvent.Source
                };

                SignalManager.Get <MouseMoveSignal>().Dispatch(vo);
            }
        }
Exemplo n.º 28
0
        public override void Execute(object parameter)
        {
            if (ItemSelected.FileHandler == null)
            {
                return;
            }

            if (ClipboardManager.GetData() is ProjectItem newItem)
            {
                string newItemPath = string.Empty;
                string name        = string.Empty;

                if (ItemSelected.IsFolder)
                {
                    newItemPath = Path.Combine(ItemSelected.FileHandler.Path, ItemSelected.FileHandler.Name);
                }
                else
                {
                    newItemPath = ItemSelected.FileHandler.Path;
                }

                if (newItem.IsFolder)
                {
                    name = ProjectItemFileSystem.GetValidFolderName(newItemPath, newItem.DisplayName);
                }
                else
                {
                    string extension = Util.GetExtensionByType(ItemSelected.Type);

                    name = ProjectItemFileSystem.GetValidFileName(newItemPath, newItem.DisplayName, extension);
                }

                newItem.RenamedFromAction = true;
                newItem.DisplayName       = name;
                newItem.IsLoaded          = true;

                SignalManager.Get <RegisterHistoryActionSignal>().Dispatch(new PasteProjectItemHistoryAction(newItem));

                SignalManager.Get <PasteElementSignal>().Dispatch(ItemSelected, newItem);

                ProjectItemFileSystem.CreateElement(newItem, newItemPath, name);
            }
        }
Exemplo n.º 29
0
        private void OnCloseDialog()
        {
            if (_changed)
            {
                // Save all changes
                ProjectModel project = ModelManager.Get <ProjectModel>();

                project.Header.INesMapper    = SelectedMapper;
                project.Header.CHRSize       = SelectedCHRSize;
                project.Header.PRGSize       = SelectedPRGSize;
                project.Header.FrameTiming   = FrameTiming;
                project.Header.MirroringType = SelectedMirroring;
                project.Header.Battery       = Battery;

                project.Save();
            }

            SignalManager.Get <CloseDialogSignal>().Listener -= OnCloseDialog;
        }
Exemplo n.º 30
0
        public override void Execute(object parameter)
        {
            object[] values = (object[])parameter;

            Point     croppedPoint    = (Point)values[1];
            int       selectedTileSet = (int)values[2];
            BankModel model           = (BankModel)values[3];

            if (model.GetEmptyTileIndex(out int index))
            {
                FileModelVO[] tileSets = ProjectFiles.GetModels <TileSetModel>().ToArray();

                model.PTTiles[index].GUID      = Guid.NewGuid().ToString();
                model.PTTiles[index].TileSetID = tileSets[selectedTileSet].Model.GUID;
                model.PTTiles[index].Point     = croppedPoint;
                model.PTTiles[index].Group     = index;

                SignalManager.Get <BankImageUpdatedSignal>().Dispatch();
            }
        }