Пример #1
0
        /// <summary>
        /// Draws the background of the parent control giving a transparent effect
        /// </summary>
        /// <param name="graphics">Drawing surface</param>
        /// <param name="form">Parent Container that implements <see cref="IControlBackground"/></param>
        /// <param name="bounds">Bounds of the Control</param>
        /// <param name="parent">Instance of the Parent Container</param>
        public void DrawBackground(Graphics graphics, IControlBackground form, Rectangle bounds, Control parent)
        {
            if (form.BackgroundImage == null)
            {
                return;
            }

            var g = GraphicsEx.FromGraphics(graphics);

            switch (form.BackgroundDrawMode)
            {
            case ImageDrawMode.Normal:
                g.DrawImage(form.BackgroundImage, 0, 0, bounds);
                break;

            case ImageDrawMode.Center:
                Point location = GraphicsEx.GetCenter(form.BackgroundImage.Size, parent.ClientSize);
                g.DrawImage(form.BackgroundImage,
                            location.X,
                            location.Y,
                            new Rectangle(bounds.X,
                                          bounds.Y,
                                          form.BackgroundImage.Width,
                                          form.BackgroundImage.Height));
                break;

            case ImageDrawMode.Stretch:
                using (Image image = ImageManipulator.Stretch(form.BackgroundImage, parent.ClientSize))
                    g.DrawImage(image, 0, 0, bounds);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private void DrawInstructor(string drawText, Graphics g)
        {
            if (Engine.ConfigUI.CropRegionHotkeyInfo)
            {
                Font posFont  = new Font(FontFamily.GenericSansSerif, 8);
                Size textSize = TextRenderer.MeasureText(drawText, posFont);

                Point textPos = PointToClient(new Point(screenBound.Left +
                                                        (screenBound.Width / 2) - ((textSize.Width + 10) / 2), screenBound.Top + 30));

                Rectangle labelRect = new Rectangle(textPos, new Size(textSize.Width + 30, textSize.Height + 10));

                if (PointIntersectsRectangle(mousePos, labelRect))
                {
                    textPos = PointToClient(new Point(screenBound.Left +
                                                      (screenBound.Width / 2) - ((textSize.Width + 10) / 2), screenBound.Bottom - textSize.Height - 30));
                    labelRect = new Rectangle(textPos, new Size(textSize.Width + 30, textSize.Height + 10));
                }

                using (GraphicsPath gPath = GraphicsEx.GetRoundedRectangle(labelRect, 7))
                {
                    g.FillPath(new LinearGradientBrush(new Point(labelRect.X, labelRect.Y), new Point(labelRect.X +
                                                                                                      labelRect.Width, labelRect.Y), Color.White, Color.FromArgb(150, Color.White)), gPath);
                    g.DrawPath(labelBorderPen, gPath);
                }
                g.DrawString(drawText, posFont, new SolidBrush(Color.Black), labelRect.X + 5, labelRect.Y + 5);
            }
        }
        private void DrawTooltip(string text, Point offset, Graphics g)
        {
            g.SmoothingMode     = SmoothingMode.HighQuality;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            Font      font      = new Font(FontFamily.GenericSansSerif, 8);
            Point     mPos      = mousePos;
            Rectangle labelRect = new Rectangle(new Point(mPos.X + offset.X, mPos.Y + offset.Y),
                                                new Size(TextRenderer.MeasureText(text, font).Width + 10, TextRenderer.MeasureText(text, font).Height + 10));

            if (labelRect.Right > clientBound.Right - 5)
            {
                labelRect.X = mPos.X - offset.X - labelRect.Width;
            }
            if (labelRect.Bottom > clientBound.Bottom - 5)
            {
                labelRect.Y = mPos.Y - offset.Y - labelRect.Height;
            }
            using (GraphicsPath gPath = GraphicsEx.GetRoundedRectangle(labelRect, 6))
            {
                g.FillPath(new LinearGradientBrush(new Point(labelRect.X, labelRect.Y),
                                                   new Point(labelRect.X + labelRect.Width, labelRect.Y), Color.FromArgb(200, Color.Black), Color.FromArgb(100, Color.Black)), gPath);
                g.DrawPath(labelBorderPen, gPath);
            }
            g.DrawString(text, font, new SolidBrush(Color.White), labelRect.X + 5, labelRect.Y + 5);
            if ((!selectedWindowMode || (selectedWindowMode && dragging)) && Engine.ConfigUI.CropShowMagnifyingGlass)
            {
                int posY = labelRect.Y - offset.Y * 2 - 100;
                if (posY < 5)
                {
                    posY = labelRect.Y + labelRect.Height + 10;
                }
                g.DrawImage(HelpersLib.GraphicsHelper.Core.MagnifyingGlass((Bitmap)bmpClean, mousePos, 100, 5), labelRect.X, posY);
            }
        }
Пример #4
0
        /// <summary>
        /// Raised when the form is painted
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            using (var buffer = new Bitmap(Bounds.Width, Bounds.Height))
            {
                using (var g = GraphicsEx.FromImage(buffer))
                {
                    g.GradientFill(
                        Bounds,
                        Color.DarkBlue,
                        Color.LightBlue,
                        GradientFillDirection.Vertical);

                    using (var font = FontFactory.CreateRotatedFont(Font.Name, 50))
                    {
                        var size = g.Surface.MeasureString(Text, font);
                        var x    = (Bounds.Width - size.Width) / 2f;

                        using (var brush = new SolidBrush(ForeColor))
                            g.Surface.DrawString(Text, font, brush, x, Dpi.Scale(5));
                    }
                }

                e.Graphics.DrawImage(buffer, 0, 0);
            }
        }
Пример #5
0
        private void DoDrawAxes(GraphicsEx g, Pen pen, Brush brush, RectF area)
        {
            float w = (float)this.Width;
            float h = (float)this.Height;


            g.DrawLine(pen, 0, h - cBottomOffset, w, h - cBottomOffset);
            g.DrawLine(pen, w - cArrowOffset, h - cBottomOffset - cArrowOffset / 2, w, h - cBottomOffset);
            g.DrawLine(pen, w - cArrowOffset, h - cBottomOffset + cArrowOffset / 2, w, h - cBottomOffset);

            foreach (var element in m_currentState.XPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, x, y - cArrowSize, x, y + cArrowSize);
                g.DrawString(element.X.ToString(), this.Font, brush, x - cLeftOffset, y + cBottomOffset / 3);
            }

            g.DrawLine(pen, w - cRightOffset, 0, w - cRightOffset, h);
            g.DrawLine(pen, w - cRightOffset - cArrowOffset / 2, cArrowOffset, w - cRightOffset, 0);
            g.DrawLine(pen, w - cRightOffset + cArrowOffset / 2, cArrowOffset, w - cRightOffset, 0);



            foreach (var element in m_currentState.YPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, x - cArrowSize, y, x + cArrowSize, y);
                g.DrawString(element.Y.ToString(m_parameters.PriceFormat), this.Font, brush, x, y + +cBottomOffset / 3);
            }
        }
Пример #6
0
        private static void DrawStretched(Image image, GraphicsEx graphics)
        {
            ImageAttributes attributes = GetImageAttributes(image);

            graphics.DrawImage(image,
                               new Rectangle(0, 0, image.Width, image.Height),
                               new Rectangle(0, 0, image.Width, image.Height),
                               attributes);
        }
Пример #7
0
        private void DrawNormal(GraphicsEx graphics)
        {
            ImageAttributes attributes = GetImageAttributes(Image);

            graphics.DrawImage(Image,
                               new Rectangle(0, 0, Image.Width, Image.Height),
                               new Rectangle(0, 0, Image.Width, Image.Height),
                               attributes);
        }
Пример #8
0
        private void DrawCentered(GraphicsEx graphics)
        {
            Point           location   = GraphicsEx.GetCenter(ClientSize, Image.Size);
            ImageAttributes attributes = GetImageAttributes(Image);

            graphics.DrawImage(Image,
                               new Rectangle(location.X, location.Y, Image.Width, Image.Height),
                               new Rectangle(0, 0, Image.Width, Image.Height),
                               attributes);
        }
Пример #9
0
 internal void DrawInterpolation(GraphicsEx g, Color bidColor, Color askColor)
 {
     using (Pen pen = new Pen(bidColor, 1))
     {
         m_bids.DrawInterpolation(g, pen);
     }
     using (Pen pen = new Pen(askColor, 1))
     {
         m_asks.DrawInterpolation(g, pen);
     }
 }
Пример #10
0
 internal void DrawStepped(GraphicsEx g, Color bidColor, Color askColor)
 {
     using (Pen pen = new Pen(bidColor, 1))
     {
         m_bids.DrawStepped(g, pen);
     }
     using (Pen pen = new Pen(askColor, 1))
     {
         m_asks.DrawStepped(g, pen);
     }
 }
Пример #11
0
 private void DoDraw(GraphicsEx g)
 {
     if (!m_currentState.Empty)
     {
         DoDrawData(g);
     }
     else
     {
         DoDrawEmpty(g);
     }
 }
Пример #12
0
        private void DoDrawEmpty(GraphicsEx g)
        {
            SizeF size = g.MeasureString(cOffQuotes, this.Font);
            float w    = (float)this.Width;
            float h    = (float)this.Height;

            float x = (w - size.Width) / 2;
            float y = (h - size.Height) / 2;

            g.DrawString(cOffQuotes, this.Font, m_settings.ForegroundColor, x, y);
        }
Пример #13
0
        /// <summary>
        /// Draws the Image
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Parent == null && Image == null)
            {
                base.OnPaint(e);
                return;
            }

            using (var g = GraphicsEx.FromImage(MemoryBitmap))
            {
                var form = Parent as IControlBackground;
                if (!pushed)
                {
                    if (form != null && Transparent && form.BackgroundImage != null)
                    {
                        DrawBackground(g.Surface, form, Bounds, Parent);
                    }
                    else if (Parent != null)
                    {
                        g.Surface.Clear(Parent.BackColor);
                    }
                }

                if (Image != null)
                {
                    switch (SizeMode)
                    {
                    case PictureBoxSizeMode.Normal:
                        DrawNormal(g);
                        break;

                    case PictureBoxSizeMode.CenterImage:
                        DrawCentered(g);
                        break;

                    case PictureBoxSizeMode.StretchImage:
                        DrawStretched(g);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                if (pushed && form != null && form.BackgroundImage != null)
                {
                    g.AlphaBlend(form.BackgroundImage, 170, Location.X, Location.Y);
                }
            }

            e.Graphics.DrawImage(MemoryBitmap, 0, 0);
        }
Пример #14
0
        /// <summary>
        /// Draws the control
        /// </summary>
        /// <param name="e">Drawing surface data</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            using (var gxOff = GraphicsEx.FromImage(MemoryBitmap))
            {
                gxOff.Surface.Clear(Parent.BackColor);
                if (Environment.OSVersion.Platform != PlatformID.WinCE)
                {
                    gxOff.Surface.DrawRectangle(
                        border,
                        0, 0, ClientSize.Width - 1, ClientSize.Height - 1);
                }

                if (Pushed)
                {
                    gxOff.DrawRoundedRectangle(ClientRectangle, PressedColor);
                }

                DrawImage(gxOff);

                if (!string.IsNullOrEmpty(Text))
                {
                    var size = gxOff.Surface.MeasureString(Text, Font);
                    gxOff.Surface.DrawString(
                        Text,
                        Font,
                        text,
                        (ClientSize.Width - size.Width) / 2,
                        (ClientSize.Height - size.Height));
                }

                if (Transparent)
                {
                    try
                    {
                        var bgOwner = Parent as IControlBackground;
                        if (bgOwner != null && bgOwner.BackgroundImage != null)
                        {
                            gxOff.AlphaBlend(bgOwner.BackgroundImage, 70, Location.X, Location.Y);
                        }
                    }
                    catch (PlatformNotSupportedException ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }

            e.Graphics.DrawImage(MemoryBitmap, 0, 0);
        }
Пример #15
0
        private void Draw(Graphics g)
        {
            int width  = this.Width;
            int height = this.Height;

            using (Bitmap image = new Bitmap(width, height, g))
            {
                using (Graphics g2 = Graphics.FromImage(image))
                {
                    GraphicsEx gEx = new GraphicsEx(g2);
                    gEx.FillRectangle(m_settings.BackgroundColor, 0, 0, width, height);
                    gEx.SetRenderingMode(m_settings.Mode);
                    DoDraw(gEx);
                    g.DrawImage(image, 0, 0);
                }
            }
        }
Пример #16
0
        private void DrawLine(GraphicsEx g, Graph graph, Color bidColor, Color askColor)
        {
            LineType type = m_settings.Type;

            if (LineType.Straight == type)
            {
                graph.DrawStraight(g, bidColor, askColor);
            }
            else if (LineType.Stepped == type)
            {
                graph.DrawStepped(g, bidColor, askColor);
            }
            else if (LineType.Interpolation == type)
            {
                graph.DrawInterpolation(g, bidColor, askColor);
            }
        }
Пример #17
0
        /// <summary>
        /// Draws the control
        /// </summary>
        /// <param name="e">Drawing surface data</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            using (var gxOff = GraphicsEx.FromImage(MemoryBitmap))
            {
                if (!Pushed)
                {
                    gxOff.GradientFill(ClientRectangle, GradientStart, GradientEnd, GradientFillDirection.Vertical);
                }
                else
                {
                    gxOff.GradientFill(ClientRectangle, GradientEnd, GradientStart, GradientFillDirection.Vertical);
                }

                gxOff.Surface.DrawRectangle(border, 0, 0, ClientSize.Width - 1, ClientSize.Height - 1);

                if (!string.IsNullOrEmpty(Text))
                {
                    var size = gxOff.Surface.MeasureString(Text, Font);
                    gxOff.Surface.DrawString(
                        Text,
                        Font,
                        text,
                        (ClientSize.Width - size.Width) / 2,
                        (ClientSize.Height - size.Height) / 2);
                }

                if (Transparent)
                {
                    try
                    {
                        var bgOwner = Parent as IControlBackground;
                        if (bgOwner != null && bgOwner.BackgroundImage != null)
                        {
                            gxOff.AlphaBlend(bgOwner.BackgroundImage, 70, Location.X, Location.Y);
                        }
                    }
                    catch (PlatformNotSupportedException ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }

            e.Graphics.DrawImage(MemoryBitmap, 0, 0);
        }
Пример #18
0
        private void DoDrawGrid(GraphicsEx g, Pen pen, RectF area)
        {
            foreach (var element in m_currentState.XPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, x, y, x, 0);
            }

            foreach (var element in m_currentState.YPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, 0, y, x, y);
            }
        }
Пример #19
0
        /// <summary>
        /// create stringformat for element
        /// </summary>
        private StringFormat CreateStringFormat()
        {
            StringFormat _fmt = new StringFormat(StringFormatFlags.NoWrap);

            _fmt.Trimming = StringTrimming.EllipsisCharacter;
            if (_textvertical)
            {
                _fmt.FormatFlags |=
                    StringFormatFlags.DirectionVertical;
            }
            //
            StringAlignment alignment, linealignment;

            GraphicsEx.GetStringAlignmentFromAlignment(_textalign,
                                                       out alignment, out linealignment);
            _fmt.Alignment     = alignment;
            _fmt.LineAlignment = linealignment;
            return(_fmt);
        }
Пример #20
0
        private void DoDrawData(GraphicsEx g)
        {
            m_currentState.Refresh(m_settings);
            RectF area = m_currentState.PhysicalArea;

            float w = (float)this.Width - cLeftOffset - cRightOffset;
            float h = (float)this.Height - cBottomOffset - cTopOffset;

            float kx = w / area.Width;
            float ky = h / area.Height;

            RectF physical = area;

            RectF logical = new RectF(cLeftOffset, cTopOffset, cLeftOffset + w, cTopOffset + h);

            g.Physical = physical;
            g.Logical  = logical;

            int count = m_currentState.Graphs.Count;

            for (int index = 0; index < count; ++index)
            {
                Graph graph    = m_currentState.Graphs[index];
                Color bidColor = m_settings.Lines[index].BidColor;
                Color askColor = m_settings.Lines[index].AskColor;
                DrawLine(g, graph, bidColor, askColor);
            }

            using (Pen pen = new Pen(m_settings.ForegroundColor))
            {
                using (Brush brush = new SolidBrush(m_settings.ForegroundColor))
                {
                    DoDrawAxes(g, pen, brush, area);
                }
                if (m_settings.Grid)
                {
                    pen.DashPattern = new float[] { 10, 10 };
                    pen.Width       = 0.5F;
                    DoDrawGrid(g, pen, area);
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Draws the <see cref="BackgroundImage"/> property onto <see cref="MobileUserControl"/>
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (BackgroundImage == null)
            {
                return;
            }

            var image = BackgroundImage;

            if (AutoScaleBackgroundImage && Dpi.IsHiDpi)
            {
                image = ImageManipulator.Stretch(BackgroundImage, Dpi.ScaleSize(BackgroundImage.Size));
            }

            var gfx = GraphicsEx.FromGraphics(e.Graphics);

            gfx.DrawImage(image, ClientSize, BackgroundDrawMode);
        }
        private void DrawHelpText(Graphics g)
        {
            if (Engine.ConfigUI.FreehandCropShowHelpText)
            {
                g.CompositingMode = CompositingMode.SourceOver;
                g.SmoothingMode   = SmoothingMode.HighSpeed;

                using (Font helpTextFont = new XFont("Arial", 10))
                {
                    Size      textSize  = Size.Round(g.MeasureString(helpText, helpTextFont, 500, StringFormat.GenericTypographic));
                    Point     textPos   = PointToClient(new Point(this.Left + (this.Width / 2) - ((textSize.Width + 10) / 2), this.Top + 30));
                    Rectangle labelRect = new Rectangle(textPos, new Size(textSize.Width + 10, textSize.Height + 10));
                    using (GraphicsPath gPath = GraphicsEx.GetRoundedRectangle(labelRect, 7))
                    {
                        g.FillPath(new SolidBrush(Color.FromArgb(200, Color.White)), gPath);
                        g.DrawPath(Pens.Black, gPath);
                        g.DrawString(helpText, helpTextFont, Brushes.Black, new PointF(labelRect.X + 5, labelRect.Y + 5));
                    }
                }
            }
        }
Пример #23
0
        private void DrawImage(GraphicsEx gxOff)
        {
            if (image == null)
            {
                return;
            }

            var imageAttr = new ImageAttributes();

            using (var bmp = new Bitmap(image))
            {
                var transparentKey = bmp.GetPixel(1, 1);
                imageAttr.SetColorKey(transparentKey, transparentKey);
            }

            //var imgRect = Dpi.ScaleRectangle((Width - image.Width) / 2, 5, image.Width, image.Height);
            int width   = Dpi.Scale(image.Width);
            int height  = Dpi.Scale(image.Height);
            var imgRect = new Rectangle((Width - width) / 2, Dpi.Scale(5), width, height);

            gxOff.Surface.DrawImage(image, imgRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttr);
        }
Пример #24
0
 private void DoDraw(GraphicsEx g)
 {
     if (!m_currentState.Empty)
     {
         DoDrawData(g);
     }
     else
     {
         DoDrawEmpty(g);
     }
 }
Пример #25
0
        private void DoDrawAxes(GraphicsEx g, Pen pen, Brush brush, RectF area)
        {
            float w = (float)this.Width;
            float h = (float)this.Height;

            g.DrawLine(pen, 0, h - cBottomOffset, w, h - cBottomOffset);
            g.DrawLine(pen, w - cArrowOffset, h - cBottomOffset - cArrowOffset / 2, w, h - cBottomOffset);
            g.DrawLine(pen, w - cArrowOffset, h - cBottomOffset + cArrowOffset / 2, w, h - cBottomOffset);

            foreach(var element in m_currentState.XPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, x, y - cArrowSize, x, y + cArrowSize);
                g.DrawString(element.X.ToString(), this.Font, brush, x - cLeftOffset, y + cBottomOffset / 3);
            }

            g.DrawLine(pen, w - cRightOffset, 0, w - cRightOffset, h);
            g.DrawLine(pen, w - cRightOffset - cArrowOffset / 2, cArrowOffset, w - cRightOffset, 0);
            g.DrawLine(pen, w - cRightOffset + cArrowOffset / 2, cArrowOffset, w - cRightOffset, 0);

            foreach (var element in m_currentState.YPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, x - cArrowSize, y, x + cArrowSize, y);
                g.DrawString(element.Y.ToString(m_parameters.PriceFormat), this.Font, brush, x, y + +cBottomOffset / 3);
            }
        }
Пример #26
0
        private void DoDrawData(GraphicsEx g)
        {
            m_currentState.Refresh(m_settings);
            RectF area = m_currentState.PhysicalArea;

            float w = (float)this.Width - cLeftOffset - cRightOffset;
            float h = (float)this.Height - cBottomOffset - cTopOffset;

            float kx = w / area.Width;
            float ky = h / area.Height;

            RectF physical = area;

            RectF logical = new RectF(cLeftOffset, cTopOffset, cLeftOffset + w, cTopOffset + h);

            g.Physical = physical;
            g.Logical = logical;

            int count = m_currentState.Graphs.Count;
            for (int index = 0; index < count; ++index)
            {
                Graph graph = m_currentState.Graphs[index];
                Color bidColor = m_settings.Lines[index].BidColor;
                Color askColor = m_settings.Lines[index].AskColor;
                DrawLine(g, graph, bidColor, askColor);
            }

            using (Pen pen = new Pen(m_settings.ForegroundColor))
            {
                using (Brush brush = new SolidBrush(m_settings.ForegroundColor))
                {
                    DoDrawAxes(g, pen, brush, area);
                }
                if (m_settings.Grid)
                {
                    pen.DashPattern = new float[] { 10, 10 };
                    pen.Width = 0.5F;
                    DoDrawGrid(g, pen, area);
                }
            }
        }
Пример #27
0
        internal void DrawStraight(GraphicsEx g, Pen pen)
        {
            var it = m_points.GetEnumerator();
            it.MoveNext();
            Point2F previous = it.Current;

            for (; it.MoveNext(); )
            {
                Point2F next = it.Current;
                g.DrawLineStraight(pen, previous, next);
                previous = next;
            }
            if (m_points.Count > 0)
            {
                Point2F from = m_points.Last();
                Point2F to = new Point2F(0, from.Y);
                g.DrawLineStraight(pen, from, to);
            }
        }
Пример #28
0
        internal void DrawInterpolation(GraphicsEx g, Pen pen)
        {
            var it = m_points.GetEnumerator();
            it.MoveNext();
            Point2F previous = it.Current;

            for (; it.MoveNext(); )
            {
                Point2F next = it.Current;
                g.DrawLineInterpolation(pen, previous, next);
                previous = next;
            }
        }
Пример #29
0
        private void DoDrawEmpty(GraphicsEx g)
        {
            SizeF size = g.MeasureString(cOffQuotes, this.Font);
            float w = (float)this.Width;
            float h = (float)this.Height;

            float x = (w - size.Width) / 2;
            float y = (h - size.Height) / 2;
            g.DrawString(cOffQuotes, this.Font, m_settings.ForegroundColor, x, y);
        }
Пример #30
0
        private void DoDrawGrid(GraphicsEx g, Pen pen, RectF area)
        {
            foreach (var element in m_currentState.XPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, x, y, x, 0);
            }

            foreach (var element in m_currentState.YPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, 0, y, x, y);
            }
        }
Пример #31
0
 private void Draw(Graphics g)
 {
     int width = this.Width;
     int height = this.Height;
     using (Bitmap image = new Bitmap(width, height, g))
     {
         using (Graphics g2 = Graphics.FromImage(image))
         {
             GraphicsEx gEx = new GraphicsEx(g2);
             gEx.FillRectangle(m_settings.BackgroundColor, 0, 0, width, height);
             gEx.SetRenderingMode(m_settings.Mode);
             DoDraw(gEx);
             Rectangle rect = new Rectangle(m_spreads.Location, m_spreads.Size);
             g.ExcludeClip(rect);
             g.DrawImage(image, 0, 0);
         }
     }
 }
Пример #32
0
 private void DrawLine(GraphicsEx g, Graph graph, Color bidColor, Color askColor)
 {
     LineType type = m_settings.Type;
     if (LineType.Straight == type)
     {
         graph.DrawStraight(g, bidColor, askColor);
     }
     else if (LineType.Stepped == type)
     {
         graph.DrawStepped(g, bidColor, askColor);
     }
     else if (LineType.Interpolation == type)
     {
         graph.DrawInterpolation(g, bidColor, askColor);
     }
 }
Пример #33
0
        /// <summary>
        /// Draws the control
        /// </summary>
        /// <param name="e">Drawing surface data</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            using (var gxOff = GraphicsEx.FromImage(MemoryBitmap))
            {
                var topRect    = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height / 2);
                var bottomRect = new Rectangle(0, topRect.Height, ClientSize.Width, ClientSize.Height / 2);

                if (!Pushed)
                {
                    switch (ColorTheme)
                    {
                    case ButtonTheme.Black:
                        gxOff.GradientFill(bottomRect, Color.FromArgb(0, 0, 11), Color.FromArgb(32, 32, 32), GradientFillDirection.Vertical);
                        gxOff.GradientFill(topRect, Color.FromArgb(176, 176, 176), Color.FromArgb(32, 32, 32), GradientFillDirection.Vertical);
                        break;

                    case ButtonTheme.Red:
                        gxOff.GradientFill(bottomRect, Color.FromArgb(11, 0, 0), Color.FromArgb(32, 0, 0), GradientFillDirection.Vertical);
                        gxOff.GradientFill(topRect, Color.FromArgb(176, 0, 0), Color.FromArgb(32, 0, 0), GradientFillDirection.Vertical);
                        break;

                    case ButtonTheme.Green:
                        gxOff.GradientFill(bottomRect, Color.FromArgb(0, 11, 0), Color.FromArgb(0, 32, 0), GradientFillDirection.Vertical);
                        gxOff.GradientFill(topRect, Color.FromArgb(0, 176, 0), Color.FromArgb(0, 32, 0), GradientFillDirection.Vertical);
                        break;

                    case ButtonTheme.Blue:
                        gxOff.GradientFill(bottomRect, Color.FromArgb(0, 0, 11), Color.FromArgb(0, 0, 11), GradientFillDirection.Vertical);
                        gxOff.GradientFill(topRect, Color.FromArgb(0, 0, 176), Color.FromArgb(0, 0, 32), GradientFillDirection.Vertical);
                        break;

                    case ButtonTheme.Default:
                        throw new NotImplementedException("This feature is yet to be implemented");

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                else
                {
                    switch (ColorTheme)
                    {
                    case ButtonTheme.Black:
                        gxOff.GradientFill(topRect, Color.FromArgb(0, 0, 11), Color.FromArgb(32, 32, 32), GradientFillDirection.Vertical);
                        gxOff.GradientFill(bottomRect, Color.FromArgb(176, 176, 176), Color.FromArgb(32, 32, 32), GradientFillDirection.Vertical);
                        break;

                    case ButtonTheme.Red:
                        gxOff.GradientFill(topRect, Color.FromArgb(11, 0, 0), Color.FromArgb(32, 0, 0), GradientFillDirection.Vertical);
                        gxOff.GradientFill(bottomRect, Color.FromArgb(176, 0, 0), Color.FromArgb(32, 0, 0), GradientFillDirection.Vertical);
                        break;

                    case ButtonTheme.Green:
                        gxOff.GradientFill(topRect, Color.FromArgb(0, 11, 0), Color.FromArgb(0, 32, 0), GradientFillDirection.Vertical);
                        gxOff.GradientFill(bottomRect, Color.FromArgb(0, 176, 0), Color.FromArgb(0, 32, 0), GradientFillDirection.Vertical);
                        break;

                    case ButtonTheme.Blue:
                        gxOff.GradientFill(topRect, Color.FromArgb(0, 0, 11), Color.FromArgb(0, 0, 11), GradientFillDirection.Vertical);
                        gxOff.GradientFill(bottomRect, Color.FromArgb(0, 0, 176), Color.FromArgb(0, 0, 32), GradientFillDirection.Vertical);
                        break;

                    case ButtonTheme.Default:
                        throw new NotImplementedException("This feature is yet to be implemented");

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                gxOff.Surface.DrawRectangle(border, 0, 0, ClientSize.Width - 1, ClientSize.Height - 1);

                if (!string.IsNullOrEmpty(Text))
                {
                    var size = gxOff.Surface.MeasureString(Text, Font);
                    gxOff.Surface.DrawString(
                        Text,
                        Font,
                        text,
                        (ClientSize.Width - size.Width) / 2,
                        (ClientSize.Height - size.Height) / 2);
                }

                if (Transparent)
                {
                    try
                    {
                        var bgOwner = Parent as IControlBackground;
                        if (bgOwner != null && bgOwner.BackgroundImage != null)
                        {
                            gxOff.AlphaBlend(bgOwner.BackgroundImage, 70, Location.X, Location.Y);
                        }
                    }
                    catch (PlatformNotSupportedException)
                    {
                        Debug.WriteLine("AlphaBlend is not a supported GDI feature on this device");
                    }
                }
            }

            e.Graphics.DrawImage(MemoryBitmap, 0, 0);
        }
Пример #34
0
 private void DrawStretched(GraphicsEx graphics)
 {
     using (Image image = ImageManipulator.Stretch(Image, ClientSize))
         DrawStretched(image, graphics);
 }
Пример #35
0
 public void blit(Texture source, float source_a)
 {
     GraphicsEx.blit(source, source_a, renderTexture);
 }
Пример #36
0
 //尺寸不一样的图片用这功能, 图片不会被混合, 只能覆盖, 并且居中.
 public void blit(Texture source)
 {
     GraphicsEx.blit(source, renderTexture);
 }