public static ConditionalLine HookLineOut2(ConditionalAutomation auto)
        {
            if (Globals.TempFieldLine != null)
            {
                Globals.TempFieldLine.Remove();
                Globals.TempFieldLine = null;
            }

            if (Globals.TempAutomationLine == null)
            {
                var f = new ConditionalLine();
                f.Left = auto;
                Globals.TempAutomationLine = f;
                return(f);
            }
            else
            {
                if (Globals.TempAutomationLine.Left == null && Globals.TempAutomationLine.Right != auto)
                {
                    var line = new ConditionalLine(auto, Globals.TempAutomationLine.Right);
                    Globals.TempAutomationLine.Remove();
                    Globals.TempAutomationLine = null;
                    return(line);
                }
                else
                {
                    Globals.TempAutomationLine.Remove();
                    Globals.TempAutomationLine = null;
                    return(HookLineOut2(auto));
                }
            }
        }
        public ConditionalLine(ConditionalAutomation left, Automation right)
        {
            Left  = left;
            Right = right;

            left.LineOut2 = this;
            Right.LinesIn.Add(this);
        }
        protected override void OnAfterSerialize()
        {
            if (string.IsNullOrEmpty(idLeft))
            {
                Remove();
                return;
            }


            var automations = Window.GetControls <Automation>();

            foreach (var item in automations)
            {
                if (Left == null && item.ID == idLeft)
                {
                    Left = (ConditionalAutomation)item;
                    continue;
                }

                if (Right == null && item.ID == idRight)
                {
                    Right = item;
                    continue;
                }

                if (Left != null && Right != null)
                {
                    break;
                }
            }

            if (Left == null || Right == null)
            {
                Remove();
                return;
            }

            Left.LineOut2 = this;
            Right.LinesIn.Add(this);

            SortingOrder = ESortingOrder.Line;
        }