Color_Tools.cs

23 lines | 645 B Blame History Raw Download
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Drawing;

namespace yEd.XGML.IO.Write.Tools
{
    /// <summary>
    /// ColorTranslator.ToHtml() не всегда возвращает hex, он может вернуть имя цвета.
    /// А при экспорте требуется именно hex код
    /// </summary>
    public static class Color_Tools
    {       
        public static string ColorToHex(Color color) => 
             "#" 
            + color.R.ToString("X2") 
            + color.G.ToString("X2") 
            + color.B.ToString("X2");        
    }
}