Ejemplo n.º 1
0
			public override void VisitElement (Element element)
			{
				var lgb = element.Brush as LinearGradientBrush;
				if (lgb != null && !defs.ContainsKey (lgb)) {
					var id = "linearGradient-" + (nextId++);
					defs [lgb] = id;
					w.WriteLine ("<linearGradient x1=\"{1}{5}\" y1=\"{2}{5}\" x2=\"{3}{5}\" y2=\"{4}{5}\" id=\"{0}\">",
						id,
						lgb.Start.X*100, lgb.Start.Y*100,
						lgb.End.X*100, lgb.End.Y*100,
						lgb.Absolute ? "" : "%");
					WriteStops (lgb);
					w.WriteLine ("</linearGradient>");
				}
				var rgb = element.Brush as RadialGradientBrush;
				if (rgb != null && !defs.ContainsKey (rgb)) {
					var id = "radialGradient-" + (nextId++);
					defs [rgb] = id;
					w.WriteLine ("<radialGradient cx=\"{1}{6}\" cy=\"{2}{6}\" fx=\"{3}{6}\" fy=\"{4}{6}\" r=\"{5}{6}\" id=\"{0}\">",
						id,
						rgb.Center.X*100, rgb.Center.Y*100,
						rgb.Focus.X*100, rgb.Focus.Y*100,
						rgb.Radius.Width*100,
						rgb.Absolute ? "" : "%");
					WriteStops (rgb);
					w.WriteLine ("</radialGradient>");
				}
			}
Ejemplo n.º 2
0
		protected virtual void SetCloneData (Element clone)
		{
			clone.Id = Id;
			clone.Transform = Transform;
			clone.Pen = Pen;
			clone.Brush = Brush;
		}
Ejemplo n.º 3
0
        private static void ApplyColor(NGraphics.Element element, NGraphics.Color color)
        {
            var children = (element as Group)?.Children;

            if (children != null)
            {
                foreach (var child in children)
                {
                    ApplyColor(child, color);
                }
            }

            if (element?.Pen != null)
            {
                element.Pen = new Pen(color, element.Pen.Width);
            }

            if (element?.Brush != null)
            {
                element.Brush = new SolidBrush(color);
            }
        }
Ejemplo n.º 4
0
 public void Apply(Element e)
 {
     if (e == null)
         return;
     e.Display = display;
 }
Ejemplo n.º 5
0
		void WriteStartElement (string name, Element element)
		{
			w.Write ("<{0}", name);
			if (!string.IsNullOrWhiteSpace (element.Id)) {
				w.Write (" id=\"{0}\"", element.Id);
			}
			if (element.Pen != null) {
				w.Write (" stroke-width=\"{0}\"", element.Pen.Width);
				w.Write (" stroke=\"{0}\"", element.Pen.Color.HtmlString);
				if (element.Pen.Color.A != 255) {
					w.Write (" stroke-opacity=\"{0}\"", element.Pen.Color.Alpha);
				}
			} else {
				w.Write (" stroke=\"none\"");
			}
			if (element.Brush != null) {
				//fill-rule="evenodd"
				var sb = element.Brush as SolidBrush;
				if (sb != null) {
					w.Write (" fill=\"{0}\"", sb.Color.HtmlString);
					if (sb.Color.A != 255) {
						w.Write (" fill-opacity=\"{0}\"", sb.Color.Alpha);
					}
				} else {
					w.Write (" fill=\"url(#{0})\"", defs[element.Brush]);
				}
			} else {
				w.Write (" fill=\"none\"");
			}
			var t = element.Transform;
			if (t != Transform.Identity) {
				w.Write (" transform=\"matrix({0}, {1}, {2}, {3}, {4}, {5})\"",
					t.A, t.B,
					t.C, t.D,
					t.E, t.F);
			}
		}
Ejemplo n.º 6
0
		void WriteElement (Element c)
		{
			w.WriteLine (c.ToString ());
		}
Ejemplo n.º 7
0
		public virtual void EndVisitElement (Element element)
		{
		}
Ejemplo n.º 8
0
		protected override void SetCloneData (Element clone)
		{
			base.SetCloneData (clone);
			((Group)clone).Children.AddRange (Children.Select (x => x.Clone ()));
		}
Ejemplo n.º 9
0
		protected override void SetCloneData (Element clone)
		{
			base.SetCloneData (clone);
			((Path)clone).Operations.AddRange (Operations.Select (x => x.Clone ()));
		}