/// <summary> /// Opens the control inside a context menu in the specified location /// </summary> /// <param name="startLocation">Screen coordinates location of the control</param> /// <param name="parent">Parent control to place the control at</param> public void Show(Control parent, Point startLocation) { _parentControl = parent; // Creates new contextmenu form, adds the control to it, display it. ContextMenuForm frm = new ContextMenuForm(); frm.SetContainingControl(this); frm.Height = OfficeColorPicker.PreferredHeight; _contextForm = frm; frm.Show(parent, startLocation, OfficeColorPicker.PreferredWidth); }
/// <summary> /// Overrides, when click on, handles color selection. /// </summary> /// <param name="e"></param> protected override void OnMouseClick(MouseEventArgs e) { base.OnMouseClick(e); // Check cursor, if on one of the buttons - hot track it for (int recIndex = 0; recIndex < buttons.Length; recIndex++) { if (buttons[recIndex].Contains(e.Location)) { _currentSelected = recIndex; // More colors - open dialog if (_currentSelected == 40) { Color = OpenMoreColorsDialog(); } else { Color = CustomColors.SelectableColors[recIndex]; colorToolTip.SetToolTip(this, CustomColors.SelectableColorsNames[recIndex]); } if (_contextForm != null) _contextForm.Hide(); _contextForm = null; } } this.Refresh(); }
/// <summary> /// Opens the control inside a context menu in the specified location /// </summary> /// <param name="startLocation">Screen coordinates location of the control</param> public void Show(Point startLocation) { // Creates new contextmenu form, adds the control to it, display it. _contextForm = new ContextMenuForm(); _contextForm.SetContainingControl(this); _contextForm.Height = OfficeColorPicker.PreferredHeight; _contextForm.Show(this, startLocation, OfficeColorPicker.PreferredWidth); }