/// <summary> /// オーナードロウリストボックスの描画 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDrawItemPrintColor(object sender, DrawItemEventArgs e) { if (e.Index <= -1) { return; } int index = e.Index; //System.Diagnostics.Debug.WriteLine("OnDrawItem state=" + e.State); Brush brushText = new SolidBrush(e.ForeColor); e.DrawBackground(); string str = (string)listBoxColorDisplay.Items[index]; //Font font = new Font(FontFamily.GenericSansSerif, TEXT_HEIGHT, GraphicsUnit.Pixel); e.Graphics.DrawString(str, e.Font, brushText, e.Bounds.X + COLOR_SAMPLE_WIDTH, e.Bounds.Y + 1); //font.Dispose(); e.DrawFocusRectangle(); brushText.Dispose(); uint nCol = 0; if (index < MbeLayer.valueTable.Length) { nCol = MbeColors.GetLayerPrintColor(index); } else { return; } Color col = Color.FromArgb(unchecked ((int)nCol)); SolidBrush brushSample = new SolidBrush(col); Rectangle rc = new Rectangle(e.Bounds.X, e.Bounds.Y + 2, COLOR_SAMPLE_WIDTH, 12); e.Graphics.FillRectangle(brushSample, rc); brushSample.Dispose(); Pen framePen = new Pen(Color.Black, 1); e.Graphics.DrawRectangle(framePen, rc); framePen.Dispose(); }
/// <summary> /// 印刷用色リストボックスがクリックされたときのハンドラ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listBoxColorPrint_Click(object sender, EventArgs e) { if (listBoxColorPrint.SelectedIndex <= -1) { return; } int index = listBoxColorPrint.SelectedIndex; //レイヤーのインデックス uint nCol = 0; if (index < MbeLayer.valueTable.Length) { nCol = MbeColors.GetLayerPrintColor(index); } else { return; } Color col = Color.FromArgb(unchecked ((int)nCol)); ColorDialog colorDialog = new System.Windows.Forms.ColorDialog(); colorDialog.Color = col; if (colorDialog.ShowDialog() == DialogResult.OK) { nCol = unchecked ((uint)(colorDialog.Color.ToArgb())); } else { return; } MbeColors.SetLayerPrintColor(index, nCol); MbeColors.StoreSettings(); listBoxColorPrint.Invalidate(); }