NPaletteColorPane - is it possible to reorder colours by drag and drop?


NPaletteColorPane - is it possible to reorder colours by drag and...
Author
Message
Kevin Harrison 1
Kevin Harrison 1
Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)
Group: Forum Members
Posts: 176, Visits: 1.9K

I need to select a series of colours and then have the ability to delete or reorder the selected colours (preferably with multi-selection).

Currently I am using an NPaletteColorPane to show the available colours.

Selected colours are displayed in a single column DataGridView, which allows me to reorder single or multiple selections by drag and drop or by adding Up/Down buttons etc. However, this looks messy, particularly when the scroll bar appears.

What would be really cool is to use a second NPaletteColorPane (or similar control) which allows me to reorder the colours. I can see how to achieve this using Up/Down buttons, but only for single selections. Is drag/drop possible here?

.. or do have a better suggestion to achieve what I want?

Thanks

Kevin


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hello Kevin,

You can override ProcessDialogKey to handle possible key sequence which can move the colors up and down.

Here is one example implementation:

public class MyNPaletteColorPane : NPaletteColorPane
   {
      protected override bool ProcessDialogKey(Keys keyData)
      {
         if(!Selectable)
            return base.ProcessDialogKey (keyData);

         int currIndex = SelectedIndex;

         switch(keyData)
         {               
            case Keys.Control | Keys.Up:
               currIndex--;               
               if (currIndex < 0 )
               {
                  currIndex = ColorPalette.Entries.Length - 1;
               }               
               break;
            case Keys.Control | Keys.Down:
               currIndex++;               
               if (currIndex > ColorPalette.Entries.Length - 1)
               {
                  currIndex = 0;
               }               
               break;
            default:
               return base.ProcessDialogKey(keyData);               
         }
                  
         NArgbColorValue c = ColorPalette.Entries[SelectedIndex];
         NArgbColorValue c1 = ColorPalette.Entries[currIndex];
         ColorPalette.Entries[SelectedIndex] = c1;
         ColorPalette.Entries[currIndex] = c;
         PopulateColors();
         SelectedIndex = currIndex;

         if (ChangeStyle == ColorChangeStyle.OnMouseUp)
         {
            OnColorChanged(EventArgs.Empty);
         }

         return true;
      }
   }

Unfortunately, control doesn't allow a multiple selection.


Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search