Profile Picture

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

Posted By Kevin Harrison 11 Years Ago

NPaletteColorPane - is it possible to reorder colours by drag and...

Author
Message
Kevin Harrison
Posted 11 Years Ago
View Quick Profile
Supreme Being

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
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865

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
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
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





Similar Topics


Reading This Topic