Beispiel #1
0
 public HtmlElementWrapper(HtmlElement realElement, HtmlElementWrapperBag bag) : this(realElement)
 {
     if (bag == null)
     {
         throw new ArgumentNullException("bag");
     }
     MoveBagContents(bag);
 }
Beispiel #2
0
 public HtmlElementWrapper(HtmlElement realElement, HtmlElementWrapperBag bag) : this(realElement)
 {
     if (bag == null)
     {
         throw new ArgumentNullException("bag");
     }
     MoveBagContents(bag);
 }
Beispiel #3
0
        /// <summary>
        /// Converts from a property bag to a live wrapper.  If the current
        /// wrapper is not a bag, then it creates a new wrapper around the live
        /// HtmlElement.
        /// </summary>
        private void ConvertBagWrapper()
        {
            HtmlElementWrapperBag bag = _wrapper as HtmlElementWrapperBag;

            if (bag == null)
            {
                _wrapper = new HtmlElementWrapper(_htmlElement);
            }
            else
            {
                // Create the live, direct-wired wrapper to the element
                _wrapper = new HtmlElementWrapper(_htmlElement, bag);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Copies the contents of the property, event and attribute bag into 
        /// the actual live control.
        /// </summary>
        /// <param name="bag">The bag containing the values.</param>
        private void MoveBagContents(HtmlElementWrapperBag bag)
        {
            // Attributes
            foreach (string attribute in bag.Attributes.Keys)
            {
                SetAttribute(attribute, bag.Attributes[attribute]);
            }
            bag.Attributes.Clear();

            // Properties
            foreach (string property in bag.Properties.Keys)
            {
                SetProperty(property, bag.Properties[property]);
            }
            bag.Properties.Clear();

            // Style attributes
            foreach (string style in bag.StyleAttributes.Keys)
            {
                SetStyleAttribute(style, bag.StyleAttributes[style]);
            }
            bag.StyleAttributes.Clear();

            // HTML Events
            foreach (EventAttachment<EventHandler<HtmlEventArgs>> htmlEvent in bag.HtmlEvents)
            {
                AttachEvent(htmlEvent.EventName, htmlEvent.Handler);
            }
            bag.HtmlEvents.Clear();

            // Events
            foreach (EventAttachment<EventHandler> attachment in bag.Events)
            {
                AttachEvent(attachment.EventName, attachment.Handler);
            }
            bag.Events.Clear();
        }
Beispiel #5
0
        /// <summary>
        /// Copies the contents of the property, event and attribute bag into
        /// the actual live control.
        /// </summary>
        /// <param name="bag">The bag containing the values.</param>
        private void MoveBagContents(HtmlElementWrapperBag bag)
        {
            // Attributes
            foreach (string attribute in bag.Attributes.Keys)
            {
                SetAttribute(attribute, bag.Attributes[attribute]);
            }
            bag.Attributes.Clear();

            // Properties
            foreach (string property in bag.Properties.Keys)
            {
                SetProperty(property, bag.Properties[property]);
            }
            bag.Properties.Clear();

            // Style attributes
            foreach (string style in bag.StyleAttributes.Keys)
            {
                SetStyleAttribute(style, bag.StyleAttributes[style]);
            }
            bag.StyleAttributes.Clear();

            // HTML Events
            foreach (EventAttachment <EventHandler <HtmlEventArgs> > htmlEvent in bag.HtmlEvents)
            {
                AttachEvent(htmlEvent.EventName, htmlEvent.Handler);
            }
            bag.HtmlEvents.Clear();

            // Events
            foreach (EventAttachment <EventHandler> attachment in bag.Events)
            {
                AttachEvent(attachment.EventName, attachment.Handler);
            }
            bag.Events.Clear();
        }