/// <summary> /// Handles the open tool strip menu item click event. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments.</param> private void OnOpenToolStripMenuItemClick(object sender, EventArgs e) { // Set initial file name this.openFileDialog.FileName = Path.GetFileNameWithoutExtension(this.dataFilePath); // Show open file dialog if (this.openFileDialog.ShowDialog() == DialogResult.OK) { /* Populate ticker data */ try { // Deserialize to variable this.toDoListNewsTickerData = this.ReadTickerDataFromFile(this.openFileDialog.FileName); // Load data this.LoadToDoListNewsTickerData(); } catch (Exception) { // Inform user this.mainToolStripStatusLabel.Text = "Open file error"; } } }
/// <summary> /// Initializes a new instance of the <see cref="T:SteemSoftware.TodoListNewsTickerForm"/> class. /// </summary> public TodoListNewsTickerForm() { // Required for Windows Forms designer support. this.InitializeComponent(); /* Process data file */ // Check for a previously-saved data file if (File.Exists(this.dataFilePath)) { // Read previous data from binary file this.toDoListNewsTickerData = this.ReadTickerDataFromFile(this.dataFilePath); // Bring data to life in GUI this.LoadToDoListNewsTickerData(); } else { // New ticker data instance with initial values set this.toDoListNewsTickerData = new ToDoListNewsTickerData { TimerInterval = 10, Separator = " | ", TextFont = this.fontConverter.ConvertToInvariantString(this.mainFontDialog.Font), ForegroundColor = this.foregroundColorDialog.Color, BackgroundColor = this.backgroundColorDialog.Color, LeftMargin = 50, RightMargin = 50, }; } }