Example #1
0
        /// <summary>
        /// カラーサンプルがクリックされたときの処理
        /// </summary>
        /// <param name="index"></param>
        /// <remarks>
        /// カラーダイアログを呼び出し、変更があればイベントを発行する。
        /// </remarks>
        protected void ColorSampleClick(int index)
        {
            uint  nCol = MbeColors.GetLayerColor(index);
            Color col  = Color.FromArgb(unchecked ((int)nCol));

            colorDialog.Color = col;
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                nCol = unchecked ((uint)(colorDialog.Color.ToArgb()));
                MbeColors.SetLayerColor(index, nCol);
                if (LayerColorChange != null)
                {
                    LayerColorChange(this, null);
                }
                MbeColors.StoreSettings();
                Invalidate();
            }
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (!enablePaint)
            {
                return;
            }

            Graphics g = e.Graphics;

            Font font = new Font(FontFamily.GenericSansSerif, TEXT_HEIGHT,
                                 GraphicsUnit.Pixel);
            Brush     brushDisable = new SolidBrush(Color.Gray);
            Brush     brushText    = new SolidBrush(Color.Black);
            Pen       framePen     = new Pen(Color.Black, 1);
            Rectangle rc;

            int layerCount = MbeLayer.valueTable.Length;

            for (int i = 0; i < layerCount; i++)
            {
                int y = MEMBER_HEIGHT * i;
                //レイヤー名の描画
                g.DrawString(MbeLayer.nameTable[i], font, brushText, new PointF(textX, y));

                //レイヤー色の描画
                uint nCol = MbeColors.GetLayerColor(i);
                if (MbeLayer.nameTable[i] == "L2/4")
                {
                    System.Diagnostics.Debug.WriteLine("L2/4 color " + nCol);
                }
                Color      col         = Color.FromArgb(unchecked ((int)nCol));
                SolidBrush brushSample = new SolidBrush(col);
                rc = new Rectangle(colSampleX, y, COLOR_SAMPLE_WIDTH, MEMBER_HEIGHT);
                g.FillRectangle(brushSample, rc);
                brushSample.Dispose();
                g.DrawRectangle(framePen, rc);



                //可視アイコンの描画
                if ((visibleLayer & (ulong)MbeLayer.valueTable[i]) != 0)
                {
                    if (visibleIcon == null)
                    {
                        visibleIcon = new Icon(Properties.Resources.visiblelayer, 16, 16);
                    }
                    g.DrawIcon(visibleIcon, visibleColumnX, y);
                }

                //選択アイコン背景(選択可能属性)の描画
                if ((selectableLayer & (ulong)MbeLayer.valueTable[i]) == 0)
                {
                    rc = new Rectangle(selectColumnX, y, ICON_COLUMN_WIDTH, MEMBER_HEIGHT);
                    g.FillRectangle(brushDisable, rc);
                }

                //選択アイコンの描画
                if ((selectLayer == MbeLayer.valueTable[i]) &&
                    (((ulong)selectLayer & selectableLayer) != 0))
                {
                    if (placeIcon == null)
                    {
                        placeIcon = new Icon(Properties.Resources.placelayer, 16, 16);
                    }
                    g.DrawIcon(placeIcon, selectColumnX, y);
                }
            }
            framePen.Dispose();
            brushText.Dispose();
            brushDisable.Dispose();
            font.Dispose();
        }
Example #3
0
        /// <summary>
        /// オーナードロウリストボックスの描画
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDrawItem(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.GetLayerColor(index);
            }
            else
            {
                int tabelIndex = index - MbeLayer.valueTable.Length;
                if (tabelIndex < nameTable.Length)
                {
                    switch (tabelIndex)
                    {
                    case 0: nCol = MbeColors.OriginMark; break;

                    case 1: nCol = MbeColors.GridOriginMark; break;

                    case 2: nCol = MbeColors.Grid; break;

                    case 3: nCol = MbeColors.SnapPoint; break;

                    case 4: nCol = MbeColors.ActiveSnapPoint; break;

                    case 5: nCol = MbeColors.PinNum; break;

                    case 6: nCol = MbeColors.CrossCursor; break;

                    case 7: nCol = MbeColors.Background; break;

                    case 8: nCol = MbeColors.BgNotWorkArea; break;

                    default: nCol = MbeColors.InputErr; break;
                    }
                }
            }
            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();
        }
Example #4
0
        /// <summary>
        /// リストボックスがクリックされたときのハンドラ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnClickListBoxColor(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("OnClickListBoxColor index= " + listBoxColorDisplay.SelectedIndex);

            if (listBoxColorDisplay.SelectedIndex <= -1)
            {
                return;
            }

            int index  = listBoxColorDisplay.SelectedIndex;             //レイヤーのインデックス
            int index2 = index - MbeLayer.valueTable.Length;            //レイヤー以外のインデックス

            uint nCol = 0;

            if (index < MbeLayer.valueTable.Length)
            {
                nCol = MbeColors.GetLayerColor(index);
            }
            else if (index2 < nameTable.Length)
            {
                switch (index2)
                {
                case 0: nCol = MbeColors.OriginMark; break;

                case 1: nCol = MbeColors.GridOriginMark; break;

                case 2: nCol = MbeColors.Grid; break;

                case 3: nCol = MbeColors.SnapPoint; break;

                case 4: nCol = MbeColors.ActiveSnapPoint; break;

                case 5: nCol = MbeColors.PinNum; break;

                case 6: nCol = MbeColors.CrossCursor; break;

                case 7: nCol = MbeColors.Background; break;

                case 8: nCol = MbeColors.BgNotWorkArea; break;

                default: nCol = MbeColors.InputErr; break;
                }
            }
            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;
            }

            if (index < MbeLayer.valueTable.Length)
            {
                MbeColors.SetLayerColor(index, nCol);
            }
            else
            {
                switch (index2)
                {
                case 0: MbeColors.OriginMark = nCol; break;

                case 1: MbeColors.GridOriginMark = nCol; break;

                case 2: MbeColors.Grid = nCol; break;

                case 3: MbeColors.SnapPoint = nCol; break;

                case 4: MbeColors.ActiveSnapPoint = nCol; break;

                case 5: MbeColors.PinNum = nCol; break;

                case 6: MbeColors.CrossCursor = nCol; break;

                case 7: MbeColors.Background = nCol; break;

                case 8: MbeColors.BgNotWorkArea = nCol; break;

                default: MbeColors.InputErr = nCol; break;
                }
            }
            if (ColorChange != null)
            {
                //ColorChange(this, null);
                ColorChange();
            }
            MbeColors.StoreSettings();
            listBoxColorDisplay.Invalidate();
        }