Example #1
0
        public override bool AddAndForceUniqueID(SvgElement element, SvgElement sibling, bool autoForceUniqueID, Action<SvgElement, string, string> logElementOldIDNewID)
        {
            //register events
            element.AttributeChanged += element_AttributeChanged;
            element.ContentChanged += element_ContentChanged;
            element.ChildAdded += element_ChildAdded;

            if(element is SvgVisualElement)
            {
                //check id
                if(string.IsNullOrWhiteSpace(element.ID))
                {
                    if(element.Parent != null)
                        element.SetAndForceUniqueID(element.Parent.ID + "_" + IDGenerator.NewID, true, null);
                    else
                        element.SetAndForceUniqueID(RandomString(16), true, null);
                }
            }

            return base.AddAndForceUniqueID(element, sibling, true, logElementOldIDNewID);
        }