private void SetColorComboValue(lcColor color) { int index = -1; for (int i = 0; i < this.comboColor.Items.Count; ++i) { ColorItem colorItem = this.comboColor.Items[i] as ColorItem; if (colorItem.text != null) { if (colorItem.color == color) { index = i; break; } } } if (index == -1) { ColorItem colorItem = new ColorItem(); colorItem.color = color; this.comboColor.Items.Insert(_indexToInsertCustomColor, colorItem); index = _indexToInsertCustomColor; } this.comboColor.SelectedIndex = index; }
private void OnColorComboSelectedIndexChanged(object sender, EventArgs e) { if (this.comboColor.SelectedItem == null) { return; } ColorItem selColorItem = this.comboColor.SelectedItem as ColorItem; if (selColorItem.text == null) { ColorDialog colorDlg = new ColorDialog(); colorDlg.AllowFullOpen = true; colorDlg.SolidColorOnly = true; DialogResult dlgRet = colorDlg.ShowDialog(); if (dlgRet == DialogResult.OK) { lcColor color = lcColor.FromColor(colorDlg.Color); _lastColor = color; this.SetColorComboValue(color); } else { this.SetColorComboValue(_lastColor); } } else { _lastColor = selColorItem.color; } }
private int SetColorComboValue(SharpCAD.Colors.Color color) { int index = -1; for (int i = 0; i < _toolstripColorCombo.Items.Count; ++i) { ToolStripButton colorBtn = _toolstripColorCombo.Items[i] as ToolStripButton; if (colorBtn.Tag != null) { SharpCAD.Colors.Color itemColor = (SharpCAD.Colors.Color)colorBtn.Tag; if (itemColor == color) { index = i; break; } } } if (index == -1) { ToolStripButton colorBtn = new ToolStripButton(color.Name); colorBtn.Tag = color; _toolstripColorCombo.Items.Insert(_colorComboCustomColorIndex, colorBtn); index = _colorComboCustomColorIndex; } _toolstripColorCombo.SelectedIndex = index; return(index); }
private void OnColorComboSelectedIndexChanged(object sender, EventArgs e) { if (_toolstripColorCombo.SelectedItem == null) { return; } ToolStripButton colorButton = _toolstripColorCombo.SelectedItem as ToolStripButton; if (colorButton.Tag == null) { ColorDialog colorDlg = new ColorDialog(); colorDlg.AllowFullOpen = true; colorDlg.SolidColorOnly = true; DialogResult dlgRet = colorDlg.ShowDialog(); if (dlgRet == DialogResult.OK) { SharpCAD.Colors.Color color = SharpCAD.Colors.Color.FromColor(colorDlg.Color); _document.currentColor = color; } else { this.SetColorComboValue(_document.currentColor); } } else { SharpCAD.Colors.Color color = (SharpCAD.Colors.Color)colorButton.Tag; _document.currentColor = color; } }
public override bool Read(string name, out SharpCAD.Colors.Color value) { XmlNode node = _curXmlNode.SelectSingleNode(name); if (node == null) { value = SharpCAD.Colors.Color.ByLayer; return(false); } return(SharpCAD.Colors.Color.TryParse(node.InnerText, out value)); }
private void InitializeColorCombo() { // predefined colors foreach (KeyValuePair <lcColor, string> kvp in _predefinedColors) { ColorItem colorItem = new ColorItem(); colorItem.color = kvp.Key; colorItem.text = kvp.Value; this.comboColor.Items.Add(colorItem); } _indexToInsertCustomColor = this.comboColor.Items.Count; // select custom color ColorItem selectColorItem = new ColorItem(); selectColorItem.text = null; this.comboColor.Items.Add(selectColorItem); // _lastColor = _layer.color; this.SetColorComboValue(_lastColor); this.comboColor.SelectedIndexChanged += this.OnColorComboSelectedIndexChanged; }
public override bool Write(string name, SharpCAD.Colors.Color value) { return(_Write(name, value)); }
public abstract bool Read(string name, out SharpCAD.Colors.Color color);
public abstract bool Write(string name, SharpCAD.Colors.Color color);
private void OnDocumentCurrColorChanged(SharpCAD.Colors.Color last, SharpCAD.Colors.Color current) { this.SetColorComboValue(current); }