public MainWindow() { InitializeComponent(); if (string.IsNullOrEmpty(Settings.Default.OutputFile)) { Browse_Click(null, null); } try { if (!File.Exists(Settings.Default.OutputFile)) { File.Create(Settings.Default.OutputFile); } } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(-1); } DataContext = Scorecard = new Scorecard(); if (Settings.Default.PreviousCard != null) { if (MessageBox.Show("Load Previous SR Values?", "Previous SR Values Found", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Scorecard.StartSR = Settings.Default.PreviousCard.StartSR; Scorecard.CurrentSR = Settings.Default.PreviousCard.CurrentSR; } } }
private static string ParseLine(string inputString, Scorecard scorecard) { inputString = Parse(inputString, @"%w", scorecard.WinCount); inputString = Parse(inputString, @"%ws", scorecard.WinStreak); inputString = Parse(inputString, @"%l", scorecard.LossCount); inputString = Parse(inputString, @"%ls", scorecard.LossStreak); inputString = Parse(inputString, @"%d", scorecard.DrawCount); inputString = Parse(inputString, @"%sr", scorecard.StartSR); inputString = Parse(inputString, @"%csr", scorecard.CurrentSR); inputString = Parse(inputString, @"%chsr", (scorecard.CurrentSR - scorecard.StartSR).ToString("+#;-#;0")); return(inputString); }
public static void Update_Content(Scorecard scorecard) { File.WriteAllText(Settings.Default.OutputFile, ParseLine(Settings.Default.QueryData, scorecard)); }