Example #1
0
        private void ParseEvents()
        {
            // Add widget events from control type declaration
            _events.AddRange(
                from widgetEvent in TypeDescriptor.GetAttributes(Widget).OfType <WidgetEventAttribute>()
                select new WidgetEvent(widgetEvent.Name)
                );

            IAutoPostBackWidget autoPostBackWidget = Widget as IAutoPostBackWidget;
            Boolean             autoPostBack       = autoPostBackWidget == null ? false : autoPostBackWidget.AutoPostBack;

            // Add widget events from control events
            foreach (EventDescriptor widgetEvent in TypeDescriptor.GetEvents(Widget.GetType()).OfType <EventDescriptor>())
            {
                WidgetEventAttribute attribute = widgetEvent.Attributes.OfType <WidgetEventAttribute>().SingleOrDefault();

                if (attribute == null)
                {
                    continue;
                }

                WidgetEvent @event = new WidgetEvent(attribute.Name);

                @event.CausesPostBack   = attribute.AutoPostBack && autoPostBack;
                @event.DataChangedEvent = _dataChangedEvent != null && _dataChangedEvent.Name == @event.Name;

                _events.Add(@event);
            }
        }
Example #2
0
        public JuiceWidgetState(IWidget widget)
        {
            Widget = widget;

            foreach (EventDescriptor widgetEvent in TypeDescriptor.GetEvents(Widget.GetType()).OfType <EventDescriptor>())
            {
                WidgetEventAttribute attribute = widgetEvent.Attributes.OfType <WidgetEventAttribute>().SingleOrDefault();

                if (attribute != null && attribute.DataChangedHandler == true)
                {
                    _dataChangedEvent = new WidgetEvent(attribute.Name);
                    break;
                }
            }

            _cssManager = new CssManager(widget as Control);
        }
Example #3
0
        public void RaisePostBackEvent(String eventName)
        {
            LoadPostData();

            Type type = Widget.GetType();

            foreach (EventDescriptor @event in TypeDescriptor.GetEvents(type).OfType <EventDescriptor>())
            {
                WidgetEventAttribute attribute = @event.Attributes.OfType <WidgetEventAttribute>().SingleOrDefault();

                if (attribute == null || attribute.Name != eventName)
                {
                    continue;
                }

                FieldInfo         delegateField = type.GetField(@event.Name, BindingFlags.Instance | BindingFlags.NonPublic);
                MulticastDelegate @delegate     = delegateField.GetValue(Widget) as MulticastDelegate;

                if (@delegate != null && @delegate.GetInvocationList().Length > 0)
                {
                    @delegate.DynamicInvoke(new object[] { Widget, EventArgs.Empty });
                }
            }
        }