public EditHighlightingColorDialog(EditorHighlightColor color) { SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.ColorDialog.xfrm")); if (color == null) { color = new EditorHighlightColor(true); } Color = color; boldBox = (CheckBox)ControlDictionary["boldBox"]; italicBox = (CheckBox)ControlDictionary["italicBox"]; foreNo = (RadioButton)ControlDictionary["foreNo"]; foreUser = (RadioButton)ControlDictionary["foreUser"]; foreSys = (RadioButton)ControlDictionary["foreSys"]; foreList = (ComboBox)ControlDictionary["foreList"]; backNo = (RadioButton)ControlDictionary["backNo"]; backUser = (RadioButton)ControlDictionary["backUser"]; backSys = (RadioButton)ControlDictionary["backSys"]; backList = (ComboBox)ControlDictionary["backList"]; acceptBtn = (Button)ControlDictionary["acceptBtn"]; this.foreBtn = new ColorButton(); this.foreBtn.CenterColor = System.Drawing.Color.Empty; this.foreBtn.Enabled = false; this.foreBtn.Location = new System.Drawing.Point(30, 78); this.foreBtn.Name = "foreBtn"; this.foreBtn.Size = new System.Drawing.Size(98, 24); this.ControlDictionary["foreBox"].Controls.Add(foreBtn); this.backBtn = new ColorButton(); this.backBtn.CenterColor = System.Drawing.Color.Empty; this.backBtn.Enabled = false; this.backBtn.Location = new System.Drawing.Point(30, 78); this.backBtn.Name = "backBtn"; this.backBtn.Size = new System.Drawing.Size(98, 24); this.ControlDictionary["backBox"].Controls.Add(backBtn); this.acceptBtn.Click += new EventHandler(AcceptClick); this.foreNo.CheckedChanged += new EventHandler(foreCheck); this.foreSys.CheckedChanged += new EventHandler(foreCheck); this.foreUser.CheckedChanged += new EventHandler(foreCheck); this.backNo.CheckedChanged += new EventHandler(backCheck); this.backSys.CheckedChanged += new EventHandler(backCheck); this.backUser.CheckedChanged += new EventHandler(backCheck); PropertyInfo[] names = typeof(System.Drawing.SystemColors).GetProperties(BindingFlags.Static | BindingFlags.Public); foreach (PropertyInfo info in names) { foreList.Items.Add(info.Name); backList.Items.Add(info.Name); } foreList.SelectedIndex = backList.SelectedIndex = 0; if (color.SysForeColor) { foreSys.Checked = true; for (int i = 0; i < foreList.Items.Count; ++i) { if ((string)foreList.Items[i] == color.SysForeColorName) { foreList.SelectedIndex = i; } } } else if (color.HasForeColor) { foreUser.Checked = true; foreBtn.CenterColor = color.ForeColor; } else { foreNo.Checked = true; } if (color.SysBackColor) { backSys.Checked = true; for (int i = 0; i < backList.Items.Count; ++i) { if ((string)backList.Items[i] == color.SysForeColorName) { backList.SelectedIndex = i; } } } else if (color.HasBackColor) { backUser.Checked = true; backBtn.CenterColor = color.BackColor; } else { backNo.Checked = true; } boldBox.Checked = color.Bold; italicBox.Checked = color.Italic; }
public EditHighlightingColorDialog(EditorHighlightColor color) { SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.ColorDialog.xfrm")); if (color == null) { color = new EditorHighlightColor(true); } Color = color; boldBox = (CheckBox)ControlDictionary["boldBox"]; italicBox = (CheckBox)ControlDictionary["italicBox"]; foreNo = (RadioButton)ControlDictionary["foreNo"]; foreUser = (RadioButton)ControlDictionary["foreUser"]; foreSys = (RadioButton)ControlDictionary["foreSys"]; foreList = (ComboBox)ControlDictionary["foreList"]; backNo = (RadioButton)ControlDictionary["backNo"]; backUser = (RadioButton)ControlDictionary["backUser"]; backSys = (RadioButton)ControlDictionary["backSys"]; backList = (ComboBox)ControlDictionary["backList"]; acceptBtn = (Button)ControlDictionary["acceptBtn"]; this.foreBtn = new ColorButton(); this.foreBtn.CenterColor = System.Drawing.Color.Empty; this.foreBtn.Enabled = false; this.foreBtn.Location = new System.Drawing.Point(30, 78); this.foreBtn.Name = "foreBtn"; this.foreBtn.Size = new System.Drawing.Size(98, 24); this.ControlDictionary["foreBox"].Controls.Add(foreBtn); this.backBtn = new ColorButton(); this.backBtn.CenterColor = System.Drawing.Color.Empty; this.backBtn.Enabled = false; this.backBtn.Location = new System.Drawing.Point(30, 78); this.backBtn.Name = "backBtn"; this.backBtn.Size = new System.Drawing.Size(98, 24); this.ControlDictionary["backBox"].Controls.Add(backBtn); this.acceptBtn.Click += new EventHandler(AcceptClick); this.foreNo.CheckedChanged += new EventHandler(foreCheck); this.foreSys.CheckedChanged += new EventHandler(foreCheck); this.foreUser.CheckedChanged += new EventHandler(foreCheck); this.backNo.CheckedChanged += new EventHandler(backCheck); this.backSys.CheckedChanged += new EventHandler(backCheck); this.backUser.CheckedChanged += new EventHandler(backCheck); PropertyInfo[] names = typeof(System.Drawing.SystemColors).GetProperties(BindingFlags.Static | BindingFlags.Public); foreach(PropertyInfo info in names) { foreList.Items.Add(info.Name); backList.Items.Add(info.Name); } foreList.SelectedIndex = backList.SelectedIndex = 0; if (color.SysForeColor) { foreSys.Checked = true; for (int i = 0; i < foreList.Items.Count; ++i) { if ((string)foreList.Items[i] == color.SysForeColorName) foreList.SelectedIndex = i; } } else if (color.HasForeColor) { foreUser.Checked = true; foreBtn.CenterColor = color.ForeColor; } else { foreNo.Checked = true; } if (color.SysBackColor) { backSys.Checked = true; for (int i = 0; i < backList.Items.Count; ++i) { if ((string)backList.Items[i] == color.SysForeColorName) backList.SelectedIndex = i; } } else if (color.HasBackColor) { backUser.Checked = true; backBtn.CenterColor = color.BackColor; } else { backNo.Checked = true; } boldBox.Checked = color.Bold; italicBox.Checked = color.Italic; }