Esempio n. 1
0
        public static WatchVariableWrapper CreateWatchVariableWrapper(
            WatchVariable watchVar,
            WatchVariableControl watchVarControl,
            WatchVariableSubclass subclass,
            bool?useHex,
            bool?invertBool,
            WatchVariableCoordinate?coordinate)
        {
            switch (subclass)
            {
            case WatchVariableSubclass.String:
                return(new WatchVariableWrapper(watchVar, watchVarControl));

            case WatchVariableSubclass.Number:
                return(new WatchVariableNumberWrapper(
                           watchVar,
                           watchVarControl,
                           DEFAULT_ROUNDING_LIMIT,
                           useHex,
                           DEFAULT_USE_CHECKBOX,
                           coordinate));

            case WatchVariableSubclass.Angle:
                return(new WatchVariableAngleWrapper(watchVar, watchVarControl));

            case WatchVariableSubclass.Object:
                return(new WatchVariableObjectWrapper(watchVar, watchVarControl));

            case WatchVariableSubclass.Boolean:
                return(new WatchVariableBooleanWrapper(watchVar, watchVarControl, invertBool));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 2
0
        public WatchVariableControlPrecursor(
            string name,
            WatchVariable watchVar,
            WatchVariableSubclass subclass,
            Color?backgroundColor,
            Type displayType,
            int?roundingLimit,
            bool?useHex,
            bool?invertBool,
            bool?isYaw,
            Coordinate?coordinate,
            List <VariableGroup> groupList,
            List <uint> fixedAddresses = null)
        {
            Name            = name;
            WatchVar        = watchVar;
            Subclass        = subclass;
            BackgroundColor = backgroundColor;
            DisplayType     = displayType;
            RoundingLimit   = roundingLimit;
            UseHex          = useHex;
            InvertBool      = invertBool;
            IsYaw           = isYaw;
            Coordinate      = coordinate;
            GroupList       = groupList;
            FixedAddresses  = fixedAddresses;

            VerifyState();
        }
Esempio n. 3
0
        public WatchVariableControlPrecursor(XElement element)
        {
            /// Watchvariable params
            string typeName    = (element.Attribute(XName.Get("type"))?.Value);
            string specialType = element.Attribute(XName.Get("specialType"))?.Value;
            BaseAddressTypeEnum baseAddressType = WatchVariableUtilities.GetBaseAddressType(element.Attribute(XName.Get("base")).Value);
            uint?offsetUS      = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetUS"))?.Value);
            uint?offsetJP      = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetJP"))?.Value);
            uint?offsetSH      = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetSH"))?.Value);
            uint?offsetEU      = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetEU"))?.Value);
            uint?offsetDefault = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offset"))?.Value);
            uint?mask          = element.Attribute(XName.Get("mask")) != null ?
                                 (uint?)ParsingUtilities.ParseHex(element.Attribute(XName.Get("mask")).Value) : null;
            int?shift = element.Attribute(XName.Get("shift")) != null?
                        int.Parse(element.Attribute(XName.Get("shift")).Value) : (int?)null;

            bool handleMapping = (element.Attribute(XName.Get("handleMapping")) != null) ?
                                 bool.Parse(element.Attribute(XName.Get("handleMapping")).Value) : true;
            string name = element.Value;

            WatchVar =
                new WatchVariable(
                    name,
                    typeName,
                    specialType,
                    baseAddressType,
                    offsetUS,
                    offsetJP,
                    offsetSH,
                    offsetEU,
                    offsetDefault,
                    mask,
                    shift,
                    handleMapping);

            Name            = name;
            Subclass        = WatchVariableUtilities.GetSubclass(element.Attribute(XName.Get("subclass"))?.Value);
            GroupList       = WatchVariableUtilities.ParseVariableGroupList(element.Attribute(XName.Get("groupList"))?.Value);
            BackgroundColor = (element.Attribute(XName.Get("color")) != null) ?
                              ColorUtilities.GetColorFromString(element.Attribute(XName.Get("color")).Value) : (Color?)null;
            string displayTypeName = (element.Attribute(XName.Get("display"))?.Value);

            DisplayType   = displayTypeName != null ? TypeUtilities.StringToType[displayTypeName] : null;
            RoundingLimit = (element.Attribute(XName.Get("round")) != null) ?
                            ParsingUtilities.ParseInt(element.Attribute(XName.Get("round")).Value) : (int?)null;
            UseHex = (element.Attribute(XName.Get("useHex")) != null) ?
                     bool.Parse(element.Attribute(XName.Get("useHex")).Value) : (bool?)null;
            InvertBool = element.Attribute(XName.Get("invertBool")) != null?
                         bool.Parse(element.Attribute(XName.Get("invertBool")).Value) : (bool?)null;

            IsYaw = (element.Attribute(XName.Get("yaw")) != null) ?
                    bool.Parse(element.Attribute(XName.Get("yaw")).Value) : (bool?)null;
            Coordinate = element.Attribute(XName.Get("coord")) != null?
                         WatchVariableUtilities.GetCoordinate(element.Attribute(XName.Get("coord")).Value) : (Coordinate?)null;

            FixedAddresses = element.Attribute(XName.Get("fixed")) != null?
                             ParsingUtilities.ParseHexList(element.Attribute(XName.Get("fixed")).Value) : null;

            VerifyState();
        }
Esempio n. 4
0
        public WatchVariableControlPrecursor(
            string typeName    = null,
            string specialType = null,
            BaseAddressTypeEnum baseAddressType = BaseAddressTypeEnum.Relative,
            uint?offsetUS                  = null,
            uint?offsetJP                  = null,
            uint?offsetSH                  = null,
            uint?offsetEU                  = null,
            uint?offsetDefault             = null,
            uint?mask                      = null,
            int?shift                      = null,
            bool handleMapping             = true,
            string name                    = null,
            WatchVariableSubclass subclass = WatchVariableSubclass.Number,
            Color?backgroundColor          = null,
            Type displayType               = null,
            int?roundingLimit              = null,
            bool?useHex                    = null,
            bool?invertBool                = null,
            bool?isYaw                     = null,
            Coordinate?coordinate          = null,
            List <VariableGroup> groupList = null,
            List <uint> fixedAddresses     = null)
        {
            WatchVar =
                new WatchVariable(
                    name,
                    typeName,
                    specialType,
                    baseAddressType,
                    offsetUS,
                    offsetJP,
                    offsetSH,
                    offsetEU,
                    offsetDefault,
                    mask,
                    shift,
                    handleMapping);
            Name            = name;
            Subclass        = subclass;
            BackgroundColor = backgroundColor;
            DisplayType     = displayType;
            RoundingLimit   = roundingLimit;
            UseHex          = useHex;
            InvertBool      = invertBool;
            IsYaw           = isYaw;
            Coordinate      = coordinate;
            GroupList       = groupList;
            FixedAddresses  = fixedAddresses;

            VerifyState();
        }
Esempio n. 5
0
        public static WatchVariableWrapper CreateWatchVariableWrapper(
            WatchVariable watchVar,
            WatchVariableControl watchVarControl,
            WatchVariableSubclass subclass,
            Type displayType,
            int?roundingLimit,
            bool?useHex,
            bool?invertBool,
            bool?isYaw,
            Coordinate?coordinate)
        {
            switch (subclass)
            {
            case WatchVariableSubclass.String:
                return(new WatchVariableStringWrapper(watchVar, watchVarControl));

            case WatchVariableSubclass.Number:
                return(new WatchVariableNumberWrapper(
                           watchVar,
                           watchVarControl,
                           displayType,
                           roundingLimit,
                           useHex,
                           DEFAULT_USE_CHECKBOX,
                           coordinate));

            case WatchVariableSubclass.Angle:
                return(new WatchVariableAngleWrapper(watchVar, watchVarControl, displayType, isYaw));

            case WatchVariableSubclass.Object:
                return(new WatchVariableObjectWrapper(watchVar, watchVarControl));

            case WatchVariableSubclass.Triangle:
                return(new WatchVariableTriangleWrapper(watchVar, watchVarControl));

            case WatchVariableSubclass.Address:
                return(new WatchVariableAddressWrapper(watchVar, watchVarControl));

            case WatchVariableSubclass.Boolean:
                return(new WatchVariableBooleanWrapper(watchVar, watchVarControl, invertBool));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 6
0
 public WatchVariableControlPrecursor(
     string name,
     WatchVariable watchVar,
     WatchVariableSubclass subclass,
     Color?backgroundColor,
     bool?useHex,
     bool?invertBool,
     WatchVariableCoordinate?coordinate,
     List <VariableGroup> groupList)
 {
     _name            = name;
     _watchVar        = watchVar;
     _subclass        = subclass;
     _backgroundColor = backgroundColor;
     _useHex          = useHex;
     _invertBool      = invertBool;
     _coordinate      = coordinate;
     _groupList       = groupList;
 }
Esempio n. 7
0
        public WatchVariableControl(
            WatchVariableControlPrecursor watchVarPrecursor,
            string name,
            WatchVariable watchVar,
            WatchVariableSubclass subclass,
            Color?backgroundColor,
            bool?useHex,
            bool?invertBool,
            WatchVariableCoordinate?coordinate,
            List <VariableGroup> groupList)
        {
            // Store the precursor
            _watchVarPrecursor = watchVarPrecursor;

            // Initialize main fields
            _varName         = name;
            GroupList        = groupList;
            _showBorder      = false;
            _editMode        = false;
            _renameMode      = false;
            FixedAddressList = null;

            // Initialize color fields
            _baseColor      = backgroundColor ?? DEFAULT_COLOR;
            _currentColor   = _baseColor;
            _isFlashing     = false;
            _flashStartTime = DateTime.Now;

            // Initialize size fields
            _variableNameWidth  = VariableNameWidth;
            _variableValueWidth = VariableValueWidth;
            _variableHeight     = VariableHeight;

            // Create controls
            InitializeBase();
            _namePanel      = CreateNamePanel();
            _nameTextBox    = CreateNameTextBox();
            _lockPictureBox = CreateLockPictureBox();
            _pinPictureBox  = CreatePinPictureBox();
            _valueTextBox   = CreateValueTextBox();
            _valueCheckBox  = CreateValueCheckBox();

            // Add controls to their containers
            base.Controls.Add(_valueTextBox, 1, 0);
            base.Controls.Add(_valueCheckBox, 1, 0);
            base.Controls.Add(_namePanel, 0, 0);
            _namePanel.Controls.Add(_pinPictureBox);
            _namePanel.Controls.Add(_lockPictureBox);
            _namePanel.Controls.Add(_nameTextBox);

            // Create var x
            _watchVarWrapper = WatchVariableWrapper.CreateWatchVariableWrapper(
                watchVar, this, subclass, useHex, invertBool, coordinate);

            // Initialize context menu strip
            _valueTextboxOriginalContextMenuStrip = _valueTextBox.ContextMenuStrip;
            _nameTextboxOriginalContextMenuStrip  = _nameTextBox.ContextMenuStrip;
            ContextMenuStrip = _watchVarWrapper.GetContextMenuStrip();
            _nameTextBox.ContextMenuStrip  = ContextMenuStrip;
            _valueTextBox.ContextMenuStrip = ContextMenuStrip;

            // Set whether to start as a checkbox
            SetUseCheckbox(_watchVarWrapper.StartsAsCheckbox());

            // Add functions
            _namePanel.Click          += (sender, e) => OnNameTextBoxClick();
            _nameTextBox.Click        += (sender, e) => OnNameTextBoxClick();
            _nameTextBox.Leave        += (sender, e) => { RenameMode = false; };
            _nameTextBox.KeyDown      += (sender, e) => OnNameTextValueKeyDown(e);
            _valueTextBox.DoubleClick += (sender, e) => { EditMode = true; };
            _valueTextBox.KeyDown     += (sender, e) => OnValueTextValueKeyDown(e);
            _valueTextBox.Leave       += (sender, e) => { EditMode = false; };
            _valueCheckBox.Click      += (sender, e) => OnCheckboxClick();
        }
Esempio n. 8
0
            private WatchVariableControlPrecursor CreatePrecursor(bool useObjAddress, bool useHex, bool useObj, bool useRelativeName)
            {
                WatchVariableSubclass subclass = useObj
                    ? WatchVariableSubclass.Object
                    : WatchVariableSubclass.Number;

                if (Keyboard.IsKeyDown(Key.A))
                {
                    subclass = WatchVariableSubclass.Angle;
                }
                if (Keyboard.IsKeyDown(Key.B))
                {
                    subclass = WatchVariableSubclass.Boolean;
                }
                if (Keyboard.IsKeyDown(Key.Q))
                {
                    subclass = WatchVariableSubclass.Object;
                }
                if (Keyboard.IsKeyDown(Key.T))
                {
                    subclass = WatchVariableSubclass.Triangle;
                }

                bool isObjectOrTriangle =
                    subclass == WatchVariableSubclass.Object ||
                    subclass == WatchVariableSubclass.Triangle;

                Type effectiveType = isObjectOrTriangle
                    ? typeof(uint)
                    : MemoryType;
                string typeString = TypeUtilities.TypeToString[effectiveType];

                bool?hexValue = null;

                if (useHex)
                {
                    hexValue = true;
                }
                if (isObjectOrTriangle)
                {
                    hexValue = null;
                }

                BaseAddressTypeEnum baseAddressType =
                    useObjAddress ? BaseAddressTypeEnum.Object : BaseAddressTypeEnum.Relative;
                uint offset     = useObjAddress ? (uint)ByteIndex : MemoryAddress;
                uint nameOffset = useRelativeName ? (uint)ByteIndex : MemoryAddress;

                WatchVariable watchVar = new WatchVariable(
                    memoryTypeName: typeString,
                    specialType: null,
                    baseAddressType: baseAddressType,
                    offsetUS: null,
                    offsetJP: null,
                    offsetSH: null,
                    offsetEU: null,
                    offsetDefault: offset,
                    mask: null,
                    shift: null,
                    handleMapping: true);

                return(new WatchVariableControlPrecursor(
                           name: typeString + " " + HexUtilities.FormatValue(nameOffset),
                           watchVar: watchVar,
                           subclass: subclass,
                           backgroundColor: null,
                           displayType: null,
                           roundingLimit: null,
                           useHex: hexValue,
                           invertBool: null,
                           isYaw: null,
                           coordinate: null,
                           groupList: new List <VariableGroup>()
                {
                    VariableGroup.Custom
                }));
            }
Esempio n. 9
0
        public WatchVariableControl(
            WatchVariableControlPrecursor watchVarPrecursor,
            string name,
            WatchVariable watchVar,
            WatchVariableSubclass subclass,
            Color?backgroundColor,
            Type displayType,
            int?roundingLimit,
            bool?useHex,
            bool?invertBool,
            bool?isYaw,
            Coordinate?coordinate,
            List <VariableGroup> groupList,
            List <uint> fixedAddresses)
        {
            // Initialize controls
            InitializeComponent();

            _tableLayoutPanel.BorderColor = Color.Red;
            _tableLayoutPanel.BorderWidth = 3;
            _nameTextBox.Text             = name;

            // Store the precursor
            WatchVarPrecursor = watchVarPrecursor;

            // Initialize main fields
            _varName    = name;
            GroupList   = groupList;
            _editMode   = false;
            _renameMode = false;
            IsSelected  = false;

            List <uint> copy1 = fixedAddresses == null ? null : new List <uint>(fixedAddresses);

            _defaultFixedAddressListGetter = () => copy1;
            List <uint> copy2 = fixedAddresses == null ? null : new List <uint>(fixedAddresses);

            FixedAddressListGetter = () => copy2;

            // Initialize color fields
            _initialBaseColor = backgroundColor ?? DEFAULT_COLOR;
            _baseColor        = _initialBaseColor;
            _currentColor     = _baseColor;
            _isFlashing       = false;
            _flashStartTime   = DateTime.Now;

            // Initialize flush/size fields
            _rightFlush         = true;
            _variableNameWidth  = 0;
            _variableValueWidth = 0;
            _variableHeight     = 0;
            _variableTextSize   = 0;
            _variableOffset     = 0;

            // Create watch var wrapper
            WatchVarWrapper = WatchVariableWrapper.CreateWatchVariableWrapper(
                watchVar, this, subclass, displayType, roundingLimit, useHex, invertBool, isYaw, coordinate);

            // Set whether to start as a checkbox
            SetUseCheckbox(WatchVarWrapper.StartsAsCheckbox());

            // Add functions
            _namePanel.Click       += (sender, e) => OnVariableClick();
            _namePanel.DoubleClick += (sender, e) => OnNameTextBoxDoubleClick();

            _nameTextBox.Click       += (sender, e) => OnVariableClick();
            _nameTextBox.DoubleClick += (sender, e) => OnNameTextBoxDoubleClick();
            _nameTextBox.Leave       += (sender, e) => { RenameMode = false; };
            _nameTextBox.KeyDown     += (sender, e) => OnNameTextValueKeyDown(e);

            _valueTextBox.Click       += (sender, e) => _watchVariablePanel.UnselectAllVariables();
            _valueTextBox.DoubleClick += (sender, e) => { EditMode = true; };
            _valueTextBox.KeyDown     += (sender, e) => OnValueTextValueKeyDown(e);
            _valueTextBox.Leave       += (sender, e) => { EditMode = false; };

            _valueCheckBox.Click += (sender, e) => OnCheckboxClick();

            MouseDown += ShowMainContextMenu;
            _valueTextBox.MouseDown += ShowMainContextMenu;
            _namePanel.MouseDown    += ShowMainContextMenu;
            _valuePanel.MouseDown   += ShowMainContextMenu;

            _nameTextBox.MouseDown += (sender, e) =>
            {
                if (e.Button == MouseButtons.Right)
                {
                    if (RenameMode)
                    {
                        ShowRenameContextMenu();
                    }
                    else
                    {
                        ShowContextMenu();
                    }
                }
            };

            _valueTextBox.ContextMenu = _nameTextBox.ContextMenu = DummyContextMenu;
        }
Esempio n. 10
0
            private WatchVariableControlPrecursor CreatePrecursor(bool useObjAddress, bool useHex, bool useObj)
            {
                WatchVariableSubclass subclass = useObj
                    ? WatchVariableSubclass.Object
                    : WatchVariableSubclass.Number;

                if (Keyboard.IsKeyDown(Key.A))
                {
                    subclass = WatchVariableSubclass.Angle;
                }
                if (Keyboard.IsKeyDown(Key.B))
                {
                    subclass = WatchVariableSubclass.Boolean;
                }
                if (Keyboard.IsKeyDown(Key.Q))
                {
                    subclass = WatchVariableSubclass.Object;
                }
                if (Keyboard.IsKeyDown(Key.T))
                {
                    subclass = WatchVariableSubclass.Triangle;
                }

                bool isObjectOrTriangle =
                    subclass == WatchVariableSubclass.Object ||
                    subclass == WatchVariableSubclass.Triangle;

                Type effectiveType = isObjectOrTriangle
                    ? typeof(uint)
                    : MemoryType;
                string typeString = TypeUtilities.TypeToString[effectiveType];

                bool?hexValue = null;

                if (useHex)
                {
                    hexValue = true;
                }
                if (isObjectOrTriangle)
                {
                    hexValue = null;
                }

                BaseAddressTypeEnum baseAddressType =
                    useObjAddress ? BaseAddressTypeEnum.Object : BaseAddressTypeEnum.Relative;
                uint offset = useObjAddress ? (uint)ByteIndex : MemoryAddress;

                WatchVariable watchVar = new WatchVariable(
                    typeString,
                    null /* specialType */,
                    baseAddressType,
                    null /* offsetUS */,
                    null /* offsetJP */,
                    null /* offsetPAL */,
                    offset,
                    null /* mask */,
                    null /* shift */);

                return(new WatchVariableControlPrecursor(
                           typeString + " " + HexUtilities.FormatValue(offset),
                           watchVar,
                           subclass,
                           null /* backgroundColor */,
                           null /* displayType */,
                           null /* roundingLimit */,
                           hexValue,
                           null /* invertBool */,
                           null /* isYaw */,
                           null /* coordinate */,
                           new List <VariableGroup>()
                {
                    VariableGroup.Custom
                }));
            }