Exemplo n.º 1
0
 public Drawer(DrawProperty property)
 {
     Actions  = new List <IAction>();
     Property = property;
     Life     = property.Duration > 0 ? property.Duration : -1;
     Drawers  = new List <Drawer>();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Draw 7-seg image
        /// </summary>
        /// <param name="dp"></param>
        /// <param name="format"></param>
        /// <remarks>
        /// Format:
        /// 0-9 ... draw number
        /// *   ... draw Dark 8
        /// .   ... draw Dot at last position
        /// ,   ... draw Dot at last position (dark)
        /// :   ... draw colon
        /// ;   ... draw colon(dark)
        /// !   ... draw half space
        /// _   ... draw space
        /// \b  ... back space (1/4)
        /// </remarks>
        public void Draw(DrawProperty dp, string format, ScreenPos pos, ScreenY height)
        {
            if (LoadStatus != 1)
            {
                return;
            }
            var x   = ScreenX.From(0);
            var sz0 = ScreenSize.From(Bitmaps['*'].SizeInPixels.Width, Bitmaps['*'].SizeInPixels.Height);
            var z   = height / sz0.Height;
            var sz  = sz0 * z;
            var sr  = ScreenRect.FromLTWH(0, 0, sz.Width, sz.Height);

            foreach (var c in format)
            {
                if (SpaceAdjust.TryGetValue(c, out var adjust))
                {
                    x += sz.Width * adjust;
                }
                var bmp = Bitmaps.GetValueOrDefault(c, null);
                if (bmp != null)
                {
                    dp.Graphics.DrawImage(bmp, _(sr + pos + x));
                }
                x += sz.Width;
            }
        }
Exemplo n.º 3
0
        public override void Draw(DrawProperty dp)
        {
            if (Seg7?.IsLoaded == false)
            {
                return;
            }

            var pos = dp.PaneRect.RB - ScreenSize.From(420, 40);
            var now = Parent.Now;

            Seg7.Draw(dp, "****,!**,!**_**\b;\b**\b;\b**", pos, Height);
            if (now != DateTime.MinValue)
            {
                var timestr = $"{now.Year}.!{StrUtil.Right($"_{now.Month}", 2)}.!{StrUtil.Right($"_{now.Day}", 2)}_{StrUtil.Right($"_{now.Hour}", 2)}\b:\b{StrUtil.Right($"0{now.Minute}", 2)}\b:\b{StrUtil.Right($"0{now.Second}", 2)}";
                Seg7.Draw(dp, timestr, pos, Height);

                // Sim Time Caption
                dp.Graphics.DrawText($"Sim time :", pos.X - ScreenX.From(8), pos.Y + ScreenY.From(20), Colors.Cyan, new CanvasTextFormat
                {
                    FontFamily          = "Tahoma",
                    FontSize            = 11f,
                    FontWeight          = FontWeights.Normal,
                    HorizontalAlignment = CanvasHorizontalAlignment.Right,
                });
            }

            // Current Local Time
            dp.Graphics.DrawText($"Actual time : {DateTime.Now.ToString(TimeUtil.FormatYMDHMS)}", dp.PaneRect.R - ScreenX.From(64), pos.Y - ScreenY.From(24), Colors.DarkGray, new CanvasTextFormat
            {
                FontFamily          = "Tahoma",
                FontSize            = 11f,
                FontWeight          = FontWeights.Normal,
                HorizontalAlignment = CanvasHorizontalAlignment.Right,
            });
        }
Exemplo n.º 4
0
        public override void Draw(DrawProperty dp)
        {
            if (string.IsNullOrEmpty(Text))
            {
                return;
            }
            // Yellow bar
            var r = dp.PaneRect.Clone();

            r.LT = ScreenPos.From(r.L, 0);
            r.RB = ScreenPos.From(r.R, 2);
            dp.Graphics.FillRectangle(_(r), BackgroundColor);

            // Active Template name (Back ground)
            var tf = new CanvasTextFormat
            {
                FontFamily   = "Coureir New",
                FontSize     = 11.0f,
                FontWeight   = FontWeights.Normal,
                WordWrapping = CanvasWordWrapping.NoWrap,
            };

            r.RB = r.LT + GraphicUtil.MeasureString(dp.Canvas, Text, tf) + ScreenSize.From(10, 10);
            dp.Graphics.FillRectangle(_(r), BackgroundColor);

            // Active Template name (Text)
            dp.Graphics.TextAntialiasing = CanvasTextAntialiasing.ClearType;
            dp.Graphics.DrawText(Text, 4, 2, ColorUtil.GetNegativeColor(BackgroundColor), tf);
        }
Exemplo n.º 5
0
 public override void Draw(DrawProperty dp)
 {
     base.Draw(dp);  // draw background
     if (Bitmap != null)
     {
         dp.Graphics.DrawImage(Bitmap, _(Rect));
     }
 }
Exemplo n.º 6
0
        public override void Draw(DrawProperty dp)
        {
            var s0 = GetScreenPos(dp.Pane, CodePos <Distance, Angle> .From(Distance.Zero, Angle.Zero));
            var s1 = GetScreenPos(dp.Pane);

            dp.Graphics.DrawLine(s0 - ScreenX.From(-10000), s0 + ScreenX.From(10000), Colors.Gray);
            dp.Graphics.DrawLine(s0 - ScreenY.From(-10000), s0 + ScreenY.From(10000), Colors.Gray);
            dp.Graphics.DrawLine(s0, s1, Colors.Red);
            dp.Graphics.FillCircle(s1, DotR, Colors.Magenta);
            if (IsSelected)
            {
                dp.Graphics.DrawCircle(s1, DotR, Colors.Blue, 5.0f);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Draw background
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawProperty dp)
        {
            var spos = ScreenPos.From(Location);

            Rect = ScreenRect.From(spos, Size);
            var br = Rect.Clone();

            br.RB = ScreenPos.From(br.R, br.B - 1);

            if (IsSelected)
            {
                dp.Graphics.FillRectangle(_(br), Color.FromArgb(96, 255, 255, 255));
            }
            else
            {
                dp.Graphics.FillRectangle(_(br), Color.FromArgb(16, 255, 255, 255));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Visualize
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawProperty dp)
        {
            // Connector grip size
            var lcsz = LayoutSize.From(PositionerX(CodeX <Distance> .From(Width), null), PositionerY(null, CodeY <Distance> .From(Height)));
            var scsz = ScreenSize.From(dp.Pane, lcsz);

            // Process Size
            var spsz0 = ScreenSize.From(dp.Pane, LayoutSize.From(PositionerX(CodeX <Distance> .From(ProcessFrom.Width), null), PositionerY(null, CodeY <Distance> .From(ProcessFrom.Height))));
            var spsz1 = ScreenSize.From(dp.Pane, LayoutSize.From(PositionerX(CodeX <Distance> .From(ProcessTo.Width), null), PositionerY(null, CodeY <Distance> .From(ProcessTo.Height))));
            var sc0   = ProcessFrom.GetScreenPos(dp.Pane);
            var sc1   = ProcessTo.GetScreenPos(dp.Pane);

            _angle0 = GeoEu.Angle(sc0.X.Sx, sc0.Y.Sy, sc1.X.Sx, sc1.Y.Sy);
            var k0  = GeoEu.GetLocationOfInscribedSquareInCircle(_angle0);
            var sr0 = ScreenRect.FromCS(ScreenPos.From(sc0.X + k0.X * (spsz0.Width + scsz.Width) / MathUtil.Root2, sc0.Y + -k0.Y * (spsz0.Height + scsz.Height) / MathUtil.Root2), scsz);

            var a1  = GeoEu.Angle(sc1.X.Sx, sc1.Y.Sy, sc0.X.Sx, sc0.Y.Sy);
            var k1  = GeoEu.GetLocationOfInscribedSquareInCircle(a1);
            var sr1 = ScreenRect.FromCS(ScreenPos.From(sc1.X + k1.X * (spsz1.Width + scsz.Width) / MathUtil.Root2, sc1.Y + -k1.Y * (spsz1.Height + scsz.Height) / MathUtil.Root2), scsz);

            _p0 = sr0.C + ScreenPos.From(k0.X * sr0.Width / MathUtil.Root2, -k0.Y * sr0.Height / MathUtil.Root2);
            _p1 = sr1.C;

            // from: on the grip edge
            switch (State)
            {
            case States.SELECTING:
                dp.Graphics.DrawLine(_(_p0), _(_p1), Colors.Red);
                break;

            case States.HOVER:
                dp.Graphics.DrawLine(_(_p0), _(_p1), Colors.Cyan);
                break;

            default:
                dp.Graphics.DrawLine(_(_p0), _(_p1), Colors.White);
                break;
            }
            dp.Graphics.DrawRectangle(_(sr0), Colors.White);
            dp.Graphics.FillRectangle(_(sr1), Colors.White);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Drawing main
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawProperty dp)
        {
            var lpos = GetLayoutPos();
            var sc   = ScreenPos.From(dp.Pane, lpos);
            var lsiz = LayoutSize.From(PositionerX(CodeX <Distance> .From(Width), null), PositionerY(null, CodeY <Distance> .From(Height)));
            var ssiz = ScreenSize.From(dp.Pane, lsiz);
            var sr   = ScreenRect.FromCWH(sc, ssiz.Width, ssiz.Height);

            if (IsSelected)
            {
                // draw the requested position indicator (on the inscribed square in the circle)
                var A      = GetAngle(lpos);
                var lposIn = GetLayoutPos(A);
                var scIn   = ScreenPos.From(dp.Pane, lposIn);
                var srIn   = ScreenRect.FromCWH(scIn, ssiz.Width, ssiz.Height);
                dp.Graphics.DrawLine(_(scIn), _(sc), ConnectingColor);
                if (Design == Designs.IN)
                {
                    dp.Graphics.FillRectangle(_(srIn), Colors.DarkGray);
                }
                else
                {
                    dp.Graphics.DrawRectangle(_(srIn), Colors.DarkGray);
                }

                // draw selected color
                dp.Graphics.DrawRectangle(_(sr), SelectingColor, 4f);
                dp.Graphics.FillRectangle(_(sr), SelectingColor);
            }
            if (Design == Designs.IN)
            {
                dp.Graphics.FillRectangle(_(sr), GetColor(dp));
            }
            else
            {
                dp.Graphics.DrawRectangle(_(sr), GetColor(dp));
            }

            SelectableSize = sr.ToSize();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Drawing main
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawProperty dp)
        {
            var sc   = GetScreenPos(dp.Pane);
            var lsiz = LayoutSize.From(PositionerX(CodeX <Distance> .From(Width), null), PositionerY(null, CodeY <Distance> .From(Height)));
            var ssiz = ScreenSize.From(dp.Pane, lsiz);
            var sr   = ScreenRect.FromCWH(sc, ssiz.Width, ssiz.Height);

            SelectableSize = sr.ToSize();

            dp.Graphics.DrawRectangle(_(sr), GetColor(dp));

            if (IsConnecting)
            {
                dp.Graphics.DrawRectangle(_(sr), ConnectingColor, 4f);
                return;
            }
            if (IsSelected)
            {
                dp.Graphics.DrawRectangle(_(sr), SelectingColor, 4f);
                return;
            }
        }
Exemplo n.º 11
0
 public override void Draw(DrawProperty dp)
 {
 }
Exemplo n.º 12
0
 public TriangleDrawer(DrawProperty property) : base(property)
 {
 }
Exemplo n.º 13
0
 public EdgeDrawer(DrawProperty property) : base(property)
 {
 }
Exemplo n.º 14
0
 public override void Draw(DrawProperty dp)
 {
     dp.Graphics.FillRectangle(_(dp.PaneRect), Colors.Black);
 }
Exemplo n.º 15
0
 public CircleDrawer(DrawProperty property) : base(property)
 {
 }
Exemplo n.º 16
0
 public LineDrawer(DrawProperty property) : base(property)
 {
 }
Exemplo n.º 17
0
 public VertexDrawer(DrawProperty property) : base(property)
 {
 }