示例#1
0
        private async void OnCommand_Exit_Execute()
        {
            var msgSaveBeforeExitPreview = new MessageGpxViewerSaveBeforeExit_Preview();

            this.Messenger.Publish(msgSaveBeforeExitPreview);
            if (msgSaveBeforeExitPreview.AnyUnsavedChanges)
            {
                var srvMessageBox = this.GetViewService <IMessageBoxService>();
                var msgResult     = await srvMessageBox.ShowAsync(
                    "RK Gpx Viewer", "Save changes before exit?", MessageBoxButtons.YesNoCancel);

                switch (msgResult)
                {
                case MessageBoxResult.Yes:
                    var msgSaveBeforeExit_Save = new MessageGpxViewerSaveBeforeExit_Save();
                    this.Messenger.Publish(msgSaveBeforeExit_Save);
                    foreach (var actSaveTask in msgSaveBeforeExit_Save.SaveTasks)
                    {
                        await actSaveTask;
                    }
                    break;

                case MessageBoxResult.No:
                    // Just close, no saving
                    break;

                case MessageBoxResult.Cancel:
                    return;

                default:
                    throw new ArgumentException($"Unexpected MessageBoxResult {msgResult}");
                }
            }

            this.ExitApproved = true;
            this.CloseWindow(null);
        }
示例#2
0
 private void OnMessageReceived(MessageGpxViewerSaveBeforeExit_Save message)
 {
     message.SaveTasks.Add(this.OnCommand_SaveAll_ExecuteAsync());
 }