Пример #1
0
        private void buttonDefaultPrint_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Set all printing colors default.", "MBE",
                                              MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);

            if (dr == DialogResult.OK)
            {
                MbeColors.SetDefaultPrintColor();
                MbeColors.StoreSettings();
                listBoxColorPrint.Invalidate();
            }
        }
Пример #2
0
        private void ObButtonDefault(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Set all display colors default.", "MBE",
                                              MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);

            if (dr == DialogResult.OK)
            {
                MbeColors.SetDefaultColor();
                if (ColorChange != null)
                {
                    //ColorChange(this, null);
                    ColorChange();
                }
                MbeColors.StoreSettings();
                listBoxColorDisplay.Invalidate();
            }
        }
Пример #3
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();
            }
        }
Пример #4
0
        /// <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();
        }
Пример #5
0
        /// <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();
        }
Пример #6
0
        public override void Draw(DrawParam dp)
        {
            if (((ulong)dp.layer & snapLayer) == 0)
            {
                return;
            }

            if (((ulong)dp.layer & ((ulong)MbeLayer.LayerValue.STS |
                                    (ulong)MbeLayer.LayerValue.STC)) != 0)
            {
                if (no_ResistMask)
                {
                    return;
                }
            }


            Point pt = this.GetPos(0);

            pt = ToDrawDim(pt, dp.scale);

            Color col;
            //Color cold;
            int w = 0;
            int h = 0;
            //int wd = 0;
            //int hd = 0;
            Rectangle  rc;
            SolidBrush brush;
            Pen        pen;


            #region 描画サイズの設定

            switch (dp.layer)
            {
            case MbeLayer.LayerValue.PLC:
            case MbeLayer.LayerValue.PLS:
            case MbeLayer.LayerValue.CMP:
            case MbeLayer.LayerValue.SOL:
                w = (int)(PadSize.Width / dp.scale) | 1;
                h = (int)(PadSize.Height / dp.scale) | 1;
                break;

            case MbeLayer.LayerValue.STC:
            case MbeLayer.LayerValue.STS:
                //if (no_ResistMask) return;  //Version 0.50
                w = (int)((PadSize.Width + SrMargin * 2) / dp.scale) | 1;
                h = (int)((PadSize.Height + SrMargin * 2) / dp.scale) | 1;
                break;

            case MbeLayer.LayerValue.MMC:
            case MbeLayer.LayerValue.MMS:
                if (no_MM)
                {
                    return;
                }
                w = (int)((PadSize.Width - MmReduce * 2) / dp.scale) | 1;
                h = (int)((PadSize.Height - MmReduce * 2) / dp.scale) | 1;
                break;
            }
            if (w == 1)
            {
                w++;
            }
            if (h == 1)
            {
                h++;
            }
            //if ((dp.layer == MbeLayer.LayerValue.PTH) || (dp.layer == MbeLayer.LayerValue.DRL)) {
            //    wd = (int)(Diameter / dp.scale) | 1;

            //    if (dp.layer == MbeLayer.LayerValue.PTH) {
            //        if (wd >= w) wd = w - 2;
            //        if (wd >= h) wd = h - 2;
            //    }
            //    hd = wd;
            //}



            #endregion

            #region 色の設定
            if (dp.mode == MbeDrawMode.Print)
            {
                if ((dp.option & (uint)MbeDrawOption.PrintColor) != 0)      //カラー印刷
                {
                    uint nColor;
                    switch (dp.layer)
                    {
                    case MbeLayer.LayerValue.PLC:
                        nColor = MbeColors.PRINT_PLC;
                        break;

                    case MbeLayer.LayerValue.PLS:
                        nColor = MbeColors.PRINT_PLS;
                        break;

                    case MbeLayer.LayerValue.CMP:
                        nColor = MbeColors.PRINT_CMP;
                        break;

                    case MbeLayer.LayerValue.SOL:
                        nColor = MbeColors.PRINT_SOL;
                        break;

                    case MbeLayer.LayerValue.STC:
                        nColor = MbeColors.PRINT_STC;
                        break;

                    case MbeLayer.LayerValue.MMC:
                        nColor = MbeColors.PRINT_MMC;
                        break;

                    case MbeLayer.LayerValue.MMS:
                        nColor = MbeColors.PRINT_MMS;
                        break;

                    default:
                        nColor = MbeColors.PRINT_STS;
                        break;
                    }

                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_PRINT_ALPHA, col);
                }
                else
                {
                    col = Color.Black;
                }
            }
            else
            {
                uint nColor;
                switch (dp.layer)
                {
                case MbeLayer.LayerValue.PLC:
                    nColor = MbeColors.PLC;
                    break;

                case MbeLayer.LayerValue.PLS:
                    nColor = MbeColors.PLS;
                    break;

                case MbeLayer.LayerValue.CMP:
                    nColor = MbeColors.CMP;
                    break;

                case MbeLayer.LayerValue.SOL:
                    nColor = MbeColors.SOL;
                    break;

                case MbeLayer.LayerValue.STC:
                    nColor = MbeColors.STC;
                    break;

                case MbeLayer.LayerValue.MMC:
                    nColor = MbeColors.MMC;
                    break;

                case MbeLayer.LayerValue.MMS:
                    nColor = MbeColors.MMS;
                    break;

                //case MbeLayer.LayerValue.STS:
                default:
                    nColor = MbeColors.STS;
                    break;
                    //	break;
                    //case MbeLayer.LayerValue.DRL:
                    //default:
                    //    nColor = MbeColors.Drl;
                    //    break;
                }

                if (dp.mode == MbeDrawMode.Temp || connectionCheckActive)
                {
                    col = Color.FromArgb(MBE_OBJ_ALPHA, MbeColors.HighLighten(nColor));
                }
                else
                {
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_ALPHA, col);
                }
            }
            #endregion

            #region 実際の描画の実行
            switch (dp.layer)
            {
            case MbeLayer.LayerValue.PLC:
            case MbeLayer.LayerValue.PLS:
            case MbeLayer.LayerValue.CMP:
            case MbeLayer.LayerValue.SOL:
            case MbeLayer.LayerValue.STC:
            case MbeLayer.LayerValue.STS:
            case MbeLayer.LayerValue.MMC:
            case MbeLayer.LayerValue.MMS:
                rc = new Rectangle(pt.X - w / 2, pt.Y - h / 2, w, h);

                if (Shape == PadShape.Rect)
                {
                    brush = new SolidBrush(col);
                    dp.g.FillRectangle(brush, rc);
                    brush.Dispose();
                }
                else
                {
                    if (w == h)
                    {
                        brush = new SolidBrush(col);
                        dp.g.FillEllipse(brush, rc);
                        brush.Dispose();
                    }
                    else
                    {
                        pen          = new Pen(col, (w < h ? w : h));
                        pen.StartCap = LineCap.Round;
                        pen.EndCap   = LineCap.Round;
                        if (w < h)
                        {
                            int k = (h - w + 1) / 2;
                            dp.g.DrawLine(pen, pt.X, pt.Y - k, pt.X, pt.Y + k);
                        }
                        else
                        {
                            int k = (w - h + 1) / 2;
                            dp.g.DrawLine(pen, pt.X - k, pt.Y, pt.X + k, pt.Y);
                        }
                        pen.Dispose();
                    }
                }

                if (dp.layer == MbeLayer.LayerValue.PLC ||
                    dp.layer == MbeLayer.LayerValue.PLS ||
                    dp.layer == MbeLayer.LayerValue.CMP ||
                    dp.layer == MbeLayer.LayerValue.SOL)
                {
                    //if (wd >= 3) {
                    //    rc = new Rectangle(pt.X - wd / 2, pt.Y - hd / 2, wd, hd);
                    //    brush = new SolidBrush(MbeColors.ColorBackground);
                    //    dp.g.FillEllipse(brush, rc);
                    //    brush.Dispose();
                    //}
                    //if (DrawSnapMarkFlag) {
                    if (dp.mode != MbeDrawMode.Print)
                    {
                        if (drawSnapMark)
                        {
                            int marksize = (w < h ? w : h) / 2;
                            DrawSnapPointMark(dp.g, pt, marksize, selectFlag[0]);
                            //}
                            if (dp.layer == MbeLayer.LayerValue.CMP ||
                                dp.layer == MbeLayer.LayerValue.SOL)
                            {
                                if (DrawPinNumFlag)
                                {
                                    int  fontsize = (w < h ? w : h) / 2;        //高さと幅の小さい方
                                    bool vertical = (w < h);                    //幅が大きければ縦書き
                                    DrawPinNum(dp.g, PinNum, pt, fontsize, vertical);
                                }
                            }
                        }
                    }
                }
                break;
                //case MbeLayer.LayerValue.DRL:
                //    rc = new Rectangle(pt.X - wd / 2, pt.Y - hd / 2, wd, hd);
                //    pen = new Pen(col);
                //    dp.g.DrawEllipse(pen, rc);
                //    pen.Dispose();
                //    break;
            }
            #endregion
        }
Пример #7
0
        /// <summary>
        /// 描画
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawParam dp)
        {
            if (posCount < 3)
            {
                return;
            }
            if (dp.layer != Layer)
            {
                return;
            }
            Color col;
            int   w = 0;
            Pen   pen;

            //描画幅の設定
            if (restrictMask)
            {
                w = 1;
            }
            else
            {
                w = (int)(TraceWidth / dp.scale) | 1;
            }



            if (dp.mode == MbeDrawMode.Print)
            {
                if ((dp.option & (uint)MbeDrawOption.PrintColor) != 0)      //カラー印刷
                {
                    uint nColor;
                    switch (dp.layer)
                    {
                    case MbeLayer.LayerValue.CMP:
                        nColor = MbeColors.PRINT_CMP;
                        break;

                    case MbeLayer.LayerValue.L2:
                        nColor = MbeColors.PRINT_L2;
                        break;

                    case MbeLayer.LayerValue.L3:
                        nColor = MbeColors.PRINT_L3;
                        break;

                    default:            //case MbeLayer.LayerValue.SOL:
                        nColor = MbeColors.PRINT_SOL;
                        break;
                    }
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_PRINT_ALPHA, col);
                }
                else
                {
                    col = Color.Black;
                }
            }
            else
            {
                uint nColor;
                switch (dp.layer)
                {
                case MbeLayer.LayerValue.CMP:
                    nColor = MbeColors.CMP;
                    break;

                case MbeLayer.LayerValue.L2:
                    nColor = MbeColors.L2;
                    break;

                case MbeLayer.LayerValue.L3:
                    nColor = MbeColors.L3;
                    break;

                default:        //case MbeLayer.LayerValue.SOL:
                    nColor = MbeColors.SOL;
                    break;
                }

                if (dp.mode == MbeDrawMode.Temp || connectionCheckActive)
                {
                    col = Color.FromArgb(MBE_OBJ_ALPHA, MbeColors.HighLighten(nColor));
                }
                else
                {
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_ALPHA, col);
                }
            }

            Point pt0;
            Point pt1;

            if (MbeView.ViewPolygonFrame)
            {
                pen = new Pen(col, 1);

                if (!restrictMask)
                {
                    pen.DashStyle = DashStyle.Dash;
                    pt0           = ToDrawDim(posArray[0], dp.scale);
                    pt1           = ToDrawDim(posArray[1], dp.scale);
                    dp.g.DrawLine(pen, pt0, pt1);
                }

                pen.Width     = w;
                pen.DashStyle = DashStyle.Solid;
                if (restrictMask && !Program.monoRuntime)
                {
                    Point[] drawPointArray = new Point[posCount - 1];
                    for (int i = 1; i < posCount; i++)
                    {
                        drawPointArray[i - 1] = ToDrawDim(posArray[i], dp.scale);
                    }
                    Color      bgcolor = Color.FromArgb(0, 0, 0, 0);
                    HatchBrush brush   = new HatchBrush(HatchStyle.Percent20, col, bgcolor);
                    dp.g.FillPolygon(brush, drawPointArray);
                    brush.Dispose();
                    dp.g.DrawPolygon(pen, drawPointArray);
                    drawPointArray = null;
                }
                else
                {
                    HatchBrush brush = null;
                    if (!Program.monoRuntime && !Program.inhibitHatchBrushPolygonframe)
                    {
                        Color bgcolor = Color.FromArgb(col.A, ((int)col.R) * 2 / 3, ((int)col.G) * 2 / 3, ((int)col.B) * 2 / 3);
                        brush     = new HatchBrush(HatchStyle.Percent30, col, bgcolor);
                        pen.Brush = brush;
                    }

                    pen.StartCap = LineCap.Round;
                    pen.EndCap   = LineCap.Round;
                    for (int i = 1; i < posCount; i++)
                    {
                        int index2 = i + 1;
                        if (index2 == posCount)
                        {
                            index2 = 1;
                        }
                        pt0 = ToDrawDim(posArray[i], dp.scale);
                        pt1 = ToDrawDim(posArray[index2], dp.scale);
                        //System.Diagnostics.Debug.WriteLine("Frame  " + pt0.X + "," + pt0.Y + "," + pt1.X + "," + pt1.Y);
                        dp.g.DrawLine(pen, pt0, pt1);
                    }
                    if (brush != null)
                    {
                        brush.Dispose();
                    }
                }

                pen.Dispose();

                if (drawSnapMark && dp.mode != MbeDrawMode.Print)
                {
                    for (int i = 0; i < posCount; i++)
                    {
                        pt0 = ToDrawDim(posArray[i], dp.scale);
                        int marksize = w;
                        if (i == 0)
                        {
                            if (!restrictMask)
                            {
                                if (marksize < 10)
                                {
                                    marksize = 10;
                                }
                                DrawTargetMark(dp.g, pt0, marksize, selectFlag[i]);
                            }
                        }
                        else
                        {
                            DrawSnapPointMark(dp.g, pt0, marksize, selectFlag[i]);
                        }
                    }
                }
            }
            else
            {
                if (fillLineList.Count > 0)
                {
                    pen          = new Pen(col);
                    pen.StartCap = LineCap.Round;
                    pen.EndCap   = LineCap.Round;
                    foreach (MbeGapChkObjLine obj in fillLineList)
                    {
                        pen.Width = (int)(obj.lineWidth / dp.scale) | 1;
                        pt0       = ToDrawDim(obj.p0, dp.scale);
                        pt1       = ToDrawDim(obj.p1, dp.scale);
                        //System.Diagnostics.Debug.WriteLine("Fill  "+pt0.X + "," + pt0.Y + "," + pt1.X + "," + pt1.Y);
                        dp.g.DrawLine(pen, pt0, pt1);
                    }
                    pen.Dispose();
                }
            }
        }
Пример #8
0
        /// <summary>
        /// 描画
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawParam dp)
        {
            if (((ulong)dp.layer & ((ulong)MbeLayer.LayerValue.PTH |
                                    (ulong)MbeLayer.LayerValue.STS |
                                    (ulong)MbeLayer.LayerValue.STC |
                                    (ulong)MbeLayer.LayerValue.DRL)) == 0)
            {
                return;
            }

            if (((ulong)dp.layer & ((ulong)MbeLayer.LayerValue.STS |
                                    (ulong)MbeLayer.LayerValue.STC)) != 0)
            {
                if (no_ResistMask)
                {
                    return;
                }
            }

            Point pt = this.GetPos(0);

            pt = ToDrawDim(pt, dp.scale);

            Color col;
            //Color cold;
            int        w  = 0;
            int        h  = 0;
            int        wd = 0;
            int        hd = 0;
            Rectangle  rc;
            SolidBrush brush;
            Pen        pen;


            #region 描画サイズの設定

            switch (dp.layer)
            {
            case MbeLayer.LayerValue.PTH:
                w = (int)(PadSize.Width / dp.scale) | 1;
                h = (int)(PadSize.Height / dp.scale) | 1;
                break;

            case MbeLayer.LayerValue.STC:
            case MbeLayer.LayerValue.STS:
                w = (int)((PadSize.Width + SrMargin * 2) / dp.scale) | 1;
                h = (int)((PadSize.Height + SrMargin * 2) / dp.scale) | 1;
                break;
            }
            if (w == 1)
            {
                w++;
            }
            if (h == 1)
            {
                h++;
            }
            if ((dp.layer == MbeLayer.LayerValue.PTH) || (dp.layer == MbeLayer.LayerValue.DRL))
            {
                int drillDia;
                if ((dp.option & (uint)MbeDrawOption.CenterPunchMode) != 0)
                {
                    drillDia = PrintCenterPunchModeDiameter(Diameter);
                }
                else
                {
                    drillDia = Diameter;
                }

                wd = (int)(drillDia / dp.scale) | 1;

                if (dp.layer == MbeLayer.LayerValue.PTH)
                {
                    if (wd >= w)
                    {
                        wd = w - 2;
                    }
                    if (wd >= h)
                    {
                        wd = h - 2;
                    }
                }
                hd = wd;
            }



            #endregion

            #region 色の設定
            if (dp.mode == MbeDrawMode.Print)
            {
                if ((dp.option & (uint)MbeDrawOption.PrintColor) != 0)      //カラー印刷
                {
                    uint nColor;
                    switch (dp.layer)
                    {
                    case MbeLayer.LayerValue.PTH:
                        nColor = MbeColors.PRINT_PTH;
                        break;

                    case MbeLayer.LayerValue.STC:
                        nColor = MbeColors.PRINT_STC;
                        break;

                    case MbeLayer.LayerValue.STS:
                        nColor = MbeColors.PRINT_STS;
                        break;

                    case MbeLayer.LayerValue.DRL:
                    default:
                        nColor = MbeColors.PRINT_DRL;
                        break;
                    }

                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_PRINT_ALPHA, col);
                }
                else
                {
                    col = Color.Black;
                }
            }
            else
            {
                uint nColor;
                switch (dp.layer)
                {
                case MbeLayer.LayerValue.PTH:
                    nColor = MbeColors.PTH;
                    break;

                case MbeLayer.LayerValue.STC:
                    nColor = MbeColors.STC;
                    break;

                case MbeLayer.LayerValue.STS:
                    nColor = MbeColors.STS;
                    break;

                case MbeLayer.LayerValue.DRL:
                default:
                    nColor = MbeColors.DRL;
                    break;
                }

                if (dp.mode == MbeDrawMode.Temp || connectionCheckActive)
                {
                    col = Color.FromArgb(MBE_OBJ_ALPHA, MbeColors.HighLighten(nColor));
                }
                else
                {
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_ALPHA, col);
                }
            }
            #endregion

            #region 実際の描画の実行
            switch (dp.layer)
            {
            case MbeLayer.LayerValue.PTH:
            case MbeLayer.LayerValue.STC:
            case MbeLayer.LayerValue.STS:
                rc = new Rectangle(pt.X - w / 2, pt.Y - h / 2, w, h);

                if (Shape == PadShape.Rect)
                {
                    brush = new SolidBrush(col);
                    dp.g.FillRectangle(brush, rc);
                    brush.Dispose();
                }
                else
                {
                    if (w == h)
                    {
                        brush = new SolidBrush(col);
                        dp.g.FillEllipse(brush, rc);
                        brush.Dispose();
                    }
                    else
                    {
                        pen          = new Pen(col, (w < h ? w : h));
                        pen.StartCap = LineCap.Round;
                        pen.EndCap   = LineCap.Round;
                        if (w < h)
                        {
                            int k = (h - w + 1) / 2;
                            dp.g.DrawLine(pen, pt.X, pt.Y - k, pt.X, pt.Y + k);
                        }
                        else
                        {
                            int k = (w - h + 1) / 2;
                            dp.g.DrawLine(pen, pt.X - k, pt.Y, pt.X + k, pt.Y);
                        }
                        pen.Dispose();
                    }
                }
                if (dp.layer == MbeLayer.LayerValue.PTH)
                {
                    if (dp.mode != MbeDrawMode.Print)
                    {
                        if (wd >= 3)
                        {
                            rc = new Rectangle(pt.X - wd / 2, pt.Y - hd / 2, wd, hd);
                            Color cold = MbeColors.ColorBackground;
                            if (dp.mode == MbeDrawMode.Temp)
                            {
                                cold = Color.FromArgb(MBE_OBJ_ALPHA, cold);
                            }
                            brush = new SolidBrush(cold);
                            //brush = new SolidBrush(MbeColors.ColorBackground);
                            dp.g.FillEllipse(brush, rc);
                            brush.Dispose();
                        }
                        if (drawSnapMark)
                        {
                            int marksize = (w < h ? w : h) / 2;
                            DrawSnapPointMark(dp.g, pt, marksize, selectFlag[0]);
                        }
                        if (DrawPinNumFlag)
                        {
                            int  fontsize = (w < h ? w : h) / 2;                                        //高さと幅の小さい方
                            bool vertical = (w < h);                                                    //幅が大きければ縦書き
                            DrawPinNum(dp.g, PinNum, pt, fontsize, vertical);
                        }
                    }
                    else
                    {
                        rc    = new Rectangle(pt.X - wd / 2, pt.Y - hd / 2, wd, hd);
                        brush = new SolidBrush(Color.White);
                        dp.g.FillEllipse(brush, rc);
                        brush.Dispose();
                    }
                }
                break;

            case MbeLayer.LayerValue.DRL:
                rc = new Rectangle(pt.X - wd / 2, pt.Y - hd / 2, wd, hd);
                if (dp.mode == MbeDrawMode.Print)
                {
                    brush = new SolidBrush(Color.White);
                    dp.g.FillEllipse(brush, rc);
                    brush.Dispose();
                    if ((dp.visibleLayer & (ulong)MbeLayer.LayerValue.PTH) == 0)
                    {
                        int penw = (int)(500 / dp.scale) | 1;

                        if ((dp.option & (uint)MbeDrawOption.ToolMarkMode) != 0)
                        {
                            if ((dp.visibleLayer & MbeLayer.PatternFilmLayer) == 0)
                            {
                                MbeView.DrawDrillMark(GetPos(0), Diameter, dp, col, penw);
                                return;
                            }
                        }



                        pen = new Pen(col, penw);
                        dp.g.DrawEllipse(pen, rc);
                        pen.Dispose();
                    }
                }
                else
                {
                    pen = new Pen(col);
                    dp.g.DrawEllipse(pen, rc);
                    pen.Dispose();
                }
                break;
            }
            #endregion
        }
Пример #9
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();
        }
Пример #10
0
        /// <summary>
        /// 描画
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawParam dp)
        {
            if (dp.layer != Layer)
            {
                return;
            }
            Point pt0 = this.GetPos(0);

            pt0 = ToDrawDim(pt0, dp.scale);

            Color col;
            int   w = 0;
            int   h = 0;

            //bool reverse = false;

            //描画幅の設定
            w = (int)(LineWidth / dp.scale) | 1;

            //描画文字高さの設定
            h = (int)(TextHeight / dp.scale);

            if (dp.mode == MbeDrawMode.Print)
            {
                if ((dp.option & (uint)MbeDrawOption.PrintColor) != 0)      //カラー印刷
                {
                    uint nColor;
                    switch (dp.layer)
                    {
                    case MbeLayer.LayerValue.PLC:
                        nColor = MbeColors.PRINT_PLC;
                        break;

                    case MbeLayer.LayerValue.PLS:
                        nColor = MbeColors.PRINT_PLS;
                        //reverse = true;
                        break;

                    case MbeLayer.LayerValue.STC:
                        nColor = MbeColors.PRINT_STC;
                        break;

                    case MbeLayer.LayerValue.STS:
                        nColor = MbeColors.PRINT_STS;
                        //reverse = true;
                        break;

                    case MbeLayer.LayerValue.CMP:
                        nColor = MbeColors.PRINT_CMP;
                        break;

                    case MbeLayer.LayerValue.L2:
                        nColor = MbeColors.PRINT_L2;
                        break;

                    case MbeLayer.LayerValue.L3:
                        nColor = MbeColors.PRINT_L3;
                        break;

                    case MbeLayer.LayerValue.SOL:
                        nColor = MbeColors.PRINT_SOL;
                        //reverse = true;
                        break;

                    case MbeLayer.LayerValue.DIM:
                        nColor = MbeColors.PRINT_DIM;
                        break;

                    default:
                        nColor = MbeColors.PRINT_DOC;
                        break;
                    }
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(255, col);
                }
                else
                {
                    col = Color.Black;
                }
            }
            else
            {
                uint nColor;
                switch (dp.layer)
                {
                case MbeLayer.LayerValue.PLC:
                    nColor = MbeColors.PLC;
                    break;

                case MbeLayer.LayerValue.PLS:
                    nColor = MbeColors.PLS;
                    //reverse = true;
                    break;

                case MbeLayer.LayerValue.STC:
                    nColor = MbeColors.STC;
                    break;

                case MbeLayer.LayerValue.STS:
                    nColor = MbeColors.STS;
                    //reverse = true;
                    break;

                case MbeLayer.LayerValue.CMP:
                    nColor = MbeColors.CMP;
                    break;

                case MbeLayer.LayerValue.L2:
                    nColor = MbeColors.L2;
                    break;

                case MbeLayer.LayerValue.L3:
                    nColor = MbeColors.L3;
                    break;

                case MbeLayer.LayerValue.SOL:
                    nColor = MbeColors.SOL;
                    //reverse = true;
                    break;

                case MbeLayer.LayerValue.DIM:
                    nColor = MbeColors.DIM;
                    break;

                default:
                    nColor = MbeColors.DOC;
                    break;
                }

                if (dp.mode == MbeDrawMode.Temp)
                {
                    col = Color.FromArgb(255, MbeColors.HighLighten(nColor));
                    //col = Color.FromArgb(MBE_OBJ_ALPHA, MbeColors.HighLighten(nColor));
                }
                else
                {
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(255, col);
                }
            }

            bool reverse = false;

            switch (dp.layer)
            {
            case MbeLayer.LayerValue.PLS:
            case MbeLayer.LayerValue.STS:
            case MbeLayer.LayerValue.SOL:
                reverse = true;
                break;

            default:
                reverse = false;
                break;
            }

            //文字列描画にアルファブレンドを使うかどうかの判定
            bool bDrawUsingAlphaBlend = true;

            if (Program.drawTextSolidly)
            {
                bDrawUsingAlphaBlend = false;
            }
            else if (dp.mode == MbeDrawMode.Print)
            {
                if ((dp.option & (uint)MbeDrawOption.PrintColor) == 0)   //白黒印刷時はアルファブレンドにしない
                {
                    bDrawUsingAlphaBlend = false;
                }
            }


            if (dp.layer != MbeLayer.LayerValue.DOC)
            {
                GraphicsState gState = dp.g.Save();                     //座標系保存


                dp.g.TranslateTransform(pt0.X, pt0.Y);
                if (dir != 0)
                {
                    dp.g.RotateTransform(-dir);
                }
                if (reverse)
                {
                    dp.g.ScaleTransform(-1.0F, 1.0F);
                }



                if (bDrawUsingAlphaBlend)
                {
                    int    drawWidth = MbeBoardFont.DrawWidth(h, signame);
                    int    buffCX    = drawWidth + w + w;
                    int    buffCY    = h + w + w;
                    Bitmap bmp       = new Bitmap(buffCX, buffCY);


                    Graphics gBmp  = Graphics.FromImage(bmp);
                    Color    colBg = Color.FromArgb(unchecked ((int)MbeColors.Background));
                    gBmp.Clear(colBg);
                    MbeView.boardFont.DrawString(gBmp, w, h + w, false, signame, h, w, col);

                    ColorMatrix cm = new ColorMatrix();
                    cm.Matrix00 = 1.0F;
                    cm.Matrix11 = 1.0F;
                    cm.Matrix22 = 1.0F;
                    cm.Matrix33 = 0.5F;
                    cm.Matrix44 = 1.0F;



                    ImageAttributes ia = new ImageAttributes();
                    ia.SetColorMatrix(cm);
                    ia.SetColorKey(colBg, colBg);

                    Rectangle rc = new Rectangle(-w, w - buffCY, buffCX, buffCY);
                    dp.g.DrawImage(bmp, rc, 0, 0, buffCX, buffCY, GraphicsUnit.Pixel, ia);
                }
                else
                {
                    MbeView.boardFont.DrawString(dp.g, 0, 0, false, signame, h, w, col);
                }
                dp.g.Restore(gState);                                   //座標系復帰
            }
            else
            {
                if (bDrawUsingAlphaBlend)
                {
                    col = Color.FromArgb(MBE_OBJ_ALPHA, col);
                }

                if (h >= 2)
                {
                    Font         font   = new Font(FontFamily.GenericSerif, h, GraphicsUnit.Pixel);
                    Brush        brush  = new SolidBrush(col);
                    StringFormat format = new StringFormat(StringFormatFlags.NoClip);
                    format.Alignment     = StringAlignment.Near;
                    format.LineAlignment = StringAlignment.Far;

                    GraphicsState gState = dp.g.Save();                         //座標系保存
                    dp.g.TranslateTransform(pt0.X, pt0.Y);
                    if (dir != 0)
                    {
                        dp.g.RotateTransform(-dir);
                    }
                    dp.g.DrawString(signame, font, brush, new PointF(0, 0), format);
                    dp.g.Restore(gState);                                                       //座標系復帰

                    format.Dispose();
                    brush.Dispose();
                    font.Dispose();
                }
            }


            if (drawSnapMark && dp.mode != MbeDrawMode.Print)
            {
                int marksize = h / 3;
                if (marksize > 20)
                {
                    marksize = 20;
                }
                DrawSnapPointMark(dp.g, pt0, marksize, selectFlag[0]);
            }
        }
Пример #11
0
        /// <summary>
        /// 描画(abstract メソッド)
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawParam dp)
        {
            if (dp.layer != Layer)
            {
                return;
            }

            //0.46.04 描画ズレの低減
            //0.49.02 描画ズレの低減
            Point lt = GetPos(0);
            Point rb = lt;

            lt.Offset(-Radius, Radius);
            lt = ToDrawDim(lt, dp.scale);
            rb.Offset(Radius, -Radius);
            rb = ToDrawDim(rb, dp.scale);


            int drawWidth  = rb.X - lt.X;
            int drawHeight = rb.Y - lt.Y;



            if (drawWidth == 0)         //0.49.20
            {
                drawWidth = 1;
            }
            if (drawHeight == 0)        //0.49.20
            {
                drawHeight = 1;
            }


            Rectangle rc = new Rectangle(lt.X, lt.Y, drawWidth, drawHeight);


            Color col;
            int   w = 0;
            Pen   pen;


            //描画幅の設定
            w = (int)(LineWidth / dp.scale) | 1;

            if (dp.mode == MbeDrawMode.Print)
            {
                if ((dp.option & (uint)MbeDrawOption.PrintColor) != 0)      //カラー印刷
                {
                    uint nColor;
                    switch (dp.layer)
                    {
                    case MbeLayer.LayerValue.PLC:
                        nColor = MbeColors.PRINT_PLC;
                        break;

                    case MbeLayer.LayerValue.PLS:
                        nColor = MbeColors.PRINT_PLS;
                        break;

                    case MbeLayer.LayerValue.STC:
                        nColor = MbeColors.PRINT_STC;
                        break;

                    case MbeLayer.LayerValue.STS:
                        nColor = MbeColors.PRINT_STS;
                        break;

                    case MbeLayer.LayerValue.CMP:
                        nColor = MbeColors.PRINT_CMP;
                        break;

                    case MbeLayer.LayerValue.L2:
                        nColor = MbeColors.PRINT_L2;
                        break;

                    case MbeLayer.LayerValue.L3:
                        nColor = MbeColors.PRINT_L3;
                        break;

                    case MbeLayer.LayerValue.SOL:
                        nColor = MbeColors.PRINT_SOL;
                        break;

                    case MbeLayer.LayerValue.DIM:
                        nColor = MbeColors.PRINT_DIM;
                        break;

                    default:
                        nColor = MbeColors.PRINT_DOC;
                        break;
                    }
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_PRINT_ALPHA, col);
                }
                else
                {
                    col = Color.Black;
                }
            }
            else
            {
                uint nColor;
                switch (dp.layer)
                {
                case MbeLayer.LayerValue.PLC:
                    nColor = MbeColors.PLC;
                    break;

                case MbeLayer.LayerValue.PLS:
                    nColor = MbeColors.PLS;
                    break;

                case MbeLayer.LayerValue.STC:
                    nColor = MbeColors.STC;
                    break;

                case MbeLayer.LayerValue.STS:
                    nColor = MbeColors.STS;
                    break;

                case MbeLayer.LayerValue.CMP:
                    nColor = MbeColors.CMP;
                    break;

                case MbeLayer.LayerValue.L2:
                    nColor = MbeColors.L2;
                    break;

                case MbeLayer.LayerValue.L3:
                    nColor = MbeColors.L3;
                    break;

                case MbeLayer.LayerValue.SOL:
                    nColor = MbeColors.SOL;
                    break;

                case MbeLayer.LayerValue.DIM:
                    nColor = MbeColors.DIM;
                    break;

                default:
                    nColor = MbeColors.DOC;
                    break;
                }

                if (dp.mode == MbeDrawMode.Temp || connectionCheckActive)
                {
                    col = Color.FromArgb(MBE_OBJ_ALPHA, MbeColors.HighLighten(nColor));
                }
                else
                {
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_ALPHA, col);
                }
            }

            pen          = new Pen(col, w);
            pen.StartCap = LineCap.Round;
            pen.EndCap   = LineCap.Round;

            int sweepAngle;

            if (LimitStartEnd())
            {
                sweepAngle = 3600;
            }
            else if (StartAngle > EndAngle)
            {
                sweepAngle = 3600 - StartAngle + EndAngle;
            }
            else
            {
                sweepAngle = EndAngle - StartAngle;
            }
            if (drawWidth > 0)
            {
                dp.g.DrawArc(pen, rc, ((float)-StartAngle) / 10, ((float)-sweepAngle) / 10);
            }
            pen.Dispose();

            if (drawSnapMark && dp.mode != MbeDrawMode.Print)
            {
                Point pt0 = GetPos(0);
                Point pt1 = GetPos(1);
                Point pt2 = GetPos(2);
                pt0 = ToDrawDim(pt0, dp.scale);
                pt1 = ToDrawDim(pt1, dp.scale);
                pt2 = ToDrawDim(pt2, dp.scale);

                int marksize = (int)(drawWidth / 10);
                if (marksize < 10)
                {
                    marksize = 10;
                }
                DrawSnapPointMark(dp.g, pt0, marksize, selectFlag[0]);

                marksize = w;
                if (marksize < 5)
                {
                    marksize = 5;
                }
                if (!selectFlag[2])
                {
                    DrawSnapPointMark(dp.g, pt2, marksize, selectFlag[2]);
                    DrawSnapPointMark(dp.g, pt1, marksize, selectFlag[1]);
                }
                else
                {
                    DrawSnapPointMark(dp.g, pt1, marksize, selectFlag[1]);
                    DrawSnapPointMark(dp.g, pt2, marksize, selectFlag[2]);
                }
            }
        }
Пример #12
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();
        }
Пример #13
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();
        }
Пример #14
0
        /// <summary>
        /// 描画
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawParam dp)
        {
            if (((ulong)dp.layer & ((ulong)MbeLayer.LayerValue.STS |
                                    (ulong)MbeLayer.LayerValue.STC |
                                    (ulong)MbeLayer.LayerValue.DRL)) == 0)
            {
                return;
            }

            //if (dp.layer != MbeLayer.LayerValue.DRL) return;

            Point pt = this.GetPos(0);

            pt = ToDrawDim(pt, dp.scale);

            Color col;
            Color cold;
            //int w = 0;
            //int h = 0;
            int wd = 0;
            //int hd = 0;
            Rectangle  rc;
            SolidBrush brush;
            Pen        pen;
            bool       centerPunchMode = false;

            int drillDia;

            if ((dp.option & (uint)MbeDrawOption.CenterPunchMode) != 0)
            {
                drillDia        = PrintCenterPunchModeDiameter(Diameter);
                centerPunchMode = true;
            }
            else
            {
                drillDia = Diameter;
            }


            switch (dp.layer)
            {
            case MbeLayer.LayerValue.DRL:
                wd = (int)(drillDia / dp.scale) | 1;
                break;

            case MbeLayer.LayerValue.STC:
            case MbeLayer.LayerValue.STS:
                wd = (int)((Diameter + DEFAULT_SRMARGIN * 2) / dp.scale) | 1;
                break;
            }


            //wd = (int)(Diameter / dp.scale) | 1;


            #region 色の設定
            if (dp.mode == MbeDrawMode.Print)
            {
                cold = Color.White;
                if ((dp.option & (uint)MbeDrawOption.PrintColor) != 0)      //カラー印刷
                {
                    uint nColor;

                    switch (dp.layer)
                    {
                    case MbeLayer.LayerValue.STC:
                        nColor = MbeColors.PRINT_STC;
                        break;

                    case MbeLayer.LayerValue.STS:
                        nColor = MbeColors.PRINT_STS;
                        break;

                    case MbeLayer.LayerValue.DRL:
                    default:
                        nColor = MbeColors.PRINT_DRL;
                        break;
                    }
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_PRINT_ALPHA, col);
                }
                else
                {
                    col = Color.Black;
                }
            }
            else
            {
                uint nColor;
                switch (dp.layer)
                {
                case MbeLayer.LayerValue.STC:
                    nColor = MbeColors.STC;
                    break;

                case MbeLayer.LayerValue.STS:
                    nColor = MbeColors.STS;
                    break;

                case MbeLayer.LayerValue.DRL:
                default:
                    nColor = MbeColors.DRL;
                    break;
                }

                cold = MbeColors.ColorBackground;
                if (dp.mode == MbeDrawMode.Temp)
                {
                    col  = Color.FromArgb(MBE_OBJ_ALPHA, MbeColors.HighLighten(nColor));
                    cold = Color.FromArgb(0x20, cold);
                }
                else
                {
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_ALPHA, col);
                }
            }
            #endregion


            rc = new Rectangle(pt.X - wd / 2, pt.Y - wd / 2, wd, wd);

            if (dp.layer == MbeLayer.LayerValue.DRL)
            {
                if (dp.mode != MbeDrawMode.Print)
                {
                    cold = Color.FromArgb(0x90, cold);
                }
                brush = new SolidBrush(cold);
                dp.g.FillEllipse(brush, rc);
                brush.Dispose();

                //DRLレイヤーへの描画では、輪郭を描く。
                //印刷時はプリンタの能力に左右されにくいように幅を設定する。
                //センターポンチモードでは、感光基板による自作を想定してやや太めのラインとする。
                int w = 1;

                if (dp.mode == MbeDrawMode.Print)
                {
                    if (centerPunchMode && (dp.visibleLayer & ((ulong)MbeLayer.LayerValue.PTH |
                                                               (ulong)MbeLayer.LayerValue.CMP |
                                                               (ulong)MbeLayer.LayerValue.SOL)) != 0)
                    {
                        w = 1000;
                    }
                    else
                    {
                        w = 500;
                    }

                    w = (int)(w / dp.scale) | 1;

                    if ((dp.option & (uint)MbeDrawOption.ToolMarkMode) != 0)
                    {
                        if ((dp.visibleLayer & MbeLayer.PatternFilmLayer) == 0)
                        {
                            MbeView.DrawDrillMark(GetPos(0), Diameter, dp, col, w);
                            return;
                        }
                    }
                }
                pen = new Pen(col, w);
                dp.g.DrawEllipse(pen, rc);
                pen.Dispose();
                if (drawSnapMark && dp.mode != MbeDrawMode.Print)
                {
                    int marksize = wd / 2;
                    DrawSnapPointMark(dp.g, pt, marksize, selectFlag[0]);
                }
            }
            else
            {
                brush = new SolidBrush(col);
                dp.g.FillEllipse(brush, rc);
                brush.Dispose();
            }
        }
Пример #15
0
        /// <summary>
        /// 描画
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawParam dp)
        {
            if (dp.layer != Layer)
            {
                return;
            }
            Point pt0 = this.GetPos(0);
            Point pt1 = this.GetPos(1);
            Point ptVia;

            //両端点が一致していたら描画しない。Version 0.48.02 2009/04/24
            if (pt0.X == pt1.X && pt0.Y == pt1.Y)
            {
                return;
            }

            bool bendMode = getPointVia(out ptVia);

            //折れ曲がり点が端点と一致していたら、折れ曲がり線ではないと見做す。Version 0.48.02 2009/04/24
            if (bendMode)
            {
                if ((pt0.X == ptVia.X && pt0.Y == ptVia.Y) || (pt1.X == ptVia.X && pt1.Y == ptVia.Y))
                {
                    bendMode = false;
                }
                else
                {
                    ptVia = ToDrawDim(ptVia, dp.scale);
                }
            }

            pt0 = ToDrawDim(pt0, dp.scale);
            pt1 = ToDrawDim(pt1, dp.scale);


            Color col;
            int   w = 0;
            Pen   pen;


            //描画幅の設定
            w = (int)(LineWidth / dp.scale) | 1;

            if (dp.mode == MbeDrawMode.Print)
            {
                if ((dp.option & (uint)MbeDrawOption.PrintColor) != 0)      //カラー印刷
                {
                    uint nColor;
                    switch (dp.layer)
                    {
                    case MbeLayer.LayerValue.PLC:
                        nColor = MbeColors.PRINT_PLC;
                        break;

                    case MbeLayer.LayerValue.PLS:
                        nColor = MbeColors.PRINT_PLS;
                        break;

                    case MbeLayer.LayerValue.MMC:
                        nColor = MbeColors.PRINT_MMC;
                        break;

                    case MbeLayer.LayerValue.MMS:
                        nColor = MbeColors.PRINT_MMS;
                        break;

                    case MbeLayer.LayerValue.STC:
                        nColor = MbeColors.PRINT_STC;
                        break;

                    case MbeLayer.LayerValue.STS:
                        nColor = MbeColors.PRINT_STS;
                        break;

                    case MbeLayer.LayerValue.CMP:
                        nColor = MbeColors.PRINT_CMP;
                        break;

                    case MbeLayer.LayerValue.L2:
                        nColor = MbeColors.PRINT_L2;
                        break;

                    case MbeLayer.LayerValue.L3:
                        nColor = MbeColors.PRINT_L3;
                        break;

                    case MbeLayer.LayerValue.SOL:
                        nColor = MbeColors.PRINT_SOL;
                        break;

                    case MbeLayer.LayerValue.DIM:
                        nColor = MbeColors.PRINT_DIM;
                        break;

                    default:
                        nColor = MbeColors.PRINT_DOC;
                        break;
                    }
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_PRINT_ALPHA, col);
                }
                else
                {
                    col = Color.Black;
                }
            }
            else
            {
                uint nColor;
                switch (dp.layer)
                {
                case MbeLayer.LayerValue.PLC:
                    nColor = MbeColors.PLC;
                    break;

                case MbeLayer.LayerValue.PLS:
                    nColor = MbeColors.PLS;
                    break;

                case MbeLayer.LayerValue.MMC:
                    nColor = MbeColors.MMC;
                    break;

                case MbeLayer.LayerValue.MMS:
                    nColor = MbeColors.MMS;
                    break;

                case MbeLayer.LayerValue.STC:
                    nColor = MbeColors.STC;
                    break;

                case MbeLayer.LayerValue.STS:
                    nColor = MbeColors.STS;
                    break;

                case MbeLayer.LayerValue.CMP:
                    nColor = MbeColors.CMP;
                    break;

                case MbeLayer.LayerValue.L2:
                    nColor = MbeColors.L2;
                    break;

                case MbeLayer.LayerValue.L3:
                    nColor = MbeColors.L3;
                    break;

                case MbeLayer.LayerValue.SOL:
                    nColor = MbeColors.SOL;
                    break;

                case MbeLayer.LayerValue.DIM:
                    nColor = MbeColors.DIM;
                    break;

                default:
                    nColor = MbeColors.DOC;
                    break;
                }

                if (dp.mode == MbeDrawMode.Temp || connectionCheckActive)
                {
                    col = Color.FromArgb(MBE_OBJ_ALPHA, MbeColors.HighLighten(nColor));
                }
                else
                {
                    col = Color.FromArgb(unchecked ((int)nColor));
                    col = Color.FromArgb(MBE_OBJ_ALPHA, col);
                }
            }

            pen          = new Pen(col, w);
            pen.StartCap = LineCap.Round;
            pen.EndCap   = LineCap.Round;
            if (!bendMode)
            {
                //Version 0.48.02 非常に短いラインデータの描画が消えないようにする
                //DrawLine()を直接使わずに、メンバーのDrawLineData()を呼ぶ
                //dp.g.DrawLine(pen, pt0, pt1);
                DrawLineData(dp.g, pen, pt0, pt1);
            }
            else
            {
                //Version 0.48.02 非常に短いラインデータの描画が消えないようにする
                //DrawLine()を直接使わずに、メンバーのDrawLineData()を呼ぶ
                //dp.g.DrawLine(pen, pt0, ptVia);
                //dp.g.DrawLine(pen, ptVia, pt1);
                DrawLineData(dp.g, pen, pt0, ptVia);
                DrawLineData(dp.g, pen, ptVia, pt1);
            }
            pen.Dispose();

            if (drawSnapMark && dp.mode != MbeDrawMode.Print)
            {
                int marksize = w;
                DrawSnapPointMark(dp.g, pt0, marksize, selectFlag[0]);
                DrawSnapPointMark(dp.g, pt1, marksize, selectFlag[1]);
            }
        }