protected InstructionLDParallel(IEditorItem parent, NodeInstruction instruction)
            : base(parent, m_InstructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                newInstruction = newInstruction.NodeInstructionChildren.Append(
                    InstructionLDSeries.EmptyRung());
                newInstruction = newInstruction.NodeInstructionChildren.Append(
                    InstructionLDSeries.EmptyRung());
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate InstructionLDParallel but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
示例#2
0
        protected InstructionLDParallel(IEditorItem parent, NodeInstruction instruction)
            : base(parent, m_InstructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                newInstruction = newInstruction.NodeInstructionChildren.Append(
                    InstructionLDSeries.EmptyRung());
                newInstruction = newInstruction.NodeInstructionChildren.Append(
                    InstructionLDSeries.EmptyRung());
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate InstructionLDParallel but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu        = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
        protected InstructionLDAbstractEdge(IEditorItem parent, NodeInstruction instruction, FieldInstructionType instructionType)
            : base(parent, instructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                // Output signal: Named boolean - memory of last rung in
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(InstructionName),
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.BOOL.LOW)
                    );
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate an edge but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu        = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
示例#4
0
        private RenderFragment AutoGenerateTemplate(IEditorItem item) => builder =>
        {
            var fieldType = item.PropertyType;
            if (fieldType != null && Model != null)
            {
                // GetDisplayName
                var fieldName   = item.GetFieldName();
                var displayName = Utility.GetDisplayName(Model, fieldName);

                // FieldValue
                var valueInvoker = GetPropertyValueLambdaCache.GetOrAdd((typeof(TModel), fieldName), key => LambdaExtensions.GetPropertyValueLambda <TModel, object?>(Model, key.FieldName).Compile());
                var fieldValue   = valueInvoker.Invoke(Model);

                // ValueChanged
                var valueChangedInvoker = CreateLambda(fieldType).Compile();
                var fieldValueChanged   = valueChangedInvoker(Model, fieldName);

                // ValueExpression
                var body            = Expression.Property(Expression.Constant(Model), typeof(TModel), fieldName);
                var tDelegate       = typeof(Func <>).MakeGenericType(fieldType);
                var valueExpression = Expression.Lambda(tDelegate, body);

                var index         = 0;
                var componentType = EditorForm <TModel> .GenerateComponent(fieldType);

                builder.OpenComponent(index++, componentType);
                builder.AddAttribute(index++, "DisplayText", displayName);
                builder.AddAttribute(index++, "Value", fieldValue);
                builder.AddAttribute(index++, "ValueChanged", fieldValueChanged);
                builder.AddAttribute(index++, "ValueExpression", valueExpression);
                builder.AddAttribute(index++, "IsDisabled", item.Readonly);
                builder.AddMultipleAttributes(index++, CreateMultipleAttributes(fieldType, fieldName, item));
                builder.CloseComponent();
            }
        };
        protected void Do(IUndoMemento memento, IEditorItem extraUndoNode)
        {
            FireUndoableActionEvent(memento);
            DoRedoActions(this, memento);

            // Have to save the state after the edit is complete
            // so that subsequent ReDo commands can always go back to
            // this exact same state
            if (extraUndoNode != null)
            {
                saveNodeState(extraUndoNode, memento);
                var theirParent = extraUndoNode.Parent;
                while (theirParent != null)
                {
                    saveNodeState(theirParent, memento);
                    theirParent = theirParent.Parent;
                }
            }

            saveNodeState(this, memento);
            var myParent = Parent;

            while (myParent != null)
            {
                saveNodeState(myParent, memento);
                myParent = myParent.Parent;
            }
        }
        private InstructionLDCoil(IEditorItem parent, NodeInstruction instruction)
            : base(parent, m_InstructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                // Output signal: Named boolean - the coil signal
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_Coil_DefaultCoilName),
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldBool(false),
                        FieldConstant.Constants.BOOL.LOW) // not forced
                    );
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate InstructionLDCoil but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu        = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
 public InstructionGroupDummy(IEditorItem parent, NodeInstructionGroup instructionGroup)
     : base(parent)
 {
     if (instructionGroup == null)
     {
         throw new ArgumentNullException();
     }
     m_instructionGroup = instructionGroup;
 }
 public InstructionGroupDummy(IEditorItem parent, NodeInstructionGroup instructionGroup)
     : base(parent)
 {
     if (instructionGroup == null)
     {
         throw new ArgumentNullException();
     }
     m_instructionGroup = instructionGroup;
 }
        protected InstructionLDAbstractCounter(IEditorItem parent, NodeInstruction instruction, FieldInstructionType instructionType)
            : base(parent, instructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                // Output signal: Named boolean - the counter done signal
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_Ctr_DefaultName),
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.BOOL.LOW)
                    );
                newInstruction = newInstruction.NodeSignalChildren.Append( // memory of counter value
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_Ctr_DefaultName + SEPARATOR + Resources.Strings.LD_Snap_Ctr_CountName),
                        new FieldDataType(FieldDataType.DataTypeEnum.NUMBER),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.NUMBER.ZERO)
                    );
                newInstruction = newInstruction.NodeSignalChildren.Append( // previous rung-in condition
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_Ctr_DefaultName + SEPARATOR + Resources.Strings.LD_Snap_Ctr_OneshotStateName),
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.BOOL.LOW)
                    );
                // Input signal: setpoint
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.NUMBER),
                        new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, 0)));
                // Input signal: reset
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldConstant(FieldDataType.DataTypeEnum.BOOL, false)));
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate a Counter but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu        = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
 private InstructionLDContactNC(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction)
 {
     // Build the context menu
     if (extensionService != null)
     {
         ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
         ContextMenuEnabled = true;
     }
 }
 private InstructionLDContactNC(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction)
 {
     // Build the context menu
     if (extensionService != null)
     {
         ContextMenu        = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
         ContextMenuEnabled = true;
     }
 }
示例#12
0
        public AbstractInstructionItem(IEditorItem parent, FieldInstructionType instructionType)
            : base(parent)
        {
            if (instructionType == null)
            {
                throw new ArgumentNullException("instructionType");
            }
            m_InstructionType = instructionType;

            PropertyChanged += new PropertyChangedEventHandler(AbstractEditorItem_PropertyChanged);
            parentChanged();
        }
        public AbstractInstructionItem(IEditorItem parent, FieldInstructionType instructionType)
            : base(parent)
        {
            if (instructionType == null)
            {
                throw new ArgumentNullException("instructionType");
            }
            m_InstructionType = instructionType;

            PropertyChanged += new PropertyChangedEventHandler(AbstractEditorItem_PropertyChanged);
            parentChanged();
        }
示例#14
0
        private RenderFragment AutoGenerateTemplate(IEditorItem item) => builder =>
        {
            var fieldType = item.PropertyType;
            if (fieldType != null && Model != null)
            {
                var fieldName = item.GetFieldName();
                // GetDisplayName
                // 先取 Text 属性值,然后取资源文件中的值
                var displayName = item.GetDisplayName() ?? Utility.GetDisplayName(Model, fieldName);

                // FieldValue
                var valueInvoker = GetPropertyValueLambdaCache.GetOrAdd((typeof(TModel), fieldName), key => LambdaExtensions.GetPropertyValueLambda <TModel, object?>(Model, key.FieldName).Compile());
                var fieldValue   = valueInvoker.Invoke(Model);

                // ValueChanged
                var valueChangedInvoker = CreateLambda(fieldType).Compile();
                var fieldValueChanged   = valueChangedInvoker(Model, fieldName);

                // ValueExpression
                var body            = Expression.Property(Expression.Constant(Model), typeof(TModel), fieldName);
                var tDelegate       = typeof(Func <>).MakeGenericType(fieldType);
                var valueExpression = Expression.Lambda(tDelegate, body);

                if (IsDisplay)
                {
                    builder.OpenComponent(0, typeof(Display <>).MakeGenericType(fieldType));
                    builder.AddAttribute(1, "DisplayText", displayName);
                    builder.AddAttribute(2, "Value", fieldValue);
                    builder.AddAttribute(3, "ValueChanged", fieldValueChanged);
                    builder.AddAttribute(4, "ValueExpression", valueExpression);
                    builder.AddAttribute(5, "ShowLabel", ShowLabel ?? true);
                    builder.CloseComponent();
                }
                else
                {
                    var componentType = item.ComponentType ?? EditorForm <TModel> .GenerateComponent(fieldType, item.Rows != 0);

                    builder.OpenComponent(0, componentType);
                    builder.AddAttribute(1, "DisplayText", displayName);
                    builder.AddAttribute(2, "Value", fieldValue);
                    builder.AddAttribute(3, "ValueChanged", fieldValueChanged);
                    builder.AddAttribute(4, "ValueExpression", valueExpression);
                    builder.AddAttribute(5, "IsDisabled", item.Readonly);
                    if (IsCheckboxList(fieldType) && item.Data != null)
                    {
                        builder.AddAttribute(6, nameof(CheckboxList <IEnumerable <string> > .Items), item.Data);
                    }
                    builder.AddMultipleAttributes(7, CreateMultipleAttributes(fieldType, fieldName, item));
                    builder.CloseComponent();
                }
            }
        };
示例#15
0
        protected InstructionLDMathBase(IEditorItem parent, FieldInstructionType instructionType, NodeInstruction instruction,
                                        string defaultName, bool factory, string instructionName, string firstSignalName, string secondSignalName)
            : base(parent, instructionType)
        {
            if (factory)
            {
                return;
            }

            this.InstructionName  = instructionName;
            this.FirstSignalName  = firstSignalName;
            this.SecondSignalName = secondSignalName;

            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                // Output signal: Named number - result
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(defaultName),
                        new FieldDataType(FieldDataType.DataTypeEnum.NUMBER),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.NUMBER.ZERO)
                    );
                // Input signal: First
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.NUMBER),
                        new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, 0)));
                // Input signal: Second
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.NUMBER),
                        new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, 0)));
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu        = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
示例#16
0
 protected InstructionLDSeries(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType)
 {
     if (instruction == null)
     {
         Instruction = EmptyRung();
     }
     else
     {
         if (instruction.InstructionType != InstructionType)
         {
             throw new InvalidOperationException("Tried to instantiate InstructionLDSeries but passed a different instruction type.");
         }
         Instruction = instruction;
     }
 }
示例#17
0
        protected InstructionLDStringContains(IEditorItem parent, NodeInstruction instruction)
            : base(parent, m_InstructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                // Output signal: Named boolean - result of the comparison
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_StringContains_DefaultName),
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.BOOL.LOW)
                    );
                // Input signal: string to search
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.STRING),
                        new FieldConstant(FieldDataType.DataTypeEnum.STRING, string.Empty)));
                // Input signal: string to find
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.STRING),
                        new FieldConstant(FieldDataType.DataTypeEnum.STRING, string.Empty)));
                // Input signal: case sensitive
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldConstant(FieldDataType.DataTypeEnum.BOOL, false)));
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate a StringContains but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu        = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
示例#18
0
 internal InstructionGroupLD(IEditorItem parent, NodeInstructionGroup instructionGroup)
     : base(parent)
 {
     if (instructionGroup == null)
     {
         // a new group
         InstructionGroup = emptyNode();
     }
     else
     {
         if (instructionGroup.Language != Extensions.Workbench.Documents.PageEditor_.InstructionGroupItems.LD)
         {
             throw new InvalidOperationException("instructionGroup");
         }
         InstructionGroup = instructionGroup;
     }
 }
示例#19
0
 internal InstructionGroupLD(IEditorItem parent, NodeInstructionGroup instructionGroup)
     : base(parent)
 {
     if (instructionGroup == null)
     {
         // a new group
         InstructionGroup = emptyNode();
     }
     else
     {
         if (instructionGroup.Language != Extensions.Workbench.Documents.PageEditor_.InstructionGroupItems.LD)
         {
             throw new InvalidOperationException("instructionGroup");
         }
         InstructionGroup = instructionGroup;
     }
 }
        protected InstructionLDAbstractTimer(IEditorItem parent, NodeInstruction instruction, FieldInstructionType instructionType)
            : base(parent, instructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                // Output signal: Named boolean - the timer done signal
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_Tmr_DefaultName),
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.BOOL.LOW)
                    );
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_Tmr_DefaultName + SEPARATOR + Resources.Strings.LD_Snap_Tmr_ElapsedName),
                        new FieldDataType(FieldDataType.DataTypeEnum.NUMBER),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.NUMBER.ZERO)
                    );
                // Input signal: setpoint
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.NUMBER),
                        new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, 0)));
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate a Timer but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
示例#21
0
    /// <summary>
    /// RenderTreeBuilder 扩展方法 通过 IEditorItem 与 model 创建 Display 组件
    /// </summary>
    /// <param name="builder"></param>
    /// <param name="item"></param>
    /// <param name="model"></param>
    public static void CreateDisplayByFieldType(this RenderTreeBuilder builder, IEditorItem item, object model)
    {
        var fieldType   = item.PropertyType;
        var fieldName   = item.GetFieldName();
        var displayName = item.GetDisplayName() ?? GetDisplayName(model, fieldName);
        var fieldValue  = GenerateValue(model, fieldName);
        var type        = (Nullable.GetUnderlyingType(fieldType) ?? fieldType);

        if (type == typeof(bool) || fieldValue?.GetType() == typeof(bool))
        {
            builder.OpenComponent <Switch>(0);
            builder.AddAttribute(1, nameof(Switch.Value), fieldValue);
            builder.AddAttribute(2, nameof(Switch.IsDisabled), true);
            builder.AddAttribute(3, nameof(Switch.DisplayText), displayName);
            builder.AddAttribute(4, nameof(Switch.ShowLabelTooltip), item.ShowLabelTooltip);
            builder.CloseComponent();
        }
        else if (item.ComponentType == typeof(Textarea))
        {
            builder.OpenComponent(0, typeof(Textarea));
            builder.AddAttribute(1, nameof(Textarea.DisplayText), displayName);
            builder.AddAttribute(2, nameof(Textarea.Value), fieldValue);
            builder.AddAttribute(3, nameof(Textarea.ShowLabelTooltip), item.ShowLabelTooltip);
            builder.AddAttribute(4, "readonly", true);
            if (item.Rows > 0)
            {
                builder.AddAttribute(5, "rows", item.Rows);
            }
            builder.CloseComponent();
        }
        else
        {
            builder.OpenComponent(0, typeof(Display <>).MakeGenericType(fieldType));
            builder.AddAttribute(1, nameof(Display <string> .DisplayText), displayName);
            builder.AddAttribute(2, nameof(Display <string> .Value), fieldValue);
            builder.AddAttribute(3, nameof(Display <string> .LookupServiceKey), item.LookupServiceKey);
            builder.AddAttribute(4, nameof(Display <string> .ShowLabelTooltip), item.ShowLabelTooltip);
            builder.CloseComponent();
        }
    }
 protected InstructionLDAbstractContact(IEditorItem parent, FieldInstructionType instructionType, NodeInstruction instruction)
     : base(parent, instructionType)
 {
     if (instruction == null)
     {
         var newInstruction = NodeInstruction.BuildWith(InstructionType);
         // Input signal: (coil that we're a contact off) default to always false
         newInstruction = newInstruction.NodeSignalInChildren.Append(
             NodeSignalIn.BuildWith(
                 new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                 new FieldConstant(FieldDataType.DataTypeEnum.BOOL, false)));
         Instruction = newInstruction;
     }
     else
     {
         if (instructionType != instruction.InstructionType)
         {
             throw new ArgumentOutOfRangeException("Tried to instantiate a contact of type " +
                 instructionType.ToString() + " with an instruction of a different type.");
         }
         Instruction = instruction;
     }
 }
示例#23
0
 protected InstructionLDAbstractContact(IEditorItem parent, FieldInstructionType instructionType, NodeInstruction instruction)
     : base(parent, instructionType)
 {
     if (instruction == null)
     {
         var newInstruction = NodeInstruction.BuildWith(InstructionType);
         // Input signal: (coil that we're a contact off) default to always false
         newInstruction = newInstruction.NodeSignalInChildren.Append(
             NodeSignalIn.BuildWith(
                 new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                 new FieldConstant(FieldDataType.DataTypeEnum.BOOL, false)));
         Instruction = newInstruction;
     }
     else
     {
         if (instructionType != instruction.InstructionType)
         {
             throw new ArgumentOutOfRangeException("Tried to instantiate a contact of type " +
                                                   instructionType.ToString() + " with an instruction of a different type.");
         }
         Instruction = instruction;
     }
 }
 private InstructionLDFallingEdge(IEditorItem parent, NodeInstruction instruction)
     : base(parent, instruction, m_InstructionType)
 {
 }
 protected InstructionLDAbstractContact(IEditorItem parent, FieldInstructionType instructionType)
     : base(parent, instructionType)
 {
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDMultiply(parent, instruction);
 }
示例#27
0
 /// <summary>
 /// Just a static method that the rest of this assembly can call
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="instruction"></param>
 /// <returns></returns>
 public static IInstructionItem CreateForLD(IEditorItem parent, NodeInstruction instruction)
 {
     return(new InstructionLDSeries(parent, instruction));
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDSetReset(parent, instruction);
 }
 protected InstructionLDChooseNumber(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, Resources.Strings.LD_Snap_ChooseNumber_DefaultName, false,
     Resources.Strings.LD_Snap_ChooseNumber_InstructionName,
     Resources.Strings.LD_Snap_ChooseNumber_FirstSignalName, Resources.Strings.LD_Snap_ChooseNumber_SecondSignalName)
 {
 }
示例#30
0
 private InstructionLDCntDN(IEditorItem parent, NodeInstruction instruction)
     : base(parent, instruction, m_InstructionType)
 {
 }
 protected InstructionLDLessThan(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, false,
     Resources.Strings.LD_Snap_LessThan_InstructionName,
     Resources.Strings.LD_Snap_LessThan_FirstSignalName, Resources.Strings.LD_Snap_LessThan_SecondSignalName)
 {
 }
示例#32
0
 /// <summary>
 /// 支持每行多少个控件功能
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 private string?GetCssString(IEditorItem item) => CssBuilder.Default("form-group col-12")
 .AddClass("col-sm-6", item.Data == null && ItemsPerRow == null && item.Rows == 0)
 .AddClass($"col-sm-6 col-md-{Math.Floor(12d / (ItemsPerRow ?? 1))}", item.Data == null && ItemsPerRow != null && item.Rows == 0)
 .Build();
 public AbstractEditorItem(IEditorItem parent)
     : base(parent)
 {
     PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(AbstractEditorItem_PropertyChanged);
     parentChanged();
 }
 public virtual IInstructionGroupItem Create(IEditorItem parent, NodeInstructionGroup instructionGroup)
 {
     return null;
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDStringContains(parent, instruction);
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDGreaterThanOrEqual(parent, instruction);
 }
 protected InstructionLDGreaterThanOrEqual(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, false,
     Resources.Strings.LD_Snap_GreaterThanOrEqual_InstructionName,
     Resources.Strings.LD_Snap_GreaterThanOrEqual_FirstSignalName, Resources.Strings.LD_Snap_GreaterThanOrEqual_SecondSignalName)
 {
 }
示例#38
0
 protected InstructionLDAbstractContact(IEditorItem parent, FieldInstructionType instructionType)
     : base(parent, instructionType)
 {
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDRisingEdge(parent, instruction);
 }
 protected InstructionLDSubtract(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, Resources.Strings.LD_Snap_Subtract_DefaultName, false,
     Resources.Strings.LD_Snap_Subtract_InstructionName,
     Resources.Strings.LD_Snap_Subtract_FirstSignalName, Resources.Strings.LD_Snap_Subtract_SecondSignalName)
 {
 }
示例#41
0
 /// <summary>
 /// Factory function for creating LD Editors
 /// </summary>
 /// <param name="parent">Usually the PageEditor.PageEditorItem, but could be null</param>
 /// <param name="instructionGroup">The wrapped model class.  Null = create a new one</param>
 /// <returns></returns>
 public override IInstructionGroupItem Create(IEditorItem parent, NodeInstructionGroup instructionGroup)
 {
     return new InstructionGroupLD(parent, instructionGroup);
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDChooseNumber(parent, instruction);
 }
示例#43
0
 protected InstructionLDGreaterThan(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, false,
            Resources.Strings.LD_Snap_GreaterThan_InstructionName,
            Resources.Strings.LD_Snap_GreaterThan_FirstSignalName, Resources.Strings.LD_Snap_GreaterThan_SecondSignalName)
 {
 }
示例#44
0
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return CreateForLD(parent, instruction);
 }
 private InstructionLDRisingEdge(IEditorItem parent, NodeInstruction instruction)
     : base(parent, instruction, m_InstructionType)
 {
 }
示例#46
0
 protected InstructionLDSeries(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType)
 {
     if (instruction == null)
     {
         Instruction = EmptyRung();
     }
     else
     {
         if (instruction.InstructionType != InstructionType)
         {
             throw new InvalidOperationException("Tried to instantiate InstructionLDSeries but passed a different instruction type.");
         }
         Instruction = instruction;
     }
 }
        protected InstructionLDSetReset(IEditorItem parent, NodeInstruction instruction)
            : base(parent, m_InstructionType)
        {
            if (instruction == null)
            {
                var newInstruction = NodeInstruction.BuildWith(InstructionType);
                // Output signal: Named boolean - the latched state
                newInstruction = newInstruction.NodeSignalChildren.Append(
                    NodeSignal.BuildWith(
                        new FieldSignalName(Resources.Strings.LD_Snap_SetReset_DefaultName),
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldBool(false), // not forced
                        FieldConstant.Constants.BOOL.LOW)
                    );
                // Input signal: reset
                newInstruction = newInstruction.NodeSignalInChildren.Append(
                    NodeSignalIn.BuildWith(
                        new FieldDataType(FieldDataType.DataTypeEnum.BOOL),
                        new FieldConstant(FieldDataType.DataTypeEnum.BOOL, false)));
                Instruction = newInstruction;
            }
            else
            {
                if (instruction.InstructionType != InstructionType)
                {
                    throw new InvalidOperationException("Tried to instantiate a SetReset but passed a different instruction type.");
                }
                Instruction = instruction;
            }

            // Build the context menu
            if (extensionService != null)
            {
                ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu);
                ContextMenuEnabled = true;
            }
        }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return(new InstructionLDTmrON(parent, instruction));
 }
示例#49
0
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return(CreateForLD(parent, instruction));
 }
示例#50
0
 protected InstructionLDChooseNumber(IEditorItem parent, NodeInstruction instruction)
     : base(parent, m_InstructionType, instruction, Resources.Strings.LD_Snap_ChooseNumber_DefaultName, false,
            Resources.Strings.LD_Snap_ChooseNumber_InstructionName,
            Resources.Strings.LD_Snap_ChooseNumber_FirstSignalName, Resources.Strings.LD_Snap_ChooseNumber_SecondSignalName)
 {
 }
 public AbstractInstructionGroupItem(IEditorItem parent)
     : base(parent)
 {
 }
示例#52
0
 public AbstractEditorItem(IEditorItem parent)
     : base(parent)
 {
     PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(AbstractEditorItem_PropertyChanged);
     parentChanged();
 }
 private InstructionLDTmrON(IEditorItem parent, NodeInstruction instruction)
     : base(parent, instruction, m_InstructionType)
 {
 }
示例#54
0
 public AddNewItemCommand(IEditorItem item)
 {
     this.item = item;
 }
示例#55
0
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return(new InstructionLDChooseNumber(parent, instruction));
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDLessThan(parent, instruction);
 }
 public override IInstructionGroupItem Create(IEditorItem parent, NodeInstructionGroup instructionGroup)
 {
     return(new InstructionGroupDummy(parent, instructionGroup));
 }
 public override IInstructionItem Create(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDParallel(parent, instruction);
 }
示例#59
0
        private IEnumerable <KeyValuePair <string, object?> > CreateMultipleAttributes(Type fieldType, string fieldName, IEditorItem item)
        {
            var ret  = new List <KeyValuePair <string, object?> >();
            var type = Nullable.GetUnderlyingType(fieldType) ?? fieldType;

            if (type.IsEnum)
            {
                // 枚举类型
                // 通过字符串转化为枚举类实例
                var items = type.ToSelectList();
                if (items != null)
                {
                    ret.Add(new KeyValuePair <string, object?>("Items", items));
                }
            }
            else
            {
                switch (type.Name)
                {
                case nameof(String):
                    ret.Add(new KeyValuePair <string, object?>("placeholder", Utility.GetPlaceHolder(Model, fieldName) ?? PlaceHolderText));
                    if (item.Rows != 0)
                    {
                        ret.Add(new KeyValuePair <string, object?>("rows", item.Rows));
                    }
                    break;

                case nameof(Int16):
                case nameof(Int32):
                case nameof(Int64):
                case nameof(Single):
                case nameof(Double):
                case nameof(Decimal):
                    ret.Add(new KeyValuePair <string, object?>("Step", item.Step !));
                    break;

                default:
                    break;
                }
            }
            ret.Add(new KeyValuePair <string, object?>("ShowLabel", ShowLabel));
            return(ret);
        }
示例#60
0
 /// <summary>
 /// Just a static method that the rest of this assembly can call
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="instruction"></param>
 /// <returns></returns>
 public static IInstructionItem CreateForLD(IEditorItem parent, NodeInstruction instruction)
 {
     return new InstructionLDSeries(parent, instruction);
 }