Ejemplo n.º 1
0
 public override IList <IElement> Start(IWorkerContext ctx, Tag tag)
 {
     try
     {
         SvgPipelineContext context = GetSvgPipelineContext(ctx);
         context.SetDefinition(true);
     }
     catch (NoCustomContextException e)
     {
         Console.WriteLine(e.StackTrace);
     }
     return(new List <IElement>(0));
 }
Ejemplo n.º 2
0
        public override IList <IElement> End(IWorkerContext ctx, Tag tag,
                                             IList <IElement> currentContent)
        {
            Path path = null;

            try
            {
                IDictionary <String, String> attributes = tag.Attributes;
                SvgPipelineContext           context    = GetSvgPipelineContext(ctx);
                String id;
                if (attributes.TryGetValue("xlink:href", out id) && id != null)
                {
                    IList <IElement> list = context.GetSymbolById(id.Substring(1));
                    //TODO need to check that the element list contains only one element
                    //and the type needs to be Path
                    if (list != null && list.Count == 1)
                    {
                        path = (Path)list[0];
                    }
                }
            }
            catch (NoCustomContextException e)
            {
                throw new RuntimeWorkerException(e);
            }
            //if the path is not found, do exactly the same as when Text
            if (path == null && currentContent.Count > 0)
            {
                TextGroup group =
                    new TextGroup(currentContent, 0, 0, 500f, 500f, tag.CSS);
                IList <IElement> l = new List <IElement>(1);
                l.Add(group);
                return(l);
            }
            else if (currentContent.Count > 0)
            {
                TextPathGroup group =
                    new TextPathGroup(currentContent, 0, 0, 500f, 500f, tag.CSS, path);
                IList <IElement> l = new List <IElement>(1);
                l.Add(group);
                return(l);
            }
            //draw the content
            return(new List <IElement>(0));
        }
Ejemplo n.º 3
0
 public override IList <IElement> Start(IWorkerContext ctx, Tag tag)
 {
     //<use>: get the symbol and add the elements from the symbol here
     //use the current CSS but overwrite with the CSS of the symbol
     try{
         IDictionary <String, String> attributes = tag.Attributes;
         SvgPipelineContext           context    = GetSvgPipelineContext(ctx);
         String id;
         if (attributes.TryGetValue("xlink:href", out id) && id != null)
         {
             IList <IElement> list = context.GetSymbolById(id.Substring(1));
             if (list != null)
             {
                 IList <IElement> l = new List <IElement>(1);
                 l.Add(new Group(list, GetAttribute("x", attributes), GetAttribute("y", attributes), GetAttribute("width", attributes), GetAttribute("height", attributes), tag.CSS, true));
                 return(l);
             }
         }
     } catch (NoCustomContextException e) {
         throw new RuntimeWorkerException(e);
     }
     return(new List <IElement>(0));
 }