Пример #1
0
        private static bool GetColor(Control ctrl, Color initialColor, out Color resultColor, bool showNone = true)
        {
            var result = false;

            resultColor = Color.Black;
            const int offset = 6;

            using (var dialog = new ColorPicker(initialColor, showNone)) {
                dialog.Location = dialog.GetBestLocation(ctrl.PointToScreen(new Point(0, 0)), offset);
                dialog.ShowDialog();

                switch (dialog.DialogResult)
                {
                case DialogResult.OK:
                    resultColor = dialog.GetColor();
                    result      = true;
                    break;

                case DialogResult.No:
                    resultColor = Color.Transparent;
                    result      = true;
                    break;
                }
            }

            return(result);
        }
Пример #2
0
        private static bool GetColor(Control ctrl, Color initialColor, out Color resultColor, bool showNone = true)
        {
            var result = false;
            resultColor = Color.Black;
            const int offset = 6;

            using (var dialog = new ColorPicker(initialColor, showNone)) {
                dialog.Location = dialog.GetBestLocation(ctrl.PointToScreen(new Point(0, 0)), offset);
                dialog.ShowDialog();

                switch (dialog.DialogResult) {
                    case DialogResult.OK:
                        resultColor = dialog.GetColor();
                        result = true;
                        break;
                    case DialogResult.No:
                        resultColor = Color.Transparent;
                        result = true;
                        break;
                }
            }

            return result;
        }
Пример #3
0
        private Color GetColor(Control ctrl, Color initialColor)
        {
            var resultColor = initialColor;
            const int offset = 6;

            using (var dialog = new ColorPicker(initialColor)) {
                dialog.Location = dialog.GetBestLocation(ctrl.PointToScreen(new Point(0, 0)), offset);
                dialog.ColorEditorColorChanged += OnColorEditorColorChanged;
                dialog.ShowDialog();
                dialog.ColorEditorColorChanged -= OnColorEditorColorChanged;

                switch (dialog.DialogResult) {
                    case DialogResult.OK:
                        resultColor = dialog.GetColor();
                        break;
                    case DialogResult.No:
                        resultColor = Color.Transparent;
                        break;
                }
            }

            return resultColor;
        }