private async void Closing(CancelEventArgs args)
        {
            args.Cancel = true;

            if (BootConfigurationDataEditModel.Instance.CanSave())
            {
                var viewModel = new MessageDialogViewModel
                {
                    Message = "保存していない変更があります。保存しますか?",
                    Title   = ""
                };

                var view = new YesNoCancelDialog()
                {
                    DataContext = viewModel
                };

                this.IsEnabled = false;
                await System.Threading.Tasks.Task.FromResult(DialogHost.Show(view, "RootDialog", this.DialogClosing));

                return;
            }

            this.Close();
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
        private async void OnCloseRequest(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            ContentDialog cDialog = GetCurrentContentDialog();

            e.Handled = true;

            if (cDialog != null)
            {
                cDialog.Hide();
                return;
            }

            CanShowDeviceUpdateDialog = false;

            e.Handled = true;
            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;
                    }
                }

                SaveSettings();
                Log.Debug("[OnCloseRequest] Exit ...");
                CoreApplication.Exit();
            }
        }
예제 #5
0
        private async void DeleteItem_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentUserFilename == "")
            {
                return;
            }

            YesNoCancelDialog dialog = new YesNoCancelDialog
            {
                DialogTitle               = resourceLoader.GetString("YesNoCancelDialog_DeleteNow"),
                DialogContent             = resourceLoader.GetString("YesNoCancelDialog_DeleteHint"),
                DialogYesButtonContent    = resourceLoader.GetString("YesNoCancelDialog_Delete"),
                DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Cancel")
            };

            await dialog.ShowAsync();

            ContentDialogResult result = dialog.Result;

            if (result != ContentDialogResult.Primary)
            {
                return;
            }

            Log.Debug("[DeleteFile] Delete file : " + CurrentUserFilename);
            StorageFile localscript = await m_LocalUserScriptFolder.GetFileAsync(CurrentUserFilename + ".xml");

            await localscript.DeleteAsync(StorageDeleteOption.PermanentDelete);

            StorageFile localfile = await m_LocalUserFileFolder.GetFileAsync(CurrentUserFilename + ".xml");

            await localfile.DeleteAsync(StorageDeleteOption.PermanentDelete);

            Log.Debug("[DeleteFile] Delete successfully !");

            foreach (var item in FileListMenuFlyout.Items)
            {
                MenuFlyoutItem mfi = item as MenuFlyoutItem;
                if (mfi.Text == CurrentUserFilename)
                {
                    FileListMenuFlyout.Items.Remove(mfi);
                    break;
                }
                ;
            }

            ResetToDefault();
            SendMessageToServer("[XML] Change");
        }
예제 #6
0
        public static MessageBoxResult ShowDialog(string message, string title, string yesMessage, string noMessage, string cancelMessage)
        {
            var viewModel = new YesNoCancelDialogViewModel
            {
                Title         = title,
                YesMessage    = yesMessage,
                ModalContent  = message,
                NoMessage     = noMessage,
                CancelMessage = cancelMessage
            };
            var dialog = new YesNoCancelDialog
            {
                DataContext = viewModel,
                Owner       = Application.Current.MainWindow
            };

            dialog.ShowDialog();
            return(dialog.Result);
        }
예제 #7
0
        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);
        }