示例#1
0
        // TODO dont use callermembername. this should all be staticly typed using the other contructor.
        public Material(Color color, [CallerMemberName] string cmn = null)
        {
            Color = color;
            Brush = new SolidColorBrush(color);
            if (cmn == null)
            {
                throw new Exception("CallerMemberName not assigned.");
            }
            var brushName           = "";
            var intensityStr        = "";
            var hasEncounteredDigit = false;

            foreach (var c in cmn.ToCharArray())
            {
                if (!char.IsLetterOrDigit(c))
                {
                    throw new Exception("Improper naming convension for auto brush");
                }

                if (char.IsDigit(c))
                {
                    hasEncounteredDigit = true;
                    intensityStr       += c;
                }
                if (char.IsLetter(c))
                {
                    if (hasEncounteredDigit)
                    {
                        throw new Exception("Improper naming convension for auto brush ([Letter]*A?[Digit]*");
                    }
                    brushName += c;
                }
            }
            BrushFamily = brushName;
            Luminosity  = brushName.EndsWith("A") ? Luminosity.Parse("A" + intensityStr) : Luminosity.Parse("P" + intensityStr);
        }
示例#2
0
        public Material GetMaterialWithOpacity(Luminosity i, double opacity)
        {
            var material = GetMaterial(i);

            return(material.WithOpacity(opacity));
        }