예제 #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);
            }
        }
예제 #2
0
        public void PartsMoved(EventTokenPartsMovedTrigger token)
        {
            Token.Finalize(() =>
            {
                var jacUndo = new StringBuilder();
                var jacRedo = new StringBuilder();
                jacUndo.AppendLine("Gui.ClearAllSelection = true");
                jacRedo.AppendLine("Gui.ClearAllSelection = true");
                var n = 0;

                var tars =
                    from p in token.PartsSet
                    let cc = p as IGuiPartsControlCommon
                             where cc != null
                             where cc.IsCancellingMove == false
                             select cc;

                foreach (IGuiPartsControlCommon pt in tars)
                {
                    n++;
                    jacRedo.AppendLine($@"{pt.ID}.LocationX = {pt.Location.X.Cx.m}m");
                    jacRedo.AppendLine($@"{pt.ID}.LocationY = {pt.Location.Y.Cy.m}m");
                    jacRedo.AppendLine($@"Gui.UpdateLocation = {pt.ID}");
                    jacRedo.AppendLine($@"Gui.SelectParts = {pt.ID}");

                    jacUndo.AppendLine($@"{pt.ID}.LocationX = {pt.OriginalPosition.X.Cx.m}m");
                    jacUndo.AppendLine($@"{pt.ID}.LocationY = {pt.OriginalPosition.Y.Cy.m}m");
                    jacUndo.AppendLine($@"Gui.UpdateLocation = {pt.ID}");
                    jacUndo.AppendLine($@"Gui.SelectParts = {pt.ID}");
                }
                if (n > 0)
                {
                    SetNewAction(token, jacRedo.ToString(), jacUndo.ToString());
                }
            });
        }
예제 #3
0
 public void OnPartsMoved(EventTokenPartsMovedTrigger token)
 {
     if (movingWorkParts?.OriginalPosition != null)
     {
         try
         {
             var procs = Parts.GetParts <PartsJitProcess>(LAYER.JitProcess, a => a.IsConnecting).ToArray();
             if (procs.Length == 0)
             {
                 // Just Move work
                 return;
             }
             else if (procs.Length == 1)  // Set Work.Next
             {
                 var pw = Hot.ActiveTemplate.Jac.GetWork(movingWorkParts.ID);
                 var pp = Hot.ActiveTemplate.Jac.GetProcess(procs[0].ID);
                 if (pw.Next?.Process?.ID != procs[0].ID)
                 {
                     var jacredo =
                         $@"
                         {movingWorkParts.ID}
                             Next = new Location
                                 Stage = TheStage
                                 Path = '\'
                                 Process = {procs[0].ID}
                         Gui.UpdateCassetteValue = {movingWorkParts.ID}
                         Gui.SelectParts = {movingWorkParts.ID}
                     ";
                     string jacundo = "";
                     if (pw.Next == null)
                     {
                         jacundo = $@"
                             {movingWorkParts.ID}
                                 Next = null
                         ";
                     }
                     else
                     {
                         jacundo = $@"
                             {movingWorkParts.ID}
                                 Next = new Location
                                     Stage = TheStage
                                     Path = '\'
                                     Process = {(pw.Next.Process?.ID ?? "null")}
                         ";
                     }
                     {
                         jacundo += $@"
                             Gui.UpdateCassetteValue = {movingWorkParts.ID}
                             Gui.SelectParts = {movingWorkParts.ID}
                         ";
                     }
                     SetNewAction(token, jacredo, jacundo);
                     LOG.WriteLine(LLV.WAR, $"The Work.Next = {pp.Name}"); // TODO: Support Multi language with LOG.AddMes (VS2019 is now not work Resources.resw editor)
                 }
                 else
                 {
                     LOG.WriteLine(LLV.WAR, "The process is already set to this work."); // TODO: Support Multi language with LOG.AddMes (VS2019 is now not work Resources.resw editor)
                 }
             }
             else
             {
                 LOG.WriteLine(LLV.WAR, "Need to select ONE process to set work destination."); // TODO: Support Multi language with LOG.AddMes (VS2019 is now not work Resources.resw editor)
             }
             movingWorkParts.Location            = movingWorkParts.OriginalPosition;
             movingWorkParts.IsSelected          = false;
             movingWorkParts.IsCancellingMove    = true;
             movingWorkParts.IsSelectingLocation = false;
         }
         finally
         {
             foreach (var pp in Parts.GetParts <PartsJitProcess>(LAYER.JitProcess))
             {
                 pp.IsConnecting = false;
             }
             movingWorkParts.IsSelectingLocation = false;
             movingWorkParts.IsSelected          = false;
             movingWorkParts = null;
             Redraw();
         }
     }
 }