コード例 #1
0
        /// <summary>
        /// Verifies the given data is valid for this setting's data type.
        /// </summary>
        /// <param name="data">A string representation of the data.</param>
        public bool IsActionValid()
        {
            if (Setting.AllSettings[Target].ValueType == ShortcutTargetDataType.Integer)
            {
                if (int.TryParse(ActionData, out int value))
                {
                    return(Setting.AllSettings[Target].ValidateNumberValue(value));
                }

                return(false);
            }

            if (Setting.AllSettings[Target].ValueType == ShortcutTargetDataType.Float)
            {
                if (float.TryParse(ActionData, out float value))
                {
                    return(Setting.AllSettings[Target].ValidateNumberValue(value));
                }

                return(false);
            }

            if (Setting.AllSettings[Target].ValueType == ShortcutTargetDataType.Bool)
            {
                return(ActionData.Equals("t") || ActionData.Equals("f"));
            }

            if (Setting.AllSettings[Target].ValueType == ShortcutTargetDataType.Color)
            {
                return(Regex.Match(ActionData, "^([0-9]|[a-f]){6}$").Success);
            }

            return(!string.IsNullOrEmpty(ActionData));
        }
コード例 #2
0
        /// <summary>
        /// Interprets the data as representing true or false from either "t" or "f". Alternatively, it can be
        /// "toggle" to flip the value.
        /// Assumes the data is already in the proper format. Use <see cref="IsActionValid"/> to ensure.
        /// </summary>
        public bool GetDataAsBool(bool origValue)
        {
            if (Setting.AllSettings[Target].ValueType != ShortcutTargetDataType.Bool)
            {
                throw new Exception("Was expecting setting to be of the bool data type.");
            }

            if (ActionData.Equals("toggle"))
            {
                return(!origValue);
            }

            return(ActionData.Equals("t"));
        }
コード例 #3
0
            // override object.Equals
            public override bool Equals(object obj)
            {
                //
                // See the full list of guidelines at
                //   http://go.microsoft.com/fwlink/?LinkID=85237
                // and also the guidance for operator== at
                //   http://go.microsoft.com/fwlink/?LinkId=85238
                //

                if (obj == null || GetType() != obj.GetType())
                {
                    return(false);
                }

                // TODO: write your implementation of Equals() here
                ActionBubbleData refBubble = (obj as ActionBubbleData);

                return(ActionData.Equals(refBubble.ActionData) && BubbleType == refBubble.BubbleType);
            }