예제 #1
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            //base.OnPaint (ctx, bounds);

            if (Icon != 0 && IconFont != null)
            {
                float h = bounds.Height;
                float w = bounds.Right - h;
                if (Dock == Docking.Fill && Text == null)
                {
                    ctx.DrawLine(Style.BorderColorPen, w, bounds.Top, w, bounds.Bottom - 0.5f);
                }

                RectangleF rt = new RectangleF(w, bounds.Top + TextOffsetY, h, h);

                if (IconColor != Color.Empty && Enabled)
                {
                    using (Brush brush = new SolidBrush(IconColor)) {
                        ctx.DrawString(Icon.ToString(), IconFont, brush, rt, FontFormat.DefaultIconFontFormatCenter);
                    }
                }
                else
                {
                    ctx.DrawString(Icon.ToString(), IconFont, Style.ForeColorBrush, rt, FontFormat.DefaultIconFontFormatCenter);
                }
            }
        }
        public override void DrawHourLabel(IGUIContext gfx, RectangleF rect, int hour)
        {
            lock (m_SyncObj)
            {
                using (var pen = new Pen(Theme.HourLabelColor, 1.5f))
                    using (var brush = new SolidBrush(Theme.HourLabelColor))
                    {
                        rect.X     += 2;
                        rect.Width -= 2;

                        RectangleF HourRectangle = rect;
                        //HourRectangle.Offset(0, 1);
                        HourRectangle.Width = rect.Width;
                        gfx.DrawString(hour.ToString("##00"), HourFont, brush, HourRectangle, m_HourLabelFormat);

                        float delta = (rect.Width * 2f / 3f) - 4;
                        rect.X     += delta;
                        rect.Width -= delta;
                        rect.Height = rect.Height / 2f;
                        //rect.Y += 1;

                        gfx.DrawString("00", MinuteFont, brush, rect, m_HourLabelFormat);
                        gfx.DrawLine(pen, rect.Left + 2, rect.Bottom - 1, rect.Right - 7, rect.Bottom - 1);

                        rect.Y += rect.Height - 1;
                        gfx.DrawString("30", MinuteFont, brush, rect, m_HourLabelFormat);
                    }
            }
        }
예제 #3
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            //base.OnPaint (ctx, bounds);
            //bounds = bounds.Inflate (Padding);
            bounds = new RectangleF(bounds.Left + Padding.Left, bounds.Top, bounds.Width - Padding.Width, bounds.Height);

            float iconWidth = 0;

            if (IconFont != null)
            {
                char       icon       = CheckChars [Checked.ToInt()];
                RectangleF iconBounds = bounds;
                float      cp         = Font.CaptionHeight;
                iconBounds.Offset(cp * Indent, IconOffsetY);
                ctx.DrawString(icon.ToString(), IconFont, Style.ForeColorBrush, iconBounds, FontFormat.DefaultSingleBaseLine);
                iconWidth = cp * (Indent + 1);
            }

            ctx.DrawString(Text, Font, Style.ForeColorBrush, new RectangleF(
                               bounds.Left + iconWidth,
                               bounds.Top,
                               bounds.Width - iconWidth,
                               bounds.Height),
                           FontFormat.DefaultSingleLine);
        }
예제 #4
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            bounds = PaddingBounds;

            if (IconFont != null && Icon != 0)
            {
                // this is quick and dirty
                // a more complete solution should respect HAlign and VAlign

                RectangleF iconRect = bounds;
                //iconRect.Offset (0, 1);

                /******
                 * // Icon sollte rotieren, aber da dreht sich nix .. vorerst aufgegeben..
                 * //
                 * // .. das wäre dann ja aber auch das "SpinningIconTextWidget" ..
                 * // denn es soll sich ja nicht jedes Icon drehen..
                 *
                 * double radians = Math.Atan2(iconRect.X + -10, iconRect.Y + 0);
                 * double angle = radians * (80 / Math.PI);
                 *
                 * m_IconFont.Begin(ctx);
                 * //GL.Rotate(angle, 0, 0, 1);
                 * GL.Rotate(angle, 0, 0, 1);
                 * SizeF iconWidth = m_IconFont.Print(m_Icon.ToString(), iconRect, FontFormat.DefaultIconFontFormatLeft, ForeColor);
                 * m_IconFont.End();
                 * Invalidate (1);
                 *************/
                SizeF iconWidth;
                if (String.IsNullOrEmpty(Text))
                {
                    iconWidth = ctx.DrawString(Icon.ToString(), IconFont, Style.ForeColorBrush, iconRect, FontFormat.DefaultIconFontFormatCenter);
                }
                else
                {
                    iconWidth = ctx.DrawString(Icon.ToString(), IconFont, Style.ForeColorBrush, iconRect, FontFormat.DefaultIconFontFormatLeft);
                    int offset = (int)(iconWidth.Width * 1.5f);
                    bounds.X     += offset;
                    bounds.Width -= offset;
                }
            }

            if (Font != null && !String.IsNullOrEmpty(Text))
            {
                if (ctx.DrawString(Text, Font, Style.ForeColorBrush, bounds, Format).Width.Ceil() >= bounds.Width && !Format.HasFlag(FontFormatFlags.WrapText))
                {
                    Tooltip = Text;
                }
                else
                {
                    Tooltip = null;
                }
            }
        }
예제 #5
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            if (!Visible || Font == null || String.IsNullOrEmpty(Text))
            {
                return;
            }

            using (var clipChild = new ClipBoundClip(ctx, Bounds, true)) {
                ctx.DrawString(Text, Font, Style.ForeColorBrush, PaddingBounds, FontFormat.DefaultMultiLine);
            }

            // Fadeout animation
            if (bFadeOut)
            {
                try {
                    if (Style.AlphaBack >= 5)
                    {
                        Style.AlphaBack   -= 5;
                        Style.AlphaFore   -= 5;
                        Style.AlphaBorder -= 5;
                    }
                } catch (Exception ex) {
                    ex.LogError();
                } finally {
                    if (Style.AlphaBack < 5)
                    {
                        OnClose();
                    }
                    ctx.Invalidate(1);
                }
            }
        }
 public override void OnPaint(IGUIContext ctx, RectangleF bounds)
 {
     bounds = bounds.Inflate(Padding);
     if (Font != null && Text != null)
     {
         ctx.DrawString(Text, Font, Style.ForeColorBrush, bounds, Format);
     }
 }
예제 #7
0
        /***
         * protected virtual void OnDrawSelection(IGUIContext ctx, RectangleF bounds)
         * {
         *      float distance = 3f * ScaleFactor;
         *      bounds.Inflate (-distance, -distance);
         *      using (var pen = new Pen(Color.FromArgb(180, Style.ForeColorPen.Color), 1f * ScaleFactor, LineStyles.Dotted)) {
         *              ctx.DrawRectangle (pen, bounds);
         *      }
         * }
         *
         * public override void OnPaintBackground (IGUIContext ctx, RectangleF bounds)
         * {
         *      base.OnPaintBackground (ctx, bounds);
         *
         *      if (Focused && !IsMouseDown) {
         *              OnDrawSelection (ctx, bounds);
         *      }
         * }
         ***/

        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            //base.OnPaint (ctx, bounds);

            float iconWidth = 0;

            //FontFormat ff = FontFormat.DefaultIconFontFormatCenter;

            if (String.IsNullOrEmpty(Text))
            {
                iconWidth = PaddingBounds.Width;
            }
            if (Icon != 0 && IconFont != null && DisplayStyle != ButtonDisplayStyles.Text)
            {
                RectangleF rt = new RectangleF(bounds.Left + Padding.Left, bounds.Top + TextOffsetY, iconWidth, bounds.Height);
                if (IconColor != Color.Empty && Enabled)
                {
                    using (Brush brush = new SolidBrush(IconColor)) {
                        iconWidth = ctx.DrawString(Icon.ToString(), IconFont, brush,
                                                   rt, FontFormat.DefaultIconFontFormatCenter).Width;
                    }
                }
                else
                {
                    iconWidth = ctx.DrawString(Icon.ToString(), IconFont, Style.ForeColorBrush,
                                               rt, FontFormat.DefaultIconFontFormatCenter).Width;
                }

                //rt, FontFormat.DefaultSingleLineCentered).Width;
            }

            if (!String.IsNullOrEmpty(Text) && DisplayStyle != ButtonDisplayStyles.Image)
            {
                if (iconWidth > 0)
                {
                    float delta = iconWidth * 1.42f;
                    bounds.Width -= delta;
                    bounds.X     += delta;
                }

                //bounds.Offset (0, 0);
                ctx.DrawString(Text, Font, Style.ForeColorBrush, bounds, FontFormat.DefaultMnemonicLineCentered);
            }
        }
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            if (!String.IsNullOrEmpty(m_InfoText))
            {
                bounds.Inflate(-DefaultTextMargin.Width, -DefaultTextMargin.Height);
                SizeF infoSize = ctx.DrawString(m_InfoText, Font, InfoTextBrush, bounds, FontFormat.DefaultSingleLine);
                bounds.Inflate(-infoSize.Width, 0);
            }
        }
        public override void DrawUserHeader(IGUIContext gfx, System.Drawing.RectangleF rect, string UserName)
        {
            gfx.DrawGrayButton(rect);

            if (rect.Width > 4)
            {
                rect.Offset(2, 1);
                rect.Inflate(-2, 0);
                gfx.DrawString(UserName, BaseFont, SummerGUI.Theme.Brushes.Base03, rect, m_UserHeaderFormat);
            }
        }
예제 #10
0
 public override void DrawItem(IGUIContext ctx, RectangleF bounds,
                               ComboBoxItem item, IWidgetStyle style)
 {
     if (item == null)
     {
         return;
     }
     // ToDo: DPI Scaling
     bounds.Inflate(-TextMargin.Width, 0);
     ctx.DrawString(item.Text, TB.Font, style.ForeColorBrush, bounds, FontFormat.DefaultSingleLine);
 }
예제 #11
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            bounds.Inflate(-Padding.Width, -Padding.Height);
            bounds.Offset(Padding.Left, Padding.Top);

            PointF CenterPoint = new PointF(
                bounds.Left + (bounds.Width / 2f),
                bounds.Top + (bounds.Height / 2f));

            float pieRadius = Radius - Math.Max(2, (Radius / 10f));

            // for smoothness, any better idea ?
            using (Pen pen = new Pen(Color.Gray, 3f)) {
                ctx.DrawCircle(pen, CenterPoint.X, CenterPoint.Y, Radius - 1.5f);
            }

            using (Brush brush = new SolidBrush(Style.BorderColorPen.Color)) {
                ctx.FillCircle(brush, CenterPoint.X, CenterPoint.Y, Radius - 0.5f);
            }

            Color dataColor;

            if (!Enabled)
            {
                dataColor = Theme.Colors.Base1;
            }
            else if (CustomColor != Color.Empty)
            {
                dataColor = CustomColor;
            }
            else
            {
                dataColor = Theme.GetContextColor(ColorContext);
            }

            using (Brush dataBrush = new SolidBrush(dataColor)) {
                ctx.FillPie(dataBrush,
                            CenterPoint.X,
                            CenterPoint.Y,
                            pieRadius,
                            pieRadius,
                            0, 360f * Value / (MaxValue - MinValue));
            }

            ctx.FillCircle(Style.BackColorBrush, CenterPoint.X, CenterPoint.Y, Radius * 0.5f);

            ctx.DrawString((Value * 100f).ToString("n0") + "%", Font, Style.ForeColorBrush,
                           bounds, FontFormat.DefaultSingleLineCentered);
        }
예제 #12
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            RectangleF paddingBounds = PaddingBounds;

            float y = paddingBounds.Top + (paddingBounds.Height / 2f);
            //ctx.DrawLine (Theme.Pens.Red, paddingBounds.Left, y, paddingBounds.Right, y);

            Point p = BoxAlignment.AlignBoxes(paddingBounds, bounds, Format, Font.Ascender, Font.Descender);

            y = p.Y;
            ctx.DrawLine(Theme.Pens.Red, paddingBounds.Left, y, paddingBounds.Right, y);

            ctx.DrawString(Text, Font, Style.ForeColorBrush, bounds, Format);
        }
예제 #13
0
 /// <summary>
 ///   Draws strings by individual slices. Position of the text is
 ///   calculated by overridable <c>GetTextPosition</c> method of the
 ///   <c>PieSlice</c> type.
 /// </summary>
 /// <param name="graphics">
 ///   <c>Graphics</c> object.
 /// </param>
 public virtual void PlaceTexts(IGUIContext graphics)
 {
     Debug.Assert(graphics != null);
     Debug.Assert(m_font != null);
     Debug.Assert(m_foreColor != Color.Empty);
     using (Brush fontBrush = new SolidBrush(m_foreColor)) {
         foreach (PieSlice slice in m_pieSlices)
         {
             if (!string.IsNullOrEmpty(slice.Text))
             {
                 PointF point = slice.GetTextPosition();
                 graphics.DrawString(slice.Text, m_font, fontBrush, point, FontFormat.DefaultSingleLineCentered);
             }
         }
     }
 }
예제 #14
0
        protected virtual void DrawCaption(IGUIContext ctx, RectangleF bounds)
        {
            if (String.IsNullOrWhiteSpace(Caption))
            {
                return;
            }

            bounds = new RectangleF(bounds.Left + Padding.Left, bounds.Top, bounds.Width - Padding.Width, CaptionHeight);
            if (ctx.DrawString(Caption, Font, ChartStyle.CaptionForegroundBrush, bounds, FontFormat.DefaultSingleLineCentered).Width.Ceil() >= bounds.Width)
            {
                Tooltip = Caption;
            }
            else
            {
                Tooltip = null;
            }
        }
예제 #15
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            if (Font == null)
            {
                return;
            }
            for (int i = 0; i < Items.Count; i++)
            {
                ScrollingBoxItem item = Items[i];

                RectangleF r = item.rectF;
                r.Offset(bounds.Left, bounds.Top);
                if (i == 0)
                {
                    r.Offset(0, Padding.Top);
                }

                if (bounds.IntersectsWith(r))
                {
                    var txt = item as ScrollingBoxText;
                    if (txt != null)
                    {
                        ctx.DrawString(txt.Text, Font, Style.ForeColorBrush, r, Format);
                    }
                    else
                    {
                        ScrollingBoxImage img = item as ScrollingBoxImage;
                        if (img != null)
                        {
                            img.Image.Paint(ctx, new RectangleF(
                                                r.X + ImagePadding.Left,
                                                r.Top + ImagePadding.Top,
                                                r.Width - ImagePadding.Left - ImagePadding.Right,
                                                r.Height - ImagePadding.Top - ImagePadding.Bottom));
                        }
                    }
                }
            }
        }
예제 #16
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);
            if (!m_CanCollapse || IconFont == null)
            {
                return;
            }
            RectangleF iconRect = PaddingBounds;
            char       icon;

            if (m_Collapsed)
            {
                icon = (char)FontAwesomeIcons.fa_caret_right;
            }
            else
            {
                icon = (char)FontAwesomeIcons.fa_caret_down;
            }

            ctx.DrawString(icon.ToString(), IconFont, Style.ForeColorBrush, iconRect, FontFormat.DefaultIconFontFormatFar);
        }
예제 #17
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            // paint bar
            RectangleF rb = PaddingBounds;

            if (ProgressColorBrush != null && Value > 0.01f)
            {
                if (ProgressPadding > 0)
                {
                    rb.Inflate(-ProgressPadding, -ProgressPadding);
                }
                RectangleF rbp   = rb;
                float      delta = 0;
                if (infiniteDirection != 0)
                {
                    delta     = rb.Width * 0.25f;
                    rbp       = rb;
                    rbp.Width = (int)(rbp.Width * Value + 0.5f);
                    float left = rbp.Right - delta;
                    rbp = new RectangleF(left, rbp.Top, rbp.Right - left, rbp.Height);
                }
                else
                {
                    rbp       = rb;
                    rbp.Width = (int)(rbp.Width * Value + 0.5f);
                }
                if (rbp.Width > 0 && rbp.Height > 0)
                {
                    ctx.FillRectangle(ProgressColorBrush, rbp);
                }
            }

            // paint progress-text
            if (Font != null && infiniteDirection == 0)
            {
                ctx.DrawString(Text, Font, Style.ForeColorBrush, rb, FontFormat.DefaultSingleLineCentered);
            }
        }
예제 #18
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            if (IconFont == null)
            {
                return;
            }

            RectangleF iconBounds = new RectangleF(bounds.Left + Padding.Left,
                                                   bounds.Top + Padding.Top,
                                                   bounds.Width - Padding.Left - Padding.Top,
                                                   bounds.Height - Padding.Top - Padding.Bottom);

            SizeF fw = ctx.DrawString(((char)FontAwesomeIcons.fa_caret_down).ToString(), IconFont,
                                      Style.ForeColorBrush, iconBounds, FontFormat.DefaultIconFontFormatFar);

            float x = bounds.Right - Padding.Top - fw.Width - Padding.Top;

            ctx.DrawLine(Theme.Pens.Base03, x, bounds.Top + Padding.Top, x, bounds.Bottom - Padding.Bottom);
            ctx.DrawLine(Theme.Pens.Base01, x + 1, bounds.Top + Padding.Top, x + 1, bounds.Bottom - Padding.Bottom);
        }
예제 #19
0
        private void DrawAxis(IGUIContext ctx, RectangleF bounds)
        {
            if (bounds.Width <= 0 || bounds.Height <= 0)
            {
                return;
            }

            if (AxisPen == null)
            {
                AxisPen = new Pen(Theme.Colors.Base03, AxisWidth);
            }
            else
            {
                AxisPen.Width = AxisWidth;
            }

            Brush TextBrush = Theme.Brushes.Base03;

            // Size-Change
            bool bSizeXChange = OldBounds.Width > 0 && OldBounds.Width != bounds.Width;
            bool bSizeYChange = OldBounds.Height > 0 && OldBounds.Height != bounds.Height;

            if (bSizeXChange)
            {
                double ratioX = (double)(bounds.Width - PlotMargin * 6) / (double)(OldBounds.Width - PlotMargin * 6);
                m_CenterPoint.X = (int)Math.Round((double)m_CenterPoint.X * ratioX);

                if (!bSizeYChange)
                {
                    double ratioY = (double)(Bounds.Height - PlotMargin * 6) / (double)(OldBounds.Height - PlotMargin * 6) * (AspectRatio(Bounds) / AspectRatio(OldBounds));
                    m_CenterPoint.Y = (int)Math.Round((double)m_CenterPoint.Y * ratioY);
                }
            }

            if (bSizeYChange)
            {
                double ratioY = (double)(Bounds.Height - PlotMargin * 6) / (double)(OldBounds.Height - PlotMargin * 6) * (AspectRatio(Bounds) / AspectRatio(OldBounds));
                m_CenterPoint.Y = (int)Math.Round((double)m_CenterPoint.Y * ratioY);
            }

            OldBounds = bounds;

            float offsetX = bounds.X;
            float offsetY = bounds.Y;

            // Zero Point
            PointF Zero = Point2Client(0, 0, bounds).Add(offsetX, offsetY);

            // Pfeile
            PointF EndX = new PointF(bounds.Right - PlotMargin, Zero.Y);
            PointF EndY = new PointF(Zero.X, PlotMargin + offsetY);

            bool bXAxisPainted = false;
            bool bYAxisPainted = false;

            // Achsen
            if (Zero.Y < Bounds.Bottom - PlotMargin && Zero.Y > PlotMargin + offsetY)
            {
                bXAxisPainted = true;
                ctx.DrawLine(AxisPen, PlotMargin + offsetX, Zero.Y, Bounds.Right - PlotMargin, Zero.Y);
                // Y-Achse Pfeil
                ctx.DrawLine(AxisPen, EndY.X, EndY.Y, EndY.X - 3, EndY.Y + 6);
                ctx.DrawLine(AxisPen, EndY.X, EndY.Y, EndY.X + 3, EndY.Y + 6);
            }

            if (Zero.X < Bounds.Right - PlotMargin && Zero.X > PlotMargin + offsetX)
            {
                bYAxisPainted = true;
                ctx.DrawLine(AxisPen, Zero.X, PlotMargin + offsetY, Zero.X, Bounds.Bottom - PlotMargin);
                // X-Achse Pfeil
                ctx.DrawLine(AxisPen, EndX.X, EndX.Y, EndX.X - 6, EndX.Y - 3);
                ctx.DrawLine(AxisPen, EndX.X, EndX.Y, EndX.X - 6, EndX.Y + 3);
            }

            // giving some extra margin (PlotMargin * 1.5)
            // should look more beautiful at the borders.
            double MinX = Client2PointX(PlotMargin * 1.5, Bounds);
            double MaxX = Client2PointX(Bounds.Width - PlotMargin * 1.5, Bounds);
            double MinY = Client2PointY(Bounds.Height - PlotMargin * 1.5, Bounds);
            double MaxY = Client2PointY(PlotMargin * 1.5, Bounds);

            double dx = MaxX - MinX;
            double dy = MaxY - MinY;

            if (dx <= 0d || dy <= 0d)
            {
                return;
            }

            double stepX = 1;
            double stepY = 1;

            // http://en.wikipedia.org/wiki/Power_of_two

            if (dx / 40.0 > 1)
            {
                stepX = Math.Pow(2, Math.Floor(Math.Log(dx / 20, 2)));
            }
            else if (dx / 20.0 < 1)
            {
                stepX = Math.Pow(2, Math.Ceiling(Math.Log(dx / 40, 2)));
            }

            if (XAxisDataType == AxisDataTypes.axNumeric)
            {
                stepY = stepX * (yRange / xRange);
                //stepY = stepX;
            }
            else
            {
                if (dy / 40.0 > 1)
                {
                    stepY = Math.Pow(2, Math.Floor(Math.Log(dy / 20, 2)));
                }
                else if (dy / 20.0 < 1)
                {
                    stepY = Math.Pow(2, Math.Ceiling(Math.Log(dy / 40, 2)));
                }
            }

            if (stepX <= 0 || stepY <= 0)
            {
                return;
            }

            PointF pStep;
            double iStart = 0;

            // ************** Linien ***************

            Pen penGrid     = new Pen(Color.FromArgb(64, GridColor));
            Pen penGridBold = new Pen(GridColor);

            // Vertikale Linien
            // Links

            int iBold = 0;
            Pen LinePen;

            iStart = ((int)(MaxX / stepX)) * stepX;
            iStart = Math.Min(iStart, 0);
            iBold  = (int)Math.Abs(iStart / stepX);

            float tickLen = 3f.Scale(ScaleFactor);

            for (double i = iStart - stepX; i >= MinX; i -= stepX)
            {
                iBold++;
                if (iBold % 5 == 0)
                {
                    LinePen = penGridBold;
                }
                else
                {
                    LinePen = penGrid;
                }

                pStep = Point2Client(i, 0, Bounds).Add(offsetX, offsetY);

                if (DrawGrid)
                {
                    ctx.DrawLine(LinePen, pStep.X, PlotMargin + offsetY, pStep.X, Bounds.Bottom - PlotMargin);
                }

                if (bXAxisPainted)
                {
                    ctx.DrawLine(AxisPen, pStep.X, pStep.Y - tickLen, pStep.X, pStep.Y + tickLen);
                }
            }

            // Rechts

            iStart = ((int)(MinX / stepX)) * stepX;
            iStart = Math.Max(iStart, 0);
            iBold  = (int)Math.Abs(iStart / stepX);

            for (double i = iStart + stepX; i <= MaxX; i += stepX)
            {
                iBold++;
                if (iBold % 5 == 0)
                {
                    LinePen = penGridBold;
                }
                else
                {
                    LinePen = penGrid;
                }

                pStep = Point2Client(i, 0, Bounds).Add(offsetX, offsetY);

                if (DrawGrid)
                {
                    ctx.DrawLine(LinePen, pStep.X, PlotMargin + offsetY, pStep.X, bounds.Bottom - PlotMargin);
                }

                if (bXAxisPainted)
                {
                    ctx.DrawLine(AxisPen, pStep.X, pStep.Y - tickLen, pStep.X, pStep.Y + tickLen);
                }
            }

            // Horizontale Linien
            // Untere Hälfte

            iStart = ((int)(MaxY / stepY)) * stepY;
            iStart = Math.Min(iStart, 0);
            iBold  = (int)Math.Abs(iStart / stepY);

            for (double i = iStart - stepY; i >= MinY; i -= stepY)
            {
                iBold++;
                if (iBold % 5 == 0)
                {
                    LinePen = penGridBold;
                }
                else
                {
                    LinePen = penGrid;
                }

                pStep = Point2Client(0, i, Bounds).Add(offsetX, offsetY);

                if (DrawGrid)
                {
                    ctx.DrawLine(LinePen, PlotMargin + offsetX, pStep.Y, Bounds.Right - PlotMargin, pStep.Y);
                }

                if (bYAxisPainted)
                {
                    ctx.DrawLine(AxisPen, pStep.X - tickLen, pStep.Y, pStep.X + tickLen, pStep.Y);
                }
            }

            // Obere Hälfte

            iStart = ((int)(MinY / stepY)) * stepY;
            iStart = Math.Max(iStart, 0);
            iBold  = (int)Math.Abs(iStart / stepY);

            for (double i = iStart + stepY; i <= MaxY; i += stepY)
            {
                iBold++;
                if (iBold % 5 == 0)
                {
                    LinePen = penGridBold;
                }
                else
                {
                    LinePen = penGrid;
                }

                pStep = Point2Client(0, i, Bounds).Add(offsetX, offsetY);

                if (DrawGrid)
                {
                    ctx.DrawLine(LinePen, PlotMargin + offsetX, pStep.Y, Bounds.Right - PlotMargin, pStep.Y);
                }

                if (bYAxisPainted)
                {
                    ctx.DrawLine(AxisPen, pStep.X - tickLen, pStep.Y, pStep.X + tickLen, pStep.Y);
                }
            }

            penGrid.Dispose();
            penGridBold.Dispose();

            // ************************ Labels **********************
            //int lineheight = (int)Font.LineSpacing + 2;

            stepX *= 5;
            stepY *= 5;

            // Links
            iStart = ((int)(MaxX / stepX)) * stepX;
            iStart = Math.Min(iStart, 0);

            float fontHeight     = Font.Height;
            int   fontHalfHeight = (int)(Font.Height / 2f + 0.5f);

            for (double i = iStart - stepX; i >= MinX; i -= stepX)
            {
                pStep = Point2Client(i, 0, Bounds).Add(offsetX, offsetY);
                ctx.DrawString(FormatLabel(i, 0), Font, TextBrush, pStep.X, pStep.Y - (fontHeight * 2f), CenterFontFormat);
            }

            // Rechts
            iStart = ((int)(MinX / stepX)) * stepX;
            iStart = Math.Max(iStart, 0);

            for (double i = iStart + stepX; i <= MaxX; i += stepX)
            {
                pStep = Point2Client(i, 0, Bounds).Add(offsetX, offsetY);
                ctx.DrawString(FormatLabel(i, 0), Font, TextBrush, pStep.X, pStep.Y, CenterFontFormat);
            }

            // Unten
            iStart = ((int)(MaxY / stepY)) * stepY;
            iStart = Math.Min(iStart, 0);

            for (double i = iStart - stepY; i >= MinY; i -= stepY)
            {
                pStep = Point2Client(0, i, Bounds).Add(offsetX, offsetY);
                ctx.DrawString(FormatLabel(i, 1), Font, TextBrush, pStep.X - fontHalfHeight, pStep.Y - fontHeight, BelowAxisFontFormat);
            }

            // Oben
            iStart = ((int)(MinY / stepY)) * stepY;
            iStart = Math.Max(iStart, 0);

            for (double i = iStart + stepY; i <= MaxY; i += stepY)
            {
                pStep = Point2Client(0, i, Bounds).Add(offsetX, offsetY);
                ctx.DrawString(FormatLabel(i, 1), Font, TextBrush, pStep.X + fontHalfHeight, pStep.Y - fontHeight, AboveAxisFontFormat);
            }
        }
예제 #20
0
        //public override void DrawAppointment(OpenGlGdiContext gfx, Rectangle rect, Appointment appointment, bool isSelected, int gripWidth, ImageList imageList)
        public override void DrawAppointment(IGUIContext gfx, RectangleF rect, Appointment appointment, bool isSelected, int gripWidth)
        {
            if (rect.Width == 0 || rect.Height == 0)
            {
                //if (rect.Width < 6 || rect.Height < 3)
                return;
            }

            //Color start = InterpolateColors(appointment.Color, Color.White, 0.4f);
            //Color end = InterpolateColors(appointment.Color, Color.White, 0.7f);

            // better swap start and end color, text is more readable
            System.Drawing.Color end   = InterpolateColors(appointment.Color, System.Drawing.Color.White, 0.4f);
            System.Drawing.Color start = InterpolateColors(appointment.Color, System.Drawing.Color.White, 0.7f);

            if ((appointment.Locked) || isSelected)
            {
                // Draw back
                using (var m_Brush = new HatchBrush("LargeConfetti", System.Drawing.Color.FromArgb(70, 90, 125), appointment.Color)) {
                    gfx.FillRectangle(m_Brush, rect);
                }

                // little transparent
                start = System.Drawing.Color.FromArgb(230, start);
                end   = System.Drawing.Color.FromArgb(180, end);

                using (var aGB = new LinearGradientBrush(start, end, GradientDirections.ForwardDiagonal)) {
                    gfx.FillRectangle(aGB, rect);
                }
            }
            else
            {
                // Draw back
                using (var aGB = new LinearGradientBrush(start, end, GradientDirections.Vertical)) {
                    gfx.FillRectangle(aGB, rect);
                }
            }

            if (isSelected)
            {
                RectangleF m_BorderRectangle = rect;
                m_BorderRectangle.Offset(-1, 0);

                using (var m_Pen = new Pen(appointment.BorderColor, 4)) {
                    gfx.DrawRectangle(m_Pen, m_BorderRectangle);
                }
            }
            else
            {
                // Draw shadow lines
                float xLeft   = rect.X + 6;
                float xRight  = rect.Right + 1;
                float yTop    = rect.Y + 1;
                float yButton = rect.Bottom + 1;

                for (int i = 0; i < 5; i++)
                {
                    using (var shadow_Pen = new Pen(System.Drawing.Color.FromArgb(70 - 12 * i, System.Drawing.Color.Black)))
                        using (var LineBuf = new LineDrawingBuffer(gfx))
                        {
                            LineBuf.AddLine(shadow_Pen, xLeft + i, yButton + i, xRight + i - 1, yButton + i);
                            LineBuf.AddLine(shadow_Pen, xRight + i, yTop + i, xRight + i, yButton + i);

                            //gfx.DrawLine(shadow_Pen, xLeft + i, yButton + i, xRight + i - 1, yButton + i); //horisontal lines
                            //gfx.DrawLine(shadow_Pen, xRight + i, yTop + i, xRight + i, yButton + i); //vertical
                        }
                }

                rect.Width -= 1;
                using (var m_Pen = new Pen(System.Drawing.Color.FromArgb(70, 90, 125), 1)) {
                    gfx.DrawRectangle(m_Pen, rect);
                }
                rect.Width += 1;
            }

            // Draw gripper *****
            RectangleF m_GripRectangle = rect;

            m_GripRectangle.Width = gripWidth + 1;

            using (var aGB = new SolidBrush(appointment.BorderColor)) {
                gfx.FillRectangle(aGB, m_GripRectangle);
            }


            // Draw Icons *****
            rect.X     += gripWidth + 2;
            rect.Width -= gripWidth + 2;

            if (rect.Height > 56)
            {
                rect.Y      += 6;
                rect.Height -= 10;
            }
            else if (rect.Height > 38)
            {
                rect.Y      += 4;
                rect.Height -= 8;
            }
            else
            {
                rect.Y      += 3;
                rect.Height -= 6;
            }

            float LeftX     = rect.X;
            float IconWidth = 0;

            /**
             * if (appointment.ImageIndices != null && appointment.ImageIndices.Length > 0 && imageList != null && rect.Width >= 15 && rect.Height >= 10)
             * {
             * int imagecount = 0;
             *
             * int startX = rect.X;
             * foreach (int ImageIndex in appointment.ImageIndices)
             * {
             * //imageList.Draw(g, new Point(startX, rect.Y), ImageIndex);
             * imagecount++;
             * IconWidth += 18;
             * startX = rect.X + (imagecount * 18);
             *
             * if (startX + 18 > rect.Right - (gripWidth))
             * {
             * startX = rect.X;
             * rect.Y += 18;
             * rect.Height -= 18;
             * IconWidth = 0;
             *
             * if (rect.Y + 18 > rect.Height)
             *  break;
             * }
             * }
             *
             * if (IconWidth > 0)
             * IconWidth += 2;
             * }
             **/

            rect.Width -= 2;
            //rect.Y -= 1;

            // Draw Text *****
            System.Drawing.SizeF TextSize = gfx.MeasureString(appointment.Title, this.BaseFont, rect, m_AppointmentStringFormat);
            int TextLength = (int)TextSize.Width;
            int TextHeight = (int)TextSize.Height;

            if (TextLength + IconWidth + gripWidth + 2 > rect.Width && IconWidth > 20 && rect.Height > 36)
            {
                rect.Y      += 20;
                rect.Height -= 20;
            }
            else
            {
                rect.X     += IconWidth;
                rect.Width -= IconWidth;
            }

            gfx.DrawString(appointment.Title, this.BaseFont, SystemBrushes.WindowText, rect, m_AppointmentStringFormat);

            if (!String.IsNullOrEmpty(appointment.Description))
            {
                rect.X       = LeftX;
                rect.Y      += TextHeight + 16;
                rect.Height -= TextHeight + 14;

                if (rect.Height > 12)
                {
                    gfx.DrawString(appointment.Description, this.BaseFont, SystemBrushes.WindowText, rect, m_AppointmentStringFormat);
                }
            }
        }
예제 #21
0
        public override void DrawDayHeader(IGUIContext gfx, System.Drawing.RectangleF rect, DateTime date)
        {
            if (date.Date.Equals(DateTime.Now.Date))
            {
                gfx.DrawHighlightButton(rect);
            }
            else
            {
                gfx.DrawGrayButton(rect);
            }

            if (rect.Width < 2 || date == DateTime.MinValue)
            {
                return;
            }

            IGUIFont fntDay = BaseFont;

            string strDate;
            int    StringWith = 0;

            try
            {
                strDate    = date.ToString("D");
                StringWith = (int)fntDay.Measure(strDate).Width;

                if (StringWith > rect.Width - 5)
                {
                    strDate    = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek) + ", " + date.ToString("d");
                    StringWith = (int)fntDay.Measure(strDate).Width;

                    if (StringWith > rect.Width - 5)
                    {
                        strDate    = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek) + ", " + date.ToString("d");
                        StringWith = (int)fntDay.Measure(strDate).Width;

                        if (StringWith > rect.Width - 5)
                        {
                            strDate    = date.ToString("d");
                            StringWith = (int)fntDay.Measure(strDate).Width;

                            if (StringWith > rect.Width - 5)
                            {
                                strDate    = date.ToString("m");
                                StringWith = (int)fntDay.Measure(strDate).Width;

                                if (StringWith > rect.Width - 3)
                                {
                                    strDate    = date.Day.ToString() + " " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(date.Month);
                                    StringWith = (int)fntDay.Measure(strDate).Width;

                                    if (StringWith > rect.Width - 3)
                                    {
                                        strDate = date.Day.ToString();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                strDate = "?";
            }

            //gfx.DrawString (strDate, BaseFont, SummerGUI.Theme.Brushes.Base02, rect, m_DayHeaderFormat);

            gfx.DrawString(strDate, HeaderFont, SummerGUI.Theme.Brushes.Base01, rect, m_DayHeaderFormat);
        }
예제 #22
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            float x          = bounds.Left;
            float y          = Padding.Top;
            float line       = 0;
            float lineHeight = LineHeight;
            //int lineHeight = Bounds.Height;

            bool buildTree = false;

            if (lastBounds != bounds || Tree == null)
            {
                try {
                    lastBounds         = bounds;
                    Tree               = new QuadTree(bounds);
                    itemStartPositions = new float[Menu.Count];
                    buildTree          = true;
                } catch (Exception ex) {
                    ex.LogError();
                }
            }

            for (int i = 0; i < Menu.Children.Count; i++)
            {
                IGuiMenuItem item = Menu.Children [i];
                if (item == null || !item.Visible)
                {
                    continue;
                }

                float iconWidth = 0;
                float textWidth = 0;

                if (IconFont != null && item.ImageIndex > 0)
                {
                    iconWidth = IconFont.Measure(((char)item.ImageIndex).ToString()).Width;
                }

                if (Font != null)
                {
                    textWidth = Font.MeasureMnemonicString(item.Text).Width;
                    if (textWidth > 0)
                    {
                        iconWidth *= 1.35f;
                    }
                }

                float itemWidth = iconWidth + textWidth + Padding.Width;

                if (x + itemWidth > bounds.Width)
                {
                    line++;
                    x  = bounds.Left;
                    y += lineHeight;
                }

                RectangleF itemBounds = new RectangleF(x, y, itemWidth, lineHeight - Padding.Height);
                if (buildTree)
                {
                    try {
                        Tree.Add(new LayoutItem(itemBounds, item));
                        itemStartPositions[i] = itemBounds.X;
                    } catch (Exception ex) {
                        ex.LogError();
                    }
                }

                WidgetStates state = WidgetStates.Default;
                if (!item.Enabled)
                {
                    state = WidgetStates.Disabled;
                }
                else if (item == ActiveItem)
                {
                    if (IsFocused || Selected)
                    {
                        state = WidgetStates.Active;
                    }
                    else
                    {
                        state = WidgetStates.Selected;
                    }
                    ctx.FillRectangle(Styles.GetStyle(state).BackColorBrush,
                                      // irgendjemand scheint den mit bereits abgezogenem Padding aufzurufen, was falsch wäre
                                      new RectangleF(itemBounds.X, itemBounds.Y - Padding.Top, itemBounds.Width, itemBounds.Height + Padding.Height));
                }

                Brush brush = Styles.GetStyle(state).ForeColorBrush;

                itemBounds.Offset(Padding.Left, 1);
                itemBounds.Width -= Padding.Left;

                if (iconWidth > 0)
                {
                    ctx.DrawString(((char)item.ImageIndex).ToString(), IconFont, brush, itemBounds, FontFormat.DefaultIconFontFormatLeft);
                    itemBounds.Offset((int)iconWidth, 0);
                }

                if (textWidth > 0)
                {
                    ctx.DrawString(item.Text, Font, brush, itemBounds, FontFormat.DefaultMnemonicLine);
                }

                x += itemWidth;
                if (x > bounds.Width)
                {
                    line++;
                    x  = bounds.Left;
                    y += lineHeight;
                }
            }
        }
예제 #23
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);
            if (szDay.Width <= 0 || szDay.Height <= 0)
            {
                return;
            }

            // prev / next buttons
            ctx.DrawString(((char)FontAwesomeIcons.fa_long_arrow_left).ToString(),
                           IconFont, prevArrowHover ? Theme.Brushes.Blue : Theme.Brushes.Base02,
                           prevRec, FontFormat.DefaultIconFontFormatCenter);
            ctx.DrawString(((char)FontAwesomeIcons.fa_long_arrow_right).ToString(),
                           IconFont, nextArrowHover ? Theme.Brushes.Blue : Theme.Brushes.Base02,
                           nextRec, FontFormat.DefaultIconFontFormatCenter);

            DateTime date  = CurrentDate;
            string   title = String.Format("{0} {1}", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(date.Month).ToUpper(), date.Year.ToString());

            using (var clip = new ClipBoundClip(ctx, rTitle)) {
                ctx.DrawString(title, TitleFont, Theme.Brushes.Base02, rTitle, Format);
            }

            for (int i = 0; i < 7; i++)
            {
                RectangleF rx = new RectangleF((int)(bounds.Left + Padding.Left + (i * szDay.Width)), (int)szDay.Height + bounds.Top + Padding.Top, (int)szDay.Width, (int)szDay.Height);
                string     wd = m_Weekdays [i].Substring(0, 1);
                if (i == 0 || i == 6)
                {
                    ctx.DrawString(wd, DayFont, Theme.Brushes.Orange, rx, Format);
                }
                else
                {
                    ctx.DrawString(wd, DayFont, Theme.Brushes.Cyan, rx, Format);
                }
            }

            DateTime  firstDayOfMonth = new DateTime(CurrentDate.Year, CurrentDate.Month, 1);
            DayOfWeek dowStart        = firstDayOfMonth.DayOfWeek;

            int dayMax    = (int)dowStart < 6 ? 35 : 42;
            int currMonth = CurrentDate.Month;

            DateTime today      = DateTime.Now.Date;
            Brush    textBrusch = new SolidBrush(Style.ForeColorBrush.Color);
            float    radius     = Math.Max(MinCircleRadius, Math.Min(MaxCircleRadius, szDay.Width * 0.35f));

            for (int i = 0; i < dayMax; i++)
            {
                int       col = i % 7;
                int       row = (i / 7);
                Rectangle rx  = new Rectangle((int)(bounds.Left + Padding.Left + ((float)col * szDay.Width)), (int)(bounds.Top + Padding.Top + ((float)(row + 2) * szDay.Height)), (int)szDay.Width, (int)szDay.Height);

                DateTime dt = m_MonthView [i];
                string   wd = dt.Day.ToString();

                Color color = Color.Empty;
                if (dt == today)
                {
                    color = TodayBackColor;
                }
                else if (dt == CurrentDate)
                {
                    color = CurrentDayBackColor;
                }
                else if (dt == HoverDate)
                {
                    color = DayHoverBackColor;
                }


                Color textColor = Color.Empty;

                if (!color.IsEmpty)
                {
                    using (var brush = new SolidBrush(color))
                    {
                        ctx.FillCircle(brush, rx.Left + (rx.Width / 2f) - 0.5f, rx.Top + (rx.Height / 2f) - 1f, radius, 1);
                    }

                    textColor = Style.ForeColorBrush.Color;
                }
                else
                {
                    textColor = (col == 0 || col == 6) ? Theme.Colors.Orange : Style.ForeColorBrush.Color;
                }

                if (dt.Month != currMonth)
                {
                    textColor = Color.FromArgb(128, textColor);
                }
                textBrusch.Color = textColor;

                ctx.DrawString(wd, DayFont, textBrusch, rx, Format);
            }
        }
예제 #24
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            bounds.Inflate(Padding);

            float icoWidth = LineHeight * 0.85f;

            bool buildTree = false;

            if (lastBounds != bounds || Tree == null || MenuDirtyFlag)
            {
                try {
                    lastBounds = bounds;
                    Tree       = new QuadTree(bounds);
                    buildTree  = true;
                } catch (Exception ex) {
                    ex.LogError();
                }
            }

            RectangleF itemRect = bounds;

            try {
                foreach (var w in Queue)
                {
                    if (w.IsSeparator)
                    {
                    }
                    else
                    {
                        //float stringWidth = 0;
                        bool toolTipFlag = false;

                        itemRect.Height = LineHeight - 1;
                        if (ctx.ClipBoundStack.IsOnScreen(itemRect))
                        {
                            float indent    = 0;
                            Brush foreBrush = Theme.Brushes.Base2;
                            Brush backBrush = Theme.Brushes.Base01;

                            switch (w.Level)
                            {
                            case 0:
                                backBrush = Theme.Brushes.Base1;
                                if (w.Enabled)
                                {
                                    foreBrush = Theme.Brushes.Base02;
                                }
                                else
                                {
                                    foreBrush = Theme.Brushes.Base01;
                                }
                                break;

                            case 1:
                                indent = 8;
                                if (!w.Enabled)
                                {
                                    foreBrush = Theme.Brushes.Base02;
                                }
                                break;

                            case 2:
                                indent    = 16;
                                backBrush = Theme.Brushes.Base02;
                                if (w.Enabled)
                                {
                                    foreBrush = Theme.Brushes.Base1;
                                }
                                else
                                {
                                    //foreColor = Theme.Colors.Base1.Lerp(Color.Black, 0.35);
                                    foreBrush = Theme.Brushes.Base01;
                                }
                                break;
                            }

                            if (w != null && w == LastExpandedItem && w.Enabled)
                            {
                                using (Brush sb = new SolidBrush(backBrush.Color.Lerp(Theme.Colors.Cyan, 0.85))) {
                                    ctx.FillRectangle(sb, itemRect);
                                }
                                foreBrush = Theme.Brushes.White;
                            }
                            else if (w != null && w == m_ActiveItem && w.Enabled)
                            {
                                using (Brush sb = new SolidBrush(backBrush.Color.Lerp(Theme.Colors.Orange, 0.85))) {
                                    ctx.FillRectangle(sb, itemRect);
                                }
                                foreBrush = Theme.Brushes.White;
                            }
                            else
                            {
                                ctx.FillRectangle(backBrush, itemRect);
                            }

                            indent *= ScaleFactor;

                            RectangleF tb = itemRect;

                            if (w.HasChildren)
                            {
                                char       dropDownTriangle = w.Collapsed ? (char)FontAwesomeIcons.fa_caret_right : (char)FontAwesomeIcons.fa_caret_down;
                                RectangleF ib = new RectangleF(itemRect.Right - icoWidth, itemRect.Top, icoWidth, itemRect.Height);
                                ctx.DrawString(dropDownTriangle.ToString(), this.IconFont, foreBrush, ib, FontFormat.DefaultSingleBaseLineCentered);
                                if (w.Level == 0)
                                {
                                    tb.Width -= icoWidth * 2;
                                    tb.Offset(icoWidth, 0);
                                }
                                else
                                {
                                    tb.Width -= icoWidth + 2;
                                }
                            }

                            if (w.Level == 0)
                            {
                                tb.Offset(0, 2);
                                toolTipFlag = ctx.DrawString(w.DisplayString.ToUpper(), this.Font, foreBrush, tb, FontFormat.DefaultSingleLineCentered)
                                              .Width > tb.Width;
                            }
                            else
                            {
                                if (w.ImageIndex > 0 || w.IsToggleButton)
                                {
                                    RectangleF ib = itemRect;
                                    ib.Width = icoWidth;
                                    ib.Offset(indent, 0);
                                    string c;
                                    if (w.IsToggleButton)
                                    {
                                        if (w.Checked)
                                        {
                                            c = ((char)FontAwesomeIcons.fa_toggle_on).ToString();
                                        }
                                        else
                                        {
                                            c = ((char)FontAwesomeIcons.fa_toggle_off).ToString();
                                        }
                                    }
                                    else
                                    {
                                        c = ((char)w.ImageIndex).ToString();
                                    }

                                    ctx.DrawString(c, this.IconFont, foreBrush, ib, FontFormat.DefaultSingleBaseLine);
                                }

                                tb.Offset(icoWidth + indent, 1);
                                tb.Width   -= icoWidth + indent;
                                toolTipFlag = ctx.DrawString(w.DisplayString, this.Font, foreBrush, tb, FontFormat.DefaultSingleLine)
                                              .Width > tb.Width;
                            }
                        }

                        if (buildTree)
                        {
                            try {
                                Tree.Add(new MenuControlItem(itemRect, w, toolTipFlag));
                            } catch (Exception ex) {
                                ex.LogError();
                            }
                        }

                        itemRect.Offset(0, LineHeight);
                    }
                }
            } catch (Exception ex) {
                ex.LogError();
            }
        }
예제 #25
0
        /// <summary>
        /// Draws the chart (w/o background or grid, but with border) to the Graphics canvas
        /// </summary>
        private void DrawChart(IGUIContext ctx, RectangleF bounds)
        {
            if (drawValues.Count == 0)
            {
                return;
            }

            float captionHeight = CaptionHeight;
            float offsetY       = bounds.Top + captionHeight;

            visibleValues = (Math.Min(bounds.Width / ValueSpacing, drawValues.Count) + 2).Ceil();

            if (ScaleMode == ScaleModes.Relative)
            {
                CurrentMaxValue = GetHighestValueForRelativeMode();
            }

            // Only draw average line when possible (visibleValues) and needed (style setting)
            if (visibleValues > 0 && ChartStyle.ShowAverageLine)
            {
                DrawAverageLine(ctx, bounds, captionHeight);
            }

            // Connect all visible values with lines
            PointF previousPoint;
            float  deltaX;

            if (FlowDirection == FlowDirections.LeftToRight)
            {
                previousPoint = new PointF(bounds.Left - ValueSpacing, offsetY + ((bounds.Height - captionHeight) / 2));
                deltaX        = ValueSpacing;
            }
            else
            {
                previousPoint = new PointF(bounds.Right + ValueSpacing, offsetY + ((bounds.Height - captionHeight) / 2));
                deltaX        = -ValueSpacing;
            }

            PointF currentPoint = new Point();

            using (new PaintWrapper(RenderingFlags.HighQuality)) {
                GL.Color4(LineColor);
                GL.LineWidth(LineWidth);
                GL.Begin(PrimitiveType.Lines);

                LinkedListNode <decimal> node = drawValues.First;

                for (int i = 0; i < visibleValues; i++)
                {
                    if (node == null)                           // that's true, it always happens. Wher have I got a loop ?
                    {
                        break;
                    }

                    currentPoint.X = previousPoint.X + deltaX;
                    currentPoint.Y = (float)(CalcVerticalPosition(node.Value) + offsetY);

                    GL.Vertex2(currentPoint.X, currentPoint.Y);
                    GL.Vertex2(previousPoint.X, previousPoint.Y);

                    previousPoint = currentPoint;
                    node          = node.Next;
                }

                GL.End();
            }

            // Draw current relative maximum value string
            if (ScaleMode == ScaleModes.Relative)
            {
                SolidBrush sb = new SolidBrush(ChartStyle.ChartLinePen.Color);
                ctx.DrawString(CurrentMaxValue.ToString(), this.Font, sb, new PointF(4.0f, 2.0f),
                               FontFormat.DefaultSingleLine);
            }

            // Draw Border on top
            // ControlPaint.DrawBorder3D(g, 0, 0, Width, Height, b3dstyle);
        }
예제 #26
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            float lineHeight      = LineHeight;
            float separatorHeight = SeparatorHeight;

            RectangleF rLine = bounds;

            rLine.Height = lineHeight;
            rLine.Width -= Padding.Right;
            rLine.Offset(0, Padding.Top);
            float textOffset = lineHeight + Padding.Left;

            bool buildTree = false;

            if (lastBounds != bounds || Tree == null)
            {
                try {
                    lastBounds         = bounds;
                    Tree               = new QuadTree(bounds);
                    itemStartPositions = new float[Menu.Count];
                    buildTree          = true;
                } catch (Exception ex) {
                    ex.LogError();
                }
            }

            for (int i = 0; i < Menu.Children.Count; i++)
            {
                IGuiMenuItem item = Menu.Children [i];

                float itemHeight = 0;

                if (item.IsSeparator)
                {
                    itemHeight = separatorHeight;
                    float y = rLine.Y + separatorHeight / 2;

                    using (Pen pen = new Pen(Theme.Colors.Base02, ScaleFactor))
                        ctx.DrawLine(pen, rLine.X + textOffset, y, rLine.X + rLine.Width, y);

                    y++;
                    using (Pen pen = new Pen(Theme.Colors.Base0, ScaleFactor))
                        ctx.DrawLine(pen, rLine.X + textOffset, y, rLine.X + rLine.Width, y);
                }
                else
                {
                    itemHeight = lineHeight;
                    WidgetStates state = WidgetStates.Default;
                    if (!item.Enabled)
                    {
                        state = WidgetStates.Disabled;
                    }
                    else if (item == m_ActiveItem)
                    {
                        if (IsFocused || Selected)
                        {
                            state = WidgetStates.Active;
                        }
                        else
                        {
                            state = WidgetStates.Selected;
                        }
                        ctx.FillRectangle(Styles.GetStyle(state).BackColorBrush,
                                          new RectangleF(rLine.X + 1, rLine.Y, rLine.Width + Padding.Right - 2, rLine.Height));
                    }

                    IWidgetStyle style = Styles.GetStyle(state);

                    if (IconFont != null)
                    {
                        char icon;
                        if (item.IsToggleButton)
                        {
                            icon = item.Checked ? (char)FontAwesomeIcons.fa_toggle_on : (char)FontAwesomeIcons.fa_toggle_off;
                        }
                        else
                        {
                            icon = (char)item.ImageIndex;
                        }

                        if (icon > 0)
                        {
                            RectangleF rIcon = rLine;
                            rIcon.Width = lineHeight;
                            ctx.DrawString(icon.ToString(), IconFont, style.ForeColorBrush, rIcon, FontFormat.DefaultIconFontFormatCenter);
                        }
                    }

                    if (Font != null)
                    {
                        RectangleF rText = new RectangleF(rLine.X + textOffset, rLine.Y + 1, rLine.Width - textOffset, rLine.Height - 1);
                        ctx.DrawString(item.Text, Font, style.ForeColorBrush, rText, FontFormat.DefaultMnemonicLine);

                        if (item.HasChildren)
                        {
                            if (IconFont != null)
                            {
                                ctx.DrawString(((char)FontAwesomeIcons.fa_caret_right).ToString(), IconFont, style.ForeColorBrush, rText, FontFormat.DefaultSingleLineFar);
                            }
                        }
                        else
                        {
                            string modifier = ModifierString(item);
                            if (modifier != null)
                            {
                                ctx.DrawString(modifier, Font, style.ForeColorBrush, rText, FontFormat.DefaultSingleLineFar);
                            }
                        }
                    }
                }

                if (buildTree)
                {
                    try {
                        Tree.Add(new LayoutItem(rLine, item));
                        itemStartPositions[i] = rLine.Y;
                    } catch (Exception ex) {
                        ex.LogError();
                    }
                }

                rLine.Offset(0, itemHeight);
            }
        }
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            if (DisplayMode == DisplayModes.None)
            {
                return;
            }

            MultiLineTextManager rowManager = Owner.RowManager;
            float paddingTop = Owner.Padding.Top;

            int   selectedRowIndex = rowManager.CurrentParagraphIndex;
            Brush foreColorBrush   = Style.ForeColorBrush;

            int lineHeight = rowManager.LineHeight;
            int offsetY    = (int)Owner.ScrollOffsetY;

            int rowIndex = rowManager.FirstParagraphOnScreen;

            //float halfHeight = bounds.Height / 2f;

            while (rowIndex < rowManager.Paragraphs.Count)
            {
                Paragraph para = rowManager.Paragraphs [rowIndex];
                Rectangle rowBounds;

                if (DisplayMode == DisplayModes.LineNumber)
                {
                    rowBounds = new Rectangle((int)(bounds.Left + 0.5f), (int)(paddingTop + bounds.Top + para.Top + offsetY + 0.5f), (int)(bounds.Width + 0.5f), lineHeight);

                    for (int i = 0; i < para.LineCount; i++)
                    {
                        if (rowBounds.Bottom > bounds.Top)
                        {
                            int line = para.Index + i;
                            if (line == selectedRowIndex)
                            {
                                ctx.FillRectangle(Theme.Brushes.Base01, new RectangleF(bounds.Left, rowBounds.Top, bounds.Width, rowBounds.Height));
                                foreColorBrush = Theme.Brushes.Base2;
                            }
                            else
                            {
                                foreColorBrush = Style.ForeColorBrush;
                            }

                            ctx.DrawString((line + 1).ToString(), rowManager.Font, foreColorBrush,
                                           new RectangleF(bounds.Left, rowBounds.Top, bounds.Width - Padding.Right, lineHeight), Format);
                        }

                        rowBounds.Offset(0, lineHeight);
                        if (rowBounds.Top > bounds.Bottom)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    rowBounds = new Rectangle((int)(bounds.Left + 0.5f), (int)(paddingTop + bounds.Top + para.Top + offsetY + 0.5f), (int)(bounds.Width + 0.5f), para.LineCount * lineHeight);

                    if (rowBounds.Bottom > bounds.Top)
                    {
                        int line = para.Index;
                        if (line == selectedRowIndex)
                        {
                            ctx.FillRectangle(Theme.Brushes.Base01, new RectangleF(bounds.Left, rowBounds.Top, bounds.Width, rowBounds.Height));
                            foreColorBrush = Theme.Brushes.Base2;
                        }
                        else
                        {
                            foreColorBrush = Style.ForeColorBrush;
                        }

                        float top = Math.Min(rowBounds.Bottom - lineHeight, Math.Max(rowBounds.Top, bounds.Top));
                        ctx.DrawString((line + 1).ToString(), rowManager.Font, foreColorBrush,
                                       new RectangleF(bounds.Left, top, bounds.Width - Padding.Right, lineHeight), Format);
                    }
                }

                if (rowBounds.Top > bounds.Bottom)
                {
                    break;
                }

                rowIndex++;
            }
        }