public void OnBackColorChanged(object sender, ColorChangeEventArgs e) { if (this._currentBrush != null) { this._currentBrush.Dispose(); } this._currentBrush = new SolidBrush(e.Color); }
public void OnForeColorChanged(object sender, ColorChangeEventArgs e) { if (this._currentPen != null) { this._currentPen.Dispose(); } this._currentPen = new Pen(e.Color, Program.DEFAULT_PEN_WIDTH); }
/// <summary> /// Смена цветов рисования, инициализация событий смены /// </summary> private void tsbtnColorButtons_Click(object sender, EventArgs e) { ToolStripButton currentButton = sender as ToolStripButton; if (currentButton == null) { return; } //Установка цвета using (ColorDialog colorDialog = new ColorDialog()) { colorDialog.Color = (currentButton == this.tsbtnForeColor) ? this._foreColor : this._backColor; if (colorDialog.ShowDialog() != DialogResult.OK) { return; } currentButton.BackColor = colorDialog.Color; this._foreColor = (currentButton == this.tsbtnForeColor) ? colorDialog.Color : this._foreColor; this._backColor = (currentButton == this.tsbtnBackColor) ? colorDialog.Color : this._backColor; //Инициируем событие смены цвета ColorChangeEventArgs ce = new ColorChangeEventArgs(colorDialog.Color); if (currentButton == this.tsbtnForeColor && this.DrawingForeColorChanged != null) { this.DrawingForeColorChanged(currentButton, ce); } if (currentButton == this.tsbtnBackColor && this.DrawingBackColorChanged != null) { this.DrawingBackColorChanged(currentButton, ce); } } }