Profile Picture

PredefinedPalette.User - how do I define the palette?

Posted By Kevin Harrison 11 Years Ago
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
Perhaps I'm doing this wrong, but I decided to use an NPaletteColorPane to display a set of colours which the user can select.
The thing is I want to use my own colours not one of the two predefined palettes. I can do the following:
            NArgbColorValuePalette nevronPalette = new NArgbColorValuePalette();            nevronPalette.SetPredefinedPalette(PredefinedPalette.User);
but the Help gives me no clue how to define my own paltee from an array of Color.
Or, is there a better way to achieve this?
Thanks
Kevin
PS It shouldn't be this hard 


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

Ok - I achieved it by creating Entries one by one from my colour array. Is this the best method?

Now I need to work out which event tells me a colour has been selected, since Mouse_Click can occur between colours. Is there a specific event to attach to? The example uses Mouse_Leave which isn't that useful.

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
Ok - I achieved it by creating Entries one by one from my colour array. Is this the best method?
Yes.

To handle that the color has been changed you need to attach to ColorChanged event (I assume that you are using NPaletteColorPane control).

Best Regards,
Nevron Support Team



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
Thanks.

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
Looks like there's a bug with the ColorChanged event - it fires whenever I click on the colour pane. So, if I click between colours or in a blank area of the pane, it fires and returns the last selected colour.

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
Hi Kevin,

Indeed there is a bug.

We will fix this in the next service pack.

In meanwhile you can workaround the bug by overriding OnMouseUp method as follows:

public class MyNPaletteColorPane : NPaletteColorPane
   {
      protected override void OnMouseUp(MouseEventArgs e)
      {
         NCommand command = HitTest(e.Location);
         if (command == null)
            return;

         base.OnMouseUp(e);
      }
   }

Best Regards,
Nevron Support Team



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

Thanks. I got round it by checking if the selected index was the same as the last one and ignored it if it was. This does mean that the same colour can't be selected twice in succession but that's reasonable for my application.

Kevin





Similar Topics


Reading This Topic