Exemplo n.º 1
0
        public override Enum createEnum()
        {
            Enum retVal = new Types.Enum();

            _defaultValueSetter.SetDefaultValue(retVal);

            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Builds the boxes representing the contents of a range
        /// </summary>
        /// <param name="enumeration"></param>
        /// <param name="retVal"></param>
        private void BuildEnumBoxes(Enum enumeration, ICollection <IGraphicalDisplay> retVal)
        {
            retVal.Add(enumeration);
            foreach (EnumValue value in enumeration.Values)
            {
                retVal.Add(value);
            }

            foreach (Enum subEnum in enumeration.SubEnums)
            {
                BuildEnumBoxes(subEnum, retVal);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Accepts drop of a tree node, in a drag & drop operation
        /// </summary>
        /// <param name="sourceNode"></param>
        public override void AcceptDrop(BaseTreeNode sourceNode)
        {
            base.AcceptDrop(sourceNode);

            if (sourceNode is EnumerationTreeNode)
            {
                EnumerationTreeNode enumerationTreeNode = sourceNode as EnumerationTreeNode;
                Enum enumeration = enumerationTreeNode.Item;

                enumerationTreeNode.Delete();
                Item.appendEnumerations(enumeration);
            }
            else if (sourceNode is ParagraphTreeNode)
            {
                ParagraphTreeNode node      = sourceNode as ParagraphTreeNode;
                Paragraph         paragraph = node.Item;

                Enum enumeration = Enum.CreateDefault(Item.Enumerations);
                Item.appendEnumerations(enumeration);
                enumeration.FindOrCreateReqRef(paragraph);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates the layout for an enumeration contents
        /// </summary>
        /// <param name="enumeration"></param>
        /// <param name="location"></param>
        private ModelControl CreateEnumLayout(Enum enumeration, Point location)
        {
            // Setup the rule control location and size
            ModelControl enumerationControl = (ModelControl)GetBoxControl(enumeration);

            if (enumerationControl != null)
            {
                location = new Point(location.X + 10, location.Y);
                location = SetSizeAndLocation(enumerationControl, location);

                // Compute the position automatically
                location = new Point(location.X + 10, location.Y);
                foreach (EnumValue value in enumeration.Values)
                {
                    ModelControl valueControl = (ModelControl)GetBoxControl(value);
                    location = SetSizeAndLocation(valueControl, location);
                    if (valueControl != null)
                    {
                        location = InbedTopDown(enumerationControl, valueControl, location, false);
                    }
                    location = new Point(location.X, location.Y + 10);
                    enumerationControl.Size = new Size(enumerationControl.Size.Width, enumerationControl.Size.Height + 20);
                }

                foreach (Enum subEnum in enumeration.SubEnums)
                {
                    ModelControl subEnumControl = CreateEnumLayout(subEnum, location);
                    location = InbedTopDown(enumerationControl, subEnumControl, location, false);
                    location = new Point(location.X - 10, location.Y + 10);
                    enumerationControl.Size = new Size(enumerationControl.Size.Width, enumerationControl.Size.Height + 20);
                }

                pictureBox.Size = MaxSize(PanelSize, Size);
            }

            return(enumerationControl);
        }
Exemplo n.º 5
0
        public override Enum createEnum()
        {
            Enum retVal = new Types.Enum();

            _defaultValueSetter.SetDefaultValue(retVal);

            return retVal;
        }
Exemplo n.º 6
0
 public void AddHandler(object sender, EventArgs args)
 {
     Item.appendEnumerations(Enum.CreateDefault(Item.Enumerations));
 }
Exemplo n.º 7
0
        /// <summary>
        ///     Fills the given structure with the values provided from the database
        /// </summary>
        /// <param name="aNameSpace">Namespace of the structure</param>
        /// <param name="fields">Fields to be copied into the structure</param>
        /// <param name="index">Index (of fields list) from which we have to start copying</param>
        /// <param name="aStructure">The structure to be filled</param>
        private static void FillStructure(NameSpace aNameSpace, ArrayList fields, ref int currentIndex,
                                          StructureValue aStructure)
        {
            EfsSystem system = EfsSystem.Instance;

            int j = 0;

            while (currentIndex < fields.Count)
            {
                DBField field = fields[currentIndex] as DBField;

                KeyValuePair <string, IVariable> pair = aStructure.SubVariables.ElementAt(j);
                IVariable variable = pair.Value;

                // conditional variables can be missing in the database fields, but present in our structure => skip them
                while (!variable.Name.StartsWith(field.Variable) && j < aStructure.SubVariables.Count - 1)
                {
                    j++;
                    pair     = aStructure.SubVariables.ElementAt(j);
                    variable = pair.Value;
                }

                // We use StartsWith and not Equals because we can have N_ITER_1 and N_ITER
                if (variable.Name.StartsWith(field.Variable))
                {
                    if (variable.Type is Enum)
                    {
                        Enum type = variable.Type as Enum;
                        foreach (EnumValue enumValue in type.Values)
                        {
                            int value = int.Parse(enumValue.getValue());
                            int other = int.Parse(field.Value);
                            if (value == other)
                            {
                                variable.Value = enumValue;
                                j++;
                                break;
                            }
                        }
                    }
                    else if (variable.Type is Range)
                    {
                        Range  type = variable.Type as Range;
                        object v    = VariableConverter.INSTANCE.Convert(variable.Name, field.Value);

                        string stringValue = v as string;
                        if (stringValue != null)
                        {
                            int intValue;
                            if (int.TryParse(stringValue, out intValue))
                            {
                                v = intValue;
                            }
                        }
                        variable.Value = new IntValue(type, (int)v);
                        j++;
                    }
                    else if (variable.Type is StringType)
                    {
                        StringType type = variable.Type as StringType;
                        variable.Value = new StringValue(type, field.Value);
                        j++;
                    }
                    else
                    {
                        throw new Exception("Unhandled variable type");
                    }

                    if (variable.Name.StartsWith("N_ITER")) // we have to create a sequence
                    {
                        KeyValuePair <string, IVariable> sequencePair = aStructure.SubVariables.ElementAt(j);
                        IVariable  sequenceVariable = sequencePair.Value;
                        Collection collectionType   = (Collection)system.FindType(aNameSpace, sequenceVariable.TypeName);
                        ListValue  sequence         = new ListValue(collectionType, new List <IValue>());

                        int value = int.Parse(field.Value);
                        for (int k = 0; k < value; k++)
                        {
                            currentIndex++;
                            Structure structureType =
                                (Structure)system.FindType(aNameSpace, sequence.CollectionType.Type.FullName);
                            StructureValue structureValue = new StructureValue(structureType);
                            FillStructure(aNameSpace, fields, ref currentIndex, structureValue);
                            sequence.Val.Add(structureValue);
                        }
                        sequenceVariable.Value = sequence;
                        j++;
                    }
                }

                // Special case for X_TEXT
                if ("Sequence1".Equals(variable.Name) && "X_TEXT".Equals(field.Variable))
                {
                    KeyValuePair <string, IVariable> sequencePair = aStructure.SubVariables.ElementAt(j);
                    IVariable  sequenceVariable = sequencePair.Value;
                    Collection collectionType   = (Collection)system.FindType(aNameSpace, sequenceVariable.TypeName);
                    ListValue  sequence         = new ListValue(collectionType, new List <IValue>());
                    while (field != null && "X_TEXT".Equals(field.Variable))
                    {
                        if (string.IsNullOrEmpty(field.Value))
                        {
                            field.Value = " ";
                        }
                        Structure structureType =
                            (Structure)system.FindType(aNameSpace, sequence.CollectionType.Type.FullName);
                        StructureValue structureValue = new StructureValue(structureType);
                        FillStructure(aNameSpace, fields, ref currentIndex, structureValue);
                        sequence.Val.Add(structureValue);
                        currentIndex += 1;
                        if (currentIndex < fields.Count)
                        {
                            field = fields[currentIndex] as DBField;
                        }
                        else
                        {
                            field = null;
                        }
                    }
                    sequenceVariable.Value = sequence;
                    j++;
                }

                // if all the fields of the structue are filled, we terminated
                if (j == aStructure.SubVariables.Count)
                {
                    break;
                }
                else
                {
                    currentIndex += 1;
                }
            }
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="model"></param>
 public EnumModelControl(ModelDiagramPanel panel, Enum model)
     : base(panel, model)
 {
 }
Exemplo n.º 9
0
        /// <summary>
        ///     Method used to create a box
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public override BoxControl <IModelElement, IGraphicalDisplay, ModelArrow> CreateBox(IGraphicalDisplay model)
        {
            ModelControl retVal = null;

            NameSpace nameSpace = model as NameSpace;

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (retVal == null && nameSpace != null)
            {
                retVal = new NameSpaceModelControl(this, nameSpace);
            }

            Variable variable = model as Variable;

            if (retVal == null && variable != null)
            {
                retVal = new VariableModelControl(this, variable);
            }

            Function function = model as Function;

            if (retVal == null && function != null)
            {
                retVal = new FunctionModelControl(this, function);
            }

            Parameter parameter = model as Parameter;

            if (retVal == null && parameter != null)
            {
                retVal = new ParameterModelControl(this, parameter);
            }

            Case cas = model as Case;

            if (retVal == null && cas != null)
            {
                retVal = new CaseModelControl(this, cas);
            }

            PreCondition preCondition = model as PreCondition;

            if (retVal == null && preCondition != null)
            {
                retVal = new PreConditionModelControl(this, preCondition);
            }

            Procedure procedure = model as Procedure;

            if (procedure != null)
            {
                retVal = new ProcedureModelControl(this, procedure);
            }

            Range range = model as Range;

            if (range != null)
            {
                retVal = new RangeModelControl(this, range);
            }

            Enum enumeration = model as Enum;

            if (enumeration != null)
            {
                retVal = new EnumModelControl(this, enumeration);
            }

            EnumValue value = model as EnumValue;

            if (value != null)
            {
                retVal = new EnumValueModelControl(this, value);
            }

            Collection collection = model as Collection;

            if (collection != null)
            {
                retVal = new CollectionModelControl(this, collection);
            }

            StateMachine stateMachine = model as StateMachine;

            if (stateMachine != null)
            {
                retVal = new StateMachineModelControl(this, stateMachine);
            }

            Structure structure = model as Structure;

            if (structure != null)
            {
                if (structure.IsAbstract)
                {
                    retVal = new InterfaceModelControl(this, structure);
                }
                else
                {
                    retVal = new StructureModelControl(this, structure);
                }
            }

            StructureElement element = model as StructureElement;

            if (element != null)
            {
                retVal = new StructureElementModelControl(this, element);
            }

            Rule rule = model as Rule;

            if (rule != null)
            {
                retVal = new RuleModelControl(this, rule);
            }

            RuleCondition ruleCondition = model as RuleCondition;

            if (ruleCondition != null)
            {
                retVal = new RuleConditionModelControl(this, ruleCondition);
            }

            Action action = model as Action;

            if (action != null)
            {
                retVal = new ActionModelControl(this, action);
            }

            return(retVal);
        }