Beispiel #1
0
        public void PerformRemoveSwatch()
        {
            ISwatch swatch = SwatchDisplayer.Swatch;

            if (swatch == null)
            {
                return;
            }

            if (SwatchDisplayer.HasPrimaryColor)
            {
                swatch.RemoveAt(SwatchDisplayer.PrimaryColorIndex);

                if (swatch.Count == 0)
                {
                    SwatchDisplayer.PrimaryColorIndex = SwatchDisplayer.SecondaryColorIndex = -1;
                }
                else
                {
                    if (SwatchDisplayer.PrimaryColorIndex >= swatch.Count)
                    {
                        SwatchDisplayer.PrimaryColorIndex = swatch.Count - 1;
                    }

                    if (SwatchDisplayer.SecondaryColorIndex >= swatch.Count)
                    {
                        SwatchDisplayer.SecondaryColorIndex = swatch.Count - 1;
                    }
                }

                SwatchDisplayer.RecalculateSize();
            }
        }
Beispiel #2
0
        private static void AddDirectory(string dir, List <ISwatch> swatches)
        {
            foreach (string swatchFile in Directory.EnumerateFiles(dir, "*"))
            {
                string ext = Path.GetExtension(swatchFile);

                ISwatch swatch = null;

                if (ext.ToLower() == ".swtch")
                {
                    swatch = new MCSwatch(swatchFile);
                }
                else if (ext.ToLower() == ".gpl" || ext.ToLower() == ".gimp")
                {
                    swatch = new GIMPSwatch(swatchFile);
                }
                else if (ext.ToLower() == ".act")
                {
                    swatch = new ACTSwatch(swatchFile);
                }
                else if (ext.ToLower() == ".aco")
                {
                    swatch = new ACOSwatch(swatchFile);
                }

                if (swatch != null)
                {
                    swatches.Add(swatch);
                    swatch.Load();
                }
            }
        }
Beispiel #3
0
 internal HueViewModel(int hueIndex, Color hue, ISwatch swatch, ICommand changeHue)
 {
     HueIndex  = hueIndex;
     Hue       = hue;
     Swatch    = swatch;
     ChangeHue = changeHue;
 }
Beispiel #4
0
        internal SwatchViewModel(ISwatch swatch, ICommand changeHue)
        {
            Swatch = swatch;

            HueViewModels = swatch.Hues
                            .Map((i, h) => new HueViewModel(i, h, swatch, changeHue))
                            .ToArr <IHueViewModel>();
        }
Beispiel #5
0
        public void PerformAddSwatch()
        {
            ISwatch swatch = SwatchDisplayer.Swatch;

            if (swatch == null)
            {
                return;
            }

            swatch.Add(new NamedColor("New Color", Editor.MainForm.ColorPanel.SelectedColor.RGB));
            SwatchDisplayer.RecalculateSize();
        }
Beispiel #6
0
        private void deleteSwatchToolStripButton_Click(object sender, EventArgs e)
        {
            ISwatch swatch = SwatchDisplayer.Swatch;

            if (swatch == null)
            {
                return;
            }

            if (
                MessageBox.Show(Editor.GetLanguageString("M_SWATCHQUESTION"), Editor.GetLanguageString("M_SWATCHQUESTION_CAPTION"),
                                MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            File.Delete(swatch.FilePath);
            comboBox1.Items.Remove(swatch);
        }