private static String CreateFloat(StyleInfo styleInfo)
 {
     float min = float.Parse(styleInfo.MinValue);
     float max = float.Parse(styleInfo.MaxValue);
     float randomDouble = (float)random.NextDouble();
     float result =  randomDouble * (max - min) + min;
     return result.ToString();
 }
Example #2
0
        public String GetDefaultStyleValue(StyleInfo style)
        {
            switch (style.Type)
            {
                case StyleType.INT: return "100";

                case StyleType.BOOL: return "false";

                case StyleType.FLOAT : return "20.5";

                default:
                    return "";
            }
        }
Example #3
0
        public object Clone()
        {
            StyleInfo clonedObj = new StyleInfo();

            clonedObj.Name = this.Name;
            clonedObj.Feature = this.Feature;
            clonedObj.Value = this.Value;
            clonedObj.MinValue = this.MinValue;
            clonedObj.MaxValue = this.MaxValue;
            clonedObj.Type = this.Type;
            clonedObj.PossibleValues = this.PossibleValues;

            return clonedObj;
        }
        public static Style CreateStyle(StyleInfo style, Defaults defaults)
        {
            Style tmp = new Style();
            tmp.Name = style.Name;
            tmp.Type = style.Type;
            tmp.Value = style.Value;

            if (style.Value.Equals("")) {

                String generated = GenerateValue(style);

                if (generated == null || generated.Equals("")) generated = defaults.GetDefaultStyleValue(style);

                tmp.Value = generated;
            }

            return tmp;
        }
        private static String GenerateValue(StyleInfo styleInfo)
        {
            switch (styleInfo.Type)
            {
                case StyleType.INT:
                    return CreateInt(styleInfo);

                case StyleType.FLOAT:
                    return CreateFloat(styleInfo);

                case StyleType.ENUM:
                    return CreateEnum(styleInfo);

                case StyleType.BOOL:
                    return CreateBool();

                default:
                    return "";
            }
        }
Example #6
0
        private StyleInfo CreateStyleInfo(XmlElement styleElement)
        {
            StyleInfo tmpStyle = new StyleInfo();
            tmpStyle.Name = styleElement.Name;
            tmpStyle.Value = styleElement.GetAttribute("value");
            tmpStyle.MinValue = styleElement.GetAttribute("minValue");
            tmpStyle.MaxValue = styleElement.GetAttribute("maxValue");

            return tmpStyle;
        }
 private static String CreateInt(StyleInfo styleInfo)
 {
     int min = int.Parse(styleInfo.MinValue);
     int max = int.Parse(styleInfo.MaxValue);
     return random.Next(min, max + 1).ToString();
 }
 private static String CreateEnum(StyleInfo styleInfo)
 {
     int index = random.Next(styleInfo.PossibleValues.Count());
     return styleInfo.PossibleValues.ElementAt(index);
 }