c# - LinearGradientBrush convertor -


how convert lineargradientbrush value string value or color value .? have method returns lineargradientbrush value

    private lineargradientbrush setbackground(string color1, string color2)     {         lineargradientbrush brush = new lineargradientbrush();         brush.startpoint = new point(0, 0);         brush.endpoint = new point(0, 1);         gradientstop gra1 = new gradientstop();         gra1.color = (color)colorconverter.convertfromstring(color1);         gra1.offset = 1;         gradientstop gra2 = new gradientstop();         gra2.color = (color)colorconverter.convertfromstring(color2);         gra2.offset = 0;         brush.gradientstops.add(gra1);         brush.gradientstops.add(gra2);         return brush;     } 

i need convert return value string type or hexadecimal value such "ffff00" representation , possible ,if yes , how ? in advance

a relatively simple way of doing output various properties string. working brain compiler here, wouldn't easy as:

private string lineargradientbrushtostring(lineargradientbrush brush) {     stringbuilder output = new stringbuilder();      output.append(brush.startpoint.x + "," + brush.startpoint.y);     output.append("|" + brush.endpoint.x + "," + brush.endpoint.y);      foreach(gradientstop g in brush.gradientstops)      {         output.append("|" + g.offset + "," + colorconverter.converttostring(g.color));     }      return output.tostring(); } 

that should output string has key properties converted strings , placed in pipe , comma-delimited format. easy enough use string.split() break out , create brush again.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -