Пример #1
0
        protected override void setItems()
        {
            base.setItems();
            if (InstructionGroup.NodeInstructionChildren.Items.Count != 1)
            {
                throw new InvalidOperationException("An " +
                                                    Extensions.Workbench.Documents.PageEditor_.InstructionGroupItems.LD +
                                                    " instruction group can only have one instruction child.");
            }
            NodeInstruction nInstruction = InstructionGroup.NodeInstructionChildren.Items[0];

            if (nInstruction.InstructionType != InstructionLDSeries.StaticInstructionType)
            {
                throw new InvalidOperationException("The first and only instruction in an " +
                                                    Extensions.Workbench.Documents.PageEditor_.InstructionGroupItems.LD +
                                                    " instruction group must be a " +
                                                    InstructionLDSeries.StaticInstructionType.ToString() +
                                                    " instruction.");
            }
            var newCollection           = new ObservableCollection <INodeWrapper>();
            IInstructionItem editorItem = FindItemByNodeId(nInstruction.ID) as InstructionLDSeries;

            if (editorItem == null)
            {
                editorItem = InstructionLDSeries.CreateForLD(this, nInstruction);
                HookupHandlers(editorItem);
            }
            newCollection.Add(editorItem);
            Items = newCollection;
        }
        public SignalDescriptionDisplay(IInstructionItem instructionNode, NodeSignalIn signalIn, double maxWidth, double maxHeight, TextAlignment textAlignment)
            : base(string.Empty, maxWidth, maxHeight, textAlignment, false)
        {
            if (instructionNode == null)
            {
                throw new ArgumentNullException("instructionNode");
            }

            m_instructionNode = instructionNode;
            SignalIn = signalIn;
            if (runtimeService != null)
            {
                runtimeService.SignalChanged += new SignalChangedHandler(runtimeService_SignalChanged);
            }
        }
Пример #3
0
        public SignalDescriptionDisplay(IInstructionItem instructionNode, NodeSignalIn signalIn, double maxWidth, double maxHeight, TextAlignment textAlignment)
            : base(string.Empty, maxWidth, maxHeight, textAlignment, false)
        {
            if (instructionNode == null)
            {
                throw new ArgumentNullException("instructionNode");
            }

            m_instructionNode = instructionNode;
            SignalIn          = signalIn;
            if (runtimeService != null)
            {
                runtimeService.SignalChanged += new SignalChangedHandler(runtimeService_SignalChanged);
            }
        }
Пример #4
0
        protected override void setItems()
        {
            if (Instruction.NodeInstructionChildren.Items.Count < 2)
            {
                throw new InvalidOperationException("An LD Parallel instruction must have at least 2 series children.");
            }
            foreach (var nodeWrapper in Items)
            {
                var instruc = nodeWrapper as ILDInstructionItem;
                if (instruc != null)
                {
                    instruc.PropertyChanged -= new PropertyChangedEventHandler(editorItem_PropertyChanged);
                }
            }
            var newCollection = new ObservableCollection <INodeWrapper>();

            foreach (var nInstruction in Instruction.NodeInstructionChildren.Items)
            {
                if (nInstruction.InstructionType != InstructionLDSeries.StaticInstructionType)
                {
                    throw new InvalidOperationException("All children of the LD Parallel instruction must be " +
                                                        InstructionLDSeries.StaticInstructionType.ToString() +
                                                        " instructions.");
                }
                IInstructionItem editorItem = FindItemByNodeId(nInstruction.ID) as IInstructionItem;
                if (editorItem == null)
                {
                    editorItem = InstructionLDSeries.CreateForLD(this, nInstruction);
                    logger.Info("Created new series editor item as child of parallel instruction.");
                }
                else
                {
                    editorItem.Parent = this;
                }
                editorItem.PropertyChanged += new PropertyChangedEventHandler(editorItem_PropertyChanged);
                newCollection.Add(editorItem);
            }
            foreach (var item in Items)
            {
                if (!newCollection.Contains(item))
                {
                    item.Parent = null;
                }
            }
            Items = newCollection;
            NotifyPropertyChanged(m_IsRightArgs);
            NotifyPropertyChanged(m_VerticalRungOffsetArgs);
        }
Пример #5
0
 void HookupHandlers(IInstructionItem editorItem)
 {
     editorItem.Parent = this;
     editorItem.Edited += new EditedHandler(Instruction_Edited);
 }
Пример #6
0
 void HookupHandlers(IInstructionItem editorItem)
 {
     editorItem.Parent  = this;
     editorItem.Edited += new EditedHandler(Instruction_Edited);
 }
 private void parentChanged()
 {
     if (oldParent != Parent)
     {
         if (oldParent != null)
         {
             this.Edited -= new EditedHandler(oldParent.ChildInstruction_Edited);
             this.Deleted -= new DeletedHandler(oldParent.ChildInstruction_Deleted);
         }
         oldParent = Parent as IInstructionItem;
         if (oldParent != null)
         {
             this.Edited += new EditedHandler(oldParent.ChildInstruction_Edited);
             this.Deleted += new DeletedHandler(oldParent.ChildInstruction_Deleted);
         }
     }
 }