public ValueOfProperty(StyleContext style, string propertyName) : base(null, style) { _propertyName = propertyName; }
/// <summary> /// Private constructor for implementation Singleton pattern /// </summary> private BundleTransformerContext() { var configContext = new ConfigurationContext(); CoreSettings coreConfig = configContext.GetCoreSettings(); Configuration = configContext; FileSystem = new FileSystemContext(); Styles = new StyleContext(coreConfig.Styles); Scripts = new ScriptContext(coreConfig.Scripts); }
private void HandleEscSeq2(PegNode node, StyleContext context, StructuralGlyph parent) { int posBeg = node.match_.posBeg_; var childNode = node.child_; if (childNode == null) throw new ArgumentNullException("childNode"); string escHeader = _sourceText.Substring(posBeg, childNode.match_.posBeg_ - posBeg); switch (escHeader.ToLowerInvariant()) { case @"\=(": { var newParent = new SubSuperScript(); newParent.Style = context; parent.Add(newParent); var newContext = context.Clone(); newContext.ScaleFont(0.65); VisitNode(childNode, newContext, newParent); } break; case @"\p(": { double val; string s1 = GetText(childNode).Trim(); var newContext = context.Clone(); string numberString; Altaxo.Serialization.LengthUnit lengthUnit; if (s1.EndsWith("%")) { numberString = s1.Substring(0, s1.Length - 1); if (double.TryParse(numberString, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out val)) { newContext.BaseFontId = context.BaseFontId.WithSize(context.BaseFontId.Size * val / 100); newContext.ScaleFont(val / 100); } } else if (Altaxo.Serialization.LengthUnit.TryParse(s1, out lengthUnit, out numberString) && double.TryParse(numberString, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out val) ) { double newSize = val * (double)(lengthUnit.UnitInMeter / Altaxo.Serialization.LengthUnit.Point.UnitInMeter); newContext.BaseFontId = context.BaseFontId.WithSize(newSize); newContext.FontId = context.FontId.WithSize(newSize); } else if (double.TryParse(s1, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out val) ) { double newSize = val; newContext.BaseFontId = context.BaseFontId.WithSize(newSize); newContext.FontId = context.FontId.WithSize(newSize); } VisitNode(childNode.next_, newContext, parent); } break; case @"\c(": { string s1 = GetText(childNode).Trim(); var newContext = context.Clone(); var conv = new ColorConverter(); try { object result = conv.ConvertFromInvariantString(s1); newContext.brush = new SolidBrush((Color)result); } catch (Exception) { } VisitNode(childNode.next_, newContext, parent); } break; case @"\l(": { string s1 = GetText(childNode); string s2 = GetText(childNode.next_); int plotNumber, plotLayer; if (int.TryParse(s1, out plotLayer) && int.TryParse(s2, out plotNumber)) { parent.Add(new PlotSymbol(context, plotNumber, plotLayer)); } } break; case @"\%(": { string s1 = GetText(childNode); string s2 = GetText(childNode.next_); int plotNumber, plotLayer; if (int.TryParse(s1, out plotLayer) && int.TryParse(s2, out plotNumber)) { parent.Add(new PlotName(context, plotNumber, plotLayer)); } else if (int.TryParse(s1, out plotNumber)) { var label = new PlotName(context, plotNumber); label.SetPropertyColumnName(s2); parent.Add(label); } } break; } }
public void UpdateContent(string html) { string pixmaps_path = IO.Path.Combine(UserInterface.AssetsPath, "pixmaps"); string icons_path = IO.Path.Combine(UserInterface.AssetsPath, "icons", "hicolor", "12x12", "status"); html = html.Replace("<!-- $a-hover-color -->", "#009ff8"); html = html.Replace("<!-- $a-color -->", "#0085cf"); html = html.Replace("<!-- $body-font-family -->", StyleContext.GetFont(StateFlags.Normal).Family); html = html.Replace("<!-- $body-font-size -->", (double)(StyleContext.GetFont(StateFlags.Normal).Size / 1024 + 3) + "px"); html = html.Replace("<!-- $body-color -->", UserInterfaceHelpers.RGBAToHex(StyleContext.GetColor(StateFlags.Normal))); // TODO // html = html.Replace ("<!-- $body-background-color -->", // UserInterfaceHelpers.RGBAToHex (new TreeView ().StyleContext.GetStyleProperty ("background-color"))); html = html.Replace("<!-- $day-entry-header-font-size -->", (StyleContext.GetFont(StateFlags.Normal).Size / 1024 + 3) + "px"); html = html.Replace("<!-- $day-entry-header-background-color -->", UserInterfaceHelpers.RGBAToHex(StyleContext.GetBackgroundColor(StateFlags.Normal))); html = html.Replace("<!-- $secondary-font-color -->", UserInterfaceHelpers.RGBAToHex(StyleContext.GetColor(StateFlags.Insensitive))); html = html.Replace("<!-- $small-color -->", UserInterfaceHelpers.RGBAToHex(StyleContext.GetColor(StateFlags.Insensitive))); html = html.Replace("<!-- $small-font-size -->", "90%"); html = html.Replace("<!-- $pixmaps-path -->", pixmaps_path); html = html.Replace("<!-- $document-added-background-image -->", "file://" + IO.Path.Combine(icons_path, "document-added.png")); html = html.Replace("<!-- $document-edited-background-image -->", "file://" + IO.Path.Combine(icons_path, "document-edited.png")); html = html.Replace("<!-- $document-deleted-background-image -->", "file://" + IO.Path.Combine(icons_path, "document-deleted.png")); html = html.Replace("<!-- $document-moved-background-image -->", "file://" + IO.Path.Combine(icons_path, "document-moved.png")); this.spinner.Stop(); this.scrolled_window.Remove(this.scrolled_window.Child); this.web_view.Dispose(); this.web_view = CreateWebView(); this.web_view.LoadHtml(html, "file:///"); this.scrolled_window.Add(this.web_view); this.content_wrapper.Remove(this.content_wrapper.Child); this.content_wrapper.Add(this.scrolled_window); this.scrolled_window.ShowAll(); }
private StructuralGlyph HandleSpace(PegNode node, StyleContext context, StructuralGlyph parent) { if (_sourceText[node.match_.posBeg_] == '\t') { HandleTab(parent); return parent; } else // newline { return HandleNewline(parent, context); } }
private void HandleSentence(PegNode node, StyleContext context, StructuralGlyph parent) { var line = new GlyphLine(); parent.Add(line); if (node.child_ != null) VisitNode(node.child_, context, line); }
public TextGlyph(string text, StyleContext style) { _text = text; Style = style; }
private StructuralGlyph VisitNode(PegNode node, StyleContext context, StructuralGlyph parent) { StructuralGlyph nextparent = parent; switch ((EAltaxo_LabelV1)node.id_) { case EAltaxo_LabelV1.WordSpan: case EAltaxo_LabelV1.WordSpanExt: case EAltaxo_LabelV1.WordSpanNC: HandleWordSpan(node, context, parent); break; case EAltaxo_LabelV1.Sentence: case EAltaxo_LabelV1.SentenceNC: HandleSentence(node, context, parent); break; case EAltaxo_LabelV1.Space: nextparent = HandleSpace(node, context, parent); break; case EAltaxo_LabelV1.EscSeq1: HandleEscSeq1(node, context, parent); break; case EAltaxo_LabelV1.EscSeq2: HandleEscSeq2(node, context, parent); break; case EAltaxo_LabelV1.EscSeq3: HandleEscSeq3(node, context, parent); break; } if (null != node.next_) nextparent = VisitNode(node.next_, context, nextparent); return nextparent; }
public static System.Drawing.Brush ToGdi(this Brush brush, StyleContext context) { return context.GetBrush(brush); }
public static System.Drawing.Font ToGdi(this Font font, StyleContext context) { return context.GetFont(font); }
public static System.Drawing.Pen ToGdi(this Pen pen, StyleContext context) { return context.GetPen(pen); }
public static System.Drawing.Brush ToGdi(this Brush brush, StyleContext context) { return(context.GetBrush(brush)); }
public static System.Drawing.Pen ToGdi(this Pen pen, StyleContext context) { return(context.GetPen(pen)); }
private void InterpretText() { var parser = new Altaxo_LabelV1(); parser.SetSource(_text); bool bMatches = parser.MainSentence(); var tree = parser.GetRoot(); TreeWalker walker = new TreeWalker(_text); StyleContext style = new StyleContext(_font, _textBrush); style.BaseFontId = _font; _rootNode = walker.VisitTree(tree, style, _lineSpacingFactor, true); }
public PlotName(StyleContext context, int plotNumber) : this(context, plotNumber, -1) { }
public StructuralGlyph VisitTree(PegNode root, StyleContext context, double lineSpacingFactor, bool isFixedLineSpacing) { var rootGlyph = new VerticalStack(); rootGlyph.Style = context; rootGlyph.LineSpacingFactor = lineSpacingFactor; rootGlyph.FixedLineSpacing = isFixedLineSpacing; var line = new GlyphLine(); line.Style = context; rootGlyph.Add(line); if (null != root && null != root.child_) VisitNode(root.child_, context, line); return rootGlyph; }
public PlotName(StyleContext context, int plotNumber, int plotLayer) : base(string.Empty, context) { _plotNumber = plotNumber; _layerNumber = plotLayer; }
private void HandleWordSpan(PegNode node, StyleContext context, StructuralGlyph parent) { int posBeg = node.match_.posBeg_; int posEnd = node.match_.posEnd_; var childNode = node.child_; string str = string.Empty; if (null == childNode) // no escape sequences { str = _sourceText.Substring(posBeg, posEnd - posBeg); } else // at least one child node (Esc seq) { int beg = posBeg; int end = childNode.match_.posBeg_; while (childNode != null) { str += _sourceText.Substring(beg, end - beg); str += _sourceText.Substring(childNode.match_.posBeg_ + 1, 1); beg = childNode.match_.posEnd_; childNode = childNode.next_; end = null != childNode ? childNode.match_.posBeg_ : posEnd; } str += _sourceText.Substring(beg, end - beg); } parent.Add(new TextGlyph(str, context)); }
public PlotSymbol(StyleContext style, int plotNumber) : this(style, plotNumber, -1) { }
private StructuralGlyph HandleNewline(StructuralGlyph parent, StyleContext context) { StructuralGlyph newcontext; if (parent is GlyphLine) // normal case { if (parent.Parent is VerticalStack) { newcontext = new GlyphLine(); newcontext.Style = context; parent.Parent.Add(newcontext); } else // parent.Parent is not a VerticalStack { var vertStack = new VerticalStack(); parent.Parent.Exchange(parent, vertStack); vertStack.Add(parent); newcontext = new GlyphLine(); newcontext.Style = context; vertStack.Add(newcontext); } } else { throw new NotImplementedException(); } return newcontext; }
public PlotSymbol(StyleContext style, int plotNumber, int layerNumber) { Style = style; _plotNumber = plotNumber; _layerNumber = layerNumber; }
private void HandleEscSeq1(PegNode node, StyleContext context, StructuralGlyph parent) { int posBeg = node.match_.posBeg_; var childNode = node.child_; if (childNode == null) throw new ArgumentNullException("childNode"); string escHeader = _sourceText.Substring(posBeg, childNode.match_.posBeg_ - posBeg); switch (escHeader.ToLowerInvariant()) { case @"\id(": { const string DefPropertyHead = "$Property[\""; const string DefPropertyTail = "\"]"; string s = GetText(childNode).Trim(); if (s == "$DI") { parent.Add(new DocumentIdentifier(context)); } else if (s.StartsWith(DefPropertyHead) && s.EndsWith(DefPropertyTail)) { string propertyName = s.Substring(DefPropertyHead.Length, s.Length - DefPropertyHead.Length - DefPropertyTail.Length); if (!string.IsNullOrEmpty(propertyName)) parent.Add(new ValueOfProperty(context, propertyName)); } } break; case @"\g(": { var newContext = context.Clone(); newContext.SetFont(context.FontId.WithFamily("Symbol")); VisitNode(childNode, newContext, parent); } break; case @"\i(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Italic); VisitNode(childNode, newContext, parent); } break; case @"\b(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Bold); VisitNode(childNode, newContext, parent); } break; case @"\u(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Underline); VisitNode(childNode, newContext, parent); } break; case @"\s(": { var newContext = context.Clone(); newContext.MergeFontStyle(FontXStyle.Strikeout); VisitNode(childNode, newContext, parent); } break; case @"\n(": { var newContext = context.Clone(); newContext.SetFontStyle(FontXStyle.Regular); VisitNode(childNode, newContext, parent); } break; case @"\+(": { var newParent = new Superscript(); newParent.Style = context; parent.Add(newParent); var newContext = context.Clone(); newContext.ScaleFont(0.65); VisitNode(childNode, newContext, newParent); } break; case @"\-(": { var newParent = new Subscript(); newParent.Style = context; parent.Add(newParent); var newContext = context.Clone(); newContext.ScaleFont(0.65); VisitNode(childNode, newContext, newParent); } break; case @"\l(": { string s = GetText(childNode); int plotNumber; if (int.TryParse(s, out plotNumber)) { parent.Add(new PlotSymbol(context, plotNumber)); } } break; case @"\%(": { string s = GetText(childNode); int plotNumber; if (int.TryParse(s, out plotNumber)) { parent.Add(new PlotName(context, plotNumber)); } } break; case @"\ad(": { var newParent = new DotOverGlyph(); newParent.Style = context; parent.Add(newParent); VisitNode(childNode, context, newParent); } break; case @"\ab(": { var newParent = new BarOverGlyph(); newParent.Style = context; parent.Add(newParent); VisitNode(childNode, context, newParent); } break; } }
public DocumentIdentifier(StyleContext style) : base(null, style) { }
private void HandleEscSeq3(PegNode node, StyleContext context, StructuralGlyph parent) { int posBeg = node.match_.posBeg_; var childNode = node.child_; if (childNode == null) throw new ArgumentNullException("childNode"); string escHeader = _sourceText.Substring(posBeg, childNode.match_.posBeg_ - posBeg); switch (escHeader.ToLowerInvariant()) { case @"\%(": { string s1 = GetText(childNode); string s2 = GetText(childNode.next_); string s3 = GetText(childNode.next_.next_); int plotNumber, plotLayer; if (int.TryParse(s1, out plotLayer) && int.TryParse(s2, out plotNumber)) { var label = new PlotName(context, plotNumber, plotLayer); label.SetPropertyColumnName(s3); parent.Add(label); } } break; } }
protected override void OnParametersSet() { _fillColor = StyleContext.GetColorOrDefault(VariableNames.IconColor, VariableNames.NeutralPrimary); }