Example #1
0
 void IWindowsFormsEditorService.DropDownControl(Control ctl)
 {
     if (this.dropDownHolder == null)
     {
         this.dropDownHolder = new DropDownHolder(this);
     }
     this.dropDownHolder.SetComponent(ctl);
     this.dropDownHolder.Location = base.PointToScreen(new Point(0, base.Height));
     try
     {
         this.dropDownHolder.Visible = true;
         System.Design.UnsafeNativeMethods.SetWindowLong(new HandleRef(this.dropDownHolder, this.dropDownHolder.Handle), -8, new HandleRef(this, base.Handle));
         this.dropDownHolder.FocusComponent();
         this.dropDownHolder.DoModalLoop();
     }
     finally
     {
         System.Design.UnsafeNativeMethods.SetWindowLong(new HandleRef(this.dropDownHolder, this.dropDownHolder.Handle), -8, new HandleRef(null, IntPtr.Zero));
     }
 }
Example #2
0
            public virtual void DropDownControl(Control control)
            {
                if (dropDownHolder == null)
                {
                    dropDownHolder = new DropDownHolder(this);
                }
                control.RightToLeft = parentControl.RightToLeft;
                dropDownHolder.Visible = false;
                dropDownHolder.SetComponent(control);

                control.BackColor = parentControl.BackColor;
                control.ForeColor = parentControl.ForeColor;
                control.Font = parentControl.Font;

                Rectangle rectparent = parentControl.Bounds;
                Size size = dropDownHolder.Size;
                Point point = parentControl.Parent.PointToScreen(new Point(0, 0));
                Rectangle rectworking = Screen.GetWorkingArea(Control.MousePosition);

                if (parentControl.RightToLeft == RightToLeft.No)
                {
                    point.X = Math.Min((rectworking.X + rectworking.Width) - size.Width, Math.Max(rectworking.X, ((point.X + rectparent.X) + rectparent.Width) - size.Width));
                }
                else
                {
                    point.X = Math.Min((rectworking.X + rectworking.Width) - size.Width, Math.Max(rectworking.X, point.X + rectparent.X));
                }
                point.Y += rectparent.Y;
                if ((rectworking.Y + rectworking.Height) < (size.Height + point.Y + parentControl.pickerTextBox.Height))
                {
                    point.Y -= size.Height;
                }
                else
                {
                    point.Y = point.Y + rectparent.Height + 1;
                }

                dropDownHolder.SetBounds(point.X, point.Y, size.Width, size.Height);
                dropDownHolder.Visible = true;
                dropDownHolder.FocusComponent();
                parentControl.pickerTextBox.SelectAll();
                dropDownHolder.DoModalLoop();
            }
Example #3
0
        /// <include file='doc\PropertyGridView.uex' path='docs/doc[@for="PropertyGridView.DropDownControl"]/*' />
        /// <devdoc>
        ///      Displays the provided control in a drop down.  When possible, the
        ///      current dimensions of the control will be respected.  If this is not possible
        ///      for the current screen layout the control may be resized, so it should
        ///      be implemented using appropriate docking and anchoring so it will resize
        ///      nicely.  If the user performs an action that would cause the drop down
        ///      to prematurely disappear the control will be hidden.
        /// </devdoc>
        public void /* cpr IWindowsFormsEditorService. */ DropDownControl(Control ctl) {
            Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose,  "PropertyGridView:DropDownControl");
            Debug.WriteLineIf(GridViewDebugPaint.TraceVerbose,  "DropDownControl(ctl = " + ctl.GetType().Name + ")");
            if (dropDownHolder == null) {
                dropDownHolder = new DropDownHolder(this);
            }

            dropDownHolder.Visible = false;
            dropDownHolder.SetComponent(ctl, GetFlag(FlagResizableDropDown));
            Rectangle rect = GetRectangle(selectedRow,ROWVALUE);
            Size size = dropDownHolder.Size;
            Point loc = PointToScreen(new Point(0, 0));
            Rectangle rectScreen = Screen.FromControl(Edit).WorkingArea;
            size.Width = Math.Max(rect.Width+1,size.Width);

            // Not needed... CYMAXDDLHEIGHT used to be 200, but why limit it???
            //size.Height = Math.Min(size.Height,CYMAXDDLHEIGHT);

            loc.X = Math.Min(rectScreen.X + rectScreen.Width - size.Width,
                             Math.Max(rectScreen.X,loc.X + rect.X + rect.Width - size.Width));
            loc.Y += rect.Y;
            if (rectScreen.Y + rectScreen.Height < (size.Height + loc.Y + Edit.Height)) {
                loc.Y -= size.Height;
                dropDownHolder.ResizeUp = true;
            }
            else {
                loc.Y += rect.Height + 1;
                dropDownHolder.ResizeUp = false;
            }

            UnsafeNativeMethods.SetWindowLong(new HandleRef(dropDownHolder, dropDownHolder.Handle), NativeMethods.GWL_HWNDPARENT, new HandleRef(this, Handle));
            dropDownHolder.SetBounds(loc.X,loc.Y,size.Width,size.Height);
            SafeNativeMethods.ShowWindow(new HandleRef(dropDownHolder, dropDownHolder.Handle), NativeMethods.SW_SHOWNA);
            Edit.Filter = true;
            dropDownHolder.Visible = true;

            dropDownHolder.FocusComponent();
            SelectEdit(false);            

            try {
                DropDownButton.IgnoreMouse = true;                
                dropDownHolder.DoModalLoop();
            }    
            finally {
                DropDownButton.IgnoreMouse = false;
            }

            if (selectedRow != -1) {
                FocusInternal();
                SelectRow(selectedRow);
            }
        }
Example #4
0
        protected override void Dispose(bool disposing) {
            if (disposing) {
                Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose,  "PropertyGridView:Dispose");
                if (scrollBar != null) scrollBar.Dispose();
                if (listBox != null) listBox.Dispose();
                if (dropDownHolder != null) dropDownHolder.Dispose();
                scrollBar = null;
                listBox = null;
                dropDownHolder = null;

                ownerGrid = null;
                topLevelGridEntries = null;
                allGridEntries = null;
                serviceProvider = null;
                
                topHelpService = null;

                if (helpService != null && helpService is IDisposable)
                    ((IDisposable)helpService).Dispose();

                helpService = null;

                if (edit != null) {
                    edit.Dispose();
                    edit = null;
                }

                if (fontBold != null) {
                    fontBold.Dispose();
                    fontBold = null;

                }

                if (btnDropDown != null) {
                    btnDropDown.Dispose();
                    btnDropDown = null;
                }

                if (btnDialog != null) {
                    btnDialog.Dispose();
                    btnDialog = null;
                }

                if (toolTip != null) {
                    toolTip.Dispose();
                    toolTip = null;
                }
            }

            base.Dispose(disposing);
        }
 void IWindowsFormsEditorService.DropDownControl(Control ctl)
 {
     if (this.dropDownHolder == null)
     {
         this.dropDownHolder = new DropDownHolder(this);
     }
     this.dropDownHolder.SetComponent(ctl);
     this.dropDownHolder.Location = base.PointToScreen(new Point(0, base.Height));
     try
     {
         this.dropDownHolder.Visible = true;
         System.Design.UnsafeNativeMethods.SetWindowLong(new HandleRef(this.dropDownHolder, this.dropDownHolder.Handle), -8, new HandleRef(this, base.Handle));
         this.dropDownHolder.FocusComponent();
         this.dropDownHolder.DoModalLoop();
     }
     finally
     {
         System.Design.UnsafeNativeMethods.SetWindowLong(new HandleRef(this.dropDownHolder, this.dropDownHolder.Handle), -8, new HandleRef(null, IntPtr.Zero));
     }
 }
 public void DropDownControl(Control ctl)
 {
     if (this.dropDownHolder == null)
     {
         this.dropDownHolder = new DropDownHolder(this);
     }
     this.dropDownHolder.Visible = false;
     this.dropDownHolder.SetComponent(ctl, this.GetFlag(0x400));
     Rectangle rectangle = this.GetRectangle(this.selectedRow, 2);
     Size size = this.dropDownHolder.Size;
     Point point = base.PointToScreen(new Point(0, 0));
     Rectangle workingArea = Screen.FromControl(this.Edit).WorkingArea;
     size.Width = Math.Max(rectangle.Width + 1, size.Width);
     point.X = Math.Min((workingArea.X + workingArea.Width) - size.Width, Math.Max(workingArea.X, ((point.X + rectangle.X) + rectangle.Width) - size.Width));
     point.Y += rectangle.Y;
     if ((workingArea.Y + workingArea.Height) < ((size.Height + point.Y) + this.Edit.Height))
     {
         point.Y -= size.Height;
         this.dropDownHolder.ResizeUp = true;
     }
     else
     {
         point.Y += rectangle.Height + 1;
         this.dropDownHolder.ResizeUp = false;
     }
     System.Windows.Forms.UnsafeNativeMethods.SetWindowLong(new HandleRef(this.dropDownHolder, this.dropDownHolder.Handle), -8, new HandleRef(this, base.Handle));
     this.dropDownHolder.SetBounds(point.X, point.Y, size.Width, size.Height);
     System.Windows.Forms.SafeNativeMethods.ShowWindow(new HandleRef(this.dropDownHolder, this.dropDownHolder.Handle), 8);
     this.Edit.Filter = true;
     this.dropDownHolder.Visible = true;
     this.dropDownHolder.FocusComponent();
     this.SelectEdit(false);
     try
     {
         this.DropDownButton.IgnoreMouse = true;
         this.dropDownHolder.DoModalLoop();
     }
     finally
     {
         this.DropDownButton.IgnoreMouse = false;
     }
     if (this.selectedRow != -1)
     {
         this.FocusInternal();
         this.SelectRow(this.selectedRow);
     }
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.scrollBar != null)
         {
             this.scrollBar.Dispose();
         }
         if (this.listBox != null)
         {
             this.listBox.Dispose();
         }
         if (this.dropDownHolder != null)
         {
             this.dropDownHolder.Dispose();
         }
         this.scrollBar = null;
         this.listBox = null;
         this.dropDownHolder = null;
         this.ownerGrid = null;
         this.topLevelGridEntries = null;
         this.allGridEntries = null;
         this.serviceProvider = null;
         this.topHelpService = null;
         if ((this.helpService != null) && (this.helpService is IDisposable))
         {
             ((IDisposable) this.helpService).Dispose();
         }
         this.helpService = null;
         if (this.edit != null)
         {
             this.edit.Dispose();
             this.edit = null;
         }
         if (this.fontBold != null)
         {
             this.fontBold.Dispose();
             this.fontBold = null;
         }
         if (this.btnDropDown != null)
         {
             this.btnDropDown.Dispose();
             this.btnDropDown = null;
         }
         if (this.btnDialog != null)
         {
             this.btnDialog.Dispose();
             this.btnDialog = null;
         }
         if (this.toolTip != null)
         {
             this.toolTip.Dispose();
             this.toolTip = null;
         }
     }
     base.Dispose(disposing);
 }