Exemplo n.º 1
0
        public IPAddressControl()
        {
            BackColor = SystemColors.Window;

            ResetBackColorChanged();

            for (int index = 0; index < ipAddressFieldControls.Length; ++index)
            {
                ipAddressFieldControls[index] = new IPAddressFieldControl();

                ipAddressFieldControls[index].CreateControl();

                ipAddressFieldControls[index].FieldIndex = index;
                ipAddressFieldControls[index].Name       = "FieldControl" + index.ToString(CultureInfo.InvariantCulture);
                ipAddressFieldControls[index].Parent     = this;

                ipAddressFieldControls[index].CedeFocusEvent   += new EventHandler <CedeFocusEventArgs>(OnCedeFocus);
                ipAddressFieldControls[index].Click            += new EventHandler(OnSubControlClicked);
                ipAddressFieldControls[index].DoubleClick      += new EventHandler(OnSubControlDoubleClicked);
                ipAddressFieldControls[index].GotFocus         += new EventHandler(OnFieldGotFocus);
                ipAddressFieldControls[index].KeyDown          += new KeyEventHandler(OnFieldKeyDown);
                ipAddressFieldControls[index].KeyPress         += new KeyPressEventHandler(OnFieldKeyPressed);
                ipAddressFieldControls[index].KeyUp            += new KeyEventHandler(OnFieldKeyUp);
                ipAddressFieldControls[index].LostFocus        += new EventHandler(OnFieldLostFocus);
                ipAddressFieldControls[index].MouseClick       += new MouseEventHandler(OnSubControlMouseClicked);
                ipAddressFieldControls[index].MouseDoubleClick += new MouseEventHandler(OnSubControlMouseDoubleClicked);
                ipAddressFieldControls[index].MouseEnter       += new EventHandler(OnSubControlMouseEntered);
                ipAddressFieldControls[index].MouseHover       += new EventHandler(OnSubControlMouseHovered);
                ipAddressFieldControls[index].MouseLeave       += new EventHandler(OnSubControlMouseLeft);
                ipAddressFieldControls[index].MouseMove        += new MouseEventHandler(OnSubControlMouseMoved);
                ipAddressFieldControls[index].PreviewKeyDown   += new PreviewKeyDownEventHandler(OnFieldPreviewKeyDown);
                ipAddressFieldControls[index].TextChangedEvent += new EventHandler <TextChangedEventArgs>(OnFieldTextChanged);

                Controls.Add(ipAddressFieldControls[index]);

                if (index < (FieldCount - 1))
                {
                    ipAddressDotControls[index] = new IPAddressDotControl();

                    ipAddressDotControls[index].CreateControl();

                    ipAddressDotControls[index].Name   = "DotControl" + index.ToString(CultureInfo.InvariantCulture);
                    ipAddressDotControls[index].Parent = this;

                    ipAddressDotControls[index].Click            += new EventHandler(OnSubControlClicked);
                    ipAddressDotControls[index].DoubleClick      += new EventHandler(OnSubControlDoubleClicked);
                    ipAddressDotControls[index].MouseClick       += new MouseEventHandler(OnSubControlMouseClicked);
                    ipAddressDotControls[index].MouseDoubleClick += new MouseEventHandler(OnSubControlMouseDoubleClicked);
                    ipAddressDotControls[index].MouseEnter       += new EventHandler(OnSubControlMouseEntered);
                    ipAddressDotControls[index].MouseHover       += new EventHandler(OnSubControlMouseHovered);
                    ipAddressDotControls[index].MouseLeave       += new EventHandler(OnSubControlMouseLeft);
                    ipAddressDotControls[index].MouseMove        += new MouseEventHandler(OnSubControlMouseMoved);

                    Controls.Add(ipAddressDotControls[index]);
                }
            }

            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.ContainerControl, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.FixedWidth, true);
            SetStyle(ControlStyles.FixedHeight, true);

            _referenceTextBox.AutoSize = true;

            Cursor = Cursors.IBeam;

            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode       = AutoScaleMode.Dpi;

            Size = MinimumSize;

            DragEnter += new DragEventHandler(IPAddressControl_DragEnter);
            DragDrop  += new DragEventHandler(IPAddressControl_DragDrop);
        }
        public IPAddressControl()
        {
            BackColor = SystemColors.Window;

            ResetBackColorChanged();

            for (int index = 0; index < ipAddressFieldControls.Length; ++index)
            {
                ipAddressFieldControls[index] = new IPAddressFieldControl();

                ipAddressFieldControls[index].CreateControl();

                ipAddressFieldControls[index].FieldIndex = index;
                ipAddressFieldControls[index].Name = "FieldControl" + index.ToString(CultureInfo.InvariantCulture);
                ipAddressFieldControls[index].Parent = this;

                ipAddressFieldControls[index].CedeFocusEvent += new EventHandler<CedeFocusEventArgs>(OnCedeFocus);
                ipAddressFieldControls[index].Click += new EventHandler(OnSubControlClicked);
                ipAddressFieldControls[index].DoubleClick += new EventHandler(OnSubControlDoubleClicked);
                ipAddressFieldControls[index].GotFocus += new EventHandler(OnFieldGotFocus);
                ipAddressFieldControls[index].KeyDown += new KeyEventHandler(OnFieldKeyDown);
                ipAddressFieldControls[index].KeyPress += new KeyPressEventHandler(OnFieldKeyPressed);
                ipAddressFieldControls[index].KeyUp += new KeyEventHandler(OnFieldKeyUp);
                ipAddressFieldControls[index].LostFocus += new EventHandler(OnFieldLostFocus);
                ipAddressFieldControls[index].MouseClick += new MouseEventHandler(OnSubControlMouseClicked);
                ipAddressFieldControls[index].MouseDoubleClick += new MouseEventHandler(OnSubControlMouseDoubleClicked);
                ipAddressFieldControls[index].MouseEnter += new EventHandler(OnSubControlMouseEntered);
                ipAddressFieldControls[index].MouseHover += new EventHandler(OnSubControlMouseHovered);
                ipAddressFieldControls[index].MouseLeave += new EventHandler(OnSubControlMouseLeft);
                ipAddressFieldControls[index].MouseMove += new MouseEventHandler(OnSubControlMouseMoved);
                ipAddressFieldControls[index].PreviewKeyDown += new PreviewKeyDownEventHandler(OnFieldPreviewKeyDown);
                ipAddressFieldControls[index].TextChangedEvent += new EventHandler<TextChangedEventArgs>(OnFieldTextChanged);

                Controls.Add(ipAddressFieldControls[index]);

                if (index < (FieldCount - 1))
                {
                    ipAddressDotControls[index] = new IPAddressDotControl();

                    ipAddressDotControls[index].CreateControl();

                    ipAddressDotControls[index].Name = "DotControl" + index.ToString(CultureInfo.InvariantCulture);
                    ipAddressDotControls[index].Parent = this;

                    ipAddressDotControls[index].Click += new EventHandler(OnSubControlClicked);
                    ipAddressDotControls[index].DoubleClick += new EventHandler(OnSubControlDoubleClicked);
                    ipAddressDotControls[index].MouseClick += new MouseEventHandler(OnSubControlMouseClicked);
                    ipAddressDotControls[index].MouseDoubleClick += new MouseEventHandler(OnSubControlMouseDoubleClicked);
                    ipAddressDotControls[index].MouseEnter += new EventHandler(OnSubControlMouseEntered);
                    ipAddressDotControls[index].MouseHover += new EventHandler(OnSubControlMouseHovered);
                    ipAddressDotControls[index].MouseLeave += new EventHandler(OnSubControlMouseLeft);
                    ipAddressDotControls[index].MouseMove += new MouseEventHandler(OnSubControlMouseMoved);

                    Controls.Add(ipAddressDotControls[index]);
                }
            }

            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.ContainerControl, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.FixedWidth, true);
            SetStyle(ControlStyles.FixedHeight, true);

            _referenceTextBox.AutoSize = true;

            Cursor = Cursors.IBeam;

            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode = AutoScaleMode.Dpi;

            Size = MinimumSize;

            DragEnter += new DragEventHandler(IPAddressControl_DragEnter);
            DragDrop += new DragEventHandler(IPAddressControl_DragDrop);
        }