コード例 #1
0
        private void UI_PaletteSlot_LeftMouseDown(object sender, MouseButtonEventArgs e)
        {
            Memory.Attach("SonicMania");
            int addr = PaletteAddresses[CurrentPaletteSet] + 2 * (int)(sender as Grid).Tag;

            if (!ready)
            {
                return;
            }
            ready = false;
            if (ColourPickerClosed)
            {
                ColorPicker = null;
            }
            else if (ColorPicker != null)
            {
                Palettes[CurrentPaletteSet].Colours[CurrentColourSlot] = OldColour;
                CurrentColourSlot = (int)(sender as Grid).Tag;
                OldColour         = Palettes[CurrentPaletteSet].Colours[CurrentColourSlot];
                ColorPicker.Invoke(new Action(() =>
                {
                    ColorPicker.Color = System.Drawing.Color.FromArgb(
                        Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Red,
                        Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Green,
                        Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Blue
                        );
                    ColorPicker.Activate();
                }));
                ready = true;
                return;
            }
            ColourPickerClosed = false;
            CurrentColourSlot  = (int)(sender as Grid).Tag;
            new Thread(() =>
            {
                OldColour             = Palettes[CurrentPaletteSet].Colours[CurrentColourSlot];
                ColorPicker           = new ColorPickerDialog();
                ColorPicker.BackColor = System.Drawing.Color.FromArgb(0x2D, 0x2D, 0x30);
                ColorPicker.ForeColor = System.Drawing.Color.FromArgb(0xEE, 0xEE, 0xEE);
                ColorPicker.Color     = System.Drawing.Color.FromArgb(
                    Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Red,
                    Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Green,
                    Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Blue
                    );
                ColorPicker.FormClosed   += ColorPicker_FormClosed;
                ColorPicker.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                ready = true;
                ColorPicker.ShowDialog();
            }).Start();
        }