private async void SaveAndApplyButton_Click(object sender, RoutedEventArgs e) { bool successful = await SaveCurrentUserFile(); if (!successful) { return; } savedUndoCommand = ReUndoManager.CurUndoCommand; long StartTime = 0; // Apply after saving file Log.Debug("[SaveAndApplyButton] Save LastScript"); StorageFolder localfolder = ApplicationData.Current.LocalFolder; StorageFile localsf = await localfolder.CreateFileAsync("LastScript.xml", Windows.Storage.CreationCollisionOption.ReplaceExisting); await Windows.Storage.FileIO.WriteTextAsync(localsf, GetLastScript()); Log.Debug("[SaveAndApplyButton] Save LastScript successfully : " + localsf.Path); Log.Debug("[SaveAndApplyButton] Bef AuraEditorTrigger"); await(new ServiceViewModel()).AuraEditorTrigger(StartTime); Log.Debug("[SaveAndApplyButton] Aft AuraEditorTrigger"); SendMessageToServer("[XML] Change"); }
private void Clean() { savedUndoCommand = null; SetLayerButton.IsEnabled = true; SetLayerRectangle.Visibility = Visibility.Collapsed; LayerPage.Clean(); SpacePage.Clean(); }
private async void ImportButton_Click(object sender, RoutedEventArgs e) { CanShowDeviceUpdateDialog = false; var inputFile = await ShowFileOpenPickerAsync(); if (inputFile == null) { return; } ContentDialogResult result = ContentDialogResult.Secondary; if (NeedSave) { YesNoCancelDialog dialog = new YesNoCancelDialog { DialogTitle = resourceLoader.GetString("YesNoCancelDialog_SaveFile"), DialogContent = resourceLoader.GetString("YesNoCancelDialog_SaveHint"), DialogYesButtonContent = resourceLoader.GetString("YesNoCancelDialog_Save"), DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Discard") }; await dialog.ShowAsync(); result = dialog.Result; } if (result != ContentDialogResult.None) { if (result == ContentDialogResult.Primary) { bool successful = await SaveCurrentUserFile(); if (!successful) { return; } savedUndoCommand = ReUndoManager.CurUndoCommand; } StorageFile copyfile = await inputFile.CopyAsync(m_LocalUserFileFolder, inputFile.Name, NameCollisionOption.ReplaceExisting); await inputFile.CopyAsync(m_LocalUserFileFolder, inputFile.Name, NameCollisionOption.ReplaceExisting); Log.Debug("[ImportButton] CopyAsync " + inputFile.Path + " to " + m_LocalUserFileFolder + "\\" + inputFile.Name); CurrentUserFilename = copyfile.Name.Replace(".xml", ""); await LoadUserFile(CurrentUserFilename); await SaveCurrentUserFile(); ReUndoManager.Clear(); SetLayerCounter = 1; } }
static public void Store(IReUndoCommand command) { if (_mutex == true) { return; } UndoStack.Push(command); RedoStack.Clear(); RaiseCanExecute(); }
private async void FileItem_Click(object sender, RoutedEventArgs e) { CanShowDeviceUpdateDialog = false; var item = sender as MenuFlyoutItem; string selectedName = item.Text; if (selectedName == CurrentUserFilename) { return; } ContentDialogResult result = ContentDialogResult.Secondary; if (NeedSave) { YesNoCancelDialog dialog = new YesNoCancelDialog { DialogTitle = resourceLoader.GetString("YesNoCancelDialog_SaveFile"), DialogContent = resourceLoader.GetString("YesNoCancelDialog_SaveHint"), DialogYesButtonContent = resourceLoader.GetString("YesNoCancelDialog_Save"), DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Discard") }; await dialog.ShowAsync(); result = dialog.Result; } if (result != ContentDialogResult.None) { if (result == ContentDialogResult.Primary) { bool successful = await SaveCurrentUserFile(); if (!successful) { return; } savedUndoCommand = ReUndoManager.CurUndoCommand; } Log.Debug("[FileItem_Click] Selected file name : " + selectedName); await LoadUserFile(selectedName); CurrentUserFilename = selectedName; ReUndoManager.Clear(); SetLayerCounter = 1; } }
private async void NewFileButton_Click(object sender, RoutedEventArgs e) { CanShowDeviceUpdateDialog = false; Log.Debug("[NewFile] New File"); ContentDialogResult result = ContentDialogResult.Secondary; if (NeedSave) { YesNoCancelDialog dialog = new YesNoCancelDialog { DialogTitle = resourceLoader.GetString("YesNoCancelDialog_SaveFile"), DialogContent = resourceLoader.GetString("YesNoCancelDialog_SaveHint"), DialogYesButtonContent = resourceLoader.GetString("YesNoCancelDialog_Save"), DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Discard") }; await dialog.ShowAsync(); result = dialog.Result; } if (result != ContentDialogResult.None) { if (result == ContentDialogResult.Primary) { bool successful = await SaveCurrentUserFile(); if (!successful) { return; } savedUndoCommand = ReUndoManager.CurUndoCommand; } ResetToDefault(); } ForHotkeyFocus.Focus(FocusState.Programmatic); }
static public void Undo() { if (UndoStack.Count == 0) { return; } _mutex = true; IReUndoCommand command = UndoStack.Pop(); command.ExecuteUndo(); RedoStack.Push(command); _mutex = false; if (command is MoveEffectCommand c) { if (c.Conflict()) { Undo(); } } RaiseCanExecute(); }