コード例 #1
0
ファイル: FSettings.cs プロジェクト: DarwinBaker/AATool
 private void OnButtonClick(object sender, EventArgs e)
 {
     if (sender == trackerBrowse)
     {
         using (var dialog = new FolderBrowserDialog())
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 trackerCustomSavesFolder.Text = dialog.SelectedPath;
             }
     }
     else if (sender == save || sender == cancel)
     {
         if (sender == save)
         {
             SaveSettings();
         }
         Close();
     }
     else if (sender == defaults)
     {
         string msg = "This will clear all customized settings, including user marked favorites and your custom save path. "
                      + "Are you sure you want to revert to the default settings?";
         if (MessageBox.Show(this, msg, "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             main.ResetToDefaults();
             main.Save();
             tracker.ResetToDefaults();
             tracker.Save();
             overlay.ResetToDefaults();
             overlay.Save();
             Directory.Delete(Paths.DIR_FAVORITES, true);
             Close();
         }
     }
     else if (sender == update)
     {
         UpdateHelper.TryCheckForUpdatesAsync(false);
     }
     else if (sender == about)
     {
         using (var dialog = new FAbout())
             dialog.ShowDialog();
     }
     else if (sender == overlayPickFavorites)
     {
         using (var dialog = new FPickFavorites(advancementTracker, achievementTracker, statisticsTracker))
             dialog.ShowDialog();
     }
     else if (sender == copyColorKey)
     {
         Clipboard.SetText($"#{overlayBackColor.BackColor.R:X2}{overlayBackColor.BackColor.G:X2}{overlayBackColor.BackColor.B:X2}");
     }
     else
     {
         using (var dialog = new ColorDialog())
         {
             dialog.Color = (sender as Control).BackColor;
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 (sender as Control).BackColor = dialog.Color;
                 if (sender == mainBackColor || sender == mainTextColor || sender == mainBorderColor)
                 {
                     mainTheme.SelectedItem = "Custom";
                 }
                 else if (sender == overlayBackColor)
                 {
                     copyColorKey.Text      = "Copy BG color " + $"#{overlayBackColor.BackColor.R:X2}{overlayBackColor.BackColor.G:X2}{overlayBackColor.BackColor.B:X2}" + " for OBS";
                     copyColorKey.LinkColor = dialog.Color;
                 }
             }
         }
     }
 }