/// <summary> /// Visits the specified element. /// </summary> /// <param name="element">The element.</param> public void Visit(StyleElement element) { HandleResult( new StyleValidator(_settings, element) .ValidateBindings() ); }
/// <summary> /// Visits the specified element. /// </summary> /// <param name="element">The element.</param> public void Visit(StyleElement element) { HandleResult( new StyleValidator(settings, element) .ValidateBindings() ); }
public ActivityData( string id, string html = null, string text = null, StyleElement parsedText = null, bool? isEditable = null, Uri postUrl = null, int? commentLength = null, CommentData[] comments = null, DateTime? postDate = null, DateTime? editDate = null, ServiceType serviceType = null, PostStatusType? status = null, IAttachable attachedContent = null, ProfileData owner = null, DateTime? getActivityDate = null, ActivityUpdateApiFlag updaterTypes = ActivityUpdateApiFlag.Unloaded) { LoadedApiTypes = updaterTypes; Id = id; IsEditable = isEditable; Html = html; Text = text; ParsedText = parsedText; CommentLength = commentLength; Comments = comments; PostUrl = postUrl; PostDate = postDate; EditDate = editDate; GetActivityDate = getActivityDate; PostStatus = status; Owner = owner; AttachedContent = attachedContent; ServiceType = serviceType; }
/// <summary> /// Creates a new rule and adds them to the given style element. /// </summary> /// <param name="styleElement">The style element the new rule will be added to.</param> /// <param name="ruleName">The name of the rule, including preceding signs (. for class, # for ID).</param> /// <param name="rule">The rule content, e.g. "font-family: Verdana" (without quotes and braces).</param> public StyleRule(StyleElement styleElement, string ruleName, string rule) { int insertedRule = ((Interop.IHTMLStyleElement)styleElement.GetBaseElement()).styleSheet.AddRule(ruleName, " ", 0); // if succeeded, synchronize content Interop.IHTMLStyleSheetRulesCollection rules = ((Interop.IHTMLStyleElement)styleElement.GetBaseElement()).styleSheet.GetRules() as Interop.IHTMLStyleSheetRulesCollection; if (rules == null) { throw new ArgumentException("Cannot create style rule"); } if (insertedRule >= 0) { styleRule = (Interop.IHTMLRuleStyle)rules.Item(insertedRule).GetStyle(); RuleName = ruleName; } else { for (int i = 0; i < rules.GetLength(); i++) { Interop.IHTMLStyleSheetRule rulestyle = rules.Item(i); if (ruleName.Equals(rulestyle.GetSelectorText())) { styleRule = rulestyle.GetStyle(); styleRule.cssText = rule; RuleName = ruleName; break; } } } }
private void Emit(StyleElement styleElement) { if (styleElement != null) { _cssBuilder.Append(styleElement.ToString()); } }
public StyleElement(Style s, TokenClass token_class, Major major, Minor minor, int param, string text) { this.token_class = token_class; this.major = major; this.minor = minor; this.param = param; this.text = text; lock (s) { if (s.Elements == null) { s.Elements = this; } else { StyleElement se = s.Elements; while (se.next != null) { se = se.next; } se.next = this; } } }
protected void rg1_ExcelMLExportStylesCreated(object sender, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e) { priceStyle = new StyleElement("priceItemStyle"); priceStyle.NumberFormat.FormatType = NumberFormatType.Currency; e.Styles.Add(priceStyle); percentStyle = new StyleElement("percentItemStyle"); percentStyle.NumberFormat.FormatType = NumberFormatType.Percent; percentStyle.FontStyle.Italic = true; e.Styles.Add(percentStyle); percentStyleNegative = new StyleElement("percentItemStyleNegative"); percentStyleNegative.NumberFormat.FormatType = NumberFormatType.Percent; percentStyleNegative.FontStyle.Italic = true; percentStyleNegative.FontStyle.Color = System.Drawing.Color.Red; e.Styles.Add(percentStyleNegative); foreach (StyleElement style in e.Styles) { if (style.Id == "headerStyle") { style.InteriorStyle.Pattern = InteriorPatternType.Solid; style.InteriorStyle.Color = System.Drawing.Color.LightGray; } } }
/// <summary> /// Removes the element from the collection. This member supports the NetRix infrastructure and is used to /// support the <see cref="System.Windows.Forms.PropertyGrid"/>. /// </summary> /// <param name="o"></param> public void Remove(StyleElement o) { if (o == null) { return; } base.List.Remove(o); }
/// <summary> /// Checks if the element is part of the collection. This member supports the NetRix infrastructure and is used to /// support the <see cref="System.Windows.Forms.PropertyGrid"/>. /// </summary> /// <param name="o"></param> /// <returns></returns> public bool Contains(StyleElement o) { if (o == null) { return(false); } return(List.Contains(o)); }
public IElement Create() { var label = new LabelElement("Test"); var align = new AlignmentElement(label) { VerticalAlignment = Alignment.Last, HorizontalAlignment = Alignment.Last }; var border = new BorderElement(align) { Border = BorderStyle.SingleLine }; var size = new SizeElement(border) { Size = new BoxConstraint(9, int.MaxValue, 5, int.MaxValue) }; var style = new StyleElement(size) { Style = new Style() { Background = Color.BurlyWood, Foreground = Color.Black } }; var label2 = new LabelElement("sup"); var border2 = new BorderElement(label2) { Border = BorderStyle.DoubleLine }; var align2 = new AlignmentElement(border2) { VerticalAlignment = Alignment.Middle, HorizontalAlignment = Alignment.Last }; var stack = new FlexLayoutElement(Axis.Vertical, new IElement[] { style, align2 }); var stack2 = new FlexLayoutElement(Axis.Horizontal, new IElement[] { new AlignmentElement(new LabelElement("hi")) { HorizontalAlignment = Alignment.Middle, VerticalAlignment = Alignment.Middle }, new LabelElement("hib"), stack }) { ItemSpacing = FlexSpacing.Evenly }; return(stack2); }
/// <summary> /// Adds a style element to the collection. This member supports the NetRix infrastructure and is used to /// support the <see cref="System.Windows.Forms.PropertyGrid"/>. /// </summary> /// <param name="o"></param> public void Add(StyleElement o) { if (o == null) { return; } o.type = "text/css"; base.List.Add(o); }
public void ApplyStyle(StyleElement configElement) { Bold = configElement.Bold; Underline = configElement.Underline; Italic = configElement.Italic; BackColor = configElement.BackColor; ForeColor = configElement.ForeColor; FontSize = configElement.FontSize; }
/////<overloads/> ///// <summary> ///// Creates a new rule and adds them to the given style element. ///// </summary> //public StyleRule() //{ //} internal void InitializeRule(StyleElement styleElement, string ruleName, string rule) { ((Interop.IHTMLStyleElement)styleElement.GetBaseElement()).styleSheet.AddRule(ruleName, rule, 0); // if succeeded, synchronize content Interop.IHTMLStyleSheetRulesCollection rules = ((Interop.IHTMLStyleElement)styleElement.GetBaseElement()).styleSheet.GetRules() as Interop.IHTMLStyleSheetRulesCollection; if (rules != null) { styleRule = (Interop.IHTMLRuleStyle)rules.Item(0).GetStyle(); RuleName = ruleName; } }
protected void RG_Usuarios_ExcelMLWorkBookCreated(object sender, Telerik.Web.UI.GridExcelBuilder.GridExcelMLWorkBookCreatedEventArgs e) { foreach (RowElement row in e.WorkBook.Worksheets[0].Table.Rows) { row.Cells[0].StyleValue = "Style1"; } StyleElement style = new StyleElement("Style1"); style.InteriorStyle.Pattern = InteriorPatternType.Solid; style.InteriorStyle.Color = System.Drawing.Color.LightGray; e.WorkBook.Styles.Add(style); }
public void ApplyStyle(StyleElement configElement) { Bold = configElement.Bold; Underline = configElement.Underline; Italic = configElement.Italic; BackColor = configElement.BackColor; ForeColor = configElement.ForeColor; FontSize = configElement.FontSize; TextRotation = configElement.TextRotation; WrapText = configElement.WrapText; }
public AttachedPostData( ContentType type, string id, string html, string text, StyleElement parsedText, string ownerId, string ownerName, string ownerIconUrl, Uri postUrl, IAttachable attachedContent) : base(type, postUrl) { Id = id; Html = html; Text = text; ParsedText = parsedText; OwnerId = ownerId; OwnerName = ownerName; OwnerIconUrl = ownerIconUrl; AttachedContent = attachedContent; }
protected void grdResult_ExcelMLWorkBookCreated(object sender, Telerik.Web.UI.GridExcelBuilder.GridExcelMLWorkBookCreatedEventArgs e) { int r = 0; foreach (RowElement row in e.WorkBook.Worksheets[0].Table.Rows) { for (int i = 0; i < row.Cells.Count; i++) { if (r != 0) { if (r % 2 == 0) { row.Cells[i].StyleValue = "Style1"; } else { row.Cells[i].StyleValue = "Style2"; } } else { row.Cells[i].StyleValue = "styleHeader"; } } r++; } StyleElement styleHeader = new StyleElement("styleHeader"); styleHeader.InteriorStyle.Pattern = InteriorPatternType.Solid; styleHeader.InteriorStyle.Color = System.Drawing.Color.White; styleHeader.FontStyle.FontName = "Tahoma"; styleHeader.FontStyle.Bold = true; styleHeader.AlignmentElement.HorizontalAlignment = HorizontalAlignmentType.Center; e.WorkBook.Styles.Add(styleHeader); StyleElement style = new StyleElement("Style1"); style.InteriorStyle.Pattern = InteriorPatternType.Solid; style.InteriorStyle.Color = System.Drawing.Color.FromArgb(162, 226, 255); style.FontStyle.FontName = "Tahoma"; style.AlignmentElement.HorizontalAlignment = HorizontalAlignmentType.Center; e.WorkBook.Styles.Add(style); StyleElement style2 = new StyleElement("Style2"); style2.AlignmentElement.HorizontalAlignment = HorizontalAlignmentType.Center; style2.InteriorStyle.Pattern = InteriorPatternType.Solid; style2.InteriorStyle.Color = System.Drawing.Color.FromArgb(217, 243, 255); style2.FontStyle.FontName = "Tahoma"; e.WorkBook.Styles.Add(style2); }
protected void RadGrid1_ExcelMLWorkBookCreated(object sender, GridExcelMLWorkBookCreatedEventArgs e) { //if (CheckBox2.Checked) { foreach (RowElement row in e.WorkBook.Worksheets[0].Table.Rows) { row.Cells[0].StyleValue = "Style1"; } StyleElement style = new StyleElement("Style1"); style.InteriorStyle.Pattern = InteriorPatternType.Solid; style.InteriorStyle.Color = System.Drawing.Color.LightGray; e.WorkBook.Styles.Add(style); } }
public void Parse() { CssParser parser = new CssParser(_css); OnDocumentBegin(); while (true) { StyleElement element = parser.Next(); if (element == null) { OnDocumentEnd(); return; } StyleText styleText = element as StyleText; if (styleText != null) { OnStyleText(styleText); } StyleLiteral styleLiteral = element as StyleLiteral; if (styleLiteral != null) { OnStyleLiteral(styleLiteral); } StyleUrl styleUrl = element as StyleUrl; if (styleUrl != null) { OnStyleUrl(styleUrl); } StyleImport styleImport = element as StyleImport; if (styleImport != null) { OnStyleImport(styleImport); } StyleComment styleComment = element as StyleComment; if (styleComment != null) { OnStyleComment(styleComment); } } }
protected void OnGridInvoiceExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e) { foreach (StyleElement style in e.Styles) { if (style.Id == "headerStyle") { style.FontStyle.Bold = true; style.FontStyle.Color = System.Drawing.Color.Gainsboro; style.InteriorStyle.Color = System.Drawing.Color.Wheat; style.InteriorStyle.Pattern = InteriorPatternType.Solid; } else if (style.Id == "itemStyle") { style.InteriorStyle.Color = System.Drawing.Color.WhiteSmoke; style.InteriorStyle.Pattern = InteriorPatternType.Solid; } else if (style.Id == "alternatingItemStyle") { style.InteriorStyle.Color = System.Drawing.Color.LightGray; style.InteriorStyle.Pattern = InteriorPatternType.Solid; } } StyleElement myStyle = new StyleElement("MyCustomStyle"); myStyle.FontStyle.Bold = true; myStyle.FontStyle.Italic = true; myStyle.InteriorStyle.Color = System.Drawing.Color.Gray; myStyle.InteriorStyle.Pattern = InteriorPatternType.Solid; e.Styles.Add(myStyle); }
public static new Element FromObj(object instance) { if (instance == null) { return(null); } try{ string tagUrn = (string)GetProperty(instance, "tagUrn"); string tagName = (string)GetProperty(instance, "tagName"); if (tagUrn == null || tagUrn == "") { switch (tagName.ToLower()) { case "!": return(CommentElement.FromObj(instance)); case "a": return(AElement.FromObj(instance)); case "area": return(AreaElement.FromObj(instance)); case "base": return(BaseElement.FromObj(instance)); case "basefont": return(BaseFontElement.FromObj(instance)); case "bgsound": return(BgsoundElement.FromObj(instance)); case "address": case "pre": case "center": case "listing": case "xmp": case "plaintext": case "blockquote": return(BlockElement.FromObj(instance)); case "body": return(BodyElement.FromObj(instance)); case "br": return(BrElement.FromObj(instance)); case "button": return(ButtonElement.FromObj(instance)); case "dd": return(DdElement.FromObj(instance)); case "div": return(DivElement.FromObj(instance)); case "dl": return(DlElement.FromObj(instance)); case "dt": return(DtElement.FromObj(instance)); case "embed": return(EmbedElement.FromObj(instance)); case "fieldset": return(FieldsetElement.FromObj(instance)); case "font": return(FontElement.FromObj(instance)); case "form": return(FormElement.FromObj(instance)); case "frame": return(FrameElement.FromObj(instance)); case "frameset": return(FramesetElement.FromObj(instance)); case "head": return(HeadElement.FromObj(instance)); case "h1": case "h2": case "h3": case "h4": case "h5": case "h6": return(HnElement.FromObj(instance)); case "hr": return(HrElement.FromObj(instance)); case "html": return(HtmlElement.FromObj(instance)); case "iframe": return(IframeElement.FromObj(instance)); case "img": return(ImgElement.FromObj(instance)); case "input": return(InputElement.FromObj(instance)); case "isindex": return(IsindexElement.FromObj(instance)); case "legend": return(LegendElement.FromObj(instance)); case "label": return(LabelElement.FromObj(instance)); case "li": return(LiElement.FromObj(instance)); case "link": return(LinkElement.FromObj(instance)); case "map": return(MapElement.FromObj(instance)); case "marquee": return(MarqueeElement.FromObj(instance)); case "meta": return(MetaElement.FromObj(instance)); case "nextid": return(NextidElement.FromObj(instance)); case "noembed": case "noframes": case "nolayer": case "noscript": return(NoshowElement.FromObj(instance)); case "applet": case "object": return(ObjectElement.FromObj(instance)); case "ol": return(OlElement.FromObj(instance)); case "optgroup": case "option": return(OptionElement.FromObj(instance)); case "p": return(PElement.FromObj(instance)); case "param": return(ParamElement.FromObj(instance)); case "i": case "u": case "b": case "q": case "s": case "strong": case "del": case "strike": case "em": case "small": case "big": case "ruby": case "rp": case "sub": case "sup": case "acronym": case "bdo": case "cite": case "dfn": case "ins": case "code": case "kbd": case "samp": case "var": case "nobr": return(PhraseElement.FromObj(instance)); case "script": return(ScriptElement.FromObj(instance)); case "select": return(SelectElement.FromObj(instance)); case "span": return(SpanElement.FromObj(instance)); case "style": return(StyleElement.FromObj(instance)); case "caption": return(CaptionElement.FromObj(instance)); case "td": case "th": return(TableCellElement.FromObj(instance)); case "table": return(TableElement.FromObj(instance)); case "colgroup": case "col": return(ColElement.FromObj(instance)); case "tr": return(TrElement.FromObj(instance)); case "thead": case "tbody": case "tfoot": return(TableSectionElement.FromObj(instance)); case "textarea": return(TextAreaElement.FromObj(instance)); case "wbr": return(TextElement.FromObj(instance)); case "title": return(TitleElement.FromObj(instance)); case "dir": case "menu": case "ul": return(UlElement.FromObj(instance)); // optionbutton ? // spanflow ? // default: return UnknownElement.FromObj(instance); } } }catch { // IHTMLElement でない可能性 } return(new Element(instance)); }
/// <summary> /// Creates a new rule and adds them to the given style element. /// </summary> /// <param name="styleElement"></param> /// <param name="ruleName"></param> public StyleRule(StyleElement styleElement, string ruleName) : this(styleElement, ruleName, " " /* cannot add empty string, so we add a space */) { }
private static VectorStyle CreateStyle(StyleElement[] styles, string type) { if (styles.Length == 1) { VectorStyle vs = new VectorStyle(); vs.Symbol = null; vs.Fill = null; vs.Line = null; if (string.Compare(type, "point", true) == 0) { Brush b = new SolidBrush(styles[0].color); vs.PointColor = b; vs.PointSize = (float)styles[0].Size; if (styles[0].Offset != Point.Empty) { vs.SymbolOffset = new PointF(styles[0].Offset.X, styles[0].Offset.Y); } } else if (string.Compare(type, "line", true) == 0) { vs.Line = new Pen(styles[0].color, (float)styles[0].Width); if (styles[0].Offset != Point.Empty) { vs.LineOffset = styles[0].Offset.Y; } } else if (string.Compare(type, "polygon", true) == 0) { Brush b = new SolidBrush(styles[0].color); vs.Fill = b; } if (styles[0].OutlineColor != Color.Empty) { vs.EnableOutline = true; vs.Outline = new Pen(styles[0].OutlineColor); } return vs; } else { GroupStyle gs = new GroupStyle(); for (int i = 0; i < styles.Length; i++) gs.AddStyle(CreateStyle(new StyleElement[] { styles[i] }, type)); return gs; } }
private static StyleElement ParseStyle(StreamReader sr) { string line; StyleElement styleel = new StyleElement() { Angle = 0, LineCap = System.Drawing.Drawing2D.LineCap.Round, LineJoin = System.Drawing.Drawing2D.LineJoin.Round, BackGroundColor = Color.Empty, OutlineColor = Color.Empty, Size = 1, Offset = Point.Empty }; while ((line = sr.ReadLine()) != null) { line = TrimFixLine(line); string[] parts = ParseLine(line); if (parts != null && parts.Length > 0) { if (string.Compare(parts[0], "END", true) == 0) { return styleel; } else if (string.Compare(parts[0], "BACKGROUNDCOLOR", true) == 0) { styleel.BackGroundColor = Color.FromArgb(int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); } else if (string.Compare(parts[0], "COLOR", true) == 0) { styleel.color = Color.FromArgb(int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); } else if (string.Compare(parts[0], "EXPRESSION", true) == 0) { styleel.Offset = new Point(int.Parse(parts[1]), int.Parse(parts[2])); } else if (string.Compare(parts[0], "SIZE", true) == 0) { styleel.Size = Convert.ToDouble(parts[1], CultureInfo.InvariantCulture); } else if (string.Compare(parts[0], "WIDTH", true) == 0) { styleel.Width = Convert.ToDouble(parts[1], CultureInfo.InvariantCulture); } else if (string.Compare(parts[0], "WIDTH", true) == 0) { styleel.Symbol = parts[1]; } else if (string.Compare(parts[0], "OUTLINECOLOR", true) == 0) { styleel.OutlineColor = Color.FromArgb(int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); } else if (string.Compare(parts[0], "LINECAP", true) == 0) { switch(parts[1].ToLower()) { case "square": styleel.LineCap = System.Drawing.Drawing2D.LineCap.Square; break; case "round": styleel.LineCap = System.Drawing.Drawing2D.LineCap.Round; break; case "butt": styleel.LineCap = System.Drawing.Drawing2D.LineCap.Flat; break; } } else if (string.Compare(parts[0], "LINEJOIN", true) == 0) { switch (parts[1].ToLower()) { case "miter": styleel.LineJoin = System.Drawing.Drawing2D.LineJoin.Miter; break; case "round": styleel.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; break; case "bevel": styleel.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; break; } } } } return null; }
private static StyleElement ParseStyle(TextReader sr) { string line; StyleElement styleEl = new StyleElement() { Angle = 0, LineCap = System.Drawing.Drawing2D.LineCap.Round, LineJoin = System.Drawing.Drawing2D.LineJoin.Round, BackGroundColor = Color.Empty, OutlineColor = Color.Empty, Size = 1, Offset = Point.Empty }; while ((line = sr.ReadLine()) != null) { line = TrimFixLine(line); string[] parts = ParseLine(line); if (parts != null && parts.Length > 0) { if (string.Compare(parts[0], "END", StringComparison.InvariantCultureIgnoreCase) == 0) { return(styleEl); } else if (string.Compare(parts[0], "BACKGROUNDCOLOR", StringComparison.InvariantCultureIgnoreCase) == 0) { styleEl.BackGroundColor = Color.FromArgb(int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); } else if (string.Compare(parts[0], "COLOR", StringComparison.InvariantCultureIgnoreCase) == 0) { styleEl.Color = Color.FromArgb(int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); } else if (string.Compare(parts[0], "EXPRESSION", StringComparison.InvariantCultureIgnoreCase) == 0) { styleEl.Offset = new Point(int.Parse(parts[1]), int.Parse(parts[2])); } else if (string.Compare(parts[0], "SIZE", StringComparison.InvariantCultureIgnoreCase) == 0) { styleEl.Size = Convert.ToDouble(parts[1], CultureInfo.InvariantCulture); } else if (string.Compare(parts[0], "WIDTH", StringComparison.InvariantCultureIgnoreCase) == 0) { styleEl.Width = Convert.ToDouble(parts[1], CultureInfo.InvariantCulture); } else if (string.Compare(parts[0], "WIDTH", StringComparison.InvariantCultureIgnoreCase) == 0) { styleEl.Symbol = parts[1]; } else if (string.Compare(parts[0], "OUTLINECOLOR", StringComparison.InvariantCultureIgnoreCase) == 0) { styleEl.OutlineColor = Color.FromArgb(int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); } else if (string.Compare(parts[0], "LINECAP", StringComparison.InvariantCultureIgnoreCase) == 0) { switch (parts[1].ToLower()) { case "square": styleEl.LineCap = System.Drawing.Drawing2D.LineCap.Square; break; case "round": styleEl.LineCap = System.Drawing.Drawing2D.LineCap.Round; break; case "butt": styleEl.LineCap = System.Drawing.Drawing2D.LineCap.Flat; break; } } else if (string.Compare(parts[0], "LINEJOIN", StringComparison.InvariantCultureIgnoreCase) == 0) { switch (parts[1].ToLower()) { case "miter": styleEl.LineJoin = System.Drawing.Drawing2D.LineJoin.Miter; break; case "round": styleEl.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; break; case "bevel": styleEl.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; break; } } } } return(null); }
public void ApplyColorScheme(SchemeType type, ColorRamp colorRamp, StyleElement shapeElement) { _categories.ApplyColorScheme2((tkColorSchemeType)type, colorRamp.GetInternal(), (tkShapeElements)shapeElement); }
/// <summary> /// Loads the file as data from XML data /// </summary> /// <param name="fileDocument">XML document containing the file</param> /// <param name="loadHeaderOnly">if true loads only header information</param> public void Load(XDocument fileDocument, bool loadHeaderOnly) { if (fileDocument == null) { throw new ArgumentNullException(nameof(fileDocument)); } if (fileDocument.Root == null) { throw new ArgumentException("Document's root is NULL (empty document passed)"); } // theoretically the namespace should be "http://www.gribuser.ru/xml/fictionbook/2.0" but just to be sure with invalid files _fileNameSpace = fileDocument.Root.GetDefaultNamespace(); _styles.Clear(); IEnumerable <XElement> xStyles = fileDocument.Root.Elements(_fileNameSpace + StyleElement.StyleElementName).ToArray(); // attempt to load some bad FB2 with wrong namespace if (!xStyles.Any()) { xStyles = fileDocument.Elements(StyleElement.StyleElementName); } foreach (var style in xStyles) { var element = new StyleElement(); try { element.Load(style); _styles.Add(element); } catch { // ignored } } LoadDescriptionSection(fileDocument); if (!loadHeaderOnly) { XNamespace namespaceUsed = _fileNameSpace; // Load body elements (first is main text) if (fileDocument.Root != null) { IEnumerable <XElement> xBodyElements = fileDocument.Root.Elements(_fileNameSpace + Fb2TextBodyElementName).ToArray(); // try to read some badly formatted FB2 files if (!xBodyElements.Any()) { namespaceUsed = ""; xBodyElements = fileDocument.Root.Elements(namespaceUsed + Fb2TextBodyElementName); } foreach (var body in xBodyElements) { var bodyItem = new BodyItem { NameSpace = namespaceUsed }; try { bodyItem.Load(body); } catch (Exception) { continue; } _bodiesList.Add(bodyItem); } } if (_bodiesList.Count > 0) { _mainBody = _bodiesList[0]; } // Load binaries sections (currently images only) if (fileDocument.Root != null) { IEnumerable <XElement> xBinaryElements = fileDocument.Root.Elements(namespaceUsed + Fb2BinaryElementName).ToArray(); if (!xBinaryElements.Any()) { xBinaryElements = fileDocument.Root.Elements(Fb2BinaryElementName); } foreach (var binaryElement in xBinaryElements) { var item = new BinaryItem(); try { item.Load(binaryElement); } catch { continue; } // add just unique IDs to fix some invalid FB2s if (!_binaryObjects.ContainsKey(item.Id)) { _binaryObjects.Add(item.Id, item); } } } } }
public void ApplyColorScheme(SchemeType type, ColorRamp colorRamp, StyleElement shapeElement, int categoryStartIndex, int categoryEndIndex) { _categories.ApplyColorScheme3((tkColorSchemeType)type, colorRamp.GetInternal(), (tkShapeElements)shapeElement, categoryStartIndex, categoryEndIndex); }