Ejemplo n.º 1
0
        private bool ResultValid()
        {
            uint address;

            if (comboBoxType.SelectedIndex < 0)
            {
                MessageBox.Show("Select a value type!");
                return(false);
            }
            else if (ParsingUtilities.TryParseHex(maskedTextBoxAddress.Text, out address))
            {
                MessageBox.Show("Enter a valid address!");
                return(false);
            }

            WatchVariable watchVar = new WatchVariable();

            watchVar.Name               = textBoxName.Text;
            watchVar.Type               = WatchVariableExtensions.GetStringType((string)comboBoxType.SelectedItem);
            watchVar.Address            = address;
            watchVar.AbsoluteAddressing = checkBoxAbsolute.Checked;
            _value = watchVar;

            return(true);
        }
Ejemplo n.º 2
0
        public static WatchVariable GetWatchVariableFromElement(XElement element)
        {
            var watchVar = new WatchVariable();

            watchVar.Special = (element.Attribute(XName.Get("special")) != null) ?
                               bool.Parse(element.Attribute(XName.Get("special")).Value) : false;
            watchVar.Name        = element.Value;
            watchVar.SpecialType = (element.Attribute(XName.Get("specialType")) != null) ?
                                   element.Attribute(XName.Get("specialType")).Value : null;
            watchVar.BackroundColor = (element.Attribute(XName.Get("color")) != null) ?
                                      ColorTranslator.FromHtml(element.Attribute(XName.Get("color")).Value) : (Color?)null;

            // We have fully parsed a special type
            if (watchVar.Special)
            {
                return(watchVar);
            }

            watchVar.UseHex = (element.Attribute(XName.Get("useHex")) != null) ?
                              bool.Parse(element.Attribute(XName.Get("useHex")).Value) : false;
            watchVar.AbsoluteAddressing = element.Attribute(XName.Get("absoluteAddress")) != null?
                                          bool.Parse(element.Attribute(XName.Get("absoluteAddress")).Value) : false;

            watchVar.Mask = element.Attribute(XName.Get("mask")) != null ?
                            (UInt64?)ParsingUtilities.ParseExtHex(element.Attribute(XName.Get("mask")).Value) : null;
            watchVar.IsBool = element.Attribute(XName.Get("isBool")) != null?
                              bool.Parse(element.Attribute(XName.Get("isBool")).Value) : false;

            watchVar.Type       = WatchVariableExtensions.GetStringType(element.Attribute(XName.Get("type")).Value);
            watchVar.Address    = ParsingUtilities.ParseHex(element.Attribute(XName.Get("address")).Value);
            watchVar.InvertBool = element.Attribute(XName.Get("invertBool")) != null?
                                  bool.Parse(element.Attribute(XName.Get("invertBool")).Value) : false;

            watchVar.IsAngle = element.Attribute(XName.Get("isAngle")) != null?
                               bool.Parse(element.Attribute(XName.Get("isAngle")).Value) : false;

            return(watchVar);
        }