Beispiel #1
0
        private void DrawDump(Graphics g, byte[] lineBuffer, int line)
        {
            StringBuilder stringBuilder = new StringBuilder(lineBuffer.Length);

            for (int i = 0; i < lineBuffer.Length; i++)
            {
                char c = Convert.ToChar(lineBuffer[i]);
                if (CharIsPrintable(c))
                {
                    stringBuilder.Append(c);
                }
                else
                {
                    stringBuilder.Append('.');
                }
            }
            Brush brush = new SolidBrush(ForeColor);

            try
            {
                g.DrawString(stringBuilder.ToString(), HEXDUMP_FONT, brush, 479f, 7 + line * 21);
            }
            finally
            {
                brush?.Dispose();
            }
        }
Beispiel #2
0
        private void DrawHex(Graphics g, byte[] lineBuffer, int line)
        {
            StringBuilder stringBuilder = new StringBuilder(lineBuffer.Length * 3 + 1);

            for (int i = 0; i < lineBuffer.Length; i++)
            {
                stringBuilder.Append(lineBuffer[i].ToString("X2", CultureInfo.InvariantCulture));
                stringBuilder.Append(" ");
                if (i == _columnCount / 2 - 1)
                {
                    stringBuilder.Append(" ");
                }
            }

            Brush brush = new SolidBrush(ForeColor);

            try
            {
                g.DrawString(stringBuilder.ToString(), HEXDUMP_FONT, brush, 76f, 7 + line * 21);
            }
            finally
            {
                brush?.Dispose();
            }
        }
Beispiel #3
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual new void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    base.Dispose();
                    inventoryError?.Dispose();
                    inventoryImage?.Dispose();
                    inventoryImagePatch1?.Dispose();
                    consolasBold?.Dispose();
                    darkRedBrush?.Dispose();
                    redBrush?.Dispose();
                    whiteBrush?.Dispose();
                    greyBrush?.Dispose();
                    blackBrush?.Dispose();
                    greenBrush?.Dispose();
                    yellowBrush?.Dispose();
                    backBrush?.Dispose();
                    foreBrush?.Dispose();
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Beispiel #4
0
            private void DrawXLabelArea(Graphics graph)
            {
                Font         font         = null;
                SolidBrush   solidBrush   = null;
                StringFormat stringFormat = null;
                Pen          pen          = null;

                try
                {
                    font                   = new Font(this._fontFamily, 7f);
                    solidBrush             = new SolidBrush(this._fontColor);
                    stringFormat           = new StringFormat();
                    pen                    = new Pen(this._fontColor);
                    stringFormat.Alignment = StringAlignment.Center;
                    graph.DrawLine(pen, this._xOrigin, this._yOrigin + this._graphHeight, this._xOrigin + this._graphWidth, this._yOrigin + this._graphHeight);
                    float y    = this._yOrigin + this._graphHeight + 2f;
                    float num  = this._barWidth + this._spaceBtwBars;
                    int   num2 = 0;
                    foreach (ChartItem dataPoint in base.DataPoints)
                    {
                        float      x = this._xOrigin + (float)num2 * num;
                        RectangleF layoutRectangle = new RectangleF(x, y, num, (float)font.Height);
                        string     s = this._displayLegend ? dataPoint.Label : dataPoint.Description;
                        graph.DrawString(s, font, solidBrush, layoutRectangle, stringFormat);
                        num2++;
                    }
                }
                finally
                {
                    font?.Dispose();
                    solidBrush?.Dispose();
                    stringFormat?.Dispose();
                    pen?.Dispose();
                }
            }
Beispiel #5
0
        public void DrawCpuUsage(object sender, PerformanceCounterEventArgs e)
        {
            cpuIcon?.Icon?.Dispose();

            Bitmap     cpuBitmap   = new Bitmap(16, 16);
            Graphics   cpuGraphics = Graphics.FromImage(cpuBitmap);
            SolidBrush brush       = new SolidBrush(Color.White);

            string cpuVal = $"{e.CPUValue:##}";

            cpuGraphics.Clear(Color.Transparent);

            //cpuGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            //cpuGraphics.CompositingQuality = CompositingQuality.HighQuality;
            //cpuGraphics.SmoothingMode = SmoothingMode.AntiAlias;

            cpuGraphics.DrawImageUnscaled(cpuBitmap, 0, 0);

            cpuGraphics.DrawString(cpuVal,
                                   new Font("Trebuchet MS", 8.8f, FontStyle.Regular, GraphicsUnit.Pixel),
                                   brush,
                                   new RectangleF(0, 3, 16, 13));

            cpuGraphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            cpuIcon.Icon = Icon.FromHandle(cpuBitmap.GetHicon());

            cpuBitmap?.Dispose();
            cpuGraphics?.Dispose();
            brush?.Dispose();
        }
Beispiel #6
0
        public void DrawRamUsage(float ram)
        {
            ramIcon?.Icon?.Dispose();

            Bitmap     ramBitmap   = new Bitmap(16, 16);
            Graphics   ramGraphics = Graphics.FromImage(ramBitmap);
            SolidBrush brush       = new SolidBrush(Color.White);

            float  ramUsageGb = ramInGB - ram / 1024;
            string sRamUsage  = $"{ramUsageGb:##.#}";

            ramGraphics.Clear(Color.Transparent);

            //ramGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            //ramGraphics.CompositingQuality = CompositingQuality.HighQuality;
            //ramGraphics.SmoothingMode = SmoothingMode.AntiAlias;

            ramGraphics.DrawImageUnscaled(ramBitmap, 0, 0);

            ramGraphics.DrawString(sRamUsage,
                                   new Font("Trebuchet MS", 8.8f, FontStyle.Regular, GraphicsUnit.Pixel),
                                   brush,
                                   new RectangleF(0, 3, 16, 13));

            ramGraphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            ramIcon.Icon = Icon.FromHandle(ramBitmap.GetHicon());

            brush?.Dispose();
            ramBitmap?.Dispose();
            ramGraphics?.Dispose();
        }
Beispiel #7
0
        public override void DrawTextForSelectedNode(Graphics oGraphics, Node oSelectedNode)
        {
            Debug.Assert(oGraphics != null);
            Debug.Assert(oSelectedNode != null);
            AssertValid();
            FontForRectangle  fontForRectangle  = null;
            SolidBrush        solidBrush        = null;
            SolidBrush        solidBrush2       = null;
            TextRenderingHint textRenderingHint = TextRenderingHint.SystemDefault;

            try
            {
                fontForRectangle  = new FontForRectangle(m_sFontFamily, m_fFontSizePt, oGraphics);
                textRenderingHint = SetTextRenderingHint(oGraphics, fontForRectangle.Font);
                solidBrush        = new SolidBrush(m_oSelectedFontColor);
                solidBrush2       = new SolidBrush(m_oSelectedBackColor);
                StringFormat oNonLeafStringFormat = CreateStringFormat(bLeafNode: false);
                StringFormat oLeafStringFormat    = CreateStringFormat(bLeafNode: true);
                int          textHeight           = GetTextHeight(oGraphics, fontForRectangle.Font, m_iMinimumTextHeight);
                DrawTextForNode(oGraphics, oSelectedNode, fontForRectangle, textHeight, solidBrush, solidBrush2, oNonLeafStringFormat, oLeafStringFormat);
            }
            finally
            {
                solidBrush?.Dispose();
                solidBrush2?.Dispose();
                fontForRectangle?.Dispose();
                oGraphics.TextRenderingHint = textRenderingHint;
            }
        }
        /// <summary>
        /// 设置自动调整高度
        /// </summary>
        /// <param name="cb"></param>
        /// <param name="margin">边距</param>
        public static void AutoFitItemHeight(this ComboBox cb, int margin = 5)
        {
            if (null == cb)
            {
                return;
            }

            cb.DrawMode = DrawMode.OwnerDrawVariable;

            cb.DrawItem += (sender, e) =>
            {
                SolidBrush brush = null;

                try
                {
                    var cmb = sender as ComboBox;

                    brush = new SolidBrush(cmb.ForeColor);
                    Font ft = cmb.Font;

                    var text = cmb.GetItemText(cmb.Items[e.Index]);

                    // 计算字符串尺寸(以像素为单位)
                    var size = e.Graphics.MeasureString(text, cmb.Font);

                    // 水平居中
                    float left = 0;

                    //如果需要水平居中取消注释
                    //left = (float)(e.Bounds.Width - ss.Width) / 2;
                    if (left < 0)
                    {
                        left = 0f;
                    }

                    // 垂直居中
                    float top = (e.Bounds.Height - size.Height) / 2;
                    if (top <= 0)
                    {
                        top = 0f;
                    }

                    // 输出
                    e.DrawBackground();

                    e.Graphics.DrawString(text, ft, brush, new RectangleF(
                                              e.Bounds.X + left, //设置X坐标偏移量
                                              e.Bounds.Y + top,  //设置Y坐标偏移量
                                              e.Bounds.Width, e.Bounds.Height), StringFormat.GenericDefault);

                    //e.Graphics.DrawString(cmb.GetItemText(cmb.Items[e.Index]), ft, myBrush, e.Bounds, StringFormat.GenericDefault);
                    //e.DrawFocusRectangle();
                }
                catch (Exception ex) { }
                finally
                {
                    brush?.Dispose();
                }
            };
        }
        public void DrawDiskUsage(object sender, PerformanceCounterEventArgs performanceCounterEventArgs)
        {
            diskReadTotalIcon?.Icon?.Dispose();

            Bitmap     diskBitmap   = new Bitmap(16, 16);
            Graphics   diskGraphics = Graphics.FromImage(diskBitmap);
            SolidBrush brush        = new SolidBrush(Color.White);

            string sDiskUsage = $"{performanceCounterEventArgs.DISKValue:#:##}";

            diskGraphics.Clear(Color.Transparent);

            //diskGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            //diskGraphics.CompositingQuality = CompositingQuality.HighQuality;
            //diskGraphics.SmoothingMode = SmoothingMode.AntiAlias;

            diskGraphics.DrawImageUnscaled(diskBitmap, 0, 0);

            diskGraphics.DrawString(sDiskUsage,
                                    new Font("Trebuchet MS", 8.8f, FontStyle.Regular, GraphicsUnit.Pixel),
                                    brush,
                                    new RectangleF(0, 3, 16, 13));

            diskGraphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            diskReadTotalIcon.Icon         = Icon.FromHandle(diskBitmap.GetHicon());

            diskBitmap?.Dispose();
            diskGraphics?.Dispose();
            brush?.Dispose();
Beispiel #10
0
        public override void DrawTextForSelectedNode(Graphics oGraphics, Node oSelectedNode)
        {
            Debug.Assert(oGraphics != null);
            Debug.Assert(oSelectedNode != null);
            AssertValid();
            IFontMapper       fontMapper        = null;
            Brush             brush             = null;
            TextRenderingHint textRenderingHint = TextRenderingHint.SystemDefault;

            try
            {
                fontMapper = CreateFontMapper(oGraphics);
                brush      = new SolidBrush(m_oSelectedFontColor);
                if (fontMapper.NodeToFont(oSelectedNode, oSelectedNode.Level, oGraphics, out Font oFont, out string sTextToDraw))
                {
                    textRenderingHint = SetTextRenderingHint(oGraphics, oFont);
                    StringFormat format = CreateStringFormat();
                    oGraphics.DrawString(sTextToDraw, oFont, brush, oSelectedNode.Rectangle, format);
                }
            }
            finally
            {
                fontMapper?.Dispose();
                brush?.Dispose();
                oGraphics.TextRenderingHint = textRenderingHint;
            }
        }
Beispiel #11
0
        public void SwitchBox()
        {
            switch (BoxType)
            {
            case BoxType.Normal:
                Brush?.Dispose();
                Brush   = new SolidBrush(Color.Gray);
                BoxType = BoxType.Wall;
                break;

            case BoxType.Wall:
                Brush?.Dispose();
                Brush   = new SolidBrush(Color.WhiteSmoke);
                BoxType = BoxType.Normal;
                break;
            }
        }
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         _transparentBrush?.Dispose();
         _greenPen?.Dispose();
         _greenBrush?.Dispose();
     }
 }
        public override int Shutdown()
        {
            SaveConfiguration(Config);

            try
            {
                if (_windowEventGCHandle.IsAllocated)
                {
                    _windowEventGCHandle.Free();
                }

                if (_windowEventHook != IntPtr.Zero)
                {
                    WinEventHook.WinEventUnhook(_windowEventHook);
                }

                _windowEventDispatcher?.InvokeShutdown();
            }
            catch (Exception ex)
            {
                _hostDelegates.ExceptionMessage(ex);
            }

            _black?.Dispose();
            _white?.Dispose();
            _green?.Dispose();
            _lawngreen?.Dispose();
            _grey?.Dispose();
            _darkergrey?.Dispose();
            _red?.Dispose();
            _darkred?.Dispose();
            _gold?.Dispose();
            _goldenrod?.Dispose();
            _violet?.Dispose();

            _consolas14Bold?.Dispose();
            _consolas16Bold?.Dispose();
            _consolas32Bold?.Dispose();

            _characterSheet?.Dispose();
            _characterToImageTranslation = null;

            _windowEventHook       = IntPtr.Zero;
            _windowEventDispatcher = null;

            _device = null;
            _graphics?.Dispose();
            _graphics = null;
            _window?.Dispose();
            _window = null;

            _isOverlayInitialized = false;
            _isOverlayReady       = false;

            return(0);
        }
            protected override void Dispose(bool disposing)
            {
                if (disposing)
                {
                    _watermarkBrush?.Dispose();
                    _watermarkBrush = null;
                }

                base.Dispose(disposing);
            }
Beispiel #15
0
        private void ChangeBackgroundColorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (colorDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            _backgroundColorItem?.Dispose();
            _backgroundColorItem = new SolidBrush(colorDialog.Color);
            listView1.Refresh();
        }
Beispiel #16
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         components?.Dispose();
         backgroundBrush?.Dispose();
         borderPen?.Dispose();
         hotTrackBrush?.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #17
0
        private void DrawAddress(Graphics g, int startLine, int line)
        {
            string s     = ((startLine + line) * columnCount).ToString("X8", CultureInfo.InvariantCulture);
            Brush  brush = new SolidBrush(ForeColor);

            try {
                g.DrawString(s, ADDRESS_FONT, brush, 5f, 7 + line * 21);
            } finally {
                brush?.Dispose();
            }
        }
Beispiel #18
0
        void Dispose(bool _)
        {
            if (!disposed)
            {
                raw?.ForEach(b => b.Value?.Dispose());

                txtFont?.Dispose();
                txtBrush?.Dispose();

                disposed = true;
            }
        }
Beispiel #19
0
        private (double height, double width) measureText(string text, ExcelFont excelFont, int width)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(0, 0);
            }

            Font       drawFont     = null;
            SolidBrush drawBrush    = null;
            Graphics   drawGraphics = null;
            Bitmap     textBitmap   = null;

            try
            {
                // start with empty bitmap, get it's graphic's object
                // and choose a font
                textBitmap   = new Bitmap(1, 1);
                drawGraphics = Graphics.FromImage(textBitmap);
                drawFont     = new Font(excelFont.Name, excelFont.Size);


                width = (int)(width * 7.5) * text.Length;
                // see how big the text will be
                var size = drawGraphics.MeasureString(text, drawFont, width);


                //// recreate the bitmap and graphic object with the new size
                //textBitmap = new Bitmap(textBitmap, Width, Height);
                //drawGraphics = Graphics.FromImage(textBitmap);


                //// get the drawing brush and where we're going to draw
                //drawBrush = new SolidBrush(Color.Black);
                //PointF DrawPoint = new PointF(0, 0);


                // draw
                //// clear the graphic white and draw the string
                //DrawGraphics.Clear(Color.White);
                //DrawGraphics.DrawString(TheText, DrawFont, DrawBrush, DrawPoint);


                //TextBitmap.Save("bmp2\\" + Guid.NewGuid().ToString() + ".bmp");
                return(size.Height, size.Width);
            }
            finally
            {
                // don't dispose the bitmap, the caller needs it.
                drawFont?.Dispose();
                drawBrush?.Dispose();
                drawGraphics?.Dispose();
            }
        }
Beispiel #20
0
        private void DeleteStrengthBar()
        {
            _strengthBar?.Dispose();
            _brush?.Dispose();

            SolidBrush deleteBrush     = new SolidBrush(this.BackColor);
            Graphics   deleteRectangle = pnlMeter.CreateGraphics();

            deleteRectangle.FillRectangle(deleteBrush, 1, 1, pnlMeter.Width - 1, pnlMeter.Height - 1);
            deleteRectangle.Dispose();
            deleteBrush.Dispose();
        }
        /// <summary>
        /// Paint on the ruler ticks
        /// </summary>
        private void RulerHorz_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            e.Graphics.FillRectangle(new SolidBrush(RulerHorz.BackColor), e.ClipRectangle);

            Pen        DrawPen   = new Pen(Color.Black);
            SolidBrush TextBrush = new SolidBrush(RulerHorz.ForeColor);

            RectangleF Rect;
            string     Text = string.Empty;

            // Determine the offset for the Ruler
            // First account for the difference in where the ruler's origin is vs the Workspace's origin.
            int StartTick = pnlWorkspace.Location.X - RulerHorz.Location.X;

            // Next, determine where the origin of the Canvas is relative to this point
            StartTick += pnlEasel.Location.X;
            StartTick += CanvasPane.Location.X;

            //Debug.WriteLine(CanvasPane.Location);

            int Tick    = 0;
            int Bump    = 0;
            int TextPos = 0;

            for (int x = 0; x <= _Document.Scaling.LatticeSize.Width; x++)
            {
                Tick = StartTick + (x * _Document.Scaling.CellScale);
                Bump = (x % 10 == 0) ? 12 : ((x % 10 == 5) ? 8 : 6);
                e.Graphics.DrawLine(DrawPen, new Point(Tick, RulerHorz.Height - Bump), new Point(Tick, RulerHorz.Height));

                if (x % 10 == 0)
                {
                    Text          = x.ToString();
                    TextPos       = RulerHorz.Height - Bump;
                    Rect          = new RectangleF(new Point(Tick, TextPos), e.Graphics.MeasureString(Text, RulerHorz.Font));
                    TextPos      -= (int)Rect.Height;
                    Rect.Location = new PointF(Tick - (Rect.Width / 2), TextPos);
                    e.Graphics.DrawString(Text, RulerHorz.Font, TextBrush, Rect, _rulerTextFormatter);
                }
            }

            // If the mouse is over the CanvasPane, draw the position tick mark
            if (_mouseOverCanvasPane)
            {
                Tick = StartTick + _global.CalcCanvasPoint(_global.UI.MousePosition).X;
                e.Graphics.DrawLine(DrawPen, new Point(Tick, RulerHorz.Top), new Point(Tick, RulerHorz.Height));
            }

            DrawPen?.Dispose();
            TextBrush?.Dispose();
        }
Beispiel #22
0
        public void BeVisible()
        {
            switch (BoxType)
            {
            case BoxType.Normal:
                _brush = Globals.SemiTransparency ? new SolidBrush(Globals.SemiTransparent) : new SolidBrush(Color.WhiteSmoke);
                break;

            case BoxType.Wall:
                _brush?.Dispose();
                BoxType = BoxType.Normal;
                break;
            }
        }
Beispiel #23
0
            private void DrawBars(Graphics graph)
            {
                SolidBrush   solidBrush   = null;
                Font         font         = null;
                StringFormat stringFormat = null;

                try
                {
                    solidBrush             = new SolidBrush(this._fontColor);
                    font                   = new Font(this._fontFamily, 7f);
                    stringFormat           = new StringFormat();
                    stringFormat.Alignment = StringAlignment.Center;
                    int num = 0;
                    foreach (ChartItem dataPoint in base.DataPoints)
                    {
                        using (SolidBrush brush = new SolidBrush(dataPoint.ItemColor))
                        {
                            float num2 = (dataPoint.SweepSize == 0f) ? 2f : dataPoint.SweepSize;
                            float num3 = this._yOrigin + this._graphHeight - num2;
                            graph.FillRectangle(brush, this._xOrigin + dataPoint.StartPos + (this._barWidth / 2f - 8f), num3, 16f, num2);
                            if (this._displayBarData)
                            {
                                float      x = this._xOrigin + (float)num * (this._barWidth + this._spaceBtwBars);
                                float      y = num3 - 2f - (float)font.Height;
                                RectangleF layoutRectangle = new RectangleF(x, y, this._barWidth + this._spaceBtwBars, (float)font.Height);
                                float      value           = dataPoint.Value;
                                object     s;
                                if (!(value.ToString(CultureInfo.InvariantCulture) == "0.0"))
                                {
                                    value = dataPoint.Value;
                                    s     = value.ToString(CultureInfo.InvariantCulture);
                                }
                                else
                                {
                                    s = "0";
                                }
                                graph.DrawString((string)s, font, solidBrush, layoutRectangle, stringFormat);
                            }
                            num++;
                        }
                    }
                }
                finally
                {
                    solidBrush?.Dispose();
                    font?.Dispose();
                    stringFormat?.Dispose();
                }
            }
Beispiel #24
0
        // Paints the content that spans multiple columns and the focus rectangle.
        private void bookmarksDataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            SolidBrush forebrush = null;

            try
            {
                // Determine the foreground color.
                forebrush = (e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected
                    ? new SolidBrush(e.InheritedRowStyle.SelectionForeColor)
                    : new SolidBrush(e.InheritedRowStyle.ForeColor);
            }
            finally
            {
                forebrush?.Dispose();
            }
        }
        /// <summary>
        /// Paint on the ruler ticks
        /// </summary>
        private void RulerVert_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            e.Graphics.FillRectangle(SystemBrushes.Control, e.ClipRectangle);
            Pen        DrawPen = new Pen(Color.Black);
            RectangleF Rect;
            SolidBrush TextBrush = new SolidBrush(RulerVert.ForeColor);
            string     Text      = string.Empty;

            // Determine the offset for the Ruler
            // First account for the difference in where the ruler's origin is vs the Workspace's origin.
            int StartTick = pnlWorkspace.Location.Y - RulerVert.Location.Y;

            // Next, determine where the origin of the Canvas is relative to this point
            StartTick += pnlEasel.Location.Y;
            StartTick += CanvasPane.Location.Y;
            int Tick    = 0;
            int Bump    = 0;
            int TextPos = 0;

            for (int y = 0; y <= _Document.Scaling.LatticeSize.Height; y++)
            {
                Tick = StartTick + (y * _Document.Scaling.CellScale);
                Bump = (y % 10 == 0) ? 12 : ((y % 10 == 5) ? 8 : 6);
                e.Graphics.DrawLine(DrawPen, new Point(RulerVert.Width - Bump, Tick), new Point(RulerVert.Width, Tick));

                if (y % 10 == 0)
                {
                    Text          = y.ToString();
                    TextPos       = RulerVert.Width - Bump;
                    Rect          = new RectangleF(new Point(TextPos, Tick), e.Graphics.MeasureString(Text, RulerVert.Font));
                    TextPos      -= (int)Rect.Width;
                    Rect.Location = new PointF(TextPos, Tick - (Rect.Height / 2));
                    e.Graphics.DrawString(Text, RulerVert.Font, TextBrush, Rect, _rulerTextFormatter);
                }
            }

            // If the mouse is over the CanvasPane, draw the position tick mark
            if (_mouseOverCanvasPane)
            {
                Tick = StartTick + _global.CalcCanvasPoint(_global.UI.MousePosition).Y;
                e.Graphics.DrawLine(DrawPen, new Point(RulerVert.Left, Tick), new Point(RulerVert.Width, Tick));
            }

            DrawPen?.Dispose();
            TextBrush?.Dispose();
        }
Beispiel #26
0
        public void SwitchLoad()
        {
            switch (BoxType)
            {
            case BoxType.Normal:
                _brush?.Dispose();
                _brush  = new SolidBrush(_myBrown);
                BoxType = BoxType.Load;
                break;

            case BoxType.Load:
                _brush?.Dispose();

                _brush  = Globals.SemiTransparency ? new SolidBrush(Globals.SemiTransparent) : new SolidBrush(Color.WhiteSmoke);
                BoxType = BoxType.Normal;
                break;
            }
        }
Beispiel #27
0
            private void DrawLegend(Graphics graph)
            {
                Font         font         = null;
                SolidBrush   solidBrush   = null;
                StringFormat stringFormat = null;
                Pen          pen          = null;

                try
                {
                    font                   = new Font(this._fontFamily, 9f);
                    solidBrush             = new SolidBrush(this._fontColor);
                    stringFormat           = new StringFormat();
                    pen                    = new Pen(this._fontColor);
                    stringFormat.Alignment = StringAlignment.Near;
                    float num     = this._xOrigin + this._graphWidth + 6f;
                    float yOrigin = this._yOrigin;
                    float num2    = num + 5f;
                    float x       = num2 + 10f + 5f;
                    float num3    = 0f;
                    int   num4    = 0;
                    for (int i = 0; i < base.DataPoints.Count; i++)
                    {
                        ChartItem chartItem = base.DataPoints[i];
                        string    s         = chartItem.Description + "(" + chartItem.Label + ")";
                        num3 += (float)font.Height + 5f;
                        float num5 = yOrigin + 5f + (float)(i - num4) * ((float)font.Height + 5f);
                        graph.DrawString(s, font, solidBrush, x, num5, stringFormat);
                        graph.FillRectangle(new SolidBrush(base.DataPoints[i].ItemColor), num2, num5 + 3f, 10f, 10f);
                    }
                    graph.DrawRectangle(pen, num, yOrigin, this._legendWidth, num3 + 5f);
                }
                finally
                {
                    font?.Dispose();
                    solidBrush?.Dispose();
                    stringFormat?.Dispose();
                    pen?.Dispose();
                }
            }
Beispiel #28
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }

            borderDotPen?.Dispose();
            borderPen?.Dispose();
            infoFont?.Dispose();
            magnifierBorderPen?.Dispose();
            magnifierBorderPen?.Dispose();
            magnifierCrosshairBrush?.Dispose();
            textBackgroundBrush?.Dispose();
            textFontBrush?.Dispose();

            image?.Dispose();
            backgroundBrush?.Dispose();
            backgroundHighlightBrush?.Dispose();

            base.Dispose(disposing);
        }
Beispiel #29
0
            private void DrawVerticalLabelArea(Graphics graph)
            {
                Font         font          = null;
                SolidBrush   solidBrush    = null;
                StringFormat stringFormat  = null;
                Pen          pen           = null;
                StringFormat stringFormat2 = null;

                try
                {
                    font                   = new Font(this._fontFamily, 7f);
                    solidBrush             = new SolidBrush(this._fontColor);
                    stringFormat           = new StringFormat();
                    pen                    = new Pen(this._fontColor);
                    stringFormat2          = new StringFormat();
                    stringFormat.Alignment = StringAlignment.Near;
                    RectangleF layoutRectangle = new RectangleF(0f, this._yOrigin - 10f - (float)font.Height, this._xOrigin * 2f, (float)font.Height);
                    stringFormat2.Alignment = StringAlignment.Center;
                    graph.DrawString(this._yLabel, font, solidBrush, layoutRectangle, stringFormat2);
                    for (int i = 0; i < this._yTickCount; i++)
                    {
                        float      num = this._topBuffer + (float)i * this._yTickValue / this._scaleFactor;
                        float      y   = num - (float)(font.Height / 2);
                        RectangleF layoutRectangle2 = new RectangleF(5f, y, this._maxTickValueWidth, (float)font.Height);
                        graph.DrawString((this._maxValue - (float)i * this._yTickValue).ToString("#,###.##"), font, solidBrush, layoutRectangle2, stringFormat);
                        graph.DrawLine(pen, this._xOrigin, num, this._xOrigin - 4f, num);
                    }
                    graph.DrawLine(pen, this._xOrigin, this._yOrigin, this._xOrigin, this._yOrigin + this._graphHeight);
                }
                finally
                {
                    font?.Dispose();
                    solidBrush?.Dispose();
                    stringFormat?.Dispose();
                    pen?.Dispose();
                    stringFormat2?.Dispose();
                }
            }
 public virtual void DoPaint(Graphics gr)
 {
     if ((this.GetRules() & SelectionRules.Visible) != SelectionRules.None)
     {
         bool primary = false;
         if (this.selUIsvc.selSvc != null)
         {
             primary = this.component == this.selUIsvc.selSvc.PrimarySelection;
             primary = primary == (this.selUIsvc.selSvc.SelectionCount <= 1);
         }
         Rectangle rectangle = new Rectangle(this.outerRect.X, this.outerRect.Y, 7, 7);
         Rectangle innerRect = this.innerRect;
         Rectangle outerRect = this.outerRect;
         Region clip = gr.Clip;
         System.Drawing.Color control = SystemColors.Control;
         if ((this.control != null) && (this.control.Parent != null))
         {
             control = this.control.Parent.BackColor;
         }
         Brush brush = new SolidBrush(control);
         gr.ExcludeClip(innerRect);
         gr.FillRectangle(brush, outerRect);
         brush.Dispose();
         gr.Clip = clip;
         ControlPaint.DrawSelectionFrame(gr, false, outerRect, innerRect, control);
         if (((this.GetRules() & (SelectionRules.None | SelectionRules.Locked)) == SelectionRules.None) && ((this.GetRules() & SelectionRules.AllSizeable) != SelectionRules.None))
         {
             ControlPaint.DrawGrabHandle(gr, rectangle, primary, this.sizes[0] != 0);
             rectangle.X = innerRect.X + innerRect.Width;
             ControlPaint.DrawGrabHandle(gr, rectangle, primary, this.sizes[2] != 0);
             rectangle.Y = innerRect.Y + innerRect.Height;
             ControlPaint.DrawGrabHandle(gr, rectangle, primary, this.sizes[7] != 0);
             rectangle.X = outerRect.X;
             ControlPaint.DrawGrabHandle(gr, rectangle, primary, this.sizes[5] != 0);
             rectangle.X += (outerRect.Width - 7) / 2;
             ControlPaint.DrawGrabHandle(gr, rectangle, primary, this.sizes[6] != 0);
             rectangle.Y = outerRect.Y;
             ControlPaint.DrawGrabHandle(gr, rectangle, primary, this.sizes[1] != 0);
             rectangle.X = outerRect.X;
             rectangle.Y = innerRect.Y + ((innerRect.Height - 7) / 2);
             ControlPaint.DrawGrabHandle(gr, rectangle, primary, this.sizes[3] != 0);
             rectangle.X = innerRect.X + innerRect.Width;
             ControlPaint.DrawGrabHandle(gr, rectangle, primary, this.sizes[4] != 0);
         }
         else
         {
             ControlPaint.DrawLockedFrame(gr, outerRect, primary);
         }
     }
 }
Beispiel #31
0
 public void Dispose()
 {
     font?.Dispose();
     foreBrush?.Dispose();
 }
Beispiel #32
0
 // ===================================================================
 private void DrawBar(Rectangle rect, Line line, ref Graphics g)
 {
     SolidBrush barBrush = new SolidBrush(line.m_Color);
     g.FillRectangle(barBrush, rect);
     barBrush.Dispose();
 }
Beispiel #33
0
            // ===================================================================
            protected void DrawLabels(ref Graphics g)
            {
                SizeF maxSize = g.MeasureString(m_MaxLabel, Font);
                SizeF minSize = g.MeasureString(m_MinLabel, Font);

                int textWidth = (int)((maxSize.Width > minSize.Width)
                                ? maxSize.Width
                                : minSize.Width) + 6;

                SolidBrush textBrush = new SolidBrush(m_TextColor);

                /* Draw the labels (max: Top) (min: Bottom) */

                g.DrawString(m_MaxLabel, Font, textBrush,
                              textWidth / 2 - (maxSize.Width / 2),
                              2);

                g.DrawString(m_MinLabel, Font, textBrush,
                              textWidth / 2 - (minSize.Width / 2),
                              Height - minSize.Height - 2);

                textBrush.Dispose();

                /* Draw the bordering line */

                Pen borderPen = new Pen(m_GridColor, 1);
                g.DrawLine(borderPen, textWidth + 6, 0, textWidth + 6, Height);

                borderPen.Dispose();

                /* Update the offset so we don't draw the graph over the labels */
                m_OffsetX = textWidth + 6;
            }