Esempio n. 1
0
        public override void GenerateVisualRepresentation(Graphics g, Rectangle clipRectangle)
        {
            try
            {
                string value = String.Empty;
                switch (ValueType)
                {
                case CustomValueType._8Bit:
                    value = Value8Bit.ToString();
                    break;

                case CustomValueType._16Bit:
                    value = Value16Bit.ToString();
                    break;

                case CustomValueType._32Bit:
                    value = Value32Bit.ToString();
                    break;

                case CustomValueType._64Bit:
                    value = Value64Bit.ToString();
                    break;

                case CustomValueType.Color:
                    value = ColorValue.ToString();
                    break;

                case CustomValueType.String:
                    value = StringValue;
                    break;
                }

                string displayValue = string.Format("Custom Value - {0}", value);

                Font adjustedFont = Vixen.Common.Graphics.GetAdjustedFont(g, displayValue, clipRectangle, "Vixen.Fonts.DigitalDream.ttf", 48);
                using (var stringBrush = new SolidBrush(Color.White))
                {
                    using (var backgroundBrush = new SolidBrush(Color.DarkGray))
                    {
                        g.FillRectangle(backgroundBrush, clipRectangle);
                    }
                    g.DrawString(displayValue, adjustedFont, stringBrush, clipRectangle.X + 2, 2);
                }
            }
            catch (Exception e)
            {
                Logging.Error("Exception rendering the visualization for the effect.", e);
            }
        }
Esempio n. 2
0
        public string GetPreviewString(RSTriggerInfo inTriggerContext, RSLibrary inLibrary)
        {
            switch (m_Type)
            {
            case InnerType.String:
                return(string.Format("\"{0}\"", m_StringValue));

            case InnerType.Color:
                return(ColorValue.ToString());

            case InnerType.Bool:
                return(BoolValue ? "true" : "false");

            case InnerType.Float:
                return(FloatValue.ToString());

            case InnerType.Int32:
                return(IntValue.ToString());

            case InnerType.Null:
                return("null");

            case InnerType.Vector2:
                return(AsVector2.ToString());

            case InnerType.Vector3:
                return(AsVector3.ToString());

            case InnerType.Vector4:
                return(AsVector4.ToString());

            case InnerType.EntityScope:
                return(EntityValue.GetPreviewString(inTriggerContext, inLibrary));

            case InnerType.GroupId:
                return(GroupIdValue.ToString(inLibrary));

            case InnerType.TriggerId:
                return(TriggerIdValue.ToString(inLibrary));

            case InnerType.Enum:
            {
                Type enumType = Type.GetType(m_StringValue);
                if (enumType == null)
                {
                    Debug.LogErrorFormat("Enum type {0} no longer exists", m_StringValue);
                    return(m_IntValue.ToString());
                }

                try
                {
                    return(Enum.ToObject(enumType, m_IntValue).ToString());
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                    Debug.LogErrorFormat("Enum {0} cannot be represented as type {1}", m_IntValue, enumType);
                    return(m_IntValue.ToString());
                }
            }

            case InnerType.Invalid:
                return("INVALID");

            default:
                ThrowInvalidCastException(m_Type, typeof(string));
                return(null);
            }
        }