Пример #1
0
 protected bool EditStringValue(TagNode tag)
 {
     if (FormRegistry.EditString != null)
     {
         StringFormData data = new StringFormData(tag.ToTagString().Data);
         if (FormRegistry.EditString(data))
         {
             tag.ToTagString().Data = data.Value;
             IsDataModified = true;
             return(true);
         }
     }
     return(false);
 }
Пример #2
0
        private bool ValidateValueInput()
        {
            try {
                switch (_tag.GetTagType())
                {
                case TagType.TAG_BYTE:
                    _tag.ToTagByte().Data = unchecked ((byte)sbyte.Parse(textBox1.Text));
                    break;

                case TagType.TAG_SHORT:
                    _tag.ToTagShort().Data = short.Parse(textBox1.Text);
                    break;

                case TagType.TAG_INT:
                    _tag.ToTagInt().Data = int.Parse(textBox1.Text);
                    break;

                case TagType.TAG_LONG:
                    _tag.ToTagLong().Data = long.Parse(textBox1.Text);
                    break;

                case TagType.TAG_FLOAT:
                    _tag.ToTagFloat().Data = float.Parse(textBox1.Text);
                    break;

                case TagType.TAG_DOUBLE:
                    _tag.ToTagDouble().Data = double.Parse(textBox1.Text);
                    break;

                case TagType.TAG_STRING:
                    _tag.ToTagString().Data = textBox1.Text;
                    break;
                }
            }
            catch (FormatException) {
                MessageBox.Show("指定された値の型が合っていません。。");
                return(false);
            }
            catch (OverflowException) {
                MessageBox.Show("指定された値が大きすぎです。オーバーフローします。", "エラー");
                return(false);
            }
            catch {
                return(false);
            }

            return(true);
        }
Пример #3
0
        private bool ValidateValueInput()
        {
            try {
                switch (_tag.GetTagType())
                {
                case TagType.TAG_BYTE:
                    _tag.ToTagByte().Data = unchecked ((byte)sbyte.Parse(_valueField.StringValue));
                    break;

                case TagType.TAG_SHORT:
                    _tag.ToTagShort().Data = short.Parse(_valueField.StringValue);
                    break;

                case TagType.TAG_INT:
                    _tag.ToTagInt().Data = int.Parse(_valueField.StringValue);
                    break;

                case TagType.TAG_LONG:
                    _tag.ToTagLong().Data = long.Parse(_valueField.StringValue);
                    break;

                case TagType.TAG_FLOAT:
                    _tag.ToTagFloat().Data = float.Parse(_valueField.StringValue);
                    break;

                case TagType.TAG_DOUBLE:
                    _tag.ToTagDouble().Data = double.Parse(_valueField.StringValue);
                    break;

                case TagType.TAG_STRING:
                    _tag.ToTagString().Data = _valueField.StringValue;
                    break;
                }
            }
            catch (FormatException) {
                NSAlert.WithMessage("Invalid Format", "OK", null, null, "The value is formatted incorrectly for the given type.").RunModal();
                return(false);
            }
            catch (OverflowException) {
                NSAlert.WithMessage("Invalid Range", "OK", null, null, "The value is outside the acceptable range for the given type.").RunModal();
                return(false);
            }
            catch {
                return(false);
            }

            return(true);
        }
Пример #4
0
        private bool ValidateValueInput()
        {
            try {
                switch (_tag.GetTagType())
                {
                case TagType.TAG_BYTE:
                    _tag.ToTagByte().Data = unchecked ((byte)sbyte.Parse(textBox1.Text));
                    break;

                case TagType.TAG_SHORT:
                    _tag.ToTagShort().Data = short.Parse(textBox1.Text);
                    break;

                case TagType.TAG_INT:
                    _tag.ToTagInt().Data = int.Parse(textBox1.Text);
                    break;

                case TagType.TAG_LONG:
                    _tag.ToTagLong().Data = long.Parse(textBox1.Text);
                    break;

                case TagType.TAG_FLOAT:
                    _tag.ToTagFloat().Data = float.Parse(textBox1.Text);
                    break;

                case TagType.TAG_DOUBLE:
                    _tag.ToTagDouble().Data = double.Parse(textBox1.Text);
                    break;

                case TagType.TAG_STRING:
                    _tag.ToTagString().Data = textBox1.Text;
                    break;
                }
            }
            catch (FormatException) {
                MessageBox.Show("The value is formatted incorrectly for the given type.");
                return(false);
            }
            catch (OverflowException) {
                MessageBox.Show("The value is outside the acceptable range for the given type.");
                return(false);
            }
            catch {
                return(false);
            }

            return(true);
        }
Пример #5
0
 protected bool EditStringValue (TagNode tag)
 {
     if (FormRegistry.EditString != null) {
         StringFormData data = new StringFormData(tag.ToTagString().Data);
         if (FormRegistry.EditString(data)) {
             tag.ToTagString().Data = data.Value;
             IsDataModified = true;
             return true;
         }
     }
     return false;
 }
Пример #6
0
        private static void SerializeScaler(TagNode tag, StringBuilder str)
        {
            switch (tag.GetTagType()) {
                case TagType.TAG_STRING:
                    str.Append("\"" + tag.ToTagString().Data + "\"");
                    break;

                case TagType.TAG_BYTE:
                    str.Append(tag.ToTagByte().Data);
                    break;

                case TagType.TAG_SHORT:
                    str.Append(tag.ToTagShort().Data);
                    break;

                case TagType.TAG_INT:
                    str.Append(tag.ToTagInt().Data);
                    break;

                case TagType.TAG_LONG:
                    str.Append(tag.ToTagLong().Data);
                    break;

                case TagType.TAG_FLOAT:
                    str.Append(tag.ToTagFloat().Data);
                    break;

                case TagType.TAG_DOUBLE:
                    str.Append(tag.ToTagDouble().Data);
                    break;

                case TagType.TAG_BYTE_ARRAY:
                    str.Append(Convert.ToBase64String(tag.ToTagByteArray().Data));
                    /*if (tag.ToTagByteArray().Length == (16 * 16 * 128 / 2)) {
                        str.Append(Base16.Encode(tag.ToTagByteArray().Data, 1));
                    }
                    else {
                        str.Append(Base16.Encode(tag.ToTagByteArray().Data, 2));
                    }*/
                    break;
            }
        }
Пример #7
0
        public override bool Matches(TagCompoundDataNode container, List <TagDataNode> matchedNodes)
        {
            TagDataNode childNode = GetChild(container, Name);
            TagNode     tag       = container.NamedTagContainer.GetTagNode(Name);

            if (tag == null)
            {
                return(false);
            }

            try {
                switch (tag.GetTagType())
                {
                case TagType.TAG_BYTE:
                case TagType.TAG_INT:
                case TagType.TAG_LONG:
                case TagType.TAG_SHORT:
                    switch (Operator)
                    {
                    case WildcardOperator.Equals:
                        if (long.Parse(Value) != tag.ToTagLong())
                        {
                            return(false);
                        }
                        break;

                    case WildcardOperator.NotEquals:
                        if (long.Parse(Value) == tag.ToTagLong())
                        {
                            return(false);
                        }
                        break;
                    }

                    if (!matchedNodes.Contains(childNode))
                    {
                        matchedNodes.Add(childNode);
                    }
                    return(true);

                case TagType.TAG_FLOAT:
                case TagType.TAG_DOUBLE:
                    switch (Operator)
                    {
                    case WildcardOperator.Equals:
                        if (double.Parse(Value) != tag.ToTagDouble())
                        {
                            return(false);
                        }
                        break;

                    case WildcardOperator.NotEquals:
                        if (double.Parse(Value) == tag.ToTagDouble())
                        {
                            return(false);
                        }
                        break;
                    }

                    if (!matchedNodes.Contains(childNode))
                    {
                        matchedNodes.Add(childNode);
                    }
                    return(true);

                case TagType.TAG_STRING:
                    switch (Operator)
                    {
                    case WildcardOperator.Equals:
                        if (Value != tag.ToTagString().Data)
                        {
                            return(false);
                        }
                        break;

                    case WildcardOperator.NotEquals:
                        if (Value == tag.ToTagString().Data)
                        {
                            return(false);
                        }
                        break;
                    }

                    if (!matchedNodes.Contains(childNode))
                    {
                        matchedNodes.Add(childNode);
                    }
                    return(true);
                }
            }
            catch { }

            return(false);
        }