public StrokeProps(Stroke stroke) { InitializeComponent(); // ------------------------------------------------------------------- cbPattern.Items.Clear(); cbPattern.Items.AddRange(DrawUtils.GetPenPatternNames()); // получение всех имён доступных типов линий cbPattern.SelectedIndex = 1; // ------------------------------------------------------------------- cbWidth.Items.Clear(); for (var i = 1; i < 61; i++) { cbWidth.Items.Add(i.ToString("0")); } // ------------------------------------------------------------------- cbColor.Items.Clear(); cbColor.Items.AddRange(DrawUtils.GetAllColorNames()); // получение всех имён доступных цветов cbColor.Items.Add("Выбор цвета..."); // добавление пункта выбора цвета cbColor.Text = DrawUtils.GetColorNameFromIndex(_lastColorIndex); // ------------------------------------------------------------------- _stroke = (Stroke)stroke.Clone(); // ------------------------------- var index = DrawUtils.ColorToIndex(_stroke.Color); if (index < 0) { DrawUtils.AddCustomColor(_stroke.Color); cbColor.Items.Insert(cbColor.Items.Count - 1, "Мой цвет"); index = cbColor.Items.Count - 2; } if (index >= 0) { cbColor.SelectedIndex = index; } // ------------------------------- tbTrasparent.Value = 255 - _stroke.Alpha; lbTrasparent.Text = String.Format("{0} %", (int)(tbTrasparent.Value / 255.0 * 100.0)); // ------------------------------- cbWidth.SelectedIndex = (int)_stroke.Width - 1; // ------------------------------- if (_stroke.DashStyle == DashStyle.Custom) { cbPattern.SelectedIndex = 0; } else { cbPattern.SelectedIndex = (int)_stroke.DashStyle + 1; } // ------------------------------------------------------------------- cbLineJoin.Items.Clear(); // получение всех имён доступных типов соединений линий cbLineJoin.Items.AddRange(DrawUtils.GetLineJoinNames()); cbLineJoin.SelectedIndex = (int)_stroke.LineJoin; }
public static void colorComboSelectedIndexChanged(object sender, ref int LastColorIndex, ChangeCommitted changed) { ComboBox cbox = (ComboBox)sender; if (cbox.SelectedIndex == cbox.Items.Count - 1) { try { int selIndex; using (ColorDialog dlgSelectColor = new ColorDialog()) { dlgSelectColor.Color = DrawUtils.ColorFromIndex(LastColorIndex); selIndex = LastColorIndex; if (dlgSelectColor.ShowDialog() == DialogResult.OK) { Color selColor = dlgSelectColor.Color; if (!DrawUtils.FindColor(selColor)) { DrawUtils.AddCustomColor(selColor); dlgSelectColor.CustomColors = DrawUtils.GetCustomColors(); cbox.Items.Insert(cbox.Items.Count - 1, "Мой цвет"); cbox.SelectedIndex = cbox.Items.Count - 2; } else { cbox.SelectedIndex = DrawUtils.ColorToIndex(selColor); } if (changed != null) { changed(sender, new EventArgs()); } } else { cbox.SelectedIndex = selIndex; } } } catch { } } else { LastColorIndex = cbox.SelectedIndex; cbox.Refresh(); } }
public static void colorComboSelectInList(object sender, Color color) { ComboBox cbox = (ComboBox)sender; int Index = DrawUtils.ColorToIndex(color); if (Index < 0) { DrawUtils.AddCustomColor(color); cbox.Items.Insert(cbox.Items.Count - 1, "Мой цвет"); Index = cbox.Items.Count - 2; } if (Index >= 0) { cbox.SelectedIndex = Index; } }
private void tsbRibberColor_Click(object sender, EventArgs e) { ribberColorDialog.Color = RibberTool.RibberStyle.Color; if (ribberColorDialog.ShowDialog() == DialogResult.OK) { Color selColor = ribberColorDialog.Color; foreach (var item in ribberColorDialog.CustomColors) { if (item != 16777215 && !DrawUtils.FindColor(Color.FromArgb(item))) { DrawUtils.AddCustomColor(selColor); } } RibberTool.RibberStyle.Color = selColor; UpdateRibberToolColorImage(); } }
private void tsbPencilColor_ButtonClick(object sender, EventArgs e) { penсilColorDialog.Color = PenTool.PenStyle.Color; if (penсilColorDialog.ShowDialog() == DialogResult.OK) { Color selColor = penсilColorDialog.Color; foreach (var item in penсilColorDialog.CustomColors) { if (item != 16777215 && !DrawUtils.FindColor(Color.FromArgb(item))) { DrawUtils.AddCustomColor(selColor); } } PenTool.PenStyle.Color = selColor; UpdatePenToolColorImage(); } }
private void cbColor_SelectedIndexChanged(object sender, EventArgs e) { var cbox = (ComboBox)sender; if (cbox.SelectedIndex == cbox.Items.Count - 1) { try { dlgSelectColor.Color = DrawUtils.ColorFromIndex(_lastColorIndex); var selIndex = _lastColorIndex; if (dlgSelectColor.ShowDialog() == DialogResult.OK) { Color selColor = dlgSelectColor.Color; _stroke.Color = selColor; if (!DrawUtils.FindColor(selColor)) { DrawUtils.AddCustomColor(selColor); dlgSelectColor.CustomColors = DrawUtils.GetCustomColors(); cbColor.Items.Insert(cbColor.Items.Count - 1, "Мой цвет"); cbColor.SelectedIndex = cbColor.Items.Count - 2; } else { cbox.SelectedIndex = DrawUtils.ColorToIndex(selColor); } } else { cbox.SelectedIndex = selIndex; } } catch { } } else { _lastColorIndex = cbox.SelectedIndex; cbox.Refresh(); pbPreview.Refresh(); } }