// handles keypresses in textbox void Textbox_Keypress(object sender, KeyEventArgs e) { //Ctrl+S = saves journal entry if (e.Control && e.KeyCode == Keys.S && Tab_entry_field.TabPages[0].Text != tab_log_title) { Boolean successful = save_entry(); if (successful) { Tab_entry_field.TabPages[0].Text = tab_log_title; Tab_entry_field.Refresh(); //removes annoying windows beep sound effect e.Handled = true; e.SuppressKeyPress = true; } } //Ctrl+A = select all text else if (e.Control && e.KeyCode == Keys.A) { Textbox_log.SelectAll(); Textbox_log.Focus(); //removes annoying windows beep sound effect e.Handled = true; e.SuppressKeyPress = true; } //if entry is edited without it being a shortcut else if ((e.Control == false || (e.Control && e.KeyCode == Keys.V)) && e.Shift == false && Tab_entry_field.TabPages[0].Text != tab_log_title_unsaved) { Tab_entry_field.TabPages[0].Text = tab_log_title_unsaved; Tab_entry_field.Refresh(); } }
private void load_entry(object sender, EventArgs e) { //if user hasn't saved if (Tab_entry_field.TabPages[0].Text == tab_log_title_unsaved) { string selected_date = Textbox_log.Tag.ToString(); Boolean successful = save_entry(); if (successful) { Tab_entry_field.TabPages[0].Text = tab_log_title; Tab_entry_field.Refresh(); } else { return; } } //resets image stuff pictureBox1.Visible = false; richTextBox_caption.Visible = false; //selected entry string new_date = get_selected_date(); //when nothing is selected if (new_date == "") { if (Tab_entry_field.SelectedTab == Tab_entry_field.TabPages["tabPage2"]) { Label_no_images.Visible = true; } return; } //Loads text if (Tab_entry_field.SelectedTab == Tab_entry_field.TabPages["tabPage1"]) { //Textbox_log.Focus(); //Loads entry text log try { string file_path = path + "/" + new_date + "/" + new_date + ".txt"; //creates the txt file if it doesn't exist if (File.Exists(file_path) == false) { File.Create(file_path).Close(); } var lines = File.ReadLines(file_path); StringBuilder new_lines = new StringBuilder(); foreach (var line in lines) { new_lines.Append(line + System.Environment.NewLine); } Textbox_log.Text = new_lines.ToString(); //Textbox_log2.Text = new_lines.ToString(); Textbox_log.Tag = new_date; show_word_count(); } catch (Exception exception) { MessageBox.Show("Error reading entry: " + exception.ToString()); } } //Loads media else if (Tab_entry_field.SelectedTab == Tab_entry_field.TabPages["tabPage2"]) { label6_log_info.Text = ""; toolStripStatusLabel1.Text = "Loading thumbnails..."; statusStrip1.Refresh(); Imagelist_media.Images.Clear(); Label_no_images.Visible = false; List <string> thumbnails = load_media(new_date); for (int x = 0; x < thumbnails.Count; x++) { string new_path = path + "/" + new_date + "/thumbnails/" + Path.ChangeExtension(thumbnails[x], "thumb"); Imagelist_media.Images.Add(Image.FromFile(new_path)); } listView1.Items.Clear(); //listView1.GridLines = true; //listView1.View = View.LargeIcon; for (int counter = 0; counter < Imagelist_media.Images.Count; counter++) { ListViewItem item = new ListViewItem(); item.ImageIndex = counter; //item.ImageKey = counter.ToString(); item.Tag = Path.GetFullPath(path + "/" + new_date + "/" + thumbnails[counter]); Image image = Imagelist_media.Images[counter]; this.listView1.Items.Add(item); } if (thumbnails.Count == 0) { Label_no_images.Visible = true; } this.listView1.LargeImageList = Imagelist_media; //select first item, then displays by default if (listView1.Items.Count > 0) { listView1.Items[0].Selected = true; listView1.Select(); listView1_SelectedIndexChanged(null, new EventArgs()); } toolStripStatusLabel1.Text = ""; statusStrip1.Refresh(); } else { label6_log_info.Text = ""; } }