c# - Web Color Palette Winform -


not sure being dumb. web colour palette widget call? colordialog brings picker not wanted

web color palette

i though web of palette not have web picker. in advance [edited: maybe should rephrase question, how brought above color picker? not wish use 3rd party widget except available in vs]

i hope comes out-of-the box .net solution.

if not, can write own; 1 starters..:

enter image description here

public partial class webcolors : form {     public webcolors()     {         initializecomponent();     }      public color pick { get; set; }      private void webcolors_load(object sender, eventargs e)     {         var webcolors =           enum.getvalues(typeof(knowncolor))             .cast<knowncolor>()             .where(k => k >= knowncolor.transparent && k < knowncolor.buttonface)             .select(k => color.fromknowncolor(k))             .orderby(c => c.gethue())             .thenby(c => c.getsaturation())             .thenby(c => c.getbrightness()).tolist();          int cc = webcolors.count;         int n =  (int)math.sqrt(cc) + 0;         int w = clientsize.width / (n) - 1;         height = (n+1) * w + 90;         (int = 0; < cc; i++)         {             label lbl = new label();             lbl.text = "";             lbl.autosize = false;             lbl.size = new size(w - 1, w - 1);             lbl.backcolor = webcolors[i];             lbl.borderstyle = borderstyle.fixedsingle;             lbl.location = new point(1 +  w * (i  % (n+ 1)) , w * ( / (n+1)) );             lbl.click += (ss, ee) =>             {                 pick = lbl.backcolor;                 lbl_colorname.text = pick.name;             };             controls.add(lbl);         }      }      private void cb_ok_click(object sender, eventargs e)     {         this.dialogresult = dialogresult.ok;         this.close();     }      private void cb_cancel_click(object sender, eventargs e)     {         this.close();     } } 

you can add sorting options , switch orderby clauses..


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -