Пример #1
0
        private void VisitPaletteURLToolStripMenuItemClick(object sender, EventArgs e)
        {
            CPalette pal = GetCurrentlySelectedPalette();

            if (pal != null)
            {
                Process.Start(pal.Url);
            }
        }
Пример #2
0
        public UC_EditorPalette()
        {
            InitializeComponent();
            useFixedPalette = null;

            columnCount = 8;
            rowCount    = (int)Math.Ceiling((double)256 / (double)columnCount);
            this.PaletteColorBox.SizeChanged += new EventHandler(PaletteColorBox_SizeChanged);
            this.PaletteColorBox.MouseClick  += new MouseEventHandler(PaletteColorBox_MouseClick);

            this.radioButton_Color.CheckedChanged += new EventHandler(radioButton_Color_CheckedChanged);
        }
Пример #3
0
        private void CopyColorsToolStripMenuItemClick(object sender, EventArgs e)
        {
            CPalette pal = GetCurrentlySelectedPalette();

            if (pal == null)
            {
                return;
            }
            string descStr = pal.GetColorDescStr();

            Clipboard.SetText(descStr);
            MessageBox.Show("Palette colors copied onto clipboard.", "Copied.", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #4
0
        private void ApplyToolStripMenuItemClick(object sender, EventArgs e)
        {
            CPalette pal = GetCurrentlySelectedPalette();

            if (pal == null)
            {
                return;
            }
            if (selectedDelegate != null)
            {
                selectedDelegate(pal);
            }
        }
Пример #5
0
        private void parsePalettesXml(XPathDocument doc)
        {
            XPathNavigator xn = doc.CreateNavigator();

            xn.MoveToRoot();
            palettes.Clear();
            XPathNodeIterator paletteNodes = xn.Select("//palette");

            while (paletteNodes.MoveNext())
            {
                var pal = new CPalette();
                pal.PopulateFromXPathNode(paletteNodes.Current);
                palettes.Add(pal);
            }
        }
Пример #6
0
    internal static CPalette[] LoadPaletteSetup(string filename)
    {
        CPalette[]    pals            = new CPalette[0];
        List <string> paletteSections = GetSections(filename);

        paletteSections.RemoveAll(u => !u.Contains("Palette"));
        pals = new CPalette[paletteSections.Count()];
        for (int i = 0; i < paletteSections.Count(); i++)
        {
            CPalette p       = new CPalette();
            string   palfile = GetIniFileString(filename, paletteSections[i], "PaletteFile", "");
            if (System.IO.File.Exists(palfile))
            {
                p.Load(palfile);
            }
            int cm = 0;
            int.TryParse(GetIniFileString(filename, paletteSections[i], "ConversionMethod", ""), out cm);
            p.ConversionMethod = (ColorConversionMethod)cm;
            p.PaletteName      = GetIniFileString(filename, paletteSections[i], "PaletteName", "");

            List <string> keys = GetKeys(filename, paletteSections[i]);
            keys.RemoveAll(u => !u.Contains("Color"));

            for (int c = 0; c < keys.Count(); c++)
            {
                int keynr = 0;
                int.TryParse(keys[c].Replace("Color", ""), out keynr);

                string val = GetIniFileString(filename, paletteSections[i], keys[c], "");

                bool IsUsed = true;
                bool.TryParse(val.Split('|')[0], out IsUsed);
                bool MakeTransparent = true;
                bool.TryParse(val.Split('|')[1], out MakeTransparent);
                if ((keynr >= 0) && (keynr < p.palette.Length))
                {
                    p.palette[keynr].IsUsed          = IsUsed;
                    p.palette[keynr].MakeTransparent = MakeTransparent;
                }
            }
            pals[i] = p;
        }

        return(pals);
    }
Пример #7
0
        public void LoadPalette(string defaultPaletteFolder)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if ((useFixedPalette != null) && (useFixedPalette.PaletteFile != ""))
            {
                ofd.InitialDirectory = useFixedPalette.PaletteFile;
            }
            else
            {
                ofd.InitialDirectory = defaultPaletteFolder;
            }

            ofd.Title    = "Open Palette File";
            ofd.FileName = "";
            ofd.Filter   = "Palette files|*.pal";
            if (ofd.ShowDialog() != DialogResult.Cancel)
            {
                useFixedPalette = new CPalette();
                useFixedPalette.Load(ofd.FileName);
                UpdatePalettePanel();
                OnPaletteChanged(this, null);
            }
        }
Пример #8
0
        void PaletteColorBox_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (contextMenuEnabled &&
                    (contextMenuSaveEnabled || contextMenuLoadEnabled)
                    )
                {
                    ContextMenu contextMenu = new ContextMenu();

                    CPalette currentpalette = new CPalette();
                    currentpalette = useFixedPalette;

                    if (currentpalette != null)
                    {
                        string paletteinfo = currentpalette.PaletteFile;
                        if ((paletteinfo == null) || (paletteinfo == ""))
                        {
                            paletteinfo = "temporary palette";
                        }

                        MenuItem info = new MenuItem(paletteinfo);
                        info.Enabled = false;
                        contextMenu.MenuItems.Add(info);
                    }
                    else
                    {
                        MenuItem info = new MenuItem("no palette loaded");
                        info.Enabled = false;
                        contextMenu.MenuItems.Add(info);
                    }

                    if (contextMenuLoadEnabled)
                    {
                        MenuItem loadPalette = new MenuItem("Load Palette", new System.EventHandler(this.loadPaletteMenuItem_Click));
                        contextMenu.MenuItems.Add(loadPalette);
                    }
                    if (contextMenuSaveEnabled)
                    {
                        MenuItem savePalette = new MenuItem("Save Palette", new System.EventHandler(this.savePaletteMenuItem_Click));
                        contextMenu.MenuItems.Add(savePalette);
                    }
                    contextMenu.Show(this, new Point(e.X, e.Y));
                }
            }
            if (e.Button == MouseButtons.Left)
            {
                if (allowColorSelection)
                {
                    Size   PaletteSpace = this.PaletteColorBox.Size;
                    int    columnwidth  = (PaletteSpace.Width - 1) / columnCount;
                    int    rowheight    = (PaletteSpace.Height - 1) / rowCount;
                    double cellwidth    = (double)PaletteColorImage.Width / (double)columnCount;
                    double cellheight   = (double)PaletteColorImage.Height / (double)rowCount;

                    int selectedColumn = (int)(e.X / cellwidth);
                    int selectedRow    = (int)(e.Y / cellheight);

                    //the property PaletteSelectedColor launches UpdatePalettePanel when changed
                    int selcol = selectedColumn * rowCount + selectedRow;
                    if (selcol > 255)
                    {
                        selcol = 255;               //used when palette shows more than 256 colors, due to uneven columncount
                    }
                    if (selcol < 0)
                    {
                        selcol = 0;
                    }
                    PaletteSelectedColor = selcol;
                    OnPaletteSelectedColorChanged(sender, e);
                }
            }
        }