/// <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; DataDictionary.Types.Enum enumeration = enumerationTreeNode.Item; enumerationTreeNode.Delete(); AddEnum(enumeration); } else if (SourceNode is SpecificationView.ParagraphTreeNode) { SpecificationView.ParagraphTreeNode node = SourceNode as SpecificationView.ParagraphTreeNode; DataDictionary.Specification.Paragraph paragaph = node.Item; DataDictionary.Types.Enum enumeration = (DataDictionary.Types.Enum)DataDictionary.Generated.acceptor.getFactory().createEnum(); enumeration.Name = paragaph.Name; DataDictionary.ReqRef reqRef = (DataDictionary.ReqRef)DataDictionary.Generated.acceptor.getFactory().createReqRef(); reqRef.Name = paragaph.FullId; enumeration.appendRequirements(reqRef); AddEnum(enumeration); } }
/// <summary> /// Appends an enum value to the enum provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected EnumValue CreateEnumValue(Enum enclosing, string name) { EnumValue retVal = (EnumValue)Factory.createEnumValue(); enclosing.appendValues(retVal); retVal.Name = name; return(retVal); }
/// <summary> /// Creates an enum in the namespace provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected Enum CreateEnum(Enum enclosing, string name) { Enum retVal = (Enum)Factory.createEnum(); enclosing.appendSubEnums(retVal); retVal.Name = name; return(retVal); }
/// <summary> /// Creates an enum in the namespace provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected Enum CreateEnum(NameSpace enclosing, string name) { Enum retVal = (Enum)Factory.createEnum(); enclosing.appendEnumerations(retVal); retVal.Name = name; return(retVal); }
/// <summary> /// Constructor /// </summary> /// <param name="item"></param> public EnumerationValuesTreeNode(DataDictionary.Types.Enum item) : base(item, "Values", true, false) { foreach (DataDictionary.Constants.EnumValue value in item.Values) { Nodes.Add(new EnumerationValueTreeNode(value)); } SortSubNodes(); }
public void AddHandler(object sender, EventArgs args) { DataDictionaryTreeView treeView = BaseTreeView as DataDictionaryTreeView; if (treeView != null) { DataDictionary.Types.Enum enumeration = (DataDictionary.Types.Enum)DataDictionary.Generated.acceptor.getFactory().createEnum(); enumeration.Name = "<Enumeration" + (GetNodeCount(false) + 1) + ">"; AddEnum(enumeration); } }
/// <summary> /// Adds information about an enum (or sub-enum of an enum) /// </summary> /// <param name="anEnum">The enum to add</param> /// <param name="addDetails">Add details or simply enumerate the enums</param> private void AddEnumerationSection(Enum anEnum, bool addDetails) { if (addDetails) { AddSubParagraph(anEnum.Name); AddTable(new string[] { "Enumeration " + anEnum.Name }, new int[] { 40, 20, 80 }); if (anEnum.Comment != "") { AddRow(anEnum.Comment); } AddTableHeader("Name", "Value", "Comment"); if (anEnum.Values.Count > 0) { foreach (EnumValue value in anEnum.Values) { if (value.getName().Equals(anEnum.Default)) { AddRow(value.Name, value.getValue().ToString(), "Default value"); } else { AddRow(value.Name, value.getValue().ToString(), ""); } } } CreateStatusTable(anEnum); foreach (Enum subEnum in anEnum.SubEnums) { if (considerReqRelated(subEnum)) { AddEnumerationSection(subEnum, addDetails); } } CloseSubParagraph(); } else { AddParagraph(anEnum.Name + " (" + GetRequirementsAsString(anEnum.Requirements) + ")"); } }
/// <summary> /// Appends an enum value to the enum provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected EnumValue CreateEnumValue(Enum enclosing, string name) { EnumValue retVal = (EnumValue) Factory.createEnumValue(); enclosing.appendValues(retVal); retVal.Name = name; return retVal; }
/// <summary> /// Creates an enum in the namespace provided /// </summary> /// <param name="enclosing"></param> /// <param name="name"></param> /// <returns></returns> protected Enum CreateEnum(Enum enclosing, string name) { Enum retVal = (Enum)Factory.createEnum(); enclosing.appendSubEnums(retVal); retVal.Name = name; return retVal; }
public static void HandleCellEditStarting(object sender, CellEditEventArgs e) { IVariable variable = e.RowObject as IVariable; if (variable != null) { Enum enumType = variable.Type as Enum; if (enumType != null) { ComboBox control = new ComboBox { Bounds = e.CellBounds, Font = ((ObjectListView)sender).Font, DropDownStyle = ComboBoxStyle.DropDownList, Text = (string)e.Value, DrawMode = DrawMode.OwnerDrawFixed }; foreach (EnumValue enumValue in enumType.Values) { control.Items.Add(enumValue.Name); } control.Items.Add(DefaultConst); control.Text = variable.Value.Name; control.DrawItem += cbb_DrawItem; e.Control = control; } Range rangeType = variable.Type as Range; if (rangeType != null) { ComboBox control = new ComboBox { Bounds = e.CellBounds, Font = ((ObjectListView)sender).Font, DropDownStyle = ComboBoxStyle.DropDown, Text = (string)e.Value, DrawMode = DrawMode.OwnerDrawFixed }; foreach (EnumValue enumValue in rangeType.SpecialValues) { control.Items.Add(enumValue.Name); } control.Items.Add(DefaultConst); control.Text = variable.Value.Name; control.DrawItem += cbb_DrawItem; e.Control = control; } Structure structure = variable.Type as Structure; if (structure != null) { e.Cancel = true; } Collection collection = variable.Type as Collection; if (collection != null) { e.Cancel = true; } } else { e.Cancel = true; } }
/// <summary> /// Constructor /// </summary> /// <param name="item"></param> /// <param name="buildSubNodes"></param> public EnumerationValuesTreeNode(Enum item, bool buildSubNodes) : base(item, buildSubNodes, "Values", true, false) { }
/// <summary> /// Adds a new enumeration type /// </summary> /// <param name="enumeration"></param> public void AddEnumeration(DataDictionary.Types.Enum enumeration) { enumerations.AddEnum(enumeration); }
/// <summary> /// Adds a new enumeration /// </summary> /// <param name="enumeration"></param> public void AddEnum(DataDictionary.Types.Enum enumeration) { Item.appendEnumerations(enumeration); Nodes.Add(new EnumerationTreeNode(enumeration)); SortSubNodes(); }
/// <summary> /// Adds information about an enum (or sub-enum of an enum) /// </summary> /// <param name="anEnum">The enum to add</param> /// <param name="addDetails">Add details or simply enumerate the enums</param> private void AddEnumerationSection(Enum anEnum, bool addDetails) { if (addDetails) { AddSubParagraph(anEnum.Name); AddTable(new string[] {"Enumeration " + anEnum.Name}, new int[] {40, 20, 80}); if (anEnum.Comment != "") { AddRow(anEnum.Comment); } AddTableHeader("Name", "Value", "Comment"); if (anEnum.Values.Count > 0) { foreach (EnumValue value in anEnum.Values) { if (value.getName().Equals(anEnum.Default)) { AddRow(value.Name, value.getValue().ToString(), "Default value"); } else { AddRow(value.Name, value.getValue().ToString(), ""); } } } CreateStatusTable(anEnum); foreach (Enum subEnum in anEnum.SubEnums) { if (considerReqRelated(subEnum)) { AddEnumerationSection(subEnum, addDetails); } } CloseSubParagraph(); } else { AddParagraph(anEnum.Name + " (" + GetRequirementsAsString(anEnum.Requirements) + ")"); } }
/// <summary> /// Constructor /// </summary> /// <param name="item"></param> /// <param name="buildSubNodes"></param> public EnumerationValuesTreeNode(Enum item, bool buildSubNodes) : base(item, buildSubNodes, "Values", true, false) { }
/// <summary> /// Appends the corresponding type to the name space /// </summary> /// <param name="nameSpace">The namespace in which the type must be added</param> /// <param name="name">the name of the type</param> /// <param name="type">the type to convert</param> private DataDictionary.Types.Type AppendType(DataDictionary.Types.NameSpace nameSpace, string name, ErtmsSolutions.CodecNT.Type type) { DataDictionary.Types.Type retVal = null; if (EFSType(type) == null) { if (type.value is UiValue) { UiValue uiValue = type.value as UiValue; List <DataDictionary.Constants.EnumValue> values = getSpecialValues(uiValue.special_or_reserved_values); Decimal maxValue = twoPow(type.length) - 1; if (IsEnumeration(values, maxValue)) { DataDictionary.Types.Enum enumeration = (DataDictionary.Types.Enum)DataDictionary.Generated.acceptor.getFactory().createEnum(); enumeration.Name = type.id; enumeration.Default = values[0].Name; foreach (DataDictionary.Constants.EnumValue value in values) { enumeration.appendValues(value); } nameSpace.appendEnumerations(enumeration); retVal = enumeration; } else { DataDictionary.Types.Range range = (DataDictionary.Types.Range)DataDictionary.Generated.acceptor.getFactory().createRange(); range.Name = type.id; double factor = 1.0; System.Globalization.CultureInfo info = System.Globalization.CultureInfo.InvariantCulture; ResolutionFormula resolutionFormula = uiValue.resolution_formula; if (resolutionFormula != null && resolutionFormula.Value != null) { factor = double.Parse(resolutionFormula.Value, info); // In that case the precision is integer range.setPrecision(DataDictionary.Generated.acceptor.PrecisionEnum.aIntegerPrecision); range.MinValue = "0"; range.MaxValue = "" + maxValue; range.Default = "0"; } else { if (Math.Round(factor) == factor) { // Integer precision range.setPrecision(DataDictionary.Generated.acceptor.PrecisionEnum.aIntegerPrecision); range.MinValue = "0"; range.MaxValue = "" + maxValue * new Decimal(factor); range.Default = "0"; } else { // Double precision range.setPrecision(DataDictionary.Generated.acceptor.PrecisionEnum.aDoublePrecision); range.MinValue = "0.0"; range.MaxValue = (maxValue * new Decimal(factor)).ToString(info); range.Default = "0.0"; } } foreach (DataDictionary.Constants.EnumValue value in values) { range.appendSpecialValues(value); } nameSpace.appendRanges(range); retVal = range; } } else if (type.value is CharValue) { CharValue charValue = type.value as CharValue; // Nothing to do : translated into string } else if (type.value is BcdValue) { BcdValue bcdValue = type.value as BcdValue; DataDictionary.Types.Range range = (DataDictionary.Types.Range)DataDictionary.Generated.acceptor.getFactory().createRange(); range.Name = type.id; range.MinValue = "0"; range.MaxValue = "" + (twoPow(type.length) - 1); range.Default = "0"; nameSpace.appendRanges(range); retVal = range; } if (retVal != null) { retVal.Comment = type.short_description; if (type.description != null) { retVal.Comment = retVal.Comment + "\n" + type.description; } } } return(retVal); }