Ejemplo n.º 1
0
        // AsString
        public virtual StringBuilder AsString(StringBuilder s)
        {
            s.Length = 0;

            if (Var == null)
            {
                s.Append((Child1 != null) ? "=>" : "");
            }
            else
            {
                switch (Var.Type)
                {
                case E_VarType.Bool:            { BoolD v = (BoolD)Var;                 s.Append(v.Value ? "true" : "false");                                                         break; }

                case E_VarType.Int:                     { IntD v = (IntD)Var;                   s.AppendFormat("{0:#,0}", v.Value);                                                           break; }

                case E_VarType.Float:           { FloatD v = (FloatD)Var;               s.AppendFormat("{0:#,0.0####}", v.Value);                                                     break; }

                case E_VarType.Enum:            { EnumD v = (EnumD)Var;                 s.Append(v.Options[v.Value].Name);                                                          break; }

                case E_VarType.Function:        { s.Append("-call-");                                                                                           break; }

                case E_VarType.String:          { StringD v = (StringD)Var;             s.Append(v.Value);                                                                                            break; }

                case E_VarType.Color:           { ColorD v = (ColorD)Var;               s.AppendFormat("A:{0} R:{1} G:{2} B:{3}", v.A, v.R, v.G, v.B);        break; }
                }
            }

            return(s);
        }
Ejemplo n.º 2
0
        // Decrease
        protected void Decrease()
        {
            if (!CanDecrease())
            {
                return;
            }

            switch (Current.Var.Type)
            {
            case E_VarType.Bool:    { BoolD v = (BoolD)Current.Var;                 v.Value = !v.Value;                                                                                     break; }

            case E_VarType.Int:             { IntD v = (IntD)Current.Var;                   v.Value -= v.Step; if (v.Value < v.Min)
                                              {
                                                  v.Value = v.Min;
                                              }
                                              break; }

            case E_VarType.Float:   { FloatD v = (FloatD)Current.Var;               v.Value -= v.Step; if (v.Value < v.Min)
                                      {
                                          v.Value = v.Min;
                                      }
                                      break; }

            case E_VarType.Enum:    { EnumD v = (EnumD)Current.Var;                 --v.Value;                                                                                                      break; }
            }
        }
Ejemplo n.º 3
0
        // Increase
        protected void Increase()
        {
            if (!CanIncrease())
            {
                return;
            }

            switch (Current.Var.Type)
            {
            case E_VarType.Bool:    { BoolD v = (BoolD)Current.Var;                 v.Value = !v.Value;                                                                                     break; }

            case E_VarType.Int:             { IntD v = (IntD)Current.Var;                   v.Value += v.Step; if (v.Value > v.Max)
                                              {
                                                  v.Value = v.Max;
                                              }
                                              break; }

            case E_VarType.Float:   { FloatD v = (FloatD)Current.Var;               v.Value += v.Step; if (v.Value > v.Max)
                                      {
                                          v.Value = v.Max;
                                      }
                                      break; }

            case E_VarType.Enum:    { EnumD v = (EnumD)Current.Var;                 ++v.Value;                                                                                                      break; }
            }
        }
Ejemplo n.º 4
0
        // ResetToDefault
        protected void ResetToDefault()
        {
            if (Current.Var == null)
            {
                return;
            }

            switch (Current.Var.Type)
            {
            case E_VarType.Bool:    { BoolD v = (BoolD)Current.Var;                 v.Value = v.Default;    break; }

            case E_VarType.Int:             { IntD v = (IntD)Current.Var;                   v.Value = v.Default;    break; }

            case E_VarType.Float:   { FloatD v = (FloatD)Current.Var;               v.Value = v.Default;    break; }

            case E_VarType.Enum:    { EnumD v = (EnumD)Current.Var;                 v.Value = v.Default;    break; }

            case E_VarType.String:  { StringD v = (StringD)Current.Var;             v.Value = v.Default;    break; }

            case E_VarType.Color:   { ColorD v = (ColorD)Current.Var;               v.Value = v.Default;    break; }
            }
        }
Ejemplo n.º 5
0
        // CanDecrease
        protected bool CanDecrease()
        {
            if (Current.Var == null)
            {
                return(false);
            }

            bool canDecrease = false;

            switch (Current.Var.Type)
            {
            case E_VarType.Bool:    { canDecrease = true;                                     break; }

            case E_VarType.Int:             { IntD v = (IntD)Current.Var;                   canDecrease = (v.Value > v.Min);      break; }

            case E_VarType.Float:   { FloatD v = (FloatD)Current.Var;               canDecrease = (v.Value > v.Min);      break; }

            case E_VarType.Enum:    { EnumD v = (EnumD)Current.Var;                 canDecrease = (v.Value > 0);          break; }
            }

            return(canDecrease);
        }
Ejemplo n.º 6
0
        // CanIncrease
        protected bool CanIncrease()
        {
            if (Current.Var == null)
            {
                return(false);
            }

            bool canIncrease = false;

            switch (Current.Var.Type)
            {
            case E_VarType.Bool:    { canIncrease = true;                                                                             break; }

            case E_VarType.Int:             { IntD v = (IntD)Current.Var;                   canIncrease = (v.Value < v.Max);                                              break; }

            case E_VarType.Float:   { FloatD v = (FloatD)Current.Var;               canIncrease = (v.Value < v.Max);                                              break; }

            case E_VarType.Enum:    { EnumD v = (EnumD)Current.Var;                 canIncrease = (v.Value < (v.Options.Length - 1));   break; }
            }

            return(canIncrease);
        }