示例#1
0
        EventHandler Label_ColorSwap(Label obj, int paletteno)
        {
            return((sender, e) =>
            {
                PaletteSwapForm form = (PaletteSwapForm)InputFormRef.JumpFormLow <PaletteSwapForm>();
                form.SetMainColorIndex(paletteno);
                Color[] colormap = new Color[16 + 1];
                for (int i = 1; i <= 16; i++)
                {
                    NumericUpDown r = FindNUD("R", i);
                    NumericUpDown g = FindNUD("G", i);
                    NumericUpDown b = FindNUD("B", i);
                    form.SetColor(i, (int)r.Value, (int)g.Value, (int)b.Value);
                    colormap[i] = Color.FromArgb((int)r.Value, (int)g.Value, (int)b.Value);
                }
                DialogResult dr = form.ShowDialog();
                if (dr != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                int selected = form.GetSelectedColorIndex();

                PushUndo();
                this.UndoLock = true;
                for (int i = 1; i <= 16; i++)
                {
                    NumericUpDown r = FindNUD("R", i);
                    NumericUpDown g = FindNUD("G", i);
                    NumericUpDown b = FindNUD("B", i);

                    if (selected == i)
                    {
                        r.Value = colormap[paletteno].R;
                        g.Value = colormap[paletteno].G;
                        b.Value = colormap[paletteno].B;
                    }
                    else if (paletteno == i)
                    {
                        r.Value = colormap[selected].R;
                        g.Value = colormap[selected].G;
                        b.Value = colormap[selected].B;
                    }
                }
                this.UndoLock = false;
            }
                   );
        }
示例#2
0
        static EventHandler MakePaletteUI_Label_ColorSwap(Form self, List <Control> controls, Label obj, int paletteno)
        {
            return((sender, e) =>
            {
                PaletteSwapForm form = (PaletteSwapForm)InputFormRef.JumpFormLow <PaletteSwapForm>();
                form.SetMainColorIndex(paletteno);
                Color[] colormap = new Color[16 + 1];
                for (int i = 1; i <= 16; i++)
                {
                    NumericUpDown r = (NumericUpDown)MakePaletteUI_FindObject <NumericUpDown>(controls, "R", i);
                    NumericUpDown g = (NumericUpDown)MakePaletteUI_FindObject <NumericUpDown>(controls, "G", i);
                    NumericUpDown b = (NumericUpDown)MakePaletteUI_FindObject <NumericUpDown>(controls, "B", i);
                    form.SetColor(i, (int)r.Value, (int)g.Value, (int)b.Value);
                    colormap[i] = Color.FromArgb((int)r.Value, (int)g.Value, (int)b.Value);
                }
                DialogResult dr = form.ShowDialog();
                if (dr != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                int selected = form.GetSelectedColorIndex();

                for (int i = 1; i <= 16; i++)
                {
                    NumericUpDown r = (NumericUpDown)MakePaletteUI_FindObject <NumericUpDown>(controls, "R", i);
                    NumericUpDown g = (NumericUpDown)MakePaletteUI_FindObject <NumericUpDown>(controls, "G", i);
                    NumericUpDown b = (NumericUpDown)MakePaletteUI_FindObject <NumericUpDown>(controls, "B", i);

                    if (selected == i)
                    {
                        r.Value = colormap[paletteno].R;
                        g.Value = colormap[paletteno].G;
                        b.Value = colormap[paletteno].B;
                    }
                    else if (paletteno == i)
                    {
                        r.Value = colormap[selected].R;
                        g.Value = colormap[selected].G;
                        b.Value = colormap[selected].B;
                    }
                }
            }
                   );
        }