Example #1
0
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            try
            {
                Lazydata.ParrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null &&
                                                          ChkUseSto0ZCheckBox.IsChecked.Value;
                Lazydata.ParrotData.StoozPercent = (int)sTo0zZonePercent.Value;


                if (ChkFullAxisGas.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value;
                }
                if (ChkReverseAxisGas.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value;
                }
                if (ChkFullAxisBrake.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value;
                }
                if (ChkReverseAxisBrake.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value;
                }

                if (GunSensitivityPlayer1.Value != null)
                {
                    Lazydata.ParrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value;
                }

                if (GunSensitivityPlayer2.Value != null)
                {
                    Lazydata.ParrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value;
                }

                Lazydata.ParrotData.SaveLastPlayed  = ChkSaveLastPlayed.IsChecked.Value;
                Lazydata.ParrotData.UseDiscordRPC   = ChkUseDiscordRPC.IsChecked.Value;
                Lazydata.ParrotData.CheckForUpdates = ChkCheckForUpdates.IsChecked.Value;
                Lazydata.ParrotData.SilentMode      = ChkSilentMode.IsChecked.Value;
                Lazydata.ParrotData.ConfirmExit     = ChkConfirmExit.IsChecked.Value;
                Lazydata.ParrotData.DownloadIcons   = ChkDownloadIcons.IsChecked.Value;
                Lazydata.ParrotData.UiDisableHardwareAcceleration = ChkUiDisableHardwareAcceleration.IsChecked.Value;

                Lazydata.ParrotData.UiColour        = UiColour.SelectedItem.ToString();
                Lazydata.ParrotData.UiDarkMode      = ChkUiDarkMode.IsChecked.Value;
                Lazydata.ParrotData.UiHolidayThemes = ChkUiHolidayThemes.IsChecked.Value;

                DiscordRPC.StartOrShutdown();

                JoystickHelper.Serialize();

                Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, "ParrotData.xml"));
                _contentControl.Content = _library;
            }
            catch (Exception exception)
            {
                MessageBoxHelper.ErrorOK(string.Format(Properties.Resources.ErrorCantSaveParrotData, exception.ToString()));
            }
        }
Example #2
0
 /// <summary>
 /// Loads the settings data file.
 /// </summary>
 private void LoadParrotData()
 {
     try
     {
         if (!File.Exists("ParrotData.xml"))
         {
             MessageBox.Show("Seems this is first time you are running me, please set emulation settings.",
                             "Hello World", MessageBoxButton.OK, MessageBoxImage.Information);
             _parrotData         = new ParrotData();
             Lazydata.ParrotData = _parrotData;
             JoystickHelper.Serialize(_parrotData);
             return;
         }
         _parrotData = JoystickHelper.DeSerialize();
         if (_parrotData == null)
         {
             _parrotData         = new ParrotData();
             Lazydata.ParrotData = _parrotData;
             JoystickHelper.Serialize(_parrotData);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(
             $"Exception happened during loading ParrotData.xml! Generate new one by saving!{Environment.NewLine}{Environment.NewLine}{e}",
             "Error", MessageBoxButton.OK,
             MessageBoxImage.Error);
     }
 }
Example #3
0
 private void BtnSaveSettings(object sender, RoutedEventArgs e)
 {
     try
     {
         var settingsData = new SettingsData
         {
             PlayerOneGuid        = FetchGuidFromComboBoxItem(P1JoystickComboBox.SelectedItem),
             PlayerTwoGuid        = FetchGuidFromComboBoxItem(P2JoystickComboBox.SelectedItem),
             UseKeyboard          = ChkUseKeyboard.IsChecked != null && ChkUseKeyboard.IsChecked.Value,
             SegaRacingClassicDir = TxtSrcLocation.Text,
             VirtuaTennis4Dir     = TxtVt4Location.Text,
             MeltyBloodDir        = TxtMeltyBloodLocation.Text,
             LgiDir              = TxtLgiLocation.Text,
             SegaSonicDir        = TxtSegaSonicLocation.Text,
             SegaDreamRaidersDir = TxtSdrLocation.Text,
             UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null && ChkUseSto0ZCheckBox.IsChecked.Value,
             UseMouse            = ChkUseMouse.IsChecked != null && ChkUseMouse.IsChecked.Value,
             InitialD6Dir        = TxtInitialD6Location.Text,
             XInputMode          = _xinputMode,
             GoldenGunDir        = TxtGoldenGunLocation.Text
         };
         JoystickHelper.Serialize(settingsData);
         _settingsData = settingsData;
         MessageBox.Show("Generation of SettingsData.xml was succesful!", "Save Complete", MessageBoxButton.OK,
                         MessageBoxImage.Information);
     }
     catch (Exception exception)
     {
         MessageBox.Show($"Exception happened during SettingsData.xml saving!{Environment.NewLine}{Environment.NewLine}{exception}", "Error", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
     Hide();
 }
Example #4
0
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            try
            {
                Lazydata.ParrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null &&
                                                          ChkUseSto0ZCheckBox.IsChecked.Value;
                Lazydata.ParrotData.StoozPercent = (int)sTo0zZonePercent.Value;


                if (ChkFullAxisGas.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value;
                }
                if (ChkReverseAxisGas.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value;
                }
                if (ChkFullAxisBrake.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value;
                }
                if (ChkReverseAxisBrake.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value;
                }

                if (GunSensitivityPlayer1.Value != null)
                {
                    Lazydata.ParrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value;
                }

                if (GunSensitivityPlayer2.Value != null)
                {
                    Lazydata.ParrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value;
                }

                Lazydata.ParrotData.SaveLastPlayed  = ChkSaveLastPlayed.IsChecked.Value;
                Lazydata.ParrotData.UseDiscordRPC   = ChkUseDiscordRPC.IsChecked.Value;
                Lazydata.ParrotData.CheckForUpdates = ChkCheckForUpdates.IsChecked.Value;
                Lazydata.ParrotData.SilentMode      = ChkSilentMode.IsChecked.Value;
                Lazydata.ParrotData.ConfirmExit     = ChkConfirmExit.IsChecked.Value;
                Lazydata.ParrotData.DownloadIcons   = ChkDownloadIcons.IsChecked.Value;
                Lazydata.ParrotData.UiDisableHardwareAcceleration = ChkUiDisableHardwareAcceleration.IsChecked.Value;

                Lazydata.ParrotData.UiColour   = UiColour.SelectedItem.ToString();
                Lazydata.ParrotData.UiDarkMode = ChkUiDarkMode.IsChecked.Value;

                DiscordRPC.StartOrShutdown();

                JoystickHelper.Serialize();

                MessageBox.Show("Successfully saved ParrotData.xml!");
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Exception happened during ParrotData.xml saving!{Environment.NewLine}{Environment.NewLine}{exception}", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_parrotData == null)
                {
                    _parrotData         = new ParrotData();
                    Lazydata.ParrotData = _parrotData;
                }
                _parrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null &&
                                                  ChkUseSto0ZCheckBox.IsChecked.Value;
                _parrotData.StoozPercent = (int)sTo0zZonePercent.Value;


                if (ChkFullAxisGas.IsChecked.HasValue)
                {
                    _parrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value;
                }
                if (ChkReverseAxisGas.IsChecked.HasValue)
                {
                    _parrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value;
                }
                if (ChkFullAxisBrake.IsChecked.HasValue)
                {
                    _parrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value;
                }
                if (ChkReverseAxisBrake.IsChecked.HasValue)
                {
                    _parrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value;
                }

                if (GunSensitivityPlayer1.Value != null)
                {
                    _parrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value;
                }

                if (GunSensitivityPlayer2.Value != null)
                {
                    _parrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value;
                }

                _parrotData.SaveLastPlayed  = ChkSaveLastPlayed.IsChecked.Value;
                _parrotData.UseDiscordRPC   = ChkUseDiscordRPC.IsChecked.Value;
                _parrotData.CheckForUpdates = ChkCheckForUpdates.IsChecked.Value;
                _parrotData.SilentMode      = ChkSilentMode.IsChecked.Value;

                JoystickHelper.Serialize(_parrotData);
                DiscordRPC.Shutdown();
                string[] psargs = Environment.GetCommandLineArgs();
                System.Diagnostics.Process.Start(Application.ResourceAssembly.Location, psargs[0]);
                Application.Current.Shutdown();
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Exception happened during ParrotData.xml saving!{Environment.NewLine}{Environment.NewLine}{exception}", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Example #6
0
    public static void StartOrShutdown()
    {
        // download the DLL if it doesn't exist
        if (!File.Exists(RPC_PATH))
        {
            try
            {
                var request = (HttpWebRequest)WebRequest.Create("https://github.com/discordapp/discord-rpc/releases/download/v3.4.0/discord-rpc-win.zip");
                request.Timeout = 10000;
                request.Proxy   = null;

                using (var response = request.GetResponse().GetResponseStream())
                    using (var zip = new ZipArchive(response, ZipArchiveMode.Read))
                    {
                        foreach (var entry in zip.Entries)
                        {
                            if (entry.FullName == "discord-rpc/win32-dynamic/bin/discord-rpc.dll")
                            {
                                using (var entryStream = entry.Open())
                                    using (var dll = File.Create(RPC_PATH))
                                    {
                                        entryStream.CopyTo(dll);
                                    }
                            }
                        }
                    }
            }
            catch (Exception e)
            {
                // don't bother showing a messagebox or anything
                Lazydata.ParrotData.UseDiscordRPC = false;
                JoystickHelper.Serialize();
                return;
            }
        }

        // calling Initialize / Shutdown if the library is already/hasn't been initialized is fine.
        if (Lazydata.ParrotData.UseDiscordRPC)
        {
            Initialize(APP_ID, IntPtr.Zero, false, null);
        }
        else
        {
            Shutdown();
        }
    }
Example #7
0
        private void BtnStartGame(object sender, RoutedEventArgs e)
        {
            if (GameListComboBox.Items.Count == 0)
            {
                return;
            }

            var gameProfile = (GameProfile)((ComboBoxItem)GameListComboBox.SelectedItem).Tag;

            if (_parrotData.SaveLastPlayed)
            {
                _parrotData.LastPlayed = gameProfile.GameName;
                JoystickHelper.Serialize(_parrotData);
            }

            var testMenuExe = gameProfile.TestMenuIsExecutable ? gameProfile.TestMenuParameter : "";

            var testStr = gameProfile.TestMenuIsExecutable ? gameProfile.TestMenuExtraParameters : gameProfile.TestMenuParameter;

            ValidateAndRun(gameProfile, testStr, testMenuExe);
        }
Example #8
0
        /// <summary>
        /// This button actually launches the game selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (gameList.Items.Count == 0)
            {
                return;
            }

            var gameProfile = (GameProfile)((ListBoxItem)gameList.SelectedItem).Tag;

            if (MainWindow.ParrotData.SaveLastPlayed)
            {
                MainWindow.ParrotData.LastPlayed = gameProfile.GameName;
                JoystickHelper.Serialize(MainWindow.ParrotData);
            }

            var testMenuExe = gameProfile.TestMenuIsExecutable ? gameProfile.TestMenuParameter : "";

            var testStr = gameProfile.TestMenuIsExecutable
                ? gameProfile.TestMenuExtraParameters
                : gameProfile.TestMenuParameter;

            ValidateAndRun(gameProfile, testStr, testMenuExe);
        }
Example #9
0
 /// <summary>
 /// Loads the settings data file.
 /// </summary>
 private static bool LoadSettingsData()
 {
     try
     {
         if (!File.Exists("SettingsData.xml"))
         {
             Console.WriteLine("Please use the UI to set config!");
             return(false);
         }
         _settingsData = JoystickHelper.DeSerialize();
         if (_settingsData == null)
         {
             _settingsData = new SettingsData();
             JoystickHelper.Serialize(_settingsData);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine($"Exception happened during loading SettingsData.xml! Generate new one by saving!{Environment.NewLine}{Environment.NewLine}{e}");
         return(false);
     }
     return(true);
 }
Example #10
0
        /// <summary>
        /// This button actually launches the game selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnLaunchGame(object sender, RoutedEventArgs e)
        {
            if (gameList.Items.Count == 0)
            {
                return;
            }

            var gameProfile = (GameProfile)((ListBoxItem)gameList.SelectedItem).Tag;

            if (Lazydata.ParrotData.SaveLastPlayed)
            {
                Lazydata.ParrotData.LastPlayed = gameProfile.GameName;
                JoystickHelper.Serialize();
            }

            if (ValidateAndRun(gameProfile, out var loader, out var dll))
            {
                var testMenu = ChkTestMenu.IsChecked;

                var gameRunning = new GameRunning(gameProfile, loader, dll, testMenu, false, false, this);
                Application.Current.Windows.OfType <MainWindow>().Single().contentControl.Content = gameRunning;
            }
        }
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_parrotData == null)
                {
                    _parrotData         = new ParrotData();
                    Lazydata.ParrotData = _parrotData;
                }
                if (ChkThrustmasterFix.IsChecked.HasValue)
                {
                    _parrotData.HapticThrustmasterFix = ChkThrustmasterFix.IsChecked.Value;
                }

                _parrotData.ConstantBase = Convert.ToInt16(TxtConstant.Text);
                _parrotData.SineBase     = Convert.ToInt16(TxtSine.Text);
                _parrotData.FrictionBase = Convert.ToInt16(TxtFriction.Text);
                _parrotData.SpringBase   = Convert.ToInt16(TxtSpring.Text);

                if (ChkUseFfb.IsChecked.HasValue)
                {
                    _parrotData.UseHaptic = ChkUseFfb.IsChecked.Value;
                }
                _parrotData.HapticDevice        = (string)((ComboBoxItem)HapticComboBox.SelectedItem).Tag;
                _parrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null &&
                                                  ChkUseSto0ZCheckBox.IsChecked.Value;
                _parrotData.StoozPercent = (int)sTo0zZonePercent.Value;
                _parrotData.UseMouse     = ChkUseMouse.IsChecked != null && ChkUseMouse.IsChecked.Value;
                _parrotData.XInputMode   = _xinputMode;

                if (ChkFullAxisGas.IsChecked.HasValue)
                {
                    _parrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value;
                }
                if (ChkReverseAxisGas.IsChecked.HasValue)
                {
                    _parrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value;
                }
                if (ChkFullAxisBrake.IsChecked.HasValue)
                {
                    _parrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value;
                }
                if (ChkReverseAxisBrake.IsChecked.HasValue)
                {
                    _parrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value;
                }

                if (GunSensitivityPlayer1.Value != null)
                {
                    _parrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value;
                }

                if (GunSensitivityPlayer2.Value != null)
                {
                    _parrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value;
                }

                _parrotData.SaveLastPlayed = ChkSaveLastPlayed.IsChecked.Value;
                _parrotData.UseDiscordRPC  = ChkUseDiscordRPC.IsChecked.Value;

                JoystickHelper.Serialize(_parrotData);
                MessageBox.Show("Generation of ParrotData.xml was succesful, please restart me!", "Save Complete", MessageBoxButton.OK,
                                MessageBoxImage.Information);

                MainWindow.SafeExit();
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Exception happened during ParrotData.xml saving!{Environment.NewLine}{Environment.NewLine}{exception}", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Example #12
0
        private void BtnSaveKeys(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_playerId == 1)
                {
                    // Save player 1 xml
                    var map = new JoystickMapping
                    {
                        Button1             = GetTagButtonInfo(TxtButton1),
                        Button2             = GetTagButtonInfo(TxtButton2),
                        Button3             = GetTagButtonInfo(TxtButton3),
                        Button4             = GetTagButtonInfo(TxtButton4),
                        Button5             = GetTagButtonInfo(TxtButton5),
                        Button6             = GetTagButtonInfo(TxtButton6),
                        Start               = GetTagButtonInfo(TxtStart),
                        Test                = GetTagButtonInfo(TxtTestSw),
                        Service             = GetTagButtonInfo(TxtService),
                        Up                  = GetTagButtonInfo(TxtUp),
                        Down                = GetTagButtonInfo(TxtDown),
                        Left                = GetTagButtonInfo(TxtLeft),
                        Right               = GetTagButtonInfo(TxtRight),
                        GunUp               = GetTagButtonInfo(TxtLgiUp),
                        GunDown             = GetTagButtonInfo(TxtLgiDown),
                        GunLeft             = GetTagButtonInfo(TxtLgiLeft),
                        GunRight            = GetTagButtonInfo(TxtLgiRight),
                        GunTrigger          = GetTagButtonInfo(TxtGunTrigger),
                        SonicItem           = GetTagButtonInfo(TxtSonicItemButton),
                        GasAxis             = GetTagButtonInfo(TxtGas),
                        BrakeAxis           = GetTagButtonInfo(TxtBrake),
                        WheelAxis           = GetTagButtonInfo(TxtWheel),
                        SrcGearChange1      = GetTagButtonInfo(TxtSrcGearChange1),
                        SrcGearChange2      = GetTagButtonInfo(TxtSrcGearChange2),
                        SrcGearChange3      = GetTagButtonInfo(TxtSrcGearChange3),
                        SrcGearChange4      = GetTagButtonInfo(TxtSrcGearChange4),
                        SrcViewChange1      = GetTagButtonInfo(TxtSrcViewChange1),
                        SrcViewChange2      = GetTagButtonInfo(TxtSrcViewChange2),
                        SrcViewChange3      = GetTagButtonInfo(TxtSrcViewChange3),
                        SrcViewChange4      = GetTagButtonInfo(TxtSrcViewChange4),
                        InitialD6MenuDown   = GetTagButtonInfo(TxtInitialD6MenuDown),
                        InitialD6MenuLeft   = GetTagButtonInfo(TxtInitialD6MenuLeft),
                        InitialD6MenuRight  = GetTagButtonInfo(TxtInitialD6MenuRight),
                        InitialD6MenuUp     = GetTagButtonInfo(TxtInitialD6MenuUp),
                        InitialD6ShiftDown  = GetTagButtonInfo(TxtInitialD6ShiftDown),
                        InitialD6ShiftUp    = GetTagButtonInfo(TxtInitialD6ShiftUp),
                        InitialD6ViewChange = GetTagButtonInfo(TxtInitialD6ViewChange),
                    };
                    if (map.BrakeAxis != null)
                    {
                        if (ChkBrakeFullAxis.IsChecked.HasValue)
                        {
                            map.BrakeAxis.IsFullAxis = ChkBrakeFullAxis.IsChecked.Value;
                        }
                        if (ChkBrakeReverseAxis.IsChecked.HasValue)
                        {
                            map.BrakeAxis.IsReverseAxis = ChkBrakeReverseAxis.IsChecked.Value;
                        }
                    }

                    if (map.GasAxis != null)
                    {
                        if (ChkGasFullAxis.IsChecked.HasValue)
                        {
                            map.GasAxis.IsFullAxis = ChkGasFullAxis.IsChecked.Value;
                        }
                        if (ChkGasReverseAxis.IsChecked.HasValue)
                        {
                            map.GasAxis.IsReverseAxis = ChkGasReverseAxis.IsChecked.Value;
                        }
                    }
                    map.GunMultiplier = IUpDownMovementMultiplier.Value ?? 1;
                    JoystickHelper.Serialize(map, 1);
                }

                if (_playerId == 2)
                {
                    // Save player 2 xml
                    var map = new JoystickMapping
                    {
                        Button1    = GetTagButtonInfo(TxtButton1),
                        Button2    = GetTagButtonInfo(TxtButton2),
                        Button3    = GetTagButtonInfo(TxtButton3),
                        Button4    = GetTagButtonInfo(TxtButton4),
                        Button5    = GetTagButtonInfo(TxtButton5),
                        Button6    = GetTagButtonInfo(TxtButton6),
                        Start      = GetTagButtonInfo(TxtStart),
                        Test       = GetTagButtonInfo(TxtTestSw),
                        Service    = GetTagButtonInfo(TxtService),
                        Up         = GetTagButtonInfo(TxtUp),
                        Down       = GetTagButtonInfo(TxtDown),
                        Left       = GetTagButtonInfo(TxtLeft),
                        Right      = GetTagButtonInfo(TxtRight),
                        GunUp      = GetTagButtonInfo(TxtLgiUp),
                        GunDown    = GetTagButtonInfo(TxtLgiDown),
                        GunLeft    = GetTagButtonInfo(TxtLgiLeft),
                        GunRight   = GetTagButtonInfo(TxtLgiRight),
                        GunTrigger = GetTagButtonInfo(TxtGunTrigger)
                    };
                    map.GunMultiplier = IUpDownMovementMultiplier.Value ?? 1;
                    JoystickHelper.Serialize(map, 2);
                }
                MessageBox.Show("Save Complete", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Saving failed with error: {ex.InnerException} {ex.Message}", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            Close();
        }