/// <summary>
        ///
        /// </summary>
        public override void Dispose()
        {
            base.Dispose();

            ForeBrush?.Dispose();
            BackgroundBrush?.Dispose();
        }
Beispiel #2
0
 public UnderliningStyle(AppearanceDescription description, Brush brush)
     : base(description)
 {
     BackgroundBrush.Dispose();
     BackgroundBrush = null;
     _pen            = new Pen(brush, 1.5F);
 }
Beispiel #3
0
 private void description_BackColorChanged(object sender, EventArgs e)
 {
     if (BackgroundBrush != null)
     {
         BackgroundBrush.Dispose();
     }
     BackgroundBrush = CreateBrush(Description.BackColor);
 }
Beispiel #4
0
        public override void Dispose()
        {
            base.Dispose();

            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
        }
Beispiel #5
0
        protected void DisposeDirectXResources()
        {
            PreDestroyDirectXResources();
            SharedBrush.Dispose();
            BackgroundBrush.Dispose();
            ForegroundBrush.Dispose();
            CorrectColorBrush.Dispose();
            WrongColorBrush.Dispose();

            InputTextFormat.Dispose();
            ButtonLabelTextFormat.Dispose();
            SubtitleTextFormat.Dispose();
            CueTextFormat.Dispose();

            DwFactory.Dispose();
            RenderTarget.Dispose();
            RenderTargetView.Dispose();
            D2DFactory.Dispose();
            SwapChain.Dispose();
            D3DDeviceContext.Dispose();
            D3DDevice.Dispose();
        }
Beispiel #6
0
        /// <summary>This method will paint the group title.</summary>
        /// <param name="g">The paint event graphics object.</param>
        private void PaintGroupText(System.Drawing.Graphics g)
        {
            //Check if string has something-------------
            if (this.Text == string.Empty)
            {
                return;
            }
            //------------------------------------------

            //Set Graphics smoothing mode to Anit-Alias--
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //-------------------------------------------

            //Declare Variables------------------
            SizeF StringSize  = g.MeasureString(this.Text, this.Font);
            Size  StringSize2 = StringSize.ToSize();

            if (this.GroupImage != null)
            {
                StringSize2.Width += 18;
            }
            int ArcWidth  = this.RoundCorners;
            int ArcHeight = this.RoundCorners;
            int ArcX1     = 20;
            int ArcX2     = (StringSize2.Width + 34) - (ArcWidth + 1);
            int ArcY1     = 0;
            int ArcY2     = 24 - (ArcHeight + 1);

            if (this.TitleStyle == TitleStyles.XPStyle)
            {
                ArcX1 = 0;
                ArcX2 = this.Width - (ArcWidth + 1);
                ArcY1 = 0;
                ArcY2 = 24 - (ArcHeight + 1);
            }

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(this.BorderColor);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, this.BorderThickness);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = null;//(this.PaintGroupBox) ? new LinearGradientBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor);
            System.Drawing.SolidBrush             TextColorBrush  = new SolidBrush(this.TitleTextColor);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;
            //-----------------------------------

            //Check if shadow is needed----------
            if (this.ShadowControl)
            {
                ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath  = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle);        // Top Left
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);        //Top Right
                ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle);        //Bottom Right
                ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);         //Bottom Left
                ShadowPath.CloseAllFigures();

                //Paint Rounded Rectangle------------
                g.FillPath(ShadowBrush, ShadowPath);
                //-----------------------------------
            }
            //-----------------------------------

            //Create Rounded Rectangle Path------
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle);            // Top Left
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle);            //Top Right
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle);            //Bottom Right
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle);             //Bottom Left
            path.CloseAllFigures();
            //-----------------------------------

            //Check if Gradient Mode is enabled--
            if (this.PaintGroupBox)
            {
                //Paint Rounded Rectangle------------
                BackgroundGradientBrush = new LinearGradientBrush(path.GetBounds(), this.TitileGradientColors.Color1, this.TitileGradientColors.Color2, (LinearGradientMode)this.BackgroundGradientMode);
                g.FillPath(BackgroundGradientBrush, path);
                //-----------------------------------
            }
            else
            {
                if (this.BackgroundGradientMode == GroupBoxGradientMode.None)
                {
                    //Paint Rounded Rectangle------------
                    BackgroundBrush = new SolidBrush(this.BackColor);
                    g.FillPath(BackgroundBrush, path);
                    //-----------------------------------
                }
                else
                {
                    BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), this.GradientColors.Color1, this.GradientColors.Color2, (LinearGradientMode)this.BackgroundGradientMode);

                    //Paint Rounded Rectangle------------
                    g.FillPath(BackgroundGradientBrush, path);
                    //-----------------------------------
                }
            }
            //-----------------------------------

            //Paint Borded-----------------------
            g.DrawPath(BorderPen, path);
            //-----------------------------------

            //Paint Text-------------------------
            int CustomStringWidth = (this.GroupImage != null) ? 44 : 28;

            g.DrawString(this.Text, this.Font, TextColorBrush, CustomStringWidth, 5);
            //-----------------------------------

            //Draw GroupImage if there is one----
            if (this.GroupImage != null)
            {
                g.DrawImage(this.GroupImage, 28, 4, 16, 16);
            }
            //-----------------------------------

            //Destroy Graphic Objects------------
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderBrush.Dispose();
            }
            if (BorderPen != null)
            {
                BorderPen.Dispose();
            }
            if (BackgroundGradientBrush != null)
            {
                BackgroundGradientBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
            if (TextColorBrush != null)
            {
                TextColorBrush.Dispose();
            }
            if (ShadowBrush != null)
            {
                ShadowBrush.Dispose();
            }
            if (ShadowPath != null)
            {
                ShadowPath.Dispose();
            }
            //-----------------------------------
        }
Beispiel #7
0
        public void Draw(Graphics g)
        {
            g.SmoothingMode = SmoothingMode.AntiAlias;

            int ArcWidth  = this.C_RoundCorners * 2;
            int ArcHeight = this.C_RoundCorners * 2;
            int ArcX1     = Rect.Left;
            int ArcX2     = (this.ShadowControl) ? (Rect.Left + Rect.Width - (ArcWidth + 1)) - this.ShadowThickness : Rect.Left + Rect.Width - (ArcWidth + 1);
            int ArcY1     = Rect.Top;
            int ArcY2     = (this.ShadowControl) ? (Rect.Top + Rect.Height - (ArcHeight + 1)) - this.ShadowThickness : Rect.Top + Rect.Height - (ArcHeight + 1);

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Brush BorderBrush           = new SolidBrush(Color.Orange);
            System.Drawing.Pen   BorderPen             = new Pen(BorderBrush, 2.0f);
            System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null;
            System.Drawing.Brush                  BackgroundBrush = new SolidBrush(Color.White);
            System.Drawing.SolidBrush             ShadowBrush     = null;
            System.Drawing.Drawing2D.GraphicsPath ShadowPath      = null;

            //画出阴影效果
            if (this.ShadowControl)
            {
                Color shadowColor = Color.FromArgb(192, this.ShadowColor);
                //说明:1-(128/255)=1-0.5=0.5 透明度为0.5,即50%
                ShadowBrush = new SolidBrush(shadowColor);
                //ShadowBrush = new SolidBrush(this.ShadowColor);
                ShadowPath = new System.Drawing.Drawing2D.GraphicsPath();
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 180, SweepAngle); //顶端的左角
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY1 + this.ShadowThickness, ArcWidth, ArcHeight, 270, SweepAngle); //顶端右角
                ShadowPath.AddArc(ArcX2 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 360, SweepAngle); //底部右角
                ShadowPath.AddArc(ArcX1 + this.ShadowThickness, ArcY2 + this.ShadowThickness, ArcWidth, ArcHeight, 90, SweepAngle);  //底部左角
                ShadowPath.CloseAllFigures();

                g.FillPath(ShadowBrush, ShadowPath);
            }

            //画出图形
            path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, SweepAngle);
            path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, SweepAngle);
            path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, SweepAngle);
            path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, SweepAngle);
            path.CloseAllFigures();

            if (this.C_BackgroundGradientMode == DutBoxGradientMode.None)
            {
                BackgroundBrush = new SolidBrush(this.BackgroundGradientColor);
                g.FillPath(BackgroundBrush, path);
            }
            else
            {
                Color startColor = Color.FromArgb(192, Color.White);
                BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(Rect.Left, Rect.Top, Rect.Width, Rect.Height), startColor, this.BackgroundGradientColor, (LinearGradientMode)this.BackgroundGradientMode);

                g.FillPath(BackgroundGradientBrush, path);
            }
            //画边框
            if (Focus)
            {
                g.DrawPath(BorderPen, path);
            }
            else
            {
                System.Drawing.Brush defaultBrush = new SolidBrush(this.BorderColor);
                System.Drawing.Pen   defaultPen   = new Pen(defaultBrush, this.BorderThickness);
                g.DrawPath(defaultPen, path);

                if (defaultBrush != null)
                {
                    defaultBrush.Dispose();
                }
                if (defaultPen != null)
                {
                    defaultPen.Dispose();
                }
            }
            //画内容 ID
            Font font = new Font("Arial", 14.25F, System.Drawing.FontStyle.Bold);

            g.DrawString((ID + 1).ToString(), font, Brushes.Black, Rect.Left + 6, Rect.Top + 6);
            if (Connected)
            {
                //画状态
                if (!string.IsNullOrEmpty(Status))
                {
                    font = new Font("Arial", 11.25F, FontStyle.Bold);
                    g.DrawString(Status, font, Brushes.Black, Rect.Left + 6 + 56, Rect.Top + 6 + 2);
                }
                //画进度条

                Rectangle bar = new Rectangle(Rect.Left + 6, Rect.Top + 28, Rect.Width - 10, 14);
                ProgressBar.Rect = bar;
                g.SmoothingMode  = SmoothingMode.Default;
                ProgressBar.Draw(g);
                g.SmoothingMode = SmoothingMode.AntiAlias;

                /* Button but = new Button( );
                 * but.Text = "打印";
                 * but.Location = new Point(Rect.Width - 5,14);*/

                //画打印图标 20161223 bonnie
                string haarXmlPath = @"../../打印图标.png";

                FileInfo file     = new FileInfo(haarXmlPath);
                string   fullName = file.FullName;

                //画SN
                if (!string.IsNullOrEmpty(SerialNumber))
                {
                    font = new Font("Arial", 10.25F);
                    g.DrawString("SN:" + SerialNumber, font, Brushes.Black, Rect.Left + 6, Rect.Top + 6 + 40);
                }
                //画IMEI
                if (!string.IsNullOrEmpty(IMEI))
                {
                    font = new Font("Arial", 10.25F);
                    g.DrawString("IMEI:" + IMEI, font, Brushes.Black, Rect.Left + 6, Rect.Top + 6 + 60);
                }
                font = new Font("Arial", 10.25F, FontStyle.Bold);
                //画time
                if (ElapsedTime > 0.0f)
                {
                    g.DrawString((int)ElapsedTime + "/" + (int)EstimateTime, font, Brushes.Black, Rect.Left + 6, Rect.Top + 6 + 80);
                }
                //画测试方式
                switch (Way)
                {
                case TestWay.TW_AUTO:
                    g.DrawString("Auto", font, Brushes.DarkGreen, Rect.Left + 6 + 90, Rect.Top + 6 + 80);
                    break;

                case TestWay.TW_MANUAL:
                    g.DrawString("Manual", font, Brushes.Red, Rect.Left + 6 + 80, Rect.Top + 6 + 80);
                    break;

                case TestWay.TW_NONE:
                    break;
                }
                //画Model
                if (!string.IsNullOrEmpty(Model))
                {
                    font = new Font("Arial", 10.25F);
                    g.DrawString(Model, font, Brushes.Black, Rect.Left + 6, Rect.Top + 6 + 100);
                }
                //画QRCode 48 x 48
                if (QRCode != null)
                {
                    bar = new Rectangle(Rect.Right - 58, Rect.Top + 84, 48, 48);
                    //g.FillRectangle(Brushes.Red, bar);
                    g.SmoothingMode = SmoothingMode.None;
                    g.DrawImageUnscaled(QRCode, bar);
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                }

                if (QRCode != null)
                {
                    FileInfo image_file = new FileInfo($@"./pictures/打印图标.png");
                    if (image_file.Exists)
                    {
                        PrintIocnImage  = Image.FromFile(image_file.FullName);
                        g.SmoothingMode = SmoothingMode.None;
                        g.DrawImage(PrintIocnImage, Rect.Right - 98, Rect.Top + 104);
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                    }
                }
            }
            else // disconnected - TESTING & FAIL
            {
                if (Result == ItemResult.IR_TESTING)
                {
                    StringFormat stringFormat = new StringFormat();
                    stringFormat.LineAlignment = StringAlignment.Center;
                    stringFormat.Alignment     = StringAlignment.Center;
                    stringFormat.FormatFlags   = StringFormatFlags.LineLimit;
                    stringFormat.Trimming      = StringTrimming.EllipsisCharacter;
                    font = new Font("Arial", 16.25F, FontStyle.Bold);

                    g.DrawString("OFFLINE", font, Brushes.White, Rect, stringFormat);
                }
            }
            //画对号
            if (Checked)
            {
                //g.DrawLine(BorderPen, 10, 10, 20, 20);
                int x   = Rect.Left + Rect.Width - 30;
                int y   = Rect.Top + 8;
                Pen pen = new Pen(new SolidBrush(Color.DarkOrange), this.BorderThickness);
                for (int i = 0; i < 6; i++)
                {
                    g.DrawLine(pen, x, y, x, y + 6);
                    x++; y++;
                }
                for (int i = 0; i < 11; i++)
                {
                    g.DrawLine(pen, x, y, x, y + 6);
                    x++; y--;
                }
                if (pen != null)
                {
                    pen.Dispose();
                }
            }
            //销毁Graphic 对象
            if (path != null)
            {
                path.Dispose();
            }
            if (BorderBrush != null)
            {
                BorderPen.Dispose();
            }
            if (BorderPen != null)
            {
                BorderPen.Dispose();
            }

            if (BackgroundGradientBrush != null)
            {
                BackgroundGradientBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
            if (ShadowBrush != null)
            {
                ShadowBrush.Dispose();
            }
            if (ShadowPath != null)
            {
                ShadowPath.Dispose();
            }
        }