title: ColorTranslator gives incorrect result for SystemColors.HotTrack and Color.Transparent
body: <h2>Environment</h2>
  
  <p>C#, .NET 4.5, DevExpress 13.2.7, Visual Studio 2013</p>
  
  <h2>Goal</h2>
  
  <p>A colour should be selected, then stored and finally retrieved for use.</p>
  
  <h2>Description</h2>
  
  <p>The users of my application are to select a <code>System.Drawing.Color</code> (preferably using a <code>DevExpress.XtraEditors.ColorEdit</code>) which the application will store until the colour is needed. This is currently done by converting the colour into a HTML string which is stored. When needed, the <code>string</code> is converted back to a <code>System.Drawing.Color</code>.</p>
  
  <p>This works for most colours but not when it comes to <code>SystemColors.HotTrack</code>. When this colour is converted into a HTML string and then back to a colour it becomes <code>SystemColors.Highlight</code> instead. See code below.</p>
  
  <pre><code>var hotTrackColor = SystemColors.HotTrack;
  //hotTrackColor   "{Name=HotTrack, ARGB=(255, 0, 102, 204)}"   System.Drawing.Color
  
  var htmlColor = ColorTranslator.ToHtml(hotTrackColor);
  //htmlColor   "highlight"   string
  
  var shouldBeHotTrackColor = ColorTranslator.FromHtml(htmlColor);
  //shouldBeHotTrackColor   "{Name=Highlight, ARGB=(255, 51, 153, 255)}"   System.Drawing.Color
  </code></pre>
  
  <p>Using the methods <code>ColorTranslator.ToWin32</code> and <code>ColorTranslator.FromWin32</code> gives a colour not recognized as <code>SystemColors.HotTrack</code> even though the colour itself is the same. This render the <code>DevExpress.XtraEditors.ColorEdit</code> component unable to show which colour is selected and therefore this does not seem like a suitable solution.</p>
  
  <p>Using the methods <code>ColorTranslator.ToOle</code> and <code>ColorTranslator.FromOle</code> gives a correct result for <code>SystemColors.HotTrack</code> but does not convert <code>Color.Transparent</code> correct. See code below</p>
  
  <pre><code>var transparentColor = Color.Transparent;
  //transparentColor   "{Name=Transparent, ARGB=(0, 255, 255, 255)}"   System.Drawing.Color
  
  var oleColor = ColorTranslator.ToOle(transparentColor);
  //oleColor   16777215   int
  
  var shouldBeTransparentColor = ColorTranslator.FromOle(oleColor);
  //shouldBeTransparentColor   "{Name=White, ARGB=(255, 255, 255, 255)}"   System.Drawing.Color
  </code></pre>
  
  <h2>Questions</h2>
  
  <ol>
  <li>Why do not the methods in <code>ColorTranslator</code> translate all colours correct?</li>
  <li>Where can I read more about this problem?</li>
  <li>What should I do to, in a simple way, reach my goal?</li>
  </ol>
  
  <h2>Update 2014-03-07</h2>
  
  <p>OK, it seems like there are no single method that would solve the problem for me.
  Therefore, I have used swandog's solution with a twist. I use the colour name when storing the colour, and when translating the name back to a colour I do this:</p>
  
  <pre><code>//Translate from name, as suggested by swandog.
  var translatedColor = Color.FromName(storedColor);
  
  if (!translatedColor.IsKnownColor)
  {
      //If the original colour was a custom colour (not a known colour) then
      //the stored colour will contain a HTML-string, like "ff12aadd".
  
      //Ignore the first two characters (the alpha) and hope
      //that all custom colours uses "ff" as alpha.
      var htmlString = "#" + storedColor.Substring(2);
  
      translatedColor = ColorTranslator.FromHtml(htmlString);
  }
  </code></pre>
  
  <p>This way, I get the correct colours and can still use custom colours.
  So far, it has worked out nicely for me.</p>