/// <summary> /// saves per-image settings to the settings hashtable /// </summary> /// <param name="i"></param> void save_image_settings(pf.byte_image i) { StringBuilder description = new StringBuilder(); description.Append(string.Format("{0}|{1}|", cbStartPos.SelectedIndex, util.encode(txtStartPos.Text))); if (cbDig.Checked) { description.Append(string.Format("#dig {0}|", util.encode(txtCommentDig.Text))); } if (cbBuild.Checked) { description.Append(string.Format("#build {0}|", util.encode(txtCommentBuild.Text))); } if (cbPlace.Checked) { description.Append(string.Format("#place {0}|", util.encode(txtCommentPlace.Text))); } if (cbQuery.Checked) { description.Append(string.Format("#query {0}|", util.encode(txtCommentQuery.Text))); } //save image metadata to settings in memory pf.image_settings value = new pf.image_settings(i.image_hash, description.ToString()); value.load_image_data(i); pf.set_setting(i.image_hash, value); }
private void side_preview_Click(object sender, EventArgs e) { save_image_settings(selected_image); PictureBox p = (PictureBox)sender; pf.byte_image selected = (pf.byte_image)p.Tag; selected_image = selected; display_image(selected.image, preview); Debug.Log(selected.image_path + " selected. hash: " + selected.image_hash); update_start_positions(); load_settings(selected_image); }
/// <summary> /// Loads various UI elements with last saved image values. /// </summary> /// <param name="selected">selected image</param> void load_settings(pf.byte_image selected) { if (selected == null) { return; } Debug.Log("Loading image settings..."); //load up UI elements with settings lblSelectedPicture.Text = selected.image_file; string key = selected.image_hash; if (pf.settings[key] == null) { return; } pf.image_settings s = new pf.image_settings(key, pf.settings[key].ToString()); //save image metadata to settings in memory s.load_image_data(selected); pf.set_setting(key, s); cbStartPos.SelectedIndex = s.StartPosIndex; txtStartPos.Text = s.StartString; cbDig.Checked = s.dig; cbBuild.Checked = s.build; cbPlace.Checked = s.place; cbQuery.Checked = s.query; txtCommentDig.Text = s.digComment; txtCommentBuild.Text = s.buildComment; txtCommentPlace.Text = s.placeComment; txtCommentQuery.Text = s.queryComment; txtOutPath.Text = selected.out_path; if (pf.settings[setting.file_format] != null) { txtOutputFormat.Text = pf.settings[setting.file_format].ToString(); } }
/// <summary> /// Creates a file chooser dialog, loads necessary data from each image (byte_image.get_pixel_data), and displays the top image in the preview window /// </summary> /// <returns></returns> void load_images() { //clear controls & open dialog for user to select images side_previews.Controls.Clear(); selected_image = null; OpenFileDialog d = new OpenFileDialog(); d.Multiselect = true; //TODO: remove "All files", provide more extensive list of supported image types d.Filter = "Images|*.png;*.bmp;*.jpg;|All files|*"; if (d.ShowDialog() == DialogResult.OK) { int loading_number = 1; p.loaded_images.Clear(); //load all images into a list containing image data & metadata foreach (string image_filepath in d.FileNames) { status.Text = string.Format("Loading Pixel Data ({0}/{1})", loading_number, d.FileNames.Count()); status.Refresh(); pf.byte_image temp = new pf.byte_image( Image.FromFile(image_filepath), image_filepath, null, progress_bar, status); p.loaded_images.Add(temp); loading_number++; } //display images in preview window(s) if (p.loaded_images.Count > 0) { status.Text = "Images Loaded"; status.Refresh(); //hide side panel and multi-image mode if only one image is loaded if (p.loaded_images.Count <= 1) { tableImagePreview.ColumnStyles[0].Width = 0; panelMultiImageMode.Visible = false; } else { tableImagePreview.ColumnStyles[0].Width = 222; panelMultiImageMode.Visible = true; } for (int i = 0; i < p.loaded_images.Count; i++) { //display the first image in the main preview area if (i == 0) { display_image(p.loaded_images[i].image, preview); selected_image = p.loaded_images[i]; } //display all loaded images in the side panel if (p.loaded_images.Count > 1) { PictureBox temp = new PictureBox(); temp.Tag = p.loaded_images[i]; temp.Click += side_preview_Click; temp.Width = side_previews.Width - scrollbar_width; temp.Height = side_previews.Width - scrollbar_width; side_previews.Controls.Add(temp); display_image(p.loaded_images[i].image, temp); } } load_palettes(); create_start_positions(); foreach (pf.byte_image image in p.loaded_images) { load_settings(image); } } } }