Beispiel #1
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);
            }
        }
Beispiel #2
0
        public void Cancelling(EventTokenTriggerToolDragging token)
        {
            if (CurrentParts == null)
            {
                return;
            }

            Parts.Remove(PaneJitParts, CurrentParts, LAYER.JitProcess);  // delete temporary parts
            CurrentParts = null;
            Redraw();
        }
Beispiel #3
0
        public void CreateProcess(EventTokenProcessPartsTrigger token)
        {
            var pt = new PartsJitProcess
            {
                ID          = token.Process.ID,
                Location    = CodePos <Distance, Distance> .From((Distance)token.Process.ChildVriables["LocationX"].Value, (Distance)token.Process.ChildVriables["LocationY"].Value),
                Width       = (Distance)token.Process.ChildVriables["Width"].Value,
                Height      = (Distance)token.Process.ChildVriables["Height"].Value,
                PositionerX = DistancePositionerX,
                PositionerY = DistancePositionerY,
                CoderX      = DistanceCoderX,
                CoderY      = DistanceCoderY,
            };

            Parts.Add(PaneJitParts, pt, LAYER.JitProcess);
            Redraw();
        }
Beispiel #4
0
        public void Creating(EventTokenTriggerToolDragging token)
        {
            if (CurrentParts != null)
            {
                return;
            }

            CurrentParts = new PartsJitProcess
            {
                Location    = GetCoderPos(PaneJitParts, token.Pointer),
                Width       = Distance.FromMeter(2.0),
                Height      = Distance.FromMeter(2.0),
                PositionerX = DistancePositionerX,
                PositionerY = DistancePositionerY,
                CoderX      = DistanceCoderX,
                CoderY      = DistanceCoderY,
            };
            Parts.Add(PaneJitParts, CurrentParts, LAYER.JitProcess);
        }
Beispiel #5
0
        /// <summary>
        /// Connect
        /// </summary>
        /// <param name="token"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        private void Connect(EventTokenTrigger token, PartsJitProcess from, PartsJitProcess to)
        {
            ResetConnectorGripParts();
            var jacredo =
                $@"
                TheStage
                    ProcLinks
                        add '{from.ID}' -> '{to.ID}'
                Gui.AddProcLink = '{from.ID},{to.ID}'
            ";
            var jacundo =
                $@"
                TheStage
                    ProcLinks
                        remove '{from.ID}' -> '{to.ID}'
                Gui.RemoveProcLink = '{from.ID},{to.ID}'
            ";

            SetNewAction(token, jacredo, jacundo);
        }
Beispiel #6
0
        public void Finished(EventTokenTriggerToolDragging token)
        {
            if (CurrentParts == null)
            {
                return;
            }

            CurrentParts.DesignState = PartsJitBase.DesignStates.Normal;
            CurrentParts.Location    = GetCoderPos(PaneJitParts, token.Pointer);
            var processID = JacInterpreter.MakeID("Process");

            CurrentParts.ID = processID;

            var jacredo =
                $@"
                TheStage
                    Procs
                        add new Process
                            ID = '{processID}'
                            LocationX = {CurrentParts.Location.X.Cx.m}m
                            LocationY = {CurrentParts.Location.Y.Cy.m}m
                            Width = {CurrentParts.Width.m}m
                            Height = {CurrentParts.Height.m}m
                Gui.ClearAllSelection = true
                Gui.CreateProcess = {processID}
            ";
            var jacundo =
                $@"
                Gui.RemoveProcess = {processID}
                TheStage
                    Procs
                        remove {processID}
            ";

            SetNewAction(token, jacredo, jacundo);

            // remove toolbox parts. (Expecting to be created by REDO processor)
            Parts.Remove(PaneJitParts, CurrentParts, LAYER.JitProcess);
            CurrentParts = null;
        }