Exemplo n.º 1
0
 /// <summary>
 /// Code as Screen coodinate
 /// </summary>
 /// <param name="lx"></param>
 /// <param name="ly"></param>
 /// <returns></returns>
 public static CodeX <ScreenX> CoderSx(LayoutX lx, LayoutY ly)
 {
     return(new CodeX <ScreenX>
     {
         Cx = ScreenX.From(lx.Lx),
     });
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize feature
        /// </summary>
        public override void OnInitialInstance()
        {
            base.OnInitialInstance();
            Pane.Target = Pane["ToolBox"];

            // Tool box background
            Parts.Add(Pane.Target, new PartsToolBox {
            }, LAYER.ToolButtonBox);

            var x       = ScreenX.From(0);
            var y       = ScreenY.From(48);
            var btnSize = ScreenSize.From(24, 24);
            var marginY = ScreenY.From(8);

            for (var i = 0; i < Buttons.Count; i++)
            {
                var btn = Buttons[i];
                btn.Name     = string.IsNullOrEmpty(btn.Name) ? btn.GetType().Name : btn.Name;
                btn.Size     = btnSize;
                btn.Location = CodePos <ScreenX, ScreenY> .From(x, y);

                var dmy = btn.Load(View);   // dmy = thread control
                Parts.Add(Pane.Target, btn, LAYER.ToolButtons);
                y += btnSize.Height + marginY;
            }
        }
Exemplo n.º 3
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.º 4
0
        /// <summary>
        /// title bar design
        /// </summary>
        /// <param name="dp"></param>
        /// <param name="sr">log panel drawing area</param>
        /// <returns></returns>
        protected virtual ScreenY drawTitleBar(DrawProperty dp, ScreenRect sr)
        {
            var _bd         = new CanvasSolidColorBrush(dp.Canvas, Color.FromArgb(64, 0, 0, 0));
            var titleHeight = 8;
            var w3          = sr.Width / 4;
            var pst         = new ScreenPos[] { ScreenPos.From(sr.LT.X, sr.LT.Y + titleHeight + 16), ScreenPos.From(sr.LT.X, sr.LT.Y), ScreenPos.From(sr.RB.X, sr.LT.Y), };
            var psb         = new ScreenPos[] { ScreenPos.From(sr.RB.X, sr.LT.Y + titleHeight), ScreenPos.From(sr.RB.X - w3, sr.LT.Y + titleHeight + 2), ScreenPos.From(sr.RB.X - w3 * 2, sr.LT.Y + titleHeight + 8), ScreenPos.From(sr.RB.X - w3 * 3, sr.LT.Y + titleHeight + 16), ScreenPos.From(sr.LT.X, sr.LT.Y + titleHeight + 16), };
            var ps          = pst.Union(psb).ToList();
            var path        = new CanvasPathBuilder(dp.Canvas);

            path.BeginFigure(ps[0]);
            for (var i = 1; i < ps.Count; i++)
            {
                path.AddLine(ps[i]);
            }
            path.EndFigure(CanvasFigureLoop.Closed);
            var geo = CanvasGeometry.CreatePath(path);

            dp.Graphics.FillGeometry(geo, _bd);

            // edge highlight
            for (var i = 1; i < pst.Length; i++)
            {
                dp.Graphics.DrawLine(pst[i - 1], pst[i], Color.FromArgb(96, 255, 255, 255));
            }
            // edge shadow
            for (var i = 1; i < psb.Length; i++)
            {
                dp.Graphics.DrawLine(psb[i - 1], psb[i], Color.FromArgb(96, 0, 0, 0));
            }

            // title bar design
            var btr = sr.Clone();

            btr.RB = ScreenPos.From(btr.LT.X + ScreenX.From(24), btr.LT.Y + ScreenY.From(12));
            btr    = btr + ScreenPos.From(4, 4);
            var imgttl = Assets.Image("LogPanelTitileDesign");

            if (imgttl != null)
            {
                dp.Graphics.DrawImage(imgttl, btr.LT + ScreenSize.From(-3, -14));
            }
            btr = btr + ScreenX.From(50);

            // title filter buttons
            var btn1 = Assets.Image("btnLogPanel");
            var btn0 = Assets.Image("btnLogPanelOff");

            if (btn1 != null && btn0 != null)
            {
                var ctfb = new CanvasTextFormat
                {
                    FontFamily = "Arial",
                    FontSize   = 10.0f,
                    FontWeight = FontWeights.Normal,
                    FontStyle  = FontStyle.Italic,
                };
                foreach ((var lv, var caption) in new (LLV, string)[] { (LLV.ERR, "e"), (LLV.WAR, "w"), (LLV.INF, "i"), (LLV.DEV, "d") })
Exemplo n.º 5
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.º 6
0
        public void OnPointerMoved(PointerState po)
        {
            //Debug.WriteLine($"★OnPointerMoved {po.Position} finger={po.FingerCount} Scale={po.Scale}");
            if (po.Scale != 1.0f || isZooming)
            {
                if (isZooming == false)
                {
                    _sPosDown    = po.Position;
                    _lPosDown    = LayoutPos.From(Pane.Target, po.Position);
                    _sZoomDown   = ScreenPos.From(Pane.Target.ZoomX, Pane.Target.ZoomY);
                    _lScrollDown = LayoutPos.From(Pane.Target.ScrollX, Pane.Target.ScrollY);
                    isZooming    = true;
                }
                ScreenPos sZoom;
                var       lScroll = _lScrollDown;
                var       sMove   = po.Position - _sPosDown; // pointer move distance
                switch (getTrigger(po))
                {
                case PointerState.DeviceTypes.Mouse:
                    sZoom = _sZoomDown + sMove * (0.003 * SpeedX, 0.003 * SpeedY);     // ズーム値の算出  速度変更(高解像度に伴い) 2016.11.15 Tono 2→3
                    break;

                case PointerState.DeviceTypes.Touch:
                    sZoom = _sZoomDown * po.Scale;
                    break;

                default:
                    OnPointerReleased(po);
                    return;
                }

                // sZoom.TrimMinimum(ScreenX.From(500), ScreenY.From(500));
                sZoom.TrimMinimum(ScreenX.From(0.2), ScreenY.From(0.2));  // 小さい値に対応
                sZoom.TrimMaximum(ScreenX.From(100000), ScreenY.From(100000));
                var isChanged = false;

                if (Pane.Target.ZoomX != sZoom.X || Pane.Target.ZoomY != sZoom.Y)
                {
                    Pane.Target.ZoomX = sZoom.X;
                    Pane.Target.ZoomY = sZoom.Y;
                    Token.Link(po, new EventTokenPaneChanged
                    {
                        TokenID    = TokensGeneral.Zoomed,
                        Sender     = this,
                        Remarks    = "drag zoom",
                        TargetPane = Pane.Target,
                    });
                    isChanged = true;
                }
                //if (Pane.Target.ScrollX != lScroll.X.Lx || Pane.Target.ScrollY != lScroll.Y.Ly)
                //{
                //    Pane.Target.ScrollX = lScroll.X.Lx;
                //    Pane.Target.ScrollY = lScroll.Y.Ly;
                //    Token.Link(po, new EventTokenPaneChanged
                //    {
                //        TokenID = TokensGeneral.Scrolled,
                //        Sender = this,
                //        Remarks = "auto scroll when drag zoom",
                //        TargetPane = Pane.Target,
                //    });
                //    isChanged = true;
                //}
                if (isChanged)
                {
                    onZoomed();
                    Redraw();
                }
            }
        }