Exemple #1
0
            private void DrawCtrlRoundRectangle(Graphics g)
            {
                try
                {
                    g.FillRectangle(new SolidBrush(CtrlStatus.GetBackColor(IsHot, IsPressed)), CtrlPos.X, CtrlPos.Y, CtrlPos.Width - 1, CtrlPos.Height - 1);
                    g.DrawRectangle(new Pen(CtrlStatus.GetBorderColor(IsHot), 1), CtrlPos.X, CtrlPos.Y, CtrlPos.Width - 1, CtrlPos.Height - 1);

                    StringFormat drawFormat = new StringFormat();
                    drawFormat.LineAlignment = StringAlignment.Center;
                    drawFormat.Alignment     = StringAlignment.Center;
                    RectangleF rcText = new RectangleF(System.Convert.ToSingle(CtrlPos.X), System.Convert.ToSingle(CtrlPos.Y), System.Convert.ToSingle(CtrlPos.Width), System.Convert.ToSingle(CtrlPos.Height));
                    if (IsPressed == true)
                    {
                        rcText.Location = new PointF(System.Convert.ToSingle(rcText.Left + 1), System.Convert.ToSingle(rcText.Top + 1));
                    }
                    Brush drawBrush;
                    if (this.Enabled == true)
                    {
                        drawBrush = new SolidBrush(CtrlStatus.GetTextColor());
                    }
                    else
                    {
                        drawBrush = new SolidBrush(Color.FromArgb(128, 128, 128));
                    }

                    g.DrawString(CtrlStatus.Text, new Font(CtrlStatus.TextFontName, System.Convert.ToInt32(CtrlStatus.TextSize * modCommonFunctions.GetScale(this.CtrlStatus.ZoomScale)), ((FontStyle)(Enum.Parse(typeof(FontStyle), Enum.GetValues(typeof(FontStyle)).GetValue(CtrlStatus.TextStyle).ToString())))), drawBrush, rcText, drawFormat);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "udcCtrlTag.DrawCtrlRectangle()", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
Exemple #2
0
            private void DrawCtrlPieType(Graphics g, Enums.eToolType eType, Rectangle newRect, float sStartAngle, float sSweepAngle)
            {
                try
                {
                    g.FillPie(new SolidBrush(CtrlStatus.GetBackColor(IsHot, IsPressed)), newRect, sStartAngle, sSweepAngle);
                    switch (eType)
                    {
                    case Enums.eToolType.PieType1:

                        g.DrawPie(new Pen(CtrlStatus.GetBorderColor(IsHot), 1), newRect.X + 1, newRect.Y + 1, newRect.Width - 2, newRect.Height - 3, sStartAngle, sSweepAngle);
                        break;

                    case Enums.eToolType.PieType2:

                        g.DrawPie(new Pen(CtrlStatus.GetBorderColor(IsHot), 1), newRect.X + 1, newRect.Y + 1, newRect.Width - 2, newRect.Height - 2, sStartAngle, sSweepAngle);
                        break;

                    case Enums.eToolType.PieType3:

                        g.DrawPie(new Pen(CtrlStatus.GetBorderColor(IsHot), 1), newRect.X + 1, newRect.Y + 1, newRect.Width - 3, newRect.Height - 2, sStartAngle, sSweepAngle);
                        break;

                    case Enums.eToolType.PieType4:

                        g.DrawPie(new Pen(CtrlStatus.GetBorderColor(IsHot), 1), newRect.X + 1, newRect.Y + 1, newRect.Width - 3, newRect.Height - 3, sStartAngle, sSweepAngle);
                        break;
                    }

                    StringFormat drawFormat = new StringFormat();
                    drawFormat.LineAlignment = StringAlignment.Center;
                    drawFormat.Alignment     = StringAlignment.Center;
                    RectangleF rcText = new RectangleF(System.Convert.ToSingle(CtrlPos.X), System.Convert.ToSingle(CtrlPos.Y), System.Convert.ToSingle(CtrlPos.Width), System.Convert.ToSingle(CtrlPos.Height));
                    if (IsPressed == true)
                    {
                        rcText.Location = new PointF(System.Convert.ToSingle(rcText.Left + 1), System.Convert.ToSingle(rcText.Top + 1));
                    }

                    Brush drawBrush;
                    if (this.Enabled == true)
                    {
                        drawBrush = new SolidBrush(CtrlStatus.GetTextColor());
                    }
                    else
                    {
                        drawBrush = new SolidBrush(Color.FromArgb(128, 128, 128));
                    }
                    g.DrawString(CtrlStatus.Text, new Font(CtrlStatus.TextFontName, System.Convert.ToInt32(CtrlStatus.TextSize * modCommonFunctions.GetScale(this.CtrlStatus.ZoomScale)), ((FontStyle)(Enum.Parse(typeof(FontStyle), Enum.GetValues(typeof(FontStyle)).GetValue(CtrlStatus.TextStyle).ToString())))), drawBrush, rcText, drawFormat);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "udcCtrlTag.DrawCtrlPieType()", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
Exemple #3
0
 private void DrawCtrlHorizontalLine(Graphics g)
 {
     try
     {
         g.FillRectangle(new SolidBrush(CtrlStatus.GetBackColor(IsHot, IsPressed)), CtrlPos.X, CtrlPos.Y, CtrlPos.Width - 1, CtrlPos.Height - 1);
         g.DrawRectangle(new Pen(CtrlStatus.GetBackColor(IsHot, IsPressed), 1), CtrlPos.X, CtrlPos.Y, CtrlPos.Width - 1, CtrlPos.Height - 1);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "udcCtrlTag.DrawCtrlHorizontalLine()", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #4
0
            private void DrawCtrlResource(Graphics g)
            {
                try
                {
                    g.FillRectangle(new SolidBrush(CtrlStatus.GetBackColor(IsHot, IsPressed)), CtrlPos.X, CtrlPos.Y, CtrlPos.Width - 1, CtrlPos.Height - 1);
                    g.DrawRectangle(new Pen(CtrlStatus.GetBorderColor(IsHot), 1), CtrlPos.X, CtrlPos.Y, CtrlPos.Width - 1, CtrlPos.Height - 1);

                    int iSignalSize = 0;
                    int iXPos       = 0;
                    int iYPos       = 0;

                    if (CtrlStatus.IsViewSignal == true)
                    {
                        int iRed   = 0;
                        int iGreen = 0;
                        int iBlue  = 0;
                        iSignalSize = modDefines.CTRL_LIGHT_SIZE;
                        if (CtrlStatus.UpDownFlag != "")
                        {
                            if (CtrlStatus.UpDownFlag.Substring(0, 1) == "D")
                            {
                                iRed = 1;
                            }
                        }

                        if (CtrlStatus.PrimaryStatus == "PROC")
                        {
                            iGreen = 1;
                        }

                        if (CtrlStatus.IsProcessMode == true)
                        {
                            if (CtrlStatus.ProcMode != "")
                            {
                                if (CtrlStatus.ProcMode.Substring(0, 1) == "S")
                                {
                                    iBlue = 1;
                                }
                                else if (CtrlStatus.ProcMode.Substring(0, 1) == "F")
                                {
                                    iBlue = 2;
                                }
                            }
                        }
                        else
                        {
                            if (CtrlStatus.CtrlMode != "")
                            {
                                if (string.IsNullOrEmpty(CtrlStatus.CtrlMode) == false)
                                {
                                    if (CtrlStatus.CtrlMode.Substring(0, 2) == "OL")
                                    {
                                        iBlue = 1;
                                    }
                                    else if (CtrlStatus.CtrlMode.Substring(0, 2) == "OR")
                                    {
                                        iBlue = 2;
                                    }
                                }
                            }
                        }

                        g.FillRectangle(Brushes.White, CtrlPos.X, 0, modDefines.CTRL_LIGHT_SIZE, CtrlPos.Height);

                        iYPos = CtrlPos.Y;
                        if (iRed == 1)                         // Down
                        {
                            g.FillRectangle(Brushes.Red, CtrlPos.X, iYPos, modDefines.CTRL_LIGHT_SIZE, System.Convert.ToInt32((CtrlPos.Height - 1) / 4));
                        }
                        else
                        {
                            g.FillRectangle(Brushes.White, CtrlPos.X, iYPos, modDefines.CTRL_LIGHT_SIZE, System.Convert.ToInt32((CtrlPos.Height - 1) / 4));
                        }

                        iYPos += System.Convert.ToInt32((CtrlPos.Height - 1) / 4);

                        g.FillRectangle(new SolidBrush(CtrlStatus.SignalColor), CtrlPos.X, iYPos, modDefines.CTRL_LIGHT_SIZE, System.Convert.ToInt32((CtrlPos.Height - 1) / 4));

                        iYPos += System.Convert.ToInt32((CtrlPos.Height - 1) / 4);
                        if (iGreen == 1)
                        {
                            g.FillRectangle(Brushes.Lime, CtrlPos.X, iYPos, modDefines.CTRL_LIGHT_SIZE, System.Convert.ToInt32((CtrlPos.Height - 1) / 4));
                        }
                        else
                        {
                            g.FillRectangle(Brushes.White, CtrlPos.X, iYPos, modDefines.CTRL_LIGHT_SIZE, System.Convert.ToInt32((CtrlPos.Height - 1) / 4));
                        }
                        iYPos += System.Convert.ToInt32((CtrlPos.Height - 1) / 4);
                        if (iBlue == 1)
                        {
                            g.FillRectangle(Brushes.Cyan, CtrlPos.X, iYPos, modDefines.CTRL_LIGHT_SIZE, System.Convert.ToInt32(CtrlPos.Bottom - iYPos));
                        }
                        else if (iBlue == 2)
                        {
                            g.FillRectangle(Brushes.Blue, CtrlPos.X, iYPos, modDefines.CTRL_LIGHT_SIZE, System.Convert.ToInt32(CtrlPos.Bottom - iYPos));
                        }
                        else
                        {
                            g.FillRectangle(Brushes.White, CtrlPos.X, iYPos, modDefines.CTRL_LIGHT_SIZE, System.Convert.ToInt32(CtrlPos.Bottom - iYPos));
                        }

                        g.DrawRectangle(new Pen(CtrlStatus.GetBorderColor(IsHot), 1), CtrlPos.X, CtrlPos.Y, modDefines.CTRL_LIGHT_SIZE, CtrlPos.Height - 1);
                    }
                    else
                    {
                        iSignalSize = 0;
                    }

                    StringFormat drawFormat = new StringFormat();
                    if (CtrlStatus.ImageIndex > ListBox.NoMatches && imlResource.Images.Count > CtrlStatus.ImageIndex)
                    {
                        iXPos = System.Convert.ToInt32(CtrlPos.X + iSignalSize + (CtrlPos.Width - iSignalSize) / 2 - (imlResource.ImageSize.Width * modCommonFunctions.GetScale(this.CtrlStatus.ZoomScale)) / 2);
                        iYPos = System.Convert.ToInt32(CtrlPos.Y + (CtrlPos.Height - CtrlStatus.TextSize) / 2 - (imlResource.ImageSize.Height * modCommonFunctions.GetScale(this.CtrlStatus.ZoomScale)) / 2 - 1);
                        if (iXPos < iSignalSize + 2)
                        {
                            iXPos = iSignalSize + 2;
                        }
                        if (iYPos < 2)
                        {
                            iYPos = 2;
                        }
                        Rectangle rcImage = new Rectangle(iXPos, iYPos, Convert.ToInt32(imlResource.ImageSize.Width * modCommonFunctions.GetScale(this.CtrlStatus.ZoomScale)), Convert.ToInt32(imlResource.ImageSize.Height * modCommonFunctions.GetScale(this.CtrlStatus.ZoomScale)));
                        if (IsPressed == true)
                        {
                            rcImage.Location = new Point(rcImage.Left + 1, rcImage.Top + 1);
                        }
                        g.DrawImage(imlResource.Images[CtrlStatus.ImageIndex], rcImage);
                        drawFormat.LineAlignment = StringAlignment.Far;
                    }
                    else
                    {
                        drawFormat.LineAlignment = StringAlignment.Center;
                    }
                    drawFormat.Alignment = StringAlignment.Center;
                    RectangleF rcText = new RectangleF(System.Convert.ToSingle(CtrlPos.X + iSignalSize), System.Convert.ToSingle(CtrlPos.Y), System.Convert.ToSingle(CtrlPos.Width - iSignalSize), System.Convert.ToSingle(CtrlPos.Height - 1));
                    if (IsPressed == true)
                    {
                        rcText.Location = new PointF(System.Convert.ToSingle(rcText.Left + 1), System.Convert.ToSingle(rcText.Top + 1));
                    }
                    Brush drawBrush;
                    if (this.Enabled == true)
                    {
                        drawBrush = new SolidBrush(CtrlStatus.GetTextColor());
                    }
                    else
                    {
                        drawBrush = new SolidBrush(Color.FromArgb(128, 128, 128));
                    }
                    g.DrawString(CtrlStatus.Text,
                                 new Font(CtrlStatus.TextFontName, System.Convert.ToInt32(CtrlStatus.TextSize * modCommonFunctions.GetScale(this.CtrlStatus.ZoomScale)),
                                          ((FontStyle)(Enum.Parse(typeof(FontStyle), Enum.GetValues(typeof(FontStyle)).GetValue(CtrlStatus.TextStyle).ToString())))),
                                 drawBrush, rcText, drawFormat);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "udcCtrlResource.DrawCtrlResource()", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }