Exemplo n.º 1
0
        public void ApplySettings(WatchVariableControlSettings settings)
        {
            if (settings.ChangeHighlighted)
            {
                Highlighted = settings.NewHighlighted;
            }

            if (settings.ChangeHighlightColor)
            {
                _tableLayoutPanel.BorderColor = settings.NewHighlightColor.Value;
                _tableLayoutPanel.ShowBorder  = true;
            }

            if (settings.ChangeBackgroundColor)
            {
                if (settings.ChangeBackgroundColorToDefault)
                {
                    BaseColor = _initialBaseColor;
                }
                else
                {
                    BaseColor = settings.NewBackgroundColor.Value;
                }
            }

            if (settings.ChangeFixedAddress)
            {
                if (settings.ChangeFixedAddressToDefault)
                {
                    FixedAddressListGetter = _defaultFixedAddressListGetter;
                }
                else
                {
                    SetFixedAddress(settings.NewFixedAddress);
                }
            }

            if (settings.DoFixAddressSpecial)
            {
                List <uint> addresses = FixedAddressListGetter() ?? WatchVarWrapper.GetCurrentAddressesToFix();
                if (addresses.Count > 0)
                {
                    uint objAddress = addresses[0];
                    uint parent     = Config.Stream.GetUInt32(objAddress + ObjectConfig.ParentOffset);
                    int  subtype    = Config.Stream.GetInt32(objAddress + ObjectConfig.BehaviorSubtypeOffset);
                    FixedAddressListGetter = () =>
                                             Config.ObjectSlotsManager.GetLoadedObjectsWithPredicate(
                        obj => obj.Parent == parent && obj.SubType == subtype && obj.Address != obj.Parent)
                                             .ConvertAll(obj => obj.Address);
                }
            }

            WatchVarWrapper.ApplySettings(settings);
        }