コード例 #1
0
            public ErrorProperty(ErrorProvider ep, Control control)
            {
                this.ep      = ep;
                this.control = control;

                alignment   = ErrorIconAlignment.MiddleRight;
                padding     = 0;
                text        = string.Empty;
                blink_count = 0;

                tick = new EventHandler(window_Tick);

                window         = new ErrorWindow();
                window.Visible = false;
                window.Width   = ep.icon.Width;
                window.Height  = ep.icon.Height;

#if NET_2_0
                // UIA Framework: Associate ErrorProvider with Control
                ErrorProvider.OnUIAErrorProviderHookUp(ep, new ControlEventArgs(control));

                // UIA Framework: Generate event to associate UserControl with ErrorProvider
                window.VisibleChanged += delegate(object sender, EventArgs args)
                {
                    if (window.Visible == true)
                    {
                        ErrorProvider.OnUIAControlHookUp(control, new ControlEventArgs(window));
                    }
                    else
                    {
                        ErrorProvider.OnUIAControlUnhookUp(control, new ControlEventArgs(window));
                    }
                };
#endif

                if (control.Parent != null)
                {
#if NET_2_0
                    // UIA Framework: Generate event to associate UserControl with ErrorProvider
                    ErrorProvider.OnUIAControlHookUp(control, new ControlEventArgs(window));
#endif
                    control.Parent.Controls.Add(window);
                    control.Parent.Controls.SetChildIndex(window, control.Parent.Controls.IndexOf(control) + 1);
                }

                window.Paint            += new PaintEventHandler(window_Paint);
                window.MouseEnter       += new EventHandler(window_MouseEnter);
                window.MouseLeave       += new EventHandler(window_MouseLeave);
                control.SizeChanged     += new EventHandler(control_SizeLocationChanged);
                control.LocationChanged += new EventHandler(control_SizeLocationChanged);
                control.ParentChanged   += new EventHandler(control_ParentChanged);
                // Do we want to block mouse clicks? if so we need a few more events handled

                CalculateAlignment();
            }
コード例 #2
0
            private void control_ParentChanged(object sender, EventArgs e)
            {
                if (control.Parent != null)
                {
                    // UIA Framework: Generate event to disassociate UserControl with ErrorProvider
                    ErrorProvider.OnUIAControlUnhookUp(control, new ControlEventArgs(window));
                    control.Parent.Controls.Add(window);
                    control.Parent.Controls.SetChildIndex(window, control.Parent.Controls.IndexOf(control) + 1);

                    // UIA Framework: Generate event to associate UserControl with ErrorProvider
                    ErrorProvider.OnUIAControlHookUp(control, new ControlEventArgs(window));
                }
            }