public static void ProcessColumnProperty(C1DataColumn column, Dictionary <string, ValueItem> valueItemsDict, string subLine, string value)
        {
            GroupCollection groups   = RegularExpressions.PropertyRegex.Matches(subLine)[0].Groups;
            string          property = groups[2].Value;

            switch (property.ToUpper())
            {
            case nameof(ColumnProperties.VALUEITEMS):
                if (groups[10].Value == "Add")
                {
                    string argument = groups[15].Value;
                    if (!argument.StartsWith("new "))
                    {
                        string valueItemName = argument.Split('.')[1];
                        column.ValueItems.Values.Add(valueItemsDict[valueItemName]);
                    }
                }
                else
                {
                    ValueItemCollectionPropertyReader.ProcessValueItemCollectionProperty(column.ValueItems, valueItemsDict, groups[8].Value, value);
                }
                break;

            case nameof(CommonProperties.DATACHANGED):
            case nameof(CommonProperties.TEXT):
            case nameof(CommonProperties.VALUE):
                //ignore
                break;

            default:
                column.Properties[property] = Utilities.CleanXMLProperty(value);
                break;
            }
        }
        public static C1DataColumn ParseXML(XElement xElemCol)
        {
            C1DataColumn column = new C1DataColumn();

            foreach (XAttribute attribute in xElemCol.Attributes())
            {
                column.properties[attribute.Name.ToString()] = attribute.Value;
            }
            IEnumerable <XElement> childNodes = xElemCol.Elements().Where(x => x.Name.ToString() != "GroupInfo" && x.Name.ToString() != "ValueItems");

            foreach (XElement prop in childNodes)
            {
                column.Properties[prop.Name.ToString()] = prop.Value;
            }
            column.ValueItems = ValueItemCollection.ParseXML(xElemCol.Element("ValueItems"));
            column.groupInfo  = GroupInfo.ParseXML(xElemCol.Element("GroupInfo"));
            return(column);
        }
Example #3
0
        public C1TrueDBGrid(XElement xElemGrid)
        {
            this.Splits = new List <Split>();
            AssignDefaultValues();
            IEnumerable <XElement> datacols = xElemGrid.Element("DataCols")?.Elements();

            if (datacols != null)
            {
                foreach (XElement column in datacols)
                {
                    this.DataCols.Add(C1DataColumn.ParseXML(column));
                }
            }

            XElement splits = xElemGrid.Element("Splits");

            foreach (XElement split in splits.Elements())
            {
                this.Splits.Add(Split.ParseXML(split));
            }

            IEnumerable <XElement> childNodes = xElemGrid.Elements().Where(x =>
                                                                           x.Name.ToString() != "DataCols" &&
                                                                           x.Name.ToString() != "Styles" &&
                                                                           x.Name.ToString() != "Splits" &&
                                                                           x.Name.ToString() != "NamedStyles" &&
                                                                           x.Attribute("me") == null &&
                                                                           x.Attribute("parent") == null);

            foreach (XElement prop in childNodes)
            {
                this.Properties[prop.Name.ToString()] = prop.Value;
            }
            IEnumerable <XElement> namedStylesXML = xElemGrid.Element("NamedStyles").Elements();

            foreach (XElement style in namedStylesXML)
            {
                string name = style.Attribute("me").Value;
                if (name == "Normal")
                {
                    name = "Style";
                }
                else if (name == "HighlightRow")
                {
                    name = "HighLightRowStyle";
                }
                else
                {
                    name = $"{name}Style";
                }
                this.Styles["PrintPageHeaderStyle"] = Style.ParseXML(xElemGrid.Element("PrintPageHeaderStyle"));
                this.Styles["PrintPageFooterStyle"] = Style.ParseXML(xElemGrid.Element("PrintPageFooterStyle"));
                this.Styles[name] = Style.ParseXML(style);
                this.namedStyles.Add(this.Styles[name]);
            }

            this.GenerateAllStylesDictionary();
            this.ParseStylesString(xElemGrid.Element("Styles").Element("Data").Value);
            this.ParsedFromXML            = true;
            this.PropertyBagAlreadyExists = true;
        }
        public static void ProcessGridProperty(Dictionary <string, C1TrueDBGrid> grids, Dictionary <string, C1DataColumn> columns, Dictionary <string, ValueItem> valueItemsDict, string line)
        {
            //Verify if the line is the assignment of a known grid
            GroupCollection groups = RegularExpressions.ComplexProperty.Matches(line)[0].Groups;
            C1TrueDBGrid    grid   = grids[groups[1].Value];
            int             index  = -1;

            if (groups[4].Value != "")
            {
                index = int.Parse(groups[4].Value);
            }
            string value    = groups[15].Value;
            string subLine  = groups[5].Value;
            string property = groups[2].Value;

            switch (property.ToUpper())
            {
            case nameof(SplitProperties.ALTERNATINGROWS):
                grid.Splits[0].Properties["AlternatingRowStyle"] = Utilities.FirstCharToUpper(value);
                break;

            case nameof(GridProperties.CAPTION):
                grid.Properties["Caption"] = Utilities.RemoveBeginEndQuotes(value);
                break;

            case nameof(GridProperties.BACKCOLOR):
                grid.TimesReadBackColor++;
                grid.Properties["BackColor"] = value;
                break;

            case nameof(StyleProperties.FONT):
                grid.Styles["Style"].Properties["Font"] = Utilities.ProcessFontProperty(value);
                break;

            case nameof(GridProperties.HEIGHT):
                grid.Height = Utilities.PropertyValueTwipsToPixels(value);
                break;

            case nameof(SplitProperties.HSCROLLBAR):
                if (groups[5].Value.Equals("Style"))
                {
                    grid.Splits[0].Properties["HBarStyle"] = Utilities.EnumValueToString(value);
                }
                break;

            case nameof(GridProperties.IMAGES):
                string        imageName = RegularExpressions.GetObject.Matches(groups[12].Value)[0].Groups[1].Value;
                ResourceImage image     = new ResourceImage();
                image.Name             = imageName;
                grid.Images[imageName] = image;
                break;

            case nameof(GridProperties.NAME):
                grid.Properties["Name"] = value;
                grid.TimesReadName++;
                break;

            case nameof(GridProperties.PREVIEWINFO):
                PreviewInfoPropertyReader.ProcessPreviewInfoProperty(grid.PreviewInfo, subLine, value);
                break;

            case nameof(GridProperties.PRINTINFO):
                PrintInfoPropertyReader.ProcessPrintInfoProperty(grid.PrintInfo, subLine, value);
                break;

            case nameof(GridProperties.ROWDIVIDER):
                GridLinesPropertyReader.ProcessGridLinesProperty(grid.RowDivider, subLine, value);
                break;

            case nameof(GridProperties.SIZE):
                GroupCollection groupsSize = RegularExpressions.Size.Matches(line)[0].Groups;
                grid.Width  = Int32.Parse(groupsSize[1].Value);
                grid.Height = Int32.Parse(groupsSize[2].Value);
                break;

            case nameof(GridProperties.STYLES):
                grid.IncorrectPropertiesInDesigner = true;
                break;

            case nameof(SplitProperties.VSCROLLBAR):
                if (groups[5].Value.Equals("Style"))
                {
                    grid.Splits[0].Properties["VBarStyle"] = Utilities.EnumValueToString(value);
                }
                break;

            case nameof(GridProperties.COLUMNS):
                grid.IncorrectPropertiesInDesigner = true;
                if (groups[7].Value == "Add")
                {
                    string argument = groups[12].Value;
                    if (!argument.StartsWith("new "))
                    {
                        string columnName = argument.Split('.')[1];
                        grid.DataCols.Add(columns[columnName]);
                    }
                }
                else
                {
                    int          columnIndex = Utilities.StringToIndex(groups[4].Value);
                    C1DataColumn column      = Utilities.GetCreateListElement <C1DataColumn>(grid.DataCols, columnIndex);
                    ColumnPropertyReader.ProcessColumnProperty(column, valueItemsDict, subLine, value);
                }
                break;

            case nameof(GridProperties.WIDTH):
                grid.Width = Int32.Parse(value);
                break;

            case nameof(GridProperties.SPLITS):
                grid.IncorrectPropertiesInDesigner = true;
                int   splitIndex = Utilities.StringToIndex(groups[4].Value);
                Split split      = Utilities.GetCreateListElement <Split>(grid.Splits, splitIndex);
                SplitPropertyReader.ProcessSplitProperty(split, subLine, value);
                break;

            default:
                if (grid.Splits[0].Properties.ContainsKey(property) && !grid.Properties.ContainsKey(property))
                {
                    grid.Splits[0].Properties[property] = Utilities.CleanXMLProperty(value);
                }
                else if (grid.Styles.ContainsKey(property))
                {
                    grid.IncorrectPropertiesInDesigner = true;
                    StylePropertyReader.ProcessStyleProperty(grid.Styles[property], subLine, value);
                }
                else if (groups[11].Value == "")    // if it isn't a method call from the grid
                {
                    grid.Properties[property] = Utilities.CleanGridProperty(value);
                }
                break;
            }
        }