Exemple #1
0
                protected override void DrawFlatComboDropDown(ComboBox comboBox, Graphics g, Rectangle dropDownRect)
                {
                    if (UseBaseAdapter(comboBox))
                    {
                        base.DrawFlatComboDropDown(comboBox, g, dropDownRect);
                        return;
                    }


                    if (!comboBox.Enabled || !ToolStripManager.VisualStylesEnabled)
                    {
                        g.FillRectangle(SystemBrushes.Control, dropDownRect);
                    }
                    else
                    {
                        ToolStripComboBoxControl toolStripComboBox = comboBox as ToolStripComboBoxControl;
                        ProfessionalColorTable   colorTable        = GetColorTable(toolStripComboBox);

                        if (!comboBox.DroppedDown)
                        {
                            bool focused = comboBox.ContainsFocus || comboBox.MouseIsOver;
                            if (focused)
                            {
                                using (Brush b = new LinearGradientBrush(dropDownRect, colorTable.ComboBoxButtonSelectedGradientBegin, colorTable.ComboBoxButtonSelectedGradientEnd, LinearGradientMode.Vertical)) {
                                    g.FillRectangle(b, dropDownRect);
                                }
                            }
                            else if (toolStripComboBox.Owner.IsOnOverflow)
                            {
                                using (Brush b = new SolidBrush(colorTable.ComboBoxButtonOnOverflow)) {
                                    g.FillRectangle(b, dropDownRect);
                                }
                            }
                            else
                            {
                                using (Brush b = new LinearGradientBrush(dropDownRect, colorTable.ComboBoxButtonGradientBegin, colorTable.ComboBoxButtonGradientEnd, LinearGradientMode.Vertical)) {
                                    g.FillRectangle(b, dropDownRect);
                                }
                            }
                        }
                        else
                        {
                            using (Brush b = new LinearGradientBrush(dropDownRect, colorTable.ComboBoxButtonPressedGradientBegin, colorTable.ComboBoxButtonPressedGradientEnd, LinearGradientMode.Vertical)) {
                                g.FillRectangle(b, dropDownRect);
                            }
                        }
                    }

                    Brush brush  = (comboBox.Enabled) ? SystemBrushes.ControlText : SystemBrushes.GrayText;
                    Point middle = new Point(dropDownRect.Left + dropDownRect.Width / 2, dropDownRect.Top + dropDownRect.Height / 2);

                    // if the width is odd - favor pushing it over one pixel right.
                    middle.X += (dropDownRect.Width % 2);
                    g.FillPolygon(brush, new Point[] {
                        new Point(middle.X - FlatComboAdapter.Offset2X, middle.Y - 1),
                        new Point(middle.X + FlatComboAdapter.Offset2X + 1, middle.Y - 1),
                        new Point(middle.X, middle.Y + FlatComboAdapter.Offset2Y)
                    });
                }
        private static Control CreateControlInstance()
        {
            ComboBox comboBox = new ToolStripComboBoxControl();

            comboBox.FlatStyle = FlatStyle.Popup;
            comboBox.Font      = ToolStripManager.DefaultFont;
            return(comboBox);
        }
 private static ProfessionalColorTable GetColorTable(ToolStripComboBoxControl toolStripComboBoxControl)
 {
     if (toolStripComboBoxControl != null)
     {
         return(toolStripComboBoxControl.ColorTable);
     }
     return(ProfessionalColors.ColorTable);
 }
                private static bool UseBaseAdapter(ComboBox comboBox)
                {
                    ToolStripComboBoxControl toolStripComboBox = comboBox as ToolStripComboBoxControl;

                    if (toolStripComboBox == null || !(toolStripComboBox.Owner.Renderer is ToolStripProfessionalRenderer))
                    {
                        Debug.Assert(toolStripComboBox != null, "Why are we here and not a toolstrip combo?");
                        return(true);
                    }
                    return(false);
                }
        public void ToolStripComboBoxControlAccessibleObject_ctor_default()
        {
            using ToolStripComboBox toolStripComboBox = new ToolStripComboBox();
            ToolStripComboBoxControl control = (ToolStripComboBoxControl)toolStripComboBox.ComboBox;

            control.CreateControl();
            ToolStripComboBoxControlAccessibleObject accessibleObject = new ToolStripComboBoxControlAccessibleObject(control);

            Assert.Equal(control, accessibleObject.Owner);
            Assert.True(control.IsHandleCreated);
        }
        /// <include file='doc\ToolStripComboBox.uex' path='docs/doc[@for="ToolStripComboBox.ToolStripComboBox"]/*' />
        public ToolStripComboBox() : base(CreateControlInstance())
        {
            ToolStripComboBoxControl combo = Control as ToolStripComboBoxControl;

            combo.Owner = this;

            if (DpiHelper.EnableToolStripHighDpiImprovements)
            {
                scaledPadding         = DpiHelper.LogicalToDeviceUnits(padding);
                scaledDropDownPadding = DpiHelper.LogicalToDeviceUnits(dropDownPadding);
            }
        }
Exemple #7
0
        public ToolStripComboBox() : base(CreateControlInstance())
        {
            ToolStripComboBoxControl combo = Control as ToolStripComboBoxControl;

            combo.Owner = this;

            if (DpiHelper.IsScalingRequirementMet)
            {
                _scaledPadding         = DpiHelper.LogicalToDeviceUnits(s_padding);
                _scaledDropDownPadding = DpiHelper.LogicalToDeviceUnits(s_dropDownPadding);
            }
        }
        public void ToolStripComboBoxControlAccessibleObject_GetPropertyValue_ControlType_IsExpected_ForCustomRole(AccessibleRole role)
        {
            using ToolStripComboBox toolStripComboBox = new ToolStripComboBox();
            toolStripComboBox.AccessibleRole          = role;
            ToolStripComboBoxControl control = (ToolStripComboBoxControl)toolStripComboBox.ComboBox;

            control.CreateControl();

            AccessibleObject accessibleObject = toolStripComboBox.AccessibilityObject;
            object           actual           = accessibleObject.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId);

            Assert.Equal(role, accessibleObject.Role);
            UiaCore.UIA expected = AccessibleRoleControlTypeMap.GetControlType(role);
            Assert.Equal(expected, actual);
        }
        public void ToolStripComboBoxControlAccessibleObject_ControlType_IsComboBox_IfAccessibleRoleIsDefault()
        {
            using ToolStripComboBox toolStripComboBox = new ToolStripComboBox();
            // AccessibleRole is not set = Default
            ToolStripComboBoxControl control = (ToolStripComboBoxControl)toolStripComboBox.ComboBox;

            control.CreateControl();

            AccessibleObject accessibleObject = toolStripComboBox.AccessibilityObject;
            object           actual           = accessibleObject.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId);

            Assert.Equal(AccessibleRole.ComboBox, accessibleObject.Role);
            Assert.Equal(UiaCore.UIA.ComboBoxControlTypeId, actual);
            Assert.True(control.IsHandleCreated);
        }
 public ToolStripComboBoxControlAccessibleObject(ToolStripComboBoxControl toolStripComboBoxControl)
     : base(toolStripComboBoxControl)
 {
 }
  private static ProfessionalColorTable GetColorTable(ToolStripComboBoxControl toolStripComboBoxControl) {
      if (toolStripComboBoxControl != null) {
          return toolStripComboBoxControl.ColorTable;
      }
      return ProfessionalColors.ColorTable;                    
 }
 private static Control CreateControlInstance() {
     ComboBox comboBox = new ToolStripComboBoxControl();  
     comboBox.FlatStyle = FlatStyle.Popup;
     comboBox.Font = ToolStripManager.DefaultFont;
     return comboBox;
 }
Exemple #13
0
 public ToolStripComboBoxControlAccessibleObject(ToolStripComboBoxControl toolStripComboBoxControl) : base(toolStripComboBoxControl)
 {
     childAccessibleObject = new ChildAccessibleObject(toolStripComboBoxControl, toolStripComboBoxControl.Handle);
 }
        public ToolStripComboBox() : base(CreateControlInstance())
        {
            ToolStripComboBoxControl control = base.Control as ToolStripComboBoxControl;

            control.Owner = this;
        }