Exemple #1
0
        public ColorPickerForm(Color currentColor, bool isScreenColorPickerMode = false, bool checkClipboard = true, ColorPickerOptions options = null)
        {
            InitializeComponent();
            ShareXResources.ApplyTheme(this);
            clipboardStatusHider = new ControlHider(btnClipboardStatus, 2000);

            IsScreenColorPickerMode = isScreenColorPickerMode;
            Options = options;

            if (Options == null)
            {
                Options = new ColorPickerOptions();
            }

            if (Options.RecentColorsSelected)
            {
                rbRecentColors.Checked = true;
            }
            else
            {
                rbStandardColors.Checked = true;
            }

            PrepareColorPalette();
            SetCurrentColor(currentColor, !IsScreenColorPickerMode);

            if (checkClipboard)
            {
                CheckClipboard();
            }

            btnOK.Visible  = btnCancel.Visible = !IsScreenColorPickerMode;
            mbCopy.Visible = btnClose.Visible = pCursorPosition.Visible = IsScreenColorPickerMode;
        }
Exemple #2
0
        public static bool PickColor(Color currentColor, out Color newColor, Form owner = null, Func <PointInfo> openScreenColorPicker = null, ColorPickerOptions options = null)
        {
            using (ColorPickerForm dialog = new ColorPickerForm(currentColor, options: options))
            {
                if (openScreenColorPicker != null)
                {
                    dialog.EnableScreenColorPickerButton(openScreenColorPicker);
                }

                if (dialog.ShowDialog(owner) == DialogResult.OK)
                {
                    newColor = dialog.NewColor;
                    return(true);
                }
            }

            newColor = currentColor;
            return(false);
        }