/// <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); }
/// <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(); } }
private void buttonConvert_Click(object sender, EventArgs e) { if (radioMultiLevel.Checked) { save_image_settings(selected_image); pf.image_settings settings = (pf.image_settings)pf.settings[selected_image.image_hash]; p.convert(p.loaded_images, txtOutPath.Text, txtOutputFormat.Text, true, settings, progress_bar, status); } else { foreach (pf.byte_image img in p.loaded_images) { save_image_settings(img); } p.convert(p.loaded_images, txtOutPath.Text, txtOutputFormat.Text, false, null, progress_bar, status); } save_settings(); }
public bool convert(List <byte_image> images, string outputpath, string filename_format, bool multilevel = false, image_settings settings = null, ProgressBar progress = null, Label status = null) { if (multilevel) { if (settings == null) { return(false); } foreach (KeyValuePair <string, string> kvp in settings.modelist) { string mode = kvp.Key; string description = kvp.Value; build_csv(images, outputpath, filename_format, mode, description, progress, status); } return(true); } else { //batch image mode. each image gets its own settings foreach (byte_image image in images) { List <byte_image> single_zlevel_list = new List <byte_image>() { image }; pf.image_settings img_settings = (pf.image_settings)pf.settings[image.image_hash]; foreach (KeyValuePair <string, string> kvp in img_settings.modelist) { string mode = kvp.Key; string description = kvp.Value; build_csv(single_zlevel_list, outputpath, filename_format, mode, description, progress, status); } } return(true); } }