async Task LaunchMainViewProc(Window window, string expressionsDirectoryPath)
        {
            // Load character expressions into memory
            var expressionsProvider = new CharacterExpressionsProvider();
            var loadResult          = await expressionsProvider.LoadFrom(expressionsDirectoryPath);

            if (loadResult != true)
            {
                await MessageBoxManager
                .GetMessageBoxStandardWindow("Error", $"Failed to load expressions from: {Environment.NewLine}{expressionsDirectoryPath}")
                .ShowDialog(window);

                return;
            }

            var optionsList = expressionsProvider.CharacterExpressions.Select(ce => new Option(ce, ce.Expression, ce.Image));

            if (optionsList.Count() == 0)
            {
                await MessageBoxManager
                .GetMessageBoxStandardWindow("Error", $"Loaded 0 expressions from: {Environment.NewLine}{expressionsDirectoryPath}")
                .ShowDialog(window);

                return;
            }

            ShowMainView(window, optionsList);
        }
        private async void ButtonAddGames_Click(object sender, RoutedEventArgs e)
        {
            var fileDialog = new OpenFileDialog
            {
                Title         = "Select File(s)",
                AllowMultiple = true,
                Filters       = fileFilterList
            };

            var files = await fileDialog.ShowAsync(this);

            if (files != null && files.Any())
            {
                IsBusy = true;

                var invalid = await Manager.AddGames(files);

                if (invalid.Any())
                {
                    await MessageBoxManager.GetMessageBoxStandardWindow("Ignored folders/files", string.Join(Environment.NewLine, invalid), icon : MessageBox.Avalonia.Enums.Icon.Error).ShowDialog(this);
                }

                IsBusy = false;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Command callback.
        /// Called to navigate to a category.
        /// </summary>
        /// <param name="selectedCategory">Value selected.</param>
        private async void OnCategorySelection(SettingsCategoryEnum selectedCategory)
        {
            if (selectedCategory == _currentCategory)
            {
                return;
            }

            if (ContentViewModel.IsChangePending)
            {
                var result = await MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
                {
                    ContentTitle      = "Pending changes",
                    ContentMessage    = $"Some changes were not saved{Environment.NewLine}Do you want to save them?",
                    ButtonDefinitions = ButtonEnum.YesNoCancel,
                    Icon = Icon.Info,
                }).ShowDialog(NavigationActor.Instance.MainWindow);

                switch (result)
                {
                case ButtonResult.Yes:
                    OnSaveSettings();
                    break;

                case ButtonResult.Cancel:
                    return;     // Do not navigate on cancel.
                }
            }

            Navigate(selectedCategory);
        }
Exemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif


            this.FindControl <Button>("OpenFileDialogButton").Click += async(sender, args) =>
            {
                try
                {
                    var fileDialog = new OpenFileDialog()
                    {
                        AllowMultiple = false
                    };

                    string[] files = await fileDialog.ShowAsync(this);

                    // expected: files never is null
                    string view = string.Join(";", files.Select(s => s ?? "null"));

                    await MessageBoxManager.GetMessageBoxStandardWindow("Files paths", $"{view}")
                    .ShowDialog(this);
                }
                catch (Exception e)
                {
                    await MessageBoxManager.GetMessageBoxStandardWindow("Exception", $"Message: {e.Message}")
                    .ShowDialog(this);
                }
            };
        }
Exemplo n.º 5
0
        internal List <FileAndStatus> GetCurrentlySelectedChangelist(List <FileAndStatus> cachedWorkingDirectory)
        {
            List <FileAndStatus> changelist = new List <FileAndStatus>();

            if (CurrentlySelectedChangelist >= 0)
            {
                if (CurrentlySelectedChangelist >= Changelists.Count)
                {
                    MessageBoxManager.GetMessageBoxStandardWindow("", "Invalid index. Unexpected after I fixed a bug 2016-09-13.. if it happens again, what happened?").Show();
                    return(changelist);
                }
                List <string> listOfFiles = Changelists[CurrentlySelectedChangelist].Files;
                for (int i = 0; i < listOfFiles.Count; i++)
                {
                    FileAndStatus fs = cachedWorkingDirectory.Find(c => c.FileName == listOfFiles[i]);
                    if (fs != null)
                    {
                        changelist.Add(fs);
                    }
                }
            }
            else
            {
                MessageBoxManager.GetMessageBoxStandardWindow("", "Unexpected, you're calling this with CurrentlySelectedChangelist < 0").Show();
                changelist.AddRange(cachedWorkingDirectory);
            }
            return(changelist);
        }
Exemplo n.º 6
0
 private void btnInitFlightDir_Click(object sender, RoutedEventArgs e)
 {
     if (!autoFplDirectActive) //AutoNAV not active. Turn it on.
     {
         getAPState();
         if (pFplState == null || pFplState.fpl == null)
         {
             MessageBoxManager
             .GetMessageBoxStandardWindow("Info",
                                          "Must get or set FPL first.",
                                          ButtonEnum.Ok, Icon.Info)
             .Show();
         }
         else if (pFplState.fpl.Waypoints.Length > 0)
         {
             //updateAutoNav(pAircraftState);
             autoFplDirectActive       = true;
             _lblFmsState.Text         = "AutoNAV Enabled";
             _lblFmsState.Foreground   = Brushes.DarkGreen;
             _btnInitFlightDir.Content = "Disable AutoNAV";
         }
     }
     else //AutoNav running. Turn it off.
     {
         autoFplDirectActive       = false;
         _lblFmsState.Text         = "AutoNAV Disabled";
         _lblFmsState.Foreground   = Brushes.Red;
         _btnInitFlightDir.Content = "Enable AutoNAV";
     }
 }
Exemplo n.º 7
0
        private static void ExceptionMessageBox(Exception ex)
        {
            var msgBox = MessageBoxManager
                         .GetMessageBoxStandardWindow("Ошибка", ex.Message + "\n" + ex.StackTrace);

            msgBox.Show();
        }
        public void AddSelectedSongToPlaylist(PlaylistModel playlist)
        {
            if (playlist == null)
            {
                return;
            }
            if (SelectedSong == null)
            {
                return;
            }

            if (SelectedSong.FilePath.Substring(0, 1) == StorageManager.SelectedDrive.Configuration.RootDirectory.Substring(0, 1))
            {
                if (!playlist.Songs.Contains(SelectedSong))
                {
                    playlist.Songs.Add(SelectedSong);
                }

                playlist.Save();
            }
            else
            {
                MessageBoxManager.GetMessageBoxStandardWindow("Playlist Error", "Cannot add song from another drive.",
                                                              MessageBox.Avalonia.Enums.ButtonEnum.Ok, MessageBox.Avalonia.Enums.Icon.Forbidden).ShowDialog(AppSession.ShellWindow);
            }
        }
        private async void ButtonBatchRename_Click(object sender, RoutedEventArgs e)
        {
            if (Manager.ItemList.Count == 0)
            {
                return;
            }

            IsBusy = true;
            try
            {
                var w = new CopyNameWindow();
                if (!await w.ShowDialog <bool>(this))
                {
                    return;
                }

                var count = await Manager.BatchRenameItems(w.NotOnCard, w.OnCard, w.FolderName, w.ParseTosec);

                await MessageBoxManager.GetMessageBoxStandardWindow("Done", $"{count} item(s) renamed").ShowDialog(this);
            }
            catch (Exception ex)
            {
                await MessageBoxManager.GetMessageBoxStandardWindow("Error", ex.Message, icon : MessageBox.Avalonia.Enums.Icon.Error).ShowDialog(this);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 10
0
        public async Task <IDialogService.DialogResult> ShowDialog(string message, string title         = "",
                                                                   IDialogService.ButtonType buttonType = IDialogService.ButtonType.Ok, object?window = null)
        {
            IMsBoxWindow <ButtonResult> msgBox = MessageBoxManager.GetMessageBoxStandardWindow(title, message, Convert(buttonType));

            ButtonResult res = await(window is Window parentWindow ? msgBox.ShowDialog(parentWindow) : msgBox.Show()).ConfigureAwait(true);

            return(Convert(res));
        }
Exemplo n.º 11
0
 public static async Task <ButtonResult> ShowDialog(Window window, string header, string message, ButtonEnum buttons)
 {
     return(await MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
     {
         ButtonDefinitions = buttons,
         Style = Style.Windows,
         ContentHeader = header,
         ContentMessage = message
     }).ShowDialog(window));
 }
Exemplo n.º 12
0
        /// <summary>
        /// Logs an unhandled exception and terminates the application properly.
        /// </summary>
        /// <param name="ex">Unhandled exception.</param>
        private static void OnUnhandledException(Exception ex)
        {
            LogHelper.GetLogger("Main").Fatal("A fatal exception occured:", ex);

            #if DEBUG
            throw ex;
            #else
            DispatcherHelper.Invoke(async() =>
            {
                if (await MessageBoxManager.GetMessageBoxStandardWindow(
                        new MessageBoxStandardParams
                {
                    ContentTitle = "Fatal error",
                    ContentMessage = string.Format("It appears that Houhou has been vanquished by an evil {0}.{1}"
                                                   + "Houhou will now shutdown. Sorry for the inconvenience.{1}"
                                                   + "Houhou's last words were: \"{2}\". Oh the pain it must have been.{1}{1}"
                                                   + "Please send me a mail report along with your log file if you think I should fix the issue.{1}"
                                                   + "Do you want to open the log?",
                                                   ex.GetType().Name,
                                                   Environment.NewLine,
                                                   ex.Message),
                    ButtonDefinitions = ButtonEnum.YesNoCancel,
                    Icon = Icon.Error
                }).ShowDialog(NavigationActor.Instance.ActiveWindow) == ButtonResult.Yes)
                {
                    try
                    {
                        ProcessHelper.OpenUri(LogHelper.GetLogFilePath());
                    }
                    catch (Exception ex2)
                    {
                        LogHelper.GetLogger("Main").Fatal("Failed to open the log after fatal exception. Double fatal shock.", ex2);

                        await MessageBoxManager.GetMessageBoxStandardWindow(
                            new MessageBoxStandardParams
                        {
                            ContentMessage = string.Format("Okay, so... the log file failed to open.{0}"
                                                           + "Um... I'm sorry. Now that's embarrassing...{0}"
                                                           + "Hey, listen, the log file should be there:{0}"
                                                           + "\"C:/Users/<YourUserName>/AppData/Local/Houhou SRS/Logs\"{0}"
                                                           + "If you still cannot get it, well just contact me without a log.{0}",
                                                           Environment.NewLine),
                            ContentTitle      = "Double fatal error shock",
                            ButtonDefinitions = ButtonEnum.Ok,
                            Icon = Icon.Error
                        }).ShowDialog(NavigationActor.Instance.ActiveWindow);
                    }
                }
            });

            Environment.Exit(1);
            #endif
        }
Exemplo n.º 13
0
        public SubdirectoryViewModel([NotNull] SubdirectoryModel model, Window view)
        {
            Entries             = new ObservableCollection <FileModel>();
            SelectedEntries     = new List <FileModel>();
            ExtractFilesCommand = ReactiveCommand.Create(ExecuteExtractFilesCommand);
            _model = model;
            _view  = view;

            Errno errno = model.Plugin.ReadDir(model.Path, out List <string> dirents);

            if (errno != Errno.NoError)
            {
                MessageBoxManager.
                GetMessageBoxStandardWindow("Error",
                                            $"Error {errno} trying to read \"{model.Path}\" of chosen filesystem",
                                            ButtonEnum.Ok, Icon.Error).ShowDialog(view);

                return;
            }

            foreach (string dirent in dirents)
            {
                errno = model.Plugin.Stat(model.Path + "/" + dirent, out FileEntryInfo stat);

                if (errno != Errno.NoError)
                {
                    AaruConsole.
                    ErrorWriteLine($"Error {errno} trying to get information about filesystem entry named {dirent}");

                    continue;
                }

                if (stat.Attributes.HasFlag(FileAttributes.Directory) &&
                    !model.Listed)
                {
                    model.Subdirectories.Add(new SubdirectoryModel
                    {
                        Name   = dirent,
                        Path   = model.Path + "/" + dirent,
                        Plugin = model.Plugin
                    });

                    continue;
                }

                Entries.Add(new FileModel
                {
                    Name = dirent,
                    Stat = stat
                });
            }
        }
Exemplo n.º 14
0
 private async void ButtonSort_Click(object sender, RoutedEventArgs e)
 {
     IsBusy = true;
     try
     {
         await Manager.SortList();
     }
     catch (Exception ex)
     {
         await MessageBoxManager.GetMessageBoxStandardWindow("Error", ex.Message, icon : MessageBox.Avalonia.Enums.Icon.Error).ShowDialog(this);
     }
     IsBusy = false;
 }
Exemplo n.º 15
0
 private async Task renameSelection(RenameBy renameBy)
 {
     IsBusy = true;
     try
     {
         await Manager.RenameItems(dg1.SelectedItems.Cast <GdItem>(), renameBy);
     }
     catch (Exception ex)
     {
         await MessageBoxManager.GetMessageBoxStandardWindow("Error", ex.Message, icon : MessageBox.Avalonia.Enums.Icon.Error).ShowDialog(this);
     }
     IsBusy = false;
 }
Exemplo n.º 16
0
 private static async void ShowInfo(string message)
 {
     var msgbox = MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
     {
         ButtonDefinitions = ButtonEnum.Ok,
         ContentTitle      = "Info",
         ContentMessage    = message,
         Icon         = MessageBox.Avalonia.Enums.Icon.Lock,
         Style        = Style.None,
         ShowInCenter = true
     });
     var result = await msgbox.Show();
 }
Exemplo n.º 17
0
 static public async void ShowInfoDialog(string title, string message, Window parent)
 {
     var messageBox = MessageBoxManager.GetMessageBoxStandardWindow(new MessageBox.Avalonia.DTO.MessageBoxStandardParams
     {
         ButtonDefinitions = MessageBox.Avalonia.Enums.ButtonEnum.Ok,
         ContentTitle      = title,
         ContentMessage    = message,
         Icon = MessageBox.Avalonia.Enums.Icon.Info,
         WindowStartupLocation = WindowStartupLocation.CenterScreen,
         Style = MessageBox.Avalonia.Enums.Style.Windows
     });
     await messageBox.ShowDialog(parent);
 }
Exemplo n.º 18
0
        private async Task ShowExceptionMessageBox(InteractionContext <Exception, Unit> interaction)
        {
            var msBoxStandardWindow = MessageBoxManager
                                      .GetMessageBoxStandardWindow(new MessageBoxStandardParams
            {
                ButtonDefinitions = ButtonEnum.Ok,
                ContentTitle      = "Wyjątek",
                ContentMessage    = interaction.Input.ToString(),
                Icon = global::MessageBox.Avalonia.Enums.Icon.Error,
            });

            await msBoxStandardWindow.ShowDialog(this);
        }
Exemplo n.º 19
0
 public void AddSetting()
 {
     if (SelectedTemplate != null)
     {
         var clone = SelectedTemplate.Clone();
         InnerSettings.Add(clone);
     }
     else
     {
         var messageBoxStandardWindow = MessageBoxManager.GetMessageBoxStandardWindow("Error", "Select a type of settings to add");
         messageBoxStandardWindow.Show();
     }
 }
Exemplo n.º 20
0
        static public async Task <MessageBox.Avalonia.Enums.ButtonResult> ShowOkCancelDialog(string title, string message, Window parent)
        {
            var messageBox = MessageBoxManager.GetMessageBoxStandardWindow(new MessageBox.Avalonia.DTO.MessageBoxStandardParams
            {
                ButtonDefinitions = MessageBox.Avalonia.Enums.ButtonEnum.OkCancel,
                ContentTitle      = title,
                ContentMessage    = message,
                Icon = MessageBox.Avalonia.Enums.Icon.Warning,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                Style = MessageBox.Avalonia.Enums.Style.Windows
            });

            return(await messageBox.ShowDialog(parent));
        }
        /// <summary>
        /// Command callback.
        /// Called to delete the SRS entry.
        /// </summary>
        private async void OnDelete()
        {
            var result = await MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
            {
                ContentTitle      = "Delete the SRS item",
                ContentMessage    = "Do you really want to delete the SRS item?",
                ButtonDefinitions = MessageBox.Avalonia.Enums.ButtonEnum.YesNo,
            }).ShowDialog(NavigationActor.Instance.MainWindow);

            if (result == ButtonResult.Yes)
            {
                SendEntity(SrsEntryOperationEnum.Delete);
            }
        }
Exemplo n.º 22
0
        private async Task <bool> FailIfNothingSelected()
        {
            if (dataGrid.SelectedItem == null)
            {
                await MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
                {
                    Style          = Style.Windows,
                    ContentHeader  = "Note",
                    ContentMessage = "No item selected."
                }).ShowDialog(this);

                return(true);
            }
            return(false);
        }
Exemplo n.º 23
0
 private async void MainWindow_Click(object sender, RoutedEventArgs e)
 {
     var messageBoxStandardWindow = MessageBoxManager.GetMessageBoxStandardWindow(
         new MessageBoxStandardParams
     {
         ShowInCenter          = false,
         WindowStartupLocation = WindowStartupLocation.CenterOwner,
         ContentTitle          = "Sup",
         ContentMessage        = "Bro",
         Icon              = MessageBoxAvaloniaEnums.Icon.Plus,
         Style             = MessageBoxAvaloniaEnums.Style.None,
         ButtonDefinitions = MessageBoxAvaloniaEnums.ButtonEnum.YesNo,
         CanResize         = false,
     });
     await messageBoxStandardWindow.ShowDialog(this);
 }
        protected override async Task <bool> CanChangeSet(UserResourceSetInfo setInfo)
        {
            // Show validation messagebox.
            var result = await MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
            {
                ContentTitle   = "SRS level set change warning",
                ContentMessage = "Please be aware that modifying the SRS level set may block "
                                 + "some existing SRS items in the case where the new level set has less "
                                 + $"levels than the previous one.{Environment.NewLine}Also, please note that the current "
                                 + "scheduled review dates will not be affected.",
                ButtonDefinitions = ButtonEnum.OkCancel,
                Icon = Icon.Warning,
            }).ShowDialog(NavigationActor.Instance.MainWindow);

            return(result == ButtonResult.Ok);
        }
Exemplo n.º 25
0
        public void ShowGeoData()
        {
            var msg         = string.Empty;
            var rows        = 0;
            var directories = ImageMetadataReader.ReadMetadata(Frames[SelectedIndex].Path);

            foreach (var directory in directories)
            {
                foreach (var tag in directory.Tags)
                {
                    if (directory.Name.ToLower() != "gps")
                    {
                        continue;
                    }
                    if (tag.Name.ToLower() != "gps latitude" && tag.Name.ToLower() != "gps longitude" &&
                        tag.Name.ToLower() != "gps altitude")
                    {
                        continue;
                    }

                    rows++;
                    msg += $"{tag.Name}: {TranslateGeoTag(tag.Description)}\n";
                }
            }

            if (rows != 3)
            {
                msg = "This image have hot geo tags.\nUse `Show all metadata` more for more details.";
            }
            var msgbox = MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
            {
                ButtonDefinitions = ButtonEnum.Ok,
                ContentTitle      = $"Geo position of {Path.GetFileName(Frames[SelectedIndex].Path)}",
                ContentMessage    = msg,
                Icon         = Icon.Info,
                Style        = Style.None,
                ShowInCenter = true,
                Window       = new MsBoxStandardWindow
                {
                    Height    = 300,
                    Width     = 500,
                    CanResize = true
                }
            });

            msgbox.Show();
        }
Exemplo n.º 26
0
        private async Task LoadItemsFromCard()
        {
            IsBusy = true;

            try
            {
                await Manager.LoadItemsFromCard();
            }
            catch (Exception ex)
            {
                await MessageBoxManager.GetMessageBoxStandardWindow("Invalid Folders", $"Problem loading the following folder(s):\n\n{ex.Message}", icon : MessageBox.Avalonia.Enums.Icon.Warning).ShowDialog(this);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 27
0
        public static async Task <string> SelectPath(bool fail = false)
        {
            Debug.WriteLine("Selecting path...");

            Window parent = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow
                            ?? throw new InvalidOperationException();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                return(await SelectMacApp(parent, fail));
            }

            var dialog = new OpenFolderDialog
            {
                Title = "Select your Hollow Knight folder.",
            };

            while (true)
            {
                string?result = await dialog.ShowAsync(parent);

                if (result is null)
                {
                    await MessageBoxManager.GetMessageBoxStandardWindow("Path", NO_SELECT).Show();
                }
                else if (ValidateWithSuffix(result) is not(var managed, var suffix))
                {
                    await MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams {
                        ContentTitle   = "Path",
                        ContentHeader  = INVALID_PATH_HEADER,
                        ContentMessage = INVALID_PATH,
                        MinHeight      = 140
                    }).Show();
                }
                else
                {
                    return(Path.Combine(managed, suffix));
                }

                if (fail)
                {
                    return(null !);
                }
            }
        }
Exemplo n.º 28
0
        private void chkEnableAtcAutopilot_Checked(object sender, RoutedEventArgs e)
        {
            if (_chkEnableAtcAutopilot.IsChecked == true)
            {
                //Start receiving ATC messages
                client.ExecuteCommand("Live.EnableATCMessageNotification");
            }
            if ((_chkEnableAtcAutopilot.IsChecked == true) && (_txtCurrentCallsign.Text == null || _txtCurrentCallsign.Text == ""))
            {
                MessageBoxManager
                .GetMessageBoxStandardWindow("Info",
                                             "Must enter your current callsign or this will not work!",
                                             ButtonEnum.Ok, Icon.Info)
                .Show();

                _chkEnableAtcAutopilot.IsChecked = false;
            }
        }
Exemplo n.º 29
0
        public async void Exit()
        {
            var window = MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
            {
                ContentTitle      = "Exit",
                ContentMessage    = "Do you really want to exit?",
                Icon              = Icon.Info,
                Style             = Style.None,
                ShowInCenter      = true,
                ButtonDefinitions = ButtonEnum.YesNo
            });
            var result = await window.Show();

            if (result == ButtonResult.Yes)
            {
                _window.Close();
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Command callback.
        /// Called to save current settings.
        /// </summary>
        private async void OnSaveSettings()
        {
            bool needRestart = ContentViewModel.IsRestartNeeded();

            ContentViewModel.SaveSettings();
            Interface.Properties.Settings.Default.Save();

            if (needRestart)
            {
                await MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
                {
                    ButtonDefinitions = ButtonEnum.Ok,
                    ContentTitle      = "Some settings need restart",
                    ContentMessage    = "Some changes will not take effect until the application is restarted.",
                    Icon = Icon.Info,
                }).ShowDialog(NavigationActor.Instance.MainWindow);
            }
        }