src/TF2HUD.Editor/MainWindow.xaml.cs
/// <summary>
///     Save and apply user settings to the HUD files.
/// </summary>
Save and apply user settings to the HUD files.
Save and apply user settings to the HUD files .
private void BtnSave_OnClick(object sender, RoutedEventArgs e)
        {
            var hudObject = Json.GetHUDByName(Settings.Default.hud_selected);
            if (Process.GetProcessesByName("hl2").Any() && hudObject.DirtyControls.Count > 0)
            {
                var message = hudObject.DirtyControls.Aggregate(Properties.Resources.info_game_restart, (current, control) => current + $"\n - {control}");
                if (_notifier.ShowMessageBox(MessageBoxImage.Question, message) != MessageBoxResult.OK) return;
            }
            Logger.Info("Start applying settings.");
            var worker = new BackgroundWorker();
            worker.DoWork += (_, _) =>
            {
                Dispatcher.Invoke(() =>
                {
                    if (string.IsNullOrWhiteSpace(HudSelection)) return;
                    var selection = Json.GetHUDByName(Settings.Default.hud_selected);
                    selection.Settings.SaveSettings();
                    selection.ApplyCustomizations();
                    selection.DirtyControls.Clear();
                    Logger.Info("Done applying settings.");
                });
            };
            worker.RunWorkerCompleted += (_, _) =>
            {
                LblStatus.Content = string.Format(Properties.Resources.status_applied, hudObject.Name, DateTime.Now);
            };
            worker.RunWorkerAsync();
        }
private void BtnSave_OnClick ( object sender , RoutedEventArgs e ) { var hudObject = Json . GetHUDByName ( Settings . Default . hud_selected ) ; if ( Process . GetProcessesByName ( " " ) . Any ( ) && hudObject . DirtyControls . Count > 0 ) { var message = hudObject . DirtyControls . Aggregate ( Properties . Resources . info_game_restart , ( current , control ) => current + $" \n  -  { control } " ) ; if ( _notifier . ShowMessageBox ( MessageBoxImage . Question , message ) != MessageBoxResult . OK ) return ; } Logger . Info ( " " ) ; var worker = new BackgroundWorker ( ) ; worker . DoWork += ( _ , _ ) => { Dispatcher . Invoke ( ( ) => { if ( string . IsNullOrWhiteSpace ( HudSelection ) ) return ; var selection = Json . GetHUDByName ( Settings . Default . hud_selected ) ; selection . Settings . SaveSettings ( ) ; selection . ApplyCustomizations ( ) ; selection . DirtyControls . Clear ( ) ; Logger . Info ( " " ) ; } ) ; } ; worker . RunWorkerCompleted += ( _ , _ ) => { LblStatus . Content = string . Format ( Properties . Resources . status_applied , hudObject . Name , DateTime . Now ) ; } ; worker . RunWorkerAsync ( ) ; }
Save and apply user settings to the HUD files.
Save and apply user settings to the HUD files .
sender
object
e
RoutedEventArgs