Exemplo n.º 1
0
 // Lighten up the given baseColor so it is easy to read on the system Highlight color background.
 public static Brush HighlightTextBrush(Color baseColor)
 {
     SolidBrush ht = SystemBrushes.Highlight as SolidBrush;
     Color selectedColor = ht != null ? ht.Color : Color.FromArgb(49, 106, 197);
     HLSColor cls = new HLSColor(baseColor);
     HLSColor hls = new HLSColor(selectedColor);
     int luminosity = (hls.Luminosity > 120) ? 20 : 220;
     return new SolidBrush(HLSColor.ColorFromHLS(cls.Hue, luminosity, cls.Saturation));
 }
Exemplo n.º 2
0
        // Lighten up the given baseColor so it is easy to read on the system Highlight color background.
        public static Brush HighlightTextBrush(Color baseColor)
        {
            SolidBrush ht            = SystemBrushes.Highlight as SolidBrush;
            Color      selectedColor = ht != null ? ht.Color : Color.FromArgb(49, 106, 197);
            HLSColor   cls           = new HLSColor(baseColor);
            HLSColor   hls           = new HLSColor(selectedColor);
            int        luminosity    = (hls.Luminosity > 120) ? 20 : 220;

            return(new SolidBrush(HLSColor.ColorFromHLS(cls.Hue, luminosity, cls.Saturation)));
        }
Exemplo n.º 3
0
        public override bool Equals(object o)
        {
            if (!(o is HLSColor))
            {
                return(false);
            }

            HLSColor c = (HLSColor)o;

            return(_hue == c._hue &&
                   _saturation == c._saturation &&
                   _luminosity == c._luminosity);
        }
Exemplo n.º 4
0
        public void TestUtilities()
        {
            Trace.WriteLine("TestUtilities==========================================================");
            // code coverage on hard to reach utility code.
            HLSColor hls = new HLSColor(Color.Red);
            Trace.WriteLine(hls.ToString());
            Trace.WriteLine(hls.Darker(0.5F).ToString());
            Trace.WriteLine(hls.Lighter(0.5F).ToString());
            Trace.WriteLine(hls == new HLSColor(Color.Red));
            Trace.WriteLine(hls.GetHashCode());

            // Test resource class.
            Type t = FormMain.ResourceType;
            foreach (PropertyInfo pi in t.GetProperties(BindingFlags.Static)) {
                if (pi.PropertyType == typeof(string)) {
                    string name = pi.Name;
                    object res = pi.GetValue(null, null);
                    if (res == null) {
                        throw new Exception("Unexpected null returned from property: " + name);
                    }
                    Trace.WriteLine(string.Format("{0}={1}", name, res.ToString()));
                }
            }

            // Test XmlIncludeReader
            string test = TestDir + "UnitTests\\includes\\index.xml";
            Uri baseUri = new Uri(test);
            XmlDocument doc = new XmlDocument();
            doc.Load(test);
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ProhibitDtd = false;
            foreach (XmlElement e in doc.SelectNodes("test/case")) {
                Uri input = new Uri(baseUri, e.GetAttribute("input"));
                Uri output = new Uri(baseUri, e.GetAttribute("results"));
                using (XmlIncludeReader r = XmlIncludeReader.CreateIncludeReader(input.LocalPath, settings)) {
                    CompareResults(ReadNodes(r), output.LocalPath);
                }
            }
        }