public SyntcticTreeView() { InitializeComponent(); this.top_level_nodes = new List<SyntacticTreeViewNode>(); this.TopLevelNodes = this.top_level_nodes.AsReadOnly(); this.node_map = new Dictionary<SyntacticTreeViewNode, Node>(); this.style_map = new Dictionary<SyntacticTreeViewNode, NodeStyle>(); this.top_level_node_style = new NodeStyle() { BackBrush = new SolidBrush(Color.White), LabelBrush = new SolidBrush(Color.Black), BorderPen = new Pen(new SolidBrush(Color.Black), 1), }; this.internal_node_style = new NodeStyle() { BackBrush = new SolidBrush(Color.WhiteSmoke), LabelBrush = new SolidBrush(Color.DarkGray), BorderPen = new Pen(new SolidBrush(Color.DarkGray), 1), }; this.leaf_node_style = new NodeStyle() { BackBrush = new SolidBrush(Color.White), LabelBrush = new SolidBrush(Color.Black), BorderPen = new Pen(new SolidBrush(Color.Black), 1), }; }
public void SerializeImage_InvalidChar() { MetaModel.MetaModel.Initialize(); var refNode = new MapNode(new MapTree(), "OK"); refNode.Italic = true; var nodeStyle = new NodeStyle("TestStyle\"1", refNode, true); new NodeStyleImageSerializer().SerializeImage(nodeStyle.Image, nodeStyle.Title); }
private Node CreateNode(Color fill, Color font) { var nodeStyle = new NodeStyle(); nodeStyle.FillColor = fill; nodeStyle.FontColor = font; var t = string.Format("{0}", mNodeCounter++); return new Node(t, t, nodeStyle); }
public static StyleLength GetStyleLengthDouble(NodeStyle style, StyleProperty <YogaValue> prop, StyleProperty <YogaValue> prop2) { if (style.HasValue(prop.name)) { return(YogaValueToStyleLength(style.GetStyleValue <YogaValue>(prop))); } if (style.HasValue(prop2.name)) { return(YogaValueToStyleLength(style.GetStyleValue <YogaValue>(prop2))); } else { return(StyleKeyword.Null); } }
public static StyleColor GetStyleBorderColor(NodeStyle style, StyleProperty <Color> prop) { if (style.HasValue(prop.name)) { return(style.GetStyleValue <Color>(prop)); } if (style.HasValue(StyleProperties.borderColor)) { return(style.borderColor); } else { return(StyleKeyword.Null); } }
public static StyleLength GetStyleBorderRadius(NodeStyle style, StyleProperty <int> prop) { if (style.HasValue(prop.name)) { return(style.GetStyleValue <int>(prop)); } if (style.HasValue(StyleProperties.borderRadius)) { return(style.borderRadius); } else { return(StyleKeyword.Null); } }
public static StyleFloat GetStyleFloatDouble(NodeStyle style, StyleProperty <float> prop, StyleProperty <float> prop2) { if (style.HasValue(prop.name)) { return(style.GetStyleValue <float>(prop)); } if (style.HasValue(prop2.name)) { return(style.GetStyleValue <float>(prop2)); } else { return(StyleKeyword.Null); } }
private void DeserializeNodeStyle(MetaModel.MetaModel metaModel, EventReader r) { var s = new NodeStyle(); r.Expect <MappingStart>(); r.Expect <Scalar>(); //Title s.Title = r.Expect <Scalar>().Value; r.Expect <Scalar>(); //RefNode s.RefNode = new MapYamlSerializer().Deserialize(r); r.Expect <MappingEnd>(); metaModel.NodeStyles.Add(s); }
public void ApplyTo_List() { MetaModel.MetaModel.Initialize(); var r = new MapNode(new MapTree(), "root"); r.FontSize = 15; var c1 = new MapNode(r, "c1", NodePosition.Right); var c2 = new MapNode(r, "c2"); var sut = new NodeStyle("Sample", r); var a = new [] { c1, c2 }; sut.ApplyTo(a); Assert.AreEqual(15, c1.FontSize); Assert.AreEqual(15, c2.FontSize); }
public Token?NextToken() { _startPosition = InputPosition; _value = null; _style = 0; if (InputPosition >= CharSource.Count) { return(null); } else { Token(); Debug.Assert(InputPosition > _startPosition); return(new Token((int)_type, _startPosition, InputPosition - _startPosition, _style, _value)); } }
public void RenderGraph_givenNodeShape_generatesImage( [Values(NodeShape.None, NodeShape.Box, NodeShape.Circle, NodeShape.Diamond, NodeShape.DoubleCircle, NodeShape.DoubleOctagon, NodeShape.Egg, NodeShape.Ellipse, NodeShape.Hexagon, NodeShape.House, NodeShape.InvHouse, NodeShape.InvTrapezium, NodeShape.InvTriangle, NodeShape.MCircle, NodeShape.MDiamond, NodeShape.MSquare, NodeShape.Octagon, NodeShape.Parallelogram, NodeShape.Pentagon, NodeShape.Plaintext, NodeShape.Point, NodeShape.Polygon, NodeShape.Septagon, NodeShape.Trapezium, NodeShape.Triangle, NodeShape.TripleOctagon)] NodeShape shape) { var nodeStyle = new NodeStyle(); nodeStyle.Shape = shape; var n = Enum.GetName(typeof(NodeShape), shape); var node = nodeStyle.CreateNode(n, n); var graphFactory = new GraphFactory(); var graph = graphFactory.CreateGraph(node); var renderer = new DotRenderer(graph); var filename = n + ".png"; var image = renderer.RenderImage(); image.Save(filename); }
public INodeStyleSchema GetNodeStyleSchema(NodeStyle name) { switch (name) { case NodeStyle.Minimalistic: return(ElementDesignerStyles.NodeStyleSchemaMinimalistic); case NodeStyle.Bold: return(ElementDesignerStyles.NodeStyleSchemaBold); case NodeStyle.Normal: return(ElementDesignerStyles.NodeStyleSchemaNormal); default: throw new ArgumentOutOfRangeException("name", name, null); } }
private bool PrintLiteralCore(object value, NodeStyle style) { Action <Les2Printer, object, NodeStyle> p; if (value == null) { _out.Write("@null", true); } else if (LiteralPrinters.TryGetValue(value.GetType().TypeHandle, out p)) { p(this, value, style); } else { return(false); } return(true); }
public UnityComponent(UnityUGUIContext context) { Context = context; GameObject = new GameObject(); RectTransform = GameObject.AddComponent <RectTransform>(); RectTransform.anchorMin = Vector2.up; RectTransform.anchorMax = Vector2.up; RectTransform.pivot = Vector2.up; Style = new NodeStyle(); Layout = new YogaNode(DefaultLayout); Flex = GameObject.AddComponent <FlexElement>(); Flex.Layout = Layout; Flex.Style = Style; Flex.Component = this; }
EditorComponent(EditorContext context) { Context = context; StateStyles = new StateStyles(this); ComputedStyle = new NodeStyle(StateStyles); Layout = new YogaNode(); Style.changed += StyleChanged; Data.changed += StyleChanged; Deferreds.Add(Context.Dispatcher.OnEveryUpdate(() => { if (markedStyleResolve) { ResolveStyle(markedStyleResolveRecursive); } })); }
/// <summary>Initializes an "uninterpreted literal" token designed to store /// two parts of a literal without allocating extra memory (see the Remarks /// for details). /// </summary> /// <param name="type">Value of <see cref="TypeInt"/></param> /// <param name="startIndex">Value of <see cref="StartIndex"/></param> /// <param name="sourceText">A substring of the token in the original source /// file, such that <see cref="Length"/> will be <c>sourceText.Length</c> /// and <c>sourceText.Substring(valueStart - startIndex, valueEnd - valueStart)</c> /// will be returned from <see cref="TextValue(ICharSource)"/>. For correct /// results, the <see cref="ICharSource"/> passed to TextValue later needs /// to represent the same string that was used to produce this parameter.</param> /// <param name="style">Value of <see cref="Style"/></param> /// <param name="typeMarker">Value of <see cref="TypeMarker"/>.</param> /// <param name="substringStart">Index where the TextValue starts in the source /// code; should be equal to or greater than startIndex.</param> /// <param name="substringEnd">Index where the TextValue ends in the source /// code; should be equal to or less than startIndex + tokenText.Length.</param> /// <remarks> /// Literals in many languages can be broken into two textual parts: their /// type and their value. For example, in some languages you can write 123.5f, /// where "f" indicates that the floating-point value has a size of 32 bits. /// C++ strings have up to three parts, as in <c>u"Hello"_UD</c>: <c>u</c> /// indicates the character type (u = 16-bit unicode) while <c>_UD</c> /// indicates that the string should be interpreted in a user-defined way. /// In LES3, all literals have two parts: value text and a type marker. For /// example, 123.5f has a text "123.5" and type marker "_f"; greeting"Hello" /// has text "Hello" and type marker "greeting"; and a simple number like 123 /// has text "123" and type marker "_". /// <para/> /// This constructor allows you to represent up to two "values" in a single /// token without necessarily allocating memory for them, even though Tokens /// only contain a single heap reference. When calling this constructor, the /// second value, called the "TextValue", must be a substring of the token's /// original source text; for example given the token <c>"Hello"</c>, the /// tokenizer would use <c>Hello</c> as the TextValue. Rather than allocating /// a string "Hello" and storing it in the token, you can use this constructor /// to record the fact that the string <c>Hello</c> begins one character after /// the beginning of the token (<c>valueStart = 1</c>) and one character /// before the end of the token (<c>valueEnd = startIndex + tokenText.Length - 1</c>). /// When using this contructor, the Token's <see cref="Value"/> property /// returns null; internally the value reference points to the type marker, /// which is returned from the <see cref="TypeMarker"/> property rather than /// Value. /// <para/> /// Since a Token does not have a reference to its own source file (<see /// cref="ISourceFile"/>), the language parser will need to use the <see /// cref="TextValue(ICharSource)"/> method to retrieve the value text later. /// <para/> /// <see cref="Token"/> is a small structure that allocates only 8 bits for /// the offset between the TextValue and the beginning/end of the sourceText /// (16 bits total). If the start offset is above 254, the TextValue is /// combined with the <see cref="TypeMarker"/> in a heap object of type /// <see cref="Tuple{Symbol, UString}"/>, but this is a hidden implementation /// detail. /// <para/> /// For strings that contain escape sequences, such as "Hello\n", you may /// prefer to store a parsed version of the string in the Token. There is /// another constructor for this purpose, which always allocates memory: /// <see cref="Token(int, int, int, NodeStyle, Symbol, UString)"/>. /// </remarks> public Token(int type, int startIndex, UString sourceText, NodeStyle style, Symbol typeMarker, int substringStart, int substringEnd) { _startIndex = startIndex; _length = sourceText.Length; _value = typeMarker; _typeInt = type; Debug.Assert(substringStart >= startIndex && substringEnd <= startIndex + sourceText.Length); int substringOffset = substringStart - startIndex; int substringOffsetFromEnd = startIndex + sourceText.Length - substringEnd; if ((uint)substringOffset < 255 && (uint)substringOffsetFromEnd <= 255) { _stuff = Stuff(style, (byte)substringOffset, (byte)substringOffsetFromEnd, true); return; } _stuff = Stuff(style, 0xFF, 0xFF, true); _value = new Tuple <Symbol, UString>(typeMarker, sourceText.Slice(substringStart, substringEnd - substringStart)); }
/// <summary> /// Initializes a new instance of the <see cref="EdgeGenerator"/> class. /// </summary> public EdgeGenerator() { mNodes = new Dictionary <string, Node>(); mMissingNodeStyle = new NodeStyle { FillColor = Color.Red, FontColor = Color.White, Shape = NodeShape.Octagon }; mDependencyEdges = new EdgeStyle { ArrowHead = ArrowShape.Normal, ArrowTail = ArrowShape.None, Color = Color.Gray }; }
private static string GetStyleString(NodeStyle style) { switch (style) { case NodeStyle.Invisible: return("invis"); case NodeStyle.Filled: case NodeStyle.Rounded: case NodeStyle.Dashed: return(style.ToString().ToLower()); } var flagStrings = Enum.GetValues(typeof(NodeStyle)) .Cast <NodeStyle>() .Where(x => x != NodeStyle.None) .Where(x => style.HasFlag(x)) .Select(x => GetStyleString(x)) .OrderBy(x => x) .ToArray(); return($"\"{string.Join(",", flagStrings)}\""); }
/// <summary> /// Initializes a new instance of the <see cref="NodeGenerator"/> class. /// </summary> public NodeGenerator() { mProjectStyle = new NodeStyle { FillColor = Color.WhiteSmoke, Shape = NodeShape.Box }; mExternalTargetStyle = new NodeStyle { FillColor = Color.LemonChiffon, Shape = NodeShape.Record }; mInternalTargetStyle = new NodeStyle { FillColor = Color.Khaki, Shape = NodeShape.Box }; }
public StdComplexCallNode(LNode target, RVList <LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(args, range, style) { CheckParam.IsNotNull("target", target); _target = target; }
static LNode AsStyle(NodeStyle s, LNode node) { return node.SetBaseStyle(s); }
public LNode Call(Token target, LNode _1, LNode _2, int startIndex = -1, int endIndex = -1, NodeStyle style = NodeStyle.Default) { if (endIndex < startIndex) endIndex = startIndex; return new StdSimpleCallNode(target, new VList<LNode>(_1, _2), new SourceRange(_file, startIndex, endIndex - startIndex), style); }
private void DeserializeNodeStyle(MetaModel.MetaModel metaModel, EventReader r) { var s = new NodeStyle(); r.Expect<MappingStart>(); r.Expect<Scalar>(); //Title s.Title = r.Expect<Scalar>().Value; r.Expect<Scalar>(); //RefNode s.RefNode = new MapYamlSerializer().Deserialize(r); r.Expect<MappingEnd>(); metaModel.NodeStyles.Add(s); }
public StdLiteralNode(object value, SourceRange range, NodeStyle style = NodeStyle.Default) : base(range, style) { _value = value; }
public void MarkNode( SyntacticTreeViewNode node, Color back_color ) { if( node == null ) throw new ArgumentNullException("node"); var layout_node = this.node_map[node]; NodeStyle custom_style; if( this.style_map.TryGetValue(node, out custom_style) ) { if( custom_style.BorderPen != null ) { custom_style.BorderPen.Dispose(); custom_style.BorderPen = null; } if( custom_style.LabelBrush != null ) { custom_style.LabelBrush.Dispose(); custom_style.LabelBrush = null; } } else { custom_style = new NodeStyle(); this.style_map.Add(node, custom_style); } if( custom_style.BackBrush == null ) custom_style.BackBrush = new SolidBrush(back_color); else custom_style.BackBrush.Color = back_color; this.FlagUpdate(false); }
public StdSimpleCallNode(Symbol name, VList<LNode> args, SourceRange range, int targetStart, int targetEnd, NodeStyle style = NodeStyle.Default) : base(args, range, style) { _name = name ?? GSymbol.Empty; _targetOffs = ClipUShort(targetStart - RAS.StartIndex); _targetLen = ClipUShort(targetEnd - targetStart); }
private XmlTreeNode() { m_nodeStyle = new NodeStyle(); }
protected static LNode AsStyle(NodeStyle s, LNode node) { node.BaseStyle = s; return node; }
public void Mark() { Style = NodeStyle.Marked; }
protected LiteralNode(SourceRange range, NodeStyle style) : base(range, style) { }
public INodeStyleSchema GetNodeStyleSchema(NodeStyle name) { switch (name) { case NodeStyle.Minimalistic: return ElementDesignerStyles.NodeStyleSchemaMinimalistic; break; case NodeStyle.Bold: return ElementDesignerStyles.NodeStyleSchemaBold; break; case NodeStyle.Normal: return ElementDesignerStyles.NodeStyleSchemaNormal; break; default: throw new ArgumentOutOfRangeException("name", name, null); } }
public LNode Call(Symbol target, VList<LNode> args, int startIndex, int endIndex, int targetStart, int targetEnd, NodeStyle style = NodeStyle.Default) { if (endIndex < startIndex) endIndex = startIndex; return new StdSimpleCallNode(target, args, new SourceRange(_file, startIndex, endIndex - startIndex), targetStart, targetEnd, style); }
public StdSimpleCallNodeWithAttrs(RVList<LNode> attrs, Symbol name, RVList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(name, args, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public void VisitNode_nodeWithFontcolor_setsStatementAttributeFontColor() { var style = new NodeStyle { FontColor = Color.Green }; var renderer = new DotRenderer(); var node = new Node("Name", "Label", style); var statement = renderer.VisitNode(node); Assert.That(statement.Attributes, Has.Member(Dot.FontColor)); }
public StdTriviaNode(Symbol name, object value, SourceRange range, NodeStyle style = NodeStyle.Default) : base(range, style) { _name = name ?? GSymbol.Empty; _tokenValue = value; }
public StdLiteralNodeWithAttrs(RVList <LNode> attrs, object value, SourceRange range, NodeStyle style = NodeStyle.Default) : base(value, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public LNode Call(Symbol target, LNode _1, LNode _2, int startIndex, int endIndex, int targetStart, int targetEnd, NodeStyle style = NodeStyle.Default) { Debug.Assert(endIndex >= startIndex); Debug.Assert(targetEnd >= targetStart && targetStart >= startIndex); return new StdSimpleCallNode(target, new VList<LNode>(_1, _2), new SourceRange(_file, startIndex, endIndex - startIndex), targetStart, targetEnd, style); }
public StdSimpleCallNode(Symbol name, RVList <LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(args, range, style) { _name = name ?? GSymbol.Empty; DetectTargetRange(); }
public LNode Dot(LNode prefix, LNode symbol, int startIndex, int endIndex, int dotStart, int dotEnd, NodeStyle style = NodeStyle.Default) { return new StdSimpleCallNode(S.Dot, new VList<LNode>(prefix, symbol), new SourceRange(_file, startIndex, endIndex - startIndex), dotStart, dotEnd, style); }
public StdSimpleCallNodeWithAttrs(RVList <LNode> attrs, Symbol name, RVList <LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(name, args, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public StdLiteralNodeWithAttrs(VList<LNode> attrs, object value, SourceRange range, NodeStyle style = NodeStyle.Default) : base(value, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public GalleryNodeStylePropertySet(NodeStyle style, RibbonLib.Ribbon ribbon) { this.style = style; this.itemImage = ribbon.ConvertToUIImage(style.Image); }
LNode SetBaseStyle(LNode node, NodeStyle s) { node.BaseStyle = s; return node; }
public StdCallNode(VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(range, style) { _args = args; NoNulls(args, "Args"); }
public StdSimpleCallNode(Symbol name, LNodeList args, SourceRange range, int targetStart, int targetEnd, NodeStyle style = NodeStyle.Default) : base(args, range, style) { _name = name ?? GSymbol.Empty; _targetOffs = ClipUShort(targetStart - RAS.StartIndex); _targetLen = ClipUShort(targetEnd - targetStart); }
public StdSimpleCallNode(Symbol name, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(args, range, style) { _name = name ?? GSymbol.Empty; DetectTargetRange(); }
public StdSimpleCallNode(Loyc.Syntax.Lexing.Token targetToken, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(args, range, style) { _name = (Symbol)(targetToken.Value ?? GSymbol.Empty); _targetOffs = ClipUShort(targetToken.StartIndex - RAS.StartIndex); _targetLen = ClipUShort(targetToken.Length); }
public StdCallNode(RVList <LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(range, style) { _args = args; NoNulls(args, "Args"); }
public StdIdNode(Symbol name, SourceRange range, NodeStyle style = NodeStyle.Default) : base(range, style) { if ((_name = name) == null) throw new ArgumentException("Cannot set IdNode.Name to null."); }
public StdSimpleCallNode(Loyc.Syntax.Lexing.Token targetToken, RVList <LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(args, range, style) { _name = (Symbol)(targetToken.Value ?? GSymbol.Empty); _targetOffs = ClipUShort(targetToken.StartIndex - RAS.StartIndex); _targetLen = ClipUShort(targetToken.Length); }
public StdSimpleCallNodeWithAttrs(VList<LNode> attrs, Loyc.Syntax.Lexing.Token targetToken, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(targetToken, args, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public StdSimpleCallNodeWithAttrs(RVList <LNode> attrs, Loyc.Syntax.Lexing.Token targetToken, RVList <LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(targetToken, args, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public StdComplexCallNode(LNode target, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(args, range, style) { CheckParam.IsNotNull("target", target); _target = target; }
public StdComplexCallNodeWithAttrs(RVList <LNode> attrs, LNode target, RVList <LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(target, args, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public StdComplexCallNodeWithAttrs(VList<LNode> attrs, LNode target, VList<LNode> args, SourceRange range, NodeStyle style = NodeStyle.Default) : base(target, args, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public StdIdNodeWithAttrs(LNodeList attrs, Symbol name, SourceRange range, NodeStyle style = NodeStyle.Default) : base(name, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public StdIdNodeWithAttrs(VList<LNode> attrs, Symbol name, SourceRange range, NodeStyle style = NodeStyle.Default) : base(name, range, style) { _attrs = attrs; NoNulls(attrs, "Attrs"); }
public void Unmark() { Style = NodeStyle.Simple; }