Пример #1
0
        public override void OnDraw(GraphicContext gc)
        {
            gc.AddMargin(Margin);

            if (IsVisible)
            {
                if (StartPosition == WindowStartPosition.CenterScreen)
                {
                    Location = new Point(gc.Size.Width / 2 - Size.Width / 2, gc.Size.Height / 2 - Size.Height / 2);
                }

                if (IsTitleBarVisible)
                {
                    // draw titlebar
                    gc.FillRectangle(new Rectangle(Location, new Size(Size.Width, 30)), TitleBarColor);
                }
                else
                {
                    // remove title bar offset
                    Location -= new Point(0, 30);
                }

                // draw content area
                gc.FillRectangle(new Rectangle(Location + new Point(0, 30), Size), Background);
                //draw children on new GraphicContext for ContentArea
                foreach (var w in Children)
                {
                    var cgc = new GraphicContext();
                    cgc.SetParent(gc);
                    cgc.OffSet = Location;

                    w.OnDraw(cgc);
                }
            }
        }
Пример #2
0
 public override void Render(GraphicContext context, Widget widget)
 {
     if (widget.IsVisible)
     {
         //Draw Background if Widget is visible
         var rec = new Rectangle(widget.Location, widget.Size);
         context.FillRectangle(rec, widget.Background);
     }
 }
Пример #3
0
        public override void Render(GraphicContext context, Widget widget)
        {
            var w = widget as Progressbar;

            if (w != null)
            {
                if (CheckValue(w))
                {
                    const uint tileWidth       = 20;
                    uint       tileCount       = (w.Size.Width / tileWidth) / 2;
                    Point      lastPos         = w.Location;
                    uint       actualTileCount = 0;

                    double progvalue = 100.0 / w.Maximum * w.Value;

                    //ToDo: fix actualTileCount, based on tilecount
                    if (w.Value > 0 && w.Value < 10)
                    {
                        actualTileCount = 1;
                    }
                    if (w.Value > 10 && w.Value < 25)
                    {
                        actualTileCount = 2;
                    }
                    if (w.Value > 25 && w.Value < 50)
                    {
                        actualTileCount = 3;
                    }
                    if (w.Value > 50 && w.Value < 75)
                    {
                        actualTileCount = 4;
                    }
                    if (w.Value > 75 && w.Value <= 100)
                    {
                        actualTileCount = tileCount;
                    }

                    for (int i = 0; i < actualTileCount; i++)
                    {
                        var tileRec = new Rectangle(lastPos, new Size(tileWidth, w.Size.Height));

                        context.FillRectangle(tileRec, w.IndicatorColor);

                        lastPos = new Point(lastPos.X + tileWidth * 2, w.Location.Y);
                    }

                    if (w.Value == 100)
                    {
                        w.OnFinish?.Invoke(w);
                    }
                }
            }
        }