コード例 #1
0
            /// <summary>
            /// Update visual feedback based on the current screen position of the mouse.
            /// </summary>
            /// <param name="screenPt">Latest mouse screen position.</param>
            /// <param name="dragFeedback">Type of drag feedback required.</param>
            public DragTarget Feedback(Point screenPt, PaletteDragFeedback dragFeedback)
            {
                if (ScreenRect.Contains(screenPt))
                {
                    // Create the docking indicators the first time needed
                    _indicators ??= dragFeedback switch
                    {
                        PaletteDragFeedback.Rounded => new DropDockingIndicatorsRounded(_paletteDragDrop, _renderer,
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft),
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.EdgeRight),
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.EdgeTop),
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom),
                                                                                        _hintToTarget.ContainsKey(DragTargetHint.Transfer)),
                        _ => new DropDockingIndicatorsSquare(_paletteDragDrop, _renderer,
                                                             _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft),
                                                             _hintToTarget.ContainsKey(DragTargetHint.EdgeRight),
                                                             _hintToTarget.ContainsKey(DragTargetHint.EdgeTop),
                                                             _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom),
                                                             _hintToTarget.ContainsKey(DragTargetHint.Transfer))
                    };

                    // Ensure window is Displayed in correct location
                    _indicators.ShowRelative(ScreenRect);

                    // Hit test against indicators and update display
                    return(_indicators.ScreenMouseMove(screenPt) switch
                    {
                        0x0040 => _hintToTarget[DragTargetHint.EdgeLeft],
                        0x0080 => _hintToTarget[DragTargetHint.EdgeRight],
                        0x0100 => _hintToTarget[DragTargetHint.EdgeTop],
                        0x0200 => _hintToTarget[DragTargetHint.EdgeBottom],
                        0x0400 => _hintToTarget[DragTargetHint.Transfer],
                        _ => null // Mouse is not over any of the targets
                    });
コード例 #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;
            }
        }
コード例 #3
0
        /**
         * Calculates a screen rect in normalized screen space coordinates in one of the 'standard' Page positions (top, middle, bottom).
         */
        public static ScreenRect CalcScreenRect(Vector2 pageScale, PagePosition pagePosition)
        {
            float width  = Mathf.Clamp01(pageScale.x);
            float height = Mathf.Clamp01(pageScale.y);

            ScreenRect screenRect = new ScreenRect();

            switch (pagePosition)
            {
            case PagePosition.Top:
                screenRect.x1 = 0.5f - width * 0.5f;
                screenRect.x2 = 0.5f + width * 0.5f;
                screenRect.y1 = 0f;
                screenRect.y2 = height;
                break;

            case PagePosition.Middle:
                screenRect.x1 = 0.5f - width * 0.5f;
                screenRect.x2 = 0.5f + width * 0.5f;
                screenRect.y1 = 0.5f - height * 0.5f;
                screenRect.y2 = 0.5f + height * 0.5f;
                break;

            case PagePosition.Bottom:
                screenRect.x1 = 0.5f - width * 0.5f;
                screenRect.x2 = 0.5f + width * 0.5f;
                screenRect.y1 = 1f - Mathf.Clamp01(height);
                screenRect.y2 = 1;
                break;
            }

            return(screenRect);
        }
コード例 #4
0
ファイル: Window.cs プロジェクト: vanattab/ochregui
        /// <summary>
        /// Adds a control instance to this window.  All controls must be reference-unique, or this
        /// method will throw an ArgumentException.  This method will also throw an ArgumentExeption
        /// if the control is too large to fit on the screen.  A newly added control may receive
        /// a MouseEnter message if the mouse is within it's region, and will always receive a
        /// SettingUp message if it hasn't received one previously.
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException">Thrown when the specified <paramref name="control"/>
        /// is already contained by this window.</exception>
        public bool AddControl(Control control)
        {
            if (ContainsControl(control) || controlAddList.Contains(control))
            {
                throw new ArgumentException("CurrentWindow already contians an instance of this control");
            }

            this.controlAddList.Add(control);

            bool atRequestedPos = CheckNewlyAddedControlPosition(control);

            if (!atRequestedPos)
            {
                if (!ScreenRect.Contains(control.ScreenRect.UpperLeft) ||
                    !ScreenRect.Contains(control.ScreenRect.LowerRight))
                {
                    throw new ArgumentException("The specified control is too large to fit on the screen.");
                }
            }

            CheckNewlyAddedControlMessages(control);

            control.ParentWindow = this;
            control.Pigments     = new PigmentMap(Pigments,
                                                  control.PigmentOverrides);

            if (!control.isSetup)
            {
                control.OnSettingUp();
            }

            return(atRequestedPos);
        }
コード例 #5
0
            public override bool Draw(IRichPane rp)
            {
                if (IsMasking)
                {
                    var sr = rp.GetPaneRect();
                    rp.Graphics.DrawString("PAUSE", _font, Brushes.DarkGray, sr.LT.X + 48, sr.RB.Y - 42);
                }
                else
                {
                    // Left side RED curtain
                    var sr  = rp.GetPaneRect();
                    var W   = 240;
                    var rc1 = ScreenRect.FromLTWH(sr.LT.X, sr.LT.Y, W, sr.Height);
                    rp.Graphics.FillRectangle(new LinearGradientBrush(new Point(0, 0), new PointF(W, 0), Color.FromArgb(128, 255, 0, 0), Color.FromArgb(0, 255, 0, 0)), rc1);

                    // Now pointer RED curtain
                    var now = DateTime.Now;
                    now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
                    var rc2 = GetScRect(rp, CodeRect.FromLTRB((int)(now - Hot.FirstSpeech).TotalSeconds, 0, 0, 0));
                    rc2 = ScreenRect.FromLTRB(rc2.LT.X, sr.LT.Y, sr.RB.X, sr.RB.Y);
                    rp.Graphics.FillRectangle(new LinearGradientBrush(new Point(rc2.LT.X, rc2.LT.Y), new PointF(rc2.RB.X, rc2.RB.Y), Color.FromArgb(8, 255, 0, 0), Color.FromArgb(96, 255, 0, 0)), rc2);

                    // REC LABEL
                    if (++_cnt % 2 == 0)
                    {
                        rp.Graphics.DrawString("REC", _font, Brushes.Yellow, sr.LT.X + 48, sr.RB.Y - 42);
                    }
                }
                return(true);
            }
コード例 #6
0
        /// <summary>
        /// Adds a control instance to this window.  All controls must be reference-unique, or this
        /// method will throw an ArgumentException.  This method will also throw an ArgumentExeption
        /// if the control is too large to fit on the screen.  A newly added control may receive
        /// a MouseEnter message if the mouse is within it's region, and will always receive a
        /// SettingUp message if it hasn't received one previously.
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException">Thrown when the specified <paramref name="control"/>
        /// is already contained by this window.</exception>
        public bool AddControl(Control control)
        {
            if (ContainsControl(control) || controlAddList.Contains(control))
            {
                throw new ArgumentException("CurrentWindow already contians an instance of this control");
            }

            this.controlAddList.Add(control);
            control.ParentWindow = this;
            bool atRequestedPos = CheckNewlyAddedControlPosition(control);

            if (!atRequestedPos)
            {
                if (!ScreenRect.Contains(control.ScreenRect.TopLeft) ||
                    !ScreenRect.Contains(control.ScreenRect.BottomRight.Shift(-1, -1)))
                {
                    throw new ArgumentException("The specified control is too large to fit on the screen.");
                }
            }

            CheckNewlyAddedControlMessages(control);

            control.Pigments = new PigmentMap(Pigments,
                                              control.PigmentOverrides);

            if (!control.IsSetup)
            {
                control.OnSettingUp();
            }

            control.OnAdded();
            OnAdded(new EventArgs <Component>(control));

            return(atRequestedPos);
        }
コード例 #7
0
            Window BuildWindow()
            {
                ScreenRect    wRect  = new ScreenRect(Window.Center, Window.Center, 640, 480);
                WindowFlags   wFlags = WindowFlags.Shown;
                RendererFlags rFlags = RendererFlags.Accelerated | RendererFlags.PresentVSync;

                return(new Window(windowID, "heng", wRect, wFlags, rFlags));
            }
コード例 #8
0
 protected override Brush createLogPanelBG(ScreenRect sr)
 {
     return(new System.Drawing.Drawing2D.LinearGradientBrush(
                sr.LT, sr.RT,
                Color.FromArgb(128, 0, 0, 0),
                Color.FromArgb(32, 0, 0, 0)
                ));
 }
コード例 #9
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") })
コード例 #10
0
 public override void Draw(DrawProperty dp)
 {
     if (Visible)
     {
         var sr = ScreenRect.FromLTRB(Left.Cx, Top.Cy, Right.Cx, Bottom.Cy);
         dp.Graphics.FillRectangle(_(sr), MaskBG);
         dp.Graphics.FillRectangle(_(sr), MaskPen);
     }
 }
コード例 #11
0
        /// <summary>
        /// background design
        /// </summary>
        /// <param name="dp"></param>
        /// <param name="sr"></param>
        protected virtual void drawBackground(DrawProperty dp, ScreenRect sr)
        {
            var bg = new CanvasLinearGradientBrush(dp.Canvas, Parent.BackgroundColor1, Parent.BackgroundColor2)
            {
                StartPoint = _(ScreenPos.From(sr.LT.X, sr.LT.Y)),
                EndPoint   = _(ScreenPos.From(sr.RB.X, sr.RB.Y)),
            };

            dp.Graphics.FillRectangle(_(dp.PaneRect), bg);
        }
コード例 #12
0
ファイル: RectDrawable.cs プロジェクト: idafi/heng
        /// <inheritdoc />
        public void Draw(Window window, Camera camera)
        {
            ScreenPoint pos = camera.WorldToViewportPosition(Position.PixelTranslate(Rect.BottomLeft));
            int         w   = HMath.RoundToInt(Rect.Extents.X * 2);
            int         h   = HMath.RoundToInt(Rect.Extents.Y * 2);

            ScreenRect rect = new ScreenRect(pos.X, pos.Y, w, h);

            window.DrawRect(rect, Fill, Color);
        }
コード例 #13
0
 /// <summary>
 /// cast support from ScreenRect to Windows.Foundation.Rect
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static Windows.Foundation.Rect _(ScreenRect value)
 {
     return(new Windows.Foundation.Rect
     {
         X = value.LT.X.Sx,
         Y = value.LT.Y.Sy,
         Width = value.Width.Sx,
         Height = value.Height.Sy,
     });
 }
コード例 #14
0
        public void Update(GameTime time, IMouseManager mouse, IKeyboardManager keyboard)
        {
            IsHovered = ScreenRect.Contains(mouse.Position);
            if (IsHovered)
            {
                if (mouse.IsScrollWheelUp())
                {
                    OnMouseWheel(mouse.ScrollWheelDelta);
                    if (MouseWheel != null)
                    {
                        MouseWheel(mouse.ScrollWheelDelta);
                    }
                }
                else if (mouse.IsScrollWheelDown())
                {
                    OnMouseWheel(mouse.ScrollWheelDelta);
                    if (MouseWheel != null)
                    {
                        MouseWheel(mouse.ScrollWheelDelta);
                    }
                }

                if (mouse.IsButtonPressed(MouseButton.Left))
                {
                    OnMouseClick(MouseButton.Left);
                    if (Clicked != null)
                    {
                        Clicked();
                    }
                    if (MouseClicked != null)
                    {
                        MouseClicked(MouseButton.Left);
                    }
                }
                if (mouse.IsButtonPressed(MouseButton.Middle))
                {
                    OnMouseClick(MouseButton.Middle);
                    if (MouseClicked != null)
                    {
                        MouseClicked(MouseButton.Middle);
                    }
                }
                if (mouse.IsButtonPressed(MouseButton.Right))
                {
                    OnMouseClick(MouseButton.Right);
                    if (MouseClicked != null)
                    {
                        MouseClicked(MouseButton.Right);
                    }
                }
            }

            OnUpdate(time, mouse, keyboard);
        }
コード例 #15
0
        public override void Draw(DrawProperty dp)
        {
            if (string.IsNullOrEmpty(Text) || string.IsNullOrWhiteSpace(Text))
            {
                return;
            }

            var tf = new CanvasTextFormat
            {
                FontFamily               = "Segoe UI",
                FontSize                 = 11.0f,
                FontStyle                = FontStyle.Normal,
                FontStretch              = FontStretch.Normal,
                FontWeight               = FontWeights.Normal,
                WordWrapping             = CanvasWordWrapping.NoWrap,
                Direction                = CanvasTextDirection.LeftToRightThenTopToBottom,
                HorizontalAlignment      = CanvasHorizontalAlignment.Left,
                LineSpacing              = 2.0f,
                OpticalAlignment         = CanvasOpticalAlignment.Default,
                Options                  = CanvasDrawTextOptions.Default,
                VerticalAlignment        = CanvasVerticalAlignment.Top,
                VerticalGlyphOrientation = CanvasVerticalGlyphOrientation.Default,
            };
            var ssz0 = GraphicUtil.MeasureString(dp.Canvas, Text, tf);
            var ssz  = ssz0.Clone();
            var sp   = ScreenPos.From(Location.X.Cx, Location.Y.Cy);

            if (IsUpperPositionDefault)
            {
                sp += ScreenX.From(8);
                sp -= ScreenY.From(32);
            }
            else
            {
                sp -= ssz.Width;            // adjust tooltip position
                sp += ScreenY.From(24);
            }
            if (sp.X < 0)
            {
                sp.X = ScreenX.From(0);
            }

            var sr = ScreenRect.From(sp, ssz + ScreenSize.From(12, 12));

            sp += ScreenPos.From(6, 4); // padding
            dp.Graphics.FillRectangle(_(sr), Color.FromArgb(0xee, 0xdd, 0xdd, 0xdd));
            dp.Graphics.DrawRectangle(_(sr), Color.FromArgb(0xff, 0x88, 0x88, 0x88));
            dp.Graphics.DrawText(Text, sp + ssz0.Height, Color.FromArgb(0xff, 0x00, 0x00, 0x00), tf);
        }
コード例 #16
0
        public Vector2 GetRectSize(RectTransform rect)
        {
            Vector3[] corners = new Vector3[4];
            rect.GetWorldCorners(corners);


            for (int i = 0; i < corners.Length; i++)
            {
                corners[i] = ScreenRect.InverseTransformPoint(corners[i]);
            }

            return(new Vector2(
                       Math.Abs(corners[0].x - corners[2].x),
                       Math.Abs(corners[0].y - corners[2].y)));
        }
コード例 #17
0
 private void Pane_SizeChanged(object sender, EventArgs e)
 {
     if (LogParts != null)
     {
         var r = Pane.GetPaneRect();
         LogParts.SetMargin(ScreenRect.FromLTRB(r.RB.X - 480, 0, 0, 0));
     }
     else
     {
         Timer.AddTrigger(200, () =>
         {
             Pane_SizeChanged(this, EventArgs.Empty);
         });
     }
 }
コード例 #18
0
ファイル: Window.cs プロジェクト: idafi/heng
 /// <summary>
 /// Constructs a new Window instance, based on an old instance.
 /// <para>The window's ID is always kept, but any other parameters set to null
 /// will carry settings over from the old instance.</para>
 /// </summary>
 /// <param name="old">The old instance upon which the new Window is based.</param>
 /// <param name="title">The title of the window.</param>
 /// <param name="rect">The dimensions of the window.</param>
 /// <param name="windowFlags">Configuration settings for the window.</param>
 /// <param name="rendererFlags">Configuration settings for the window's renderer.</param>
 public Window(Window old, string title = null, ScreenRect?rect             = null,
               WindowFlags?windowFlags  = null, RendererFlags?rendererFlags = null)
 {
     if (old != null)
     {
         ID            = old.ID;
         Title         = title ?? old.Title;
         Rect          = rect ?? old.Rect;
         WindowFlags   = windowFlags ?? old.WindowFlags;
         RendererFlags = rendererFlags ?? old.RendererFlags;
     }
     else
     {
         Log.Error("couldn't construct new Window: old Window is null");
     }
 }
コード例 #19
0
ファイル: GestureBehaviour.cs プロジェクト: PRomanUA/GR_3
        private void Start()
        {
            canvas            = GetComponentInChildren <Canvas>();
            unlimitedDrawArea = transform.Find("Canvas/UnlimitedDrawArea").GetComponent <RectTransform>();
            limitedDrawArea   = transform.Find("Canvas/LimitedDrawArea").GetComponent <RectTransform>();

            if (limitType == GestureLimitType.Unlimited)
            {
                limitedDrawArea.gameObject.SetActive(false);
            }
            else
            {
                unlimitedDrawArea.gameObject.SetActive(false);
                limitedDrawAreaRect = limitedDrawArea.GetScreenRect(canvas);
            }
        }
コード例 #20
0
        /**
         * Calculate a screen space rectangle given normalized screen space coords.
         * The resulting rect is clamped to always be on-screen.
         */
        public static Rect CalcPageRect(ScreenRect screenRect)
        {
            Rect rect = new Rect();

            rect.xMin = Screen.width * screenRect.x1;
            rect.yMin = Screen.height * screenRect.y1;
            rect.xMax = Screen.width * screenRect.x2;
            rect.yMax = Screen.height * screenRect.y2;

            // Clamp to be on-screen
            rect.xMax = Mathf.Min(rect.xMax, Screen.width);
            rect.xMin = Mathf.Max(rect.xMin, 0);
            rect.yMax = Mathf.Min(rect.yMax, Screen.height);
            rect.yMin = Mathf.Max(rect.yMin, 0);

            return(rect);
        }
コード例 #21
0
        public Vector2 GetRectCenter(RectTransform rect)
        {
            Vector3[] corners = new Vector3[4];
            rect.GetWorldCorners(corners);


            for (int i = 0; i < corners.Length; i++)
            {
                corners[i] = ScreenRect.InverseTransformPoint(corners[i]);
            }

            var size = GetRectSize(rect);

            return(new Vector2(
                       corners[0].x + size.x / 2,
                       corners[0].y + size.y / 2));
        }
コード例 #22
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));
            }
        }
コード例 #23
0
ファイル: SkillBarView.cs プロジェクト: chamons/ArenaLS
        public override HitTestResults HitTest(SKPointI point)
        {
            if (!ScreenRect.Contains(point))
            {
                return(null);
            }

            for (int i = 0; i < MaxNumberOfSkills; ++i)
            {
                SKRect buttonRect = RectForSkill(i);
                buttonRect.Offset(Position.X, Position.Y);
                if (buttonRect.Contains(point))
                {
                    return(new HitTestResults(this, i));
                }
            }
            return(null);
        }
コード例 #24
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);
        }
コード例 #25
0
        /**
         * Reset to the default page layout based on properties in Game class.
         */
        public void SetDefaultPageLayout()
        {
            Game       game       = Game.GetInstance();
            ScreenRect screenRect = CalcScreenRect(game.defaultPageScale, game.defaultPagePosition);

            pageRect = CalcPageRect(screenRect);
            switch (game.defaultPagePosition)
            {
            case PageController.PagePosition.Top:
                game.pageController.layout = PageController.Layout.FullSize;
                break;

            case PageController.PagePosition.Middle:
                game.pageController.layout = PageController.Layout.FitToMiddle;
                break;

            case PageController.PagePosition.Bottom:
                game.pageController.layout = PageController.Layout.FullSize;
                break;
            }
        }
コード例 #26
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();
        }
コード例 #27
0
        /// Screen座標系のRectとIntersectを取り、新しいClipping領域に設定する。
        /// @param nextScreenRect 新しいClipping領域(Intersect前)
        public void SetClippingRectByScreenRect(ScreenRect nextScreenRect)
        {
            Debug.Assert(this.IsWindowValid, "Invalid Window", "LayoutElement.SetClippingRectByScreenRect");

            // Screen座標系でのウィンドウのクライアント領域とIntersectをとる
            var boundScreenRect = Utilities.GetWindowScreenRect(this.WindowType, this.Window);

            if (!nextScreenRect.IntersectsWith(boundScreenRect))
            {
                Debug.WriteLine("No Intersection", "LayoutElement.SetClippingRectByScreenRect");
                return;
            }
            /// @warning nextScreenRectが更新されるので注意
            nextScreenRect.Intersect(boundScreenRect);

            // プロパティを変更
            this.Fit = false;
            switch (this.WindowType)
            {
            case WindowTypes.Normal:
            case WindowTypes.DXGI: {
                // Screen->Client座標系変換
                this.ClippingXWithoutFit = nextScreenRect.X - boundScreenRect.X;
                this.ClippingYWithoutFit = nextScreenRect.Y - boundScreenRect.Y;
                break;
            }

            case WindowTypes.Desktop: {
                // 変換の必要なし
                this.ClippingXWithoutFit = nextScreenRect.X;
                this.ClippingYWithoutFit = nextScreenRect.Y;
                break;
            }

            default: Debug.Fail("switch"); throw new System.ArgumentException();
            }
            // Width/Heightは共通
            this.ClippingWidthWithoutFit  = nextScreenRect.Width;
            this.ClippingHeightWithoutFit = nextScreenRect.Height;
        }
コード例 #28
0
ファイル: Window.cs プロジェクト: idafi/heng
        /// <summary>
        /// Constructs a new Window instance.
        /// </summary>
        /// <param name="id">The unique ID of the window.</param>
        /// <param name="title">The title of the window.</param>
        /// <param name="rect">The dimensions of the window.</param>
        /// <param name="windowFlags">Configuration settings for the window.</param>
        /// <param name="rendererFlags">Configuration settings for the window's renderer.</param>
        public Window(int id, string title, ScreenRect rect, WindowFlags windowFlags, RendererFlags rendererFlags)
        {
            if (id > -1)
            {
                if (title == null)
                {
                    Log.Warning("new Window has null title");
                    title = "";
                }

                ID    = id;
                Title = title;

                Rect          = rect;
                WindowFlags   = windowFlags;
                RendererFlags = rendererFlags;
            }
            else
            {
                Log.Error("couldn't construct new Window: ID is negative");
            }
        }
コード例 #29
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;
            }
        }
コード例 #30
0
        public void OnPartsMoving(EventTokenPartsMovingTrigger token)
        {
            var col0 =
                from p in token.PartsSet
                let a = p as PartsJitWork
                        where a != null
                        where a.OriginalPosition != null
                        where a.IsSelectingLocation
                        where a.IsMoved()
                        select a;
            var col = col0.ToArray();

            if (token.PartsSet.Count() > 1)
            {
                foreach (var a in col)
                {
                    a.IsSelectingLocation = false;
                }
                return;
            }

            if (col.FirstOrDefault() is PartsJitWork p2)
            {
                movingWorkParts = p2;
            }

            if (movingWorkParts != null)
            {
                var scw = movingWorkParts.GetScreenPos(Pane.Target);
                foreach (var pt in Parts.GetParts <PartsJitProcess>(LAYER.JitProcess))
                {
                    var scp = pt.GetScreenPos(Pane.Target);
                    var srp = ScreenRect.FromCS(scp, pt.SelectableSize);
                    pt.IsConnecting = movingWorkParts.IsIn(Pane.Target, srp);
                }
            }
        }
コード例 #31
0
        /// Screen座標系のRectとIntersectを取り、新しいClipping領域に設定する。
        /// @param nextScreenRect 新しいClipping領域(Intersect前)
        public void SetClippingRectByScreenRect(ScreenRect nextScreenRect)
        {
            Debug.Assert(this.IsWindowValid, "Invalid Window", "LayoutElement.SetClippingRectByScreenRect");

            // Screen座標系でのウィンドウのクライアント領域とIntersectをとる
            var boundScreenRect = Utilities.GetWindowScreenRect(this.WindowType, this.Window);
            if (!nextScreenRect.IntersectsWith(boundScreenRect)) {
              Debug.WriteLine("No Intersection", "LayoutElement.SetClippingRectByScreenRect");
              return;
            }
            /// @warning nextScreenRectが更新されるので注意
            nextScreenRect.Intersect(boundScreenRect);

            // プロパティを変更
            this.Fit = false;
            switch (this.WindowType) {
              case WindowTypes.Normal:
              case WindowTypes.DXGI: {
            // Screen->Client座標系変換
            this.ClippingXWithoutFit = nextScreenRect.X - boundScreenRect.X;
            this.ClippingYWithoutFit = nextScreenRect.Y - boundScreenRect.Y;
            break;
              }
              case WindowTypes.Desktop: {
            // 変換の必要なし
            this.ClippingXWithoutFit = nextScreenRect.X;
            this.ClippingYWithoutFit = nextScreenRect.Y;
            break;
              }
              default: Debug.Fail("switch"); throw new System.ArgumentException();
            }
            // Width/Heightは共通
            this.ClippingWidthWithoutFit = nextScreenRect.Width;
            this.ClippingHeightWithoutFit = nextScreenRect.Height;
        }