Esempio n. 1
0
        private static void MenuItemRGB_Click(object sender, EventArgs e)
        {
            try
            {
                string color = Clipboard.GetText();

                Clipboard.SetText(ConvertColor.RGBConverter(ColorTranslator.FromHtml(color)));
            }
            catch (Exception)
            {
                // ignore
            }

            menuItemHTML.Checked       = false;
            menuItemRGB.Checked        = true;
            Settings.Default.ColorHTML = false;
            Settings.Default.ColorRGB  = true;
            Settings.Default.Save();

            Settings.Default.Reload();
        }
Esempio n. 2
0
        private void PreviewImage_MouseDown(object sender, MouseEventArgs e)
        {
            thread.Abort();

            if (e.Button == MouseButtons.Left)
            {
                Color color = GetColorFromPixel(Cursor.Position.X, Cursor.Position.Y);

                if (Properties.Settings.Default.ColorHTML)
                {
                    Clipboard.SetText(ConvertColor.HexConverter(color));
                }
                else if (Properties.Settings.Default.ColorRGB)
                {
                    Clipboard.SetText(ConvertColor.RGBConverter(color));
                }
            }
            else
            {
                Program.cancelled = true;
            }

            this.Close();
        }
Esempio n. 3
0
        private static void Editor()
        {
            try
            {
                string color = Clipboard.GetText();
                if (!string.IsNullOrEmpty(color))
                {
                    Color col = ColorTranslator.FromHtml(color);
                    Settings.Default.ColorDialogWithTitle_DefaultTitle = "Color in Clipboard: " + ConvertColor.RGBConverter(col);
                    Settings.Default.Save();
                    Settings.Default.Reload();
                }
                else
                {
                    Settings.Default.ColorDialogWithTitle_DefaultTitle = "Color Dialog";
                    Settings.Default.Save();
                    Settings.Default.Reload();
                }
            }
            catch
            {
                Settings.Default.ColorDialogWithTitle_DefaultTitle = "Color Dialog";
                Settings.Default.Save();
                Settings.Default.Reload();
            }

            using (colorDialog1 = new ColorDialogWithTitle())
            {
                colorDialog1.FullOpen = true;

                try
                {
                    string color = Clipboard.GetText();
                    colorDialog1.Color = ColorTranslator.FromHtml(color);
                }
                catch
                {
                }

                if (menuItemResetCustomColor.Checked)
                {
                    colorDialog1.CustomColors = new int[] { 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215 };

                    SaveCustomColors();
                }
                else
                {
                    colorDialog1.CustomColors = new int[] { Settings.Default.CustomColor1, Settings.Default.CustomColor2, Settings.Default.CustomColor3, Settings.Default.CustomColor4, Settings.Default.CustomColor5, Settings.Default.CustomColor6, Settings.Default.CustomColor7, Settings.Default.CustomColor8, Settings.Default.CustomColor9, Settings.Default.CustomColor10, Settings.Default.CustomColor11, Settings.Default.CustomColor12, Settings.Default.CustomColor13, Settings.Default.CustomColor14, Settings.Default.CustomColor15, Settings.Default.CustomColor16 };
                }

                if (colorDialog1.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        Color selectedColor = colorDialog1.Color;

                        if (Settings.Default.ColorHTML)
                        {
                            Clipboard.SetText(ConvertColor.HexConverter(selectedColor));
                        }
                        else if (Settings.Default.ColorRGB)
                        {
                            Clipboard.SetText(ConvertColor.RGBConverter(selectedColor));
                        }

                        if (Settings.Default.SaveCustomColors)
                        {
                            SaveCustomColors();
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }