public void ParseElements(ISvgEventCaller caller, SvgElement element)
        {
            //register events
            if (element.HasNonEmptyCustomAttribute("onclick"))
            {
                element.RegisterEvents(caller);
                element.Click += child_Click;
            }

            //gather color relevant elements
            if (element.HasNonEmptyCustomAttribute("class"))
            {
                if (element.CustomAttributes["class"] == "widgetback")
                {
                    if (element is SvgVisualElement)
                    {
                        BackgroundElements.Add(element as SvgVisualElement);
                    }
                    else if (element.CustomAttributes["class"] == "widgetfore")
                    {
                        if (element is SvgVisualElement)
                        {
                            ForegroundElements.Add(element as SvgVisualElement);
                        }
                    }
                }
            }

            foreach (var child in element.Children)
            {
                ParseElements(caller, child);
            }
        }
Example #2
0
        public void ParseElements(ISvgEventCaller caller, SvgElement element)
        {
            //register events
            if(element.HasNonEmptyCustomAttribute("onclick"))
            {
                element.RegisterEvents(caller);
                element.Click += child_Click;
            }

            //gather color relevant elements
            if(element.HasNonEmptyCustomAttribute("class"))
            {
                if(element.CustomAttributes["class"] == "widgetback")
                    if(element is SvgVisualElement)
                        BackgroundElements.Add(element as SvgVisualElement);
                else if(element.CustomAttributes["class"] == "widgetfore")
                    if(element is SvgVisualElement)
                        ForegroundElements.Add(element as SvgVisualElement);
            }

            foreach (var child in element.Children)
            {
                ParseElements(caller, child);
            }
        }
Example #3
0
        //private static GraphicsPath GetPath(string text, Font font)
        //{
        //    var fontMetrics = (from c in text.Distinct()
        //                       select new { Char = c, Metrics = Metrics(c, font) }).
        //                       ToDictionary(c => c.Char, c=> c.Metrics);
        //    // Measure each character and check the metrics against the overall metrics of rendering
        //    // an entire word with kerning.
        //}
        //private static RectangleF Metrics(char c, Font font)
        //{
        //    var path = new GraphicsPath();
        //    path.AddString(c.ToString(), font.FontFamily, (int)font.Style, font.Size, new Point(0, 0), StringFormat.GenericTypographic);
        //    return path.GetBounds();
        //}

#if Net4
        public override void RegisterEvents(ISvgEventCaller caller)
        {
            //register basic events
            base.RegisterEvents(caller);

            //add change event for text
            caller.RegisterAction <string, string>(this.ID + "/onchange", OnChange);
        }
Example #4
0
        public override void UnregisterEvents(ISvgEventCaller caller)
        {
            //unregister base events
            base.UnregisterEvents(caller);

            //unregister change event
            caller.UnregisterAction(this.ID + "/onchange");
        }
        void UnregisterElementEvents(ISvgEventCaller caller, SvgElement element)
        {
            element.UnregisterEvents(caller);

            foreach (var child in element.Children)
            {
                UnregisterElementEvents(caller, child);
            }
        }
Example #6
0
        void UnregisterElementEvents(ISvgEventCaller caller, SvgElement element)
        {
            element.UnregisterEvents(caller);

            foreach (var child in element.Children)
            {
                UnregisterElementEvents(caller, child);
            }
        }
Example #7
0
 public SvgIdManager(SvgDocument doc, ISvgEventCaller caller, RemoteContext remoteContext)
     : base(doc)
 {
     FCaller               = caller;
     RemoteContext         = remoteContext;
     doc.ChildAdded       += element_ChildAdded;
     doc.AttributeChanged += element_AttributeChanged;
     doc.ContentChanged   += element_ContentChanged;
 }
Example #8
0
 public SvgIdManager(SvgDocument doc, ISvgEventCaller caller, RemoteContext remoteContext)
     : base(doc)
 {
     FCaller = caller;
     RemoteContext = remoteContext;
     doc.ChildAdded += element_ChildAdded;
     doc.AttributeChanged += element_AttributeChanged;
     doc.ContentChanged += element_ContentChanged;
 }
        public static SvgDocumentWidget Load(string filePath, ISvgEventCaller caller, int viewCount)
        {
            var newWidget = SvgDocument.Open <SvgDocumentWidget>(filePath);

            newWidget.AutoPublishEvents = false;
            newWidget.ParseElements(caller, newWidget);

            newWidget.Height = newWidget.Height / viewCount;
            newWidget.SetViewBox(0);
            newWidget.Overflow = SvgOverflow.hidden;

            return(newWidget);
        }
Example #10
0
        public static SvgDocumentWidget Load(string filePath, ISvgEventCaller caller, int viewCount)
        {
            var newWidget = SvgDocument.Open<SvgDocumentWidget>(filePath);

            newWidget.AutoPublishEvents = false;
            newWidget.ParseElements(caller, newWidget);

            newWidget.Height = newWidget.Height / viewCount;
            newWidget.SetViewBox(0);
            newWidget.Overflow = SvgOverflow.hidden;

            return newWidget;
        }
Example #11
0
        /// <summary>
        /// Use this method to provide your implementation ISvgEventCaller to unregister Actions
        /// </summary>
        /// <param name="caller"></param>
        public virtual void UnregisterEvents(ISvgEventCaller caller)
        {
            if (caller != null && !string.IsNullOrEmpty(this.ID))
            {
                var rpcID = this.ID + "/";

                caller.UnregisterAction(rpcID + "onclick");
                caller.UnregisterAction(rpcID + "onmousedown");
                caller.UnregisterAction(rpcID + "onmouseup");
                caller.UnregisterAction(rpcID + "onmousemove");
                caller.UnregisterAction(rpcID + "onmousescroll");
                caller.UnregisterAction(rpcID + "onmouseover");
                caller.UnregisterAction(rpcID + "onmouseout");
            }
        }
Example #12
0
        /*
         *      onfocusin = "<anything>"
         *      onfocusout = "<anything>"
         *      onactivate = "<anything>"
         *      onclick = "<anything>"
         *      onmousedown = "<anything>"
         *      onmouseup = "<anything>"
         *      onmouseover = "<anything>"
         *      onmousemove = "<anything>"
         *      onmouseout = "<anything>"
         */

#if Net4
        /// <summary>
        /// Use this method to provide your implementation ISvgEventCaller which can register Actions
        /// and call them if one of the events occurs. Make sure, that your SvgElement has a unique ID.
        /// The SvgTextElement overwrites this and regsiters the Change event tor its text content.
        /// </summary>
        /// <param name="caller"></param>
        public virtual void RegisterEvents(ISvgEventCaller caller)
        {
            if (caller != null && !string.IsNullOrEmpty(this.ID))
            {
                var rpcID = this.ID + "/";

                caller.RegisterAction <float, float, int, int, bool, bool, bool, string>(rpcID + "onclick", CreateMouseEventAction(RaiseMouseClick));
                caller.RegisterAction <float, float, int, int, bool, bool, bool, string>(rpcID + "onmousedown", CreateMouseEventAction(RaiseMouseDown));
                caller.RegisterAction <float, float, int, int, bool, bool, bool, string>(rpcID + "onmouseup", CreateMouseEventAction(RaiseMouseUp));
                caller.RegisterAction <float, float, int, int, bool, bool, bool, string>(rpcID + "onmousemove", CreateMouseEventAction(RaiseMouseMove));
                caller.RegisterAction <float, float, int, int, bool, bool, bool, string>(rpcID + "onmouseover", CreateMouseEventAction(RaiseMouseOver));
                caller.RegisterAction <float, float, int, int, bool, bool, bool, string>(rpcID + "onmouseout", CreateMouseEventAction(RaiseMouseOut));
                caller.RegisterAction <int, bool, bool, bool, string>(rpcID + "onmousescroll", OnMouseScroll);
            }
        }
Example #13
0
        /*
         *  onfocusin = "<anything>"
         *  onfocusout = "<anything>"
         *  onactivate = "<anything>"
         *      onclick = "<anything>"
         *      onmousedown = "<anything>"
         *      onmouseup = "<anything>"
         *      onmouseover = "<anything>"
         *      onmousemove = "<anything>"
         *      onmouseout = "<anything>"
         */

        /// <summary>
        /// Use this method to provide your implementation ISvgEventCaller which can register Actions
        /// and call them if one of the events occurs. Make sure, that your SvgElement has a unique ID.
        /// </summary>
        /// <param name="caller"></param>
        public void RegisterEvents(ISvgEventCaller caller)
        {
            if (caller != null && !string.IsNullOrWhiteSpace(this.ID))
            {
                var rpcID = this.ID + "/";

                caller.RegisterAction <float, float, int, int>(rpcID + "onclick", OnClick);
                caller.RegisterAction <float, float, int, int>(rpcID + "onmousedown", OnMouseDown);
                caller.RegisterAction <float, float, int>(rpcID + "onmouseup", OnMouseUp);
                caller.RegisterAction <float, float>(rpcID + "onmousemove", OnMouseMove);
                caller.RegisterAction <float>(rpcID + "onmousescroll", OnMouseScroll);
                caller.RegisterAction(rpcID + "onmouseover", OnMouseOver);
                caller.RegisterAction(rpcID + "onmouseout", OnMouseOut);
            }
        }
Example #14
0
 public void UnregisterEvents(ISvgEventCaller caller)
 {
     UnregisterElementEvents(caller, this);
 }
Example #15
0
 public override void UnregisterEvents(ISvgEventCaller caller)
 {
     //unregister base events
     base.UnregisterEvents(caller);
     
     //unregister change event
     caller.UnregisterAction(this.ID + "/onchange");
     
 }
Example #16
0
        //private static GraphicsPath GetPath(string text, Font font)
        //{
        //    var fontMetrics = (from c in text.Distinct()
        //                       select new { Char = c, Metrics = Metrics(c, font) }).
        //                       ToDictionary(c => c.Char, c=> c.Metrics);
        //    // Measure each character and check the metrics against the overall metrics of rendering
        //    // an entire word with kerning.
        //}
        //private static RectangleF Metrics(char c, Font font)
        //{
        //    var path = new GraphicsPath();
        //    path.AddString(c.ToString(), font.FontFamily, (int)font.Style, font.Size, new Point(0, 0), StringFormat.GenericTypographic);
        //    return path.GetBounds();
        //}

#if Net4
        public override void RegisterEvents(ISvgEventCaller caller)
        {
            //register basic events
            base.RegisterEvents(caller); 
            
            //add change event for text
            caller.RegisterAction<string, string>(this.ID + "/onchange", OnChange);
        }
Example #17
0
 public void UnregisterEvents(ISvgEventCaller caller)
 {
     UnregisterElementEvents(caller, this);
 }