/// <summary> /// Opens a profile. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonOpenProfile_OnClick(object sender, RoutedEventArgs e) { try { var dialog = new OpenFileDialog(); dialog.InitialDirectory = App.Settings.AvalonSettings.SaveDirectory; dialog.Filter = "JSON files (*.json)|*.json|Text Files (*.txt)|*.txt|All files (*.*)|*.*"; if (dialog.ShowDialog() == true) { // Load the settings for the file that was selected. App.Settings.LoadSettings(dialog.FileName); // Inject the Conveyor into the Triggers. foreach (var trigger in App.Settings.ProfileSettings.TriggerList) { trigger.Conveyor = Conveyor; } // Important! This is a new profile, we have to reload ALL of the DataList controls // and reset their bindings. AliasList.Reload(); DirectionList.Reload(); MacroList.Reload(); TriggersList.Reload(); VariableList.Reload(); // Show the user that the profile was successfully loaded. Interp.EchoText(""); Interp.EchoText($"--> Loaded {dialog.FileName}.\r\n", AnsiColors.Cyan); // Auto connect if it's setup to do so (this will disconnect from the previous server if it // was connected. if (App.Settings.ProfileSettings.AutoLogin) { Disconnect(); Connect(); } } } catch (Exception ex) { Interp.EchoText(""); Interp.EchoText($"--> An error occured: {ex.Message}.\r\n", AnsiColors.Red); } }