示例#1
0
        private void PaletteImageMouseMove(object sender, MouseEventArgs e)
        {
            if (!(sender as Control).ClientRectangle.Contains(e.Location))
            {
                return;
            }
            PaletteImage paletteImage  = sender as PaletteImage;
            int          selectedColor = paletteImage.getSelectedColor(e);

            if (e.Button != MouseButtons.None && paletteImage.NumberOfSelectedColors > 0)
            {
                paletteImage.Moved(sender, e);
                ButtonNearestColors.Enabled = (paletteImage == RemappingPalette && paletteImage.NumberOfSelectedColors > 0);
            }
            else
            {
                PaletteImage otherPaletteImage          = GetOtherPalette(paletteImage);
                int[]        otherPaletteSelectedColors = otherPaletteImage.GetSelectedIndices();
                if (otherPaletteSelectedColors.Length > 0)
                {
                    SetMatchingSelectedColorsBasedOnOtherPaletteImage(paletteImage, selectedColor, ref otherPaletteSelectedColors);
                    paletteImage.Update(PaletteImage.AllPaletteColors);
                    paletteImage.SetSelected(otherPaletteSelectedColors, true); //visual change only, to be undone below
                    foreach (var selected in otherPaletteSelectedColors)
                    {
                        paletteImage.ColorsSelected[selected] = false;
                    }
                }
            }

            Text = "Remap Image Palette \u2013 " + selectedColor;
        }
示例#2
0
 private void PaletteImageMouseMove(object sender, MouseEventArgs e)
 {
     if (!(sender as Control).ClientRectangle.Contains(e.Location))
     {
         return;
     }
     Text = "Level Palette \u2013 " + PaletteImage.getSelectedColor(e);
 }
示例#3
0
        private void PaletteImageMouseDown(object sender, MouseEventArgs e)
        {
            PaletteImage paletteImage      = sender as PaletteImage;
            PaletteImage otherPaletteImage = GetOtherPalette(paletteImage);

            if (otherPaletteImage.NumberOfSelectedColors == 0)
            {
                paletteImage.Clicked(sender, e);
                ButtonNearestColors.Enabled = (paletteImage == RemappingPalette && paletteImage.NumberOfSelectedColors > 0);
            }
            else
            {
                int[] otherPaletteSelectedColors = otherPaletteImage.GetSelectedIndices();
                int[] thisPaletteSelectedColors  = otherPaletteSelectedColors.Clone() as int[];
                SetMatchingSelectedColorsBasedOnOtherPaletteImage(paletteImage, paletteImage.getSelectedColor(e), ref thisPaletteSelectedColors);

                if (paletteImage == RemappingPalette)
                {
                    for (int i = 0; i < thisPaletteSelectedColors.Length; ++i)
                    {
                        ColorRemappings[thisPaletteSelectedColors[i]] = (byte)otherPaletteSelectedColors[i];
                    }
                }
                else
                {
                    for (int i = 0; i < thisPaletteSelectedColors.Length; ++i)
                    {
                        ColorRemappings[otherPaletteSelectedColors[i]] = (byte)thisPaletteSelectedColors[i];
                    }
                }

                for (int i = 0; i < Palette.PaletteSize; ++i)
                {
                    var remappedColor = LevelPalette.Palette[ColorRemappings[i]];
                    RemappingPalette.Palette[i]    = remappedColor;
                    ImageWorkingPalette.Entries[i] = Palette.Convert(remappedColor);
                }
                pictureBox1.Image.Palette = ImageWorkingPalette;
                pictureBox1.Refresh();

                LevelPalette.SetSelected(PaletteImage.AllPaletteColors, false);
                RemappingPalette.SetSelected(PaletteImage.AllPaletteColors, false);

                paletteImage.CurrentlySelectingColors = false;
                ButtonNearestColors.Enabled           = false;
            }
        }