Exemple #1
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);
        }
Exemple #2
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);
                }
            }
        }