public MainWindow() { InitializeComponent(); currentTimeClk.SetTime(DateTime.Now); theTicker = new TimeTicker(); theTicker.TickEvent += Tick; startTimeClk.SetTime(new DateTime()); //00:00:00 startTimeClk.ClockModified += ClockModified; var file = System.AppDomain.CurrentDomain.BaseDirectory + "\\default.chg"; if (File.Exists(file)) { var ccf = ChargeCodeFile.ReadFile(file); Timers.Clear(); chargeNumberStack.Children.Clear(); CurrentTimer = null; foreach (var ccode in ccf.ChargeCode) { var telement = new TimerElement(ccode.Code, ccode.Description); Timers.Add(telement); chargeNumberStack.Children.Add(telement); telement.TimerActionPerformed += TimerActionCallback; } } }
private void loadBtn_Click(object sender, RoutedEventArgs e) { var ofd = new Microsoft.Win32.OpenFileDialog { FileName = "ChargeCodes", DefaultExt = "chg", Filter = "Charge Codes (.chg)|*.chg" }; if (ofd.ShowDialog() == true) { var name = ofd.FileName; var ccf = ChargeCodeFile.ReadFile(name); Timers.Clear(); chargeNumberStack.Children.Clear(); CurrentTimer = null; foreach (var ccode in ccf.ChargeCode) { var telement = new TimerElement(ccode.Code, ccode.Description); Timers.Add(telement); chargeNumberStack.Children.Add(telement); telement.TimerActionPerformed += TimerActionCallback; } } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { var file = System.AppDomain.CurrentDomain.BaseDirectory + "\\default.chg"; var ccf = new ChargeCodeFile(); foreach (var timer in Timers) { ccf.ChargeCode.Add(new ChargeCode() { Code = timer.Code, Description = timer.Description }); } ccf.WriteFile(file); }
private void saveBtn_Click(object sender, RoutedEventArgs e) { var sfd = new Microsoft.Win32.SaveFileDialog { FileName = "ChargeCodes", DefaultExt = "chg", Filter = "Charge Codes (.chg)|*.chg" }; if (sfd.ShowDialog() == true) { var name = sfd.FileName; var ccf = new ChargeCodeFile(); foreach (var timer in Timers) { ccf.ChargeCode.Add(new ChargeCode() { Code = timer.Code, Description = timer.Description }); } ccf.WriteFile(name); } }