Esempio n. 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;
        }
Esempio n. 2
0
 public void AppendBranch()
 {
     if (runtimeService.DisconnectDialog(this))
     {
         var doActions       = new List <Action>();
         var undoActions     = new List <Action>();
         var origInstruction = Instruction;
         var newSeriesItem   = InstructionLDSeries.CreateForLD(this, null);
         doActions.Add(() => Items.Add(newSeriesItem));
         doActions.Add(() => Instruction   = Instruction.NodeInstructionChildren.Append(newSeriesItem.Instruction));
         undoActions.Add(() => Instruction = origInstruction);
         Do(new UndoMemento(this, ActionType.EDIT,
                            Resources.Strings.Undo_Action_Instruction_Parallel_AppendBranch, undoActions, doActions));
     }
 }
Esempio n. 3
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);
        }