Пример #1
0
        public void OnPointerMoved(PointerState po)
        {
            if (isTrigger(po))
            {
                var pts =
                    from sp in Parts.GetParts <ISelectableParts>(TargetLayer)
                    let score = sp.SelectingScore(Pane.Target, po.Position)
                                where score >= 0.0f
                                orderby score
                                select sp;

                foreach (var sp in LoopUtil <ISelectableParts> .From(pts, out var lu))
                {
                    lu.DoFirstTime(() =>
                    {
                        var score     = sp.SelectingScore(Pane.Target, po.Position);
                        sp.IsSelected = score <= 1.0f;
                    });
                    lu.DoSecondTimesAndSubsequent(() =>
                    {
                        sp.IsSelected = false;
                    });
                }
                Redraw();
            }
        }
Пример #2
0
        public void OnPointerMoved(PointerState po)
        {
            _pobak = po.Clone();
            if (isMenu)
            {
                return;
            }

            foreach (var link in LoopUtil <PartsJitProcessLink>
                     .From(
                         Parts.GetParts <PartsJitProcessLink>(LAYER.JitProcessConnector)
                         .OrderBy(a => (int)(a.SelectingScore(Pane.Target, po.Position) * 1000))
                         , out var loop))
            {
                loop.DoFirstTime(() =>
                {
                    if (link.SelectingScore(Pane.Target, po.Position) <= 1.0f)
                    {
                        link.State = PartsJitProcessLink.States.HOVER;
                    }
                    else
                    {
                        link.State = PartsJitProcessLink.States.LINE;
                    }
                });
                loop.DoSecondTimesAndSubsequent(() =>
                {
                    link.State = PartsJitProcessLink.States.LINE;
                });
            }
        }
Пример #3
0
        public void PartsMoved(EventTokenPartsMovedTrigger token)
        {
            PartsJitProcess confrom = null;

            // Fix pcon's location by Angle when updated PartsJitProcessConnector location
            foreach (var pcon in LoopUtil <PartsConnectGrip> .From(
                         token.PartsSet
                         .Where(a => a is PartsConnectGrip)
                         .Select(a => (PartsConnectGrip)a), out var loop))
            {
                pcon.SetLocation(pcon.Angle = pcon.GetAngle()); // Update Angle and Location
                loop.DoFirstTime(() =>
                {
                    confrom = pcon.TargetProcess;
                });
            }

            // Fix pcon's location by Angle when updated PartsJitProcess position
            if (token.PartsSet.Where(a => a is PartsJitProcess).FirstOrDefault() != default)
            {
                foreach (var pcon in Parts.GetParts <PartsConnectGrip>(LAYER.JitProcessConnectorGrip))
                {
                    pcon.SetLocation(pcon.Angle);
                }
            }
            var conto = Parts.GetParts <PartsJitProcess>(LAYER.JitProcess, a => a.IsConnecting).FirstOrDefault();

            if (confrom != null && conto != null)
            {
                Connect(token, confrom, conto);
            }
        }
Пример #4
0
        public void Test102()
        {
            string lastitem = "agro;jhn";

            foreach (var item in LoopUtil <string> .From(test102enum(), out var cu))
            {
                lastitem = item;
                Assert.AreEqual($"I-{cu.CurrentIndex}", item);
            }
            Assert.AreEqual("I-4", lastitem);
        }
Пример #5
0
        public void Test101()
        {
            var data = new List <int>
            {
                0, 10, 20, 30, 40, 50, 60, 70, 80, 90,
            };

            foreach (var item in LoopUtil <int> .From(data, out var cu))
            {
                Assert.AreEqual(item / 10, cu.CurrentIndex);
            }
        }
Пример #6
0
 private void Menu_Closed(object sender, object e)
 {
     foreach (var link in LoopUtil <PartsJitProcessLink> .From(Parts.GetParts <PartsJitProcessLink>(LAYER.JitProcessConnector), out var loop))
     {
         link.State = PartsJitProcessLink.States.LINE;
         loop.DoLastOneTime(() =>
         {
             Redraw();
         });
     }
     isMenu = false;
 }
Пример #7
0
        public void Test103m()
        {
            var dat = new Dictionary <int, string>
            {
                [10] = "S-10",
                [20] = "S-20",
                [30] = "S-30",
                [40] = "S-40",
                [50] = "S-50",
                [60] = "S-60",
                [70] = "S-70",
                [80] = "S-80",
                [90] = "S-90",
            };
            var c1 = 0;
            var c2 = 0;

            foreach (var item in LoopUtil <KeyValuePair <int, string> > .From(dat, out var cu))
            {
                cu.DoFirstTime(() =>
                {
                    Assert.AreEqual($"S-10", item.Value);
                    c1++;
                });
                cu.DoFirstTime(() =>
                {
                    Assert.Fail("EXPECTING NOT EXEC Because of not 'first'");
                    c1++;
                });
                cu.DoLastOneTime(() =>
                {
                    Assert.Fail("EXPECTING NOT EXEC Because of not 'last'");
                    c2++;
                });
                cu.DoLastOneTime(() =>
                {
                    Assert.AreEqual($"S-90", item.Value);   // Override last action
                    c2++;
                });
                Assert.AreEqual($"S-{item.Key}", item.Value);
            }
            Assert.AreEqual(1, c1); // Expecting One Time
            Assert.AreEqual(1, c2); // Expecting One Time
        }
Пример #8
0
        public void Test103()
        {
            var dat = new Dictionary <int, string>
            {
                [10] = "S-10",
                [20] = "S-20",
                [30] = "S-30",
                [40] = "S-40",
                [50] = "S-50",
                [60] = "S-60",
                [70] = "S-70",
                [80] = "S-80",
                [90] = "S-90",
            };
            var c1 = 0;
            var c2 = 0;
            var c3 = 0;
            var c4 = 0;

            foreach (var item in LoopUtil <KeyValuePair <int, string> > .From(dat, out var cu))
            {
                cu.DoFirstTime(() =>
                {
                    Assert.AreEqual($"S-10", item.Value);
                    c1++;
                });
                cu.DoFirstTime(() =>
                {
                    Assert.AreEqual($"S-10", item.Value);   // Can do twice
                });
                cu.DoSecondTimesAndSubsequent(() =>
                {
                    switch (c3++)
                    {
                    case 0:
                        Assert.AreEqual($"S-20", item.Value);
                        break;

                    case 1:
                        Assert.AreEqual($"S-30", item.Value);
                        break;

                    case 2:
                        Assert.AreEqual($"S-40", item.Value);
                        break;
                    }
                });
                cu.DoSecondTimesAndSubsequent(() => // Can do twice
                {
                    switch (c4++)
                    {
                    case 0:
                        Assert.AreEqual($"S-20", item.Value);
                        break;

                    case 1:
                        Assert.AreEqual($"S-30", item.Value);
                        break;

                    case 2:
                        Assert.AreEqual($"S-40", item.Value);
                        break;
                    }
                });
                cu.DoLastOneTime(() =>
                {
                    Assert.AreEqual($"S-90", item.Value);
                    c2++;
                });
                Assert.AreEqual($"S-{item.Key}", item.Value);
            }
            Assert.AreEqual(1, c1);
            Assert.AreEqual(1, c2);
            Assert.IsTrue(c3 > 2);
            Assert.IsTrue(c4 > 2);
        }