/// <summary> /// Checks if line has image settings. If so, it will set the image settings in memory /// </summary> /// <param name="line"></param> /// <returns></returns> private bool load_imagesetting(string line) { Regex hash = new Regex("image(.*) [0-9A-F]{32}:", RegexOptions.IgnoreCase); if (hash.Match(line).Success) { line = line.Substring(line.IndexOf(')') + 1).Trim(); string key = line.Substring(0, 32).ToUpper(); //32 is length of hash string string description = line.Substring(line.IndexOf(":") + 1).Trim(); image_settings value = new image_settings(key, description); set_setting(key, value); return(true); } return(false); }
public override bool Equals(object obj) { if (obj.GetType() == this.GetType()) { image_settings s = (image_settings)obj; if (s.image_hash == image_hash) { return(true); } } else if (obj.ToString() == image_hash) { return(true); } return(false); }
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); } }
/// <summary> /// Writes the settings hashtable to the settings file /// </summary> /// <returns></returns> public bool write_settings() { Debug.Log("Writing settings"); try { bool clean = settings[setting.clean].ToString().ToLower() == "true"; if (!clean) { settings[setting.clean] = "false"; } StreamWriter f = new StreamWriter(settingsfilepath); StringBuilder colors = new StringBuilder(); StringBuilder images = new StringBuilder(); StringBuilder manual = new StringBuilder(); foreach (DictionaryEntry s in settings) { string key = s.Key.ToString(); string value = s.Value.ToString(); if (value != "" || !clean) { string writeline = ""; if (key.StartsWith("#")) { writeline = string.Format("{0}: {1}\n", key, value); colors.Append(writeline); } else if (key.Length == 32) { image_settings set = (image_settings)settings[key]; string image_file = set.image_file; writeline = string.Format("image({2}) {0}:{1}\n", key, value, image_file); images.Append(writeline); } else { writeline = string.Format("{0, -20} {1}\n", key + ":", value); manual.Append(writeline); } //Debug.Log(string.Format("key:{0}- value:{1}-", key, value)); //Debug.Log("writing:" + writeline.TrimEnd('\n')); } } f.Write("\n//General Settings\n\n"); f.Write(manual.ToString()); f.Write("\n//Color Designations\n\n"); f.Write(colors.ToString()); f.Write("\n//Image Specific Settings\n\n"); f.Write(images.ToString()); f.Close(); f.Dispose(); return(true); } catch (Exception e) { Debug.Log(e); return(false); } }