/// <summary>Serializes the custom colors.</summary> public void SaveXML() { if (this.CustomColorsConfigLocationNeeded != null) { CustomColorsEventArgs args = new CustomColorsEventArgs(this.configLocation, this.configFilename); this.CustomColorsConfigLocationNeeded(this, args); this.configLocation = args.ConfigLocation; this.configFilename = args.ConfigFilename; } string fileName = this.configLocation + "\\" + configFilename; FileStream fs = new FileStream(fileName, FileMode.Create); XmlTextWriter writer = new XmlTextWriter(fs, Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("Colors"); for (int i = 0; i < customColors.Length; ++i) { writer.WriteElementString("Color", customColors[i].ToArgb().ToString()); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); }
public void SaveXML() { if (!this.SaveCustomColors) { return; } if (this.CustomColorsConfigLocationNeeded != null) { CustomColorsEventArgs args = new CustomColorsEventArgs(this.configLocation, this.configFilename); this.CustomColorsConfigLocationNeeded((object)this, args); this.configLocation = args.ConfigLocation; this.configFilename = args.ConfigFilename; } XmlTextWriter xmlTextWriter = new XmlTextWriter((Stream) new FileStream(this.configLocation + "\\" + this.configFilename, FileMode.Create), Encoding.UTF8); xmlTextWriter.Formatting = Formatting.Indented; xmlTextWriter.WriteStartDocument(); xmlTextWriter.WriteStartElement("Colors"); for (int index = 0; index < this.customColors.Length; ++index) { xmlTextWriter.WriteElementString("Color", this.customColors[index].ToArgb().ToString()); } xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndDocument(); xmlTextWriter.Close(); }
//void tabControl1_SelectedIndexChanged(object sender, EventArgs e) //{ // //selected tab is the system tab // if (this.radTabStrip1.SelectedTab == tabItem2) // colorDialog_ColorChanged(this, new ColorChangedEventArgs((Color)this.listBox1.SelectedItem)); // //selected tab is the web tab // else if (this.radTabStrip1.SelectedTab == tabItem3) // colorDialog_ColorChanged(this, new ColorChangedEventArgs((Color)this.listBox2.SelectedItem)); //} private void customColors_CustomColorsConfigLocationNeeded(object sender, CustomColorsEventArgs args) { if (this.CustomColorsConfigLocationNeeded != null) { this.CustomColorsConfigLocationNeeded(sender, args); } }
/// <summary>Deserializes the custom colors.</summary> public void LoadXML() { if (this.CustomColorsConfigLocationNeeded != null) { CustomColorsEventArgs args = new CustomColorsEventArgs(this.configLocation, this.configFilename); this.CustomColorsConfigLocationNeeded(this, args); this.configLocation = args.ConfigLocation; this.configFilename = args.ConfigFilename; } string fileName = this.configLocation + "\\" + this.configFilename; if (!File.Exists(fileName)) { return; } FileStream fs = new FileStream(fileName, FileMode.Open); XmlTextReader reader = new XmlTextReader(fs); int index = 0; while (!reader.EOF) { if (reader.ReadToFollowing("Color")) { Color newColor = Color.Empty; try { newColor = Color.FromArgb(Convert.ToInt32(reader.ReadString())); } catch (ArgumentException) { newColor = Color.White; } customColors[index] = newColor; ++index; if (index == customColors.Length) { break; } } } reader.Close(); }
public void LoadXML() { if (this.CustomColorsConfigLocationNeeded != null) { CustomColorsEventArgs args = new CustomColorsEventArgs(this.configLocation, this.configFilename); this.CustomColorsConfigLocationNeeded((object)this, args); this.configLocation = args.ConfigLocation; this.configFilename = args.ConfigFilename; } string path = this.configLocation + "\\" + this.configFilename; if (!File.Exists(path)) { return; } XmlTextReader xmlTextReader = new XmlTextReader((Stream) new FileStream(path, FileMode.Open)); int index = 0; while (!xmlTextReader.EOF) { if (xmlTextReader.ReadToFollowing("Color")) { Color empty = Color.Empty; Color color; try { color = Color.FromArgb(Convert.ToInt32(xmlTextReader.ReadString())); } catch (ArgumentException ex) { color = Color.White; } this.customColors[index] = color; ++index; if (index == this.customColors.Length) { break; } } } xmlTextReader.Close(); }