public override async void Refresh()
        {
            _memberList.DisposeAllChildren();

            if (Instance.Object != null)
            {
                var first = true;
                foreach (var group in ViewVariablesInstance.LocalPropertyList(Instance.Object,
                                                                              Instance.ViewVariablesManager, _robustSerializer))
                {
                    CreateMemberGroupHeader(
                        ref first,
                        TypeAbbreviation.Abbreviate(group.Key),
                        _memberList);

                    foreach (var control in group)
                    {
                        _memberList.AddChild(control);
                    }
                }
            }
            else
            {
                DebugTools.AssertNotNull(Instance.Session);

                var blob = await Instance.ViewVariablesManager.RequestData <ViewVariablesBlobMembers>(
                    Instance.Session !, new ViewVariablesRequestMembers());

                var otherStyle = false;
                var first      = true;
                foreach (var(groupName, groupMembers) in blob.MemberGroups)
                {
                    CreateMemberGroupHeader(ref first, groupName, _memberList);

                    foreach (var propertyData in groupMembers)
                    {
                        var propertyEdit = new ViewVariablesPropertyControl(_vvm, _robustSerializer);
                        propertyEdit.SetStyle(otherStyle = !otherStyle);
                        var editor = propertyEdit.SetProperty(propertyData);

                        var selectorChain = new object[] { new ViewVariablesMemberSelector(propertyData.PropertyIndex) };
                        editor.WireNetworkSelector(Instance.Session !.SessionId, selectorChain);
                        editor.OnValueChanged += (o, r) =>
                        {
                            Instance.ViewVariablesManager.ModifyRemote(Instance.Session !,
                                                                       selectorChain, o, r);
                        };

                        _memberList.AddChild(propertyEdit);
                    }
                }
            }
        }
        public void BuildDisplay(Dictionary <string, int> data, OptionSelectedCallback callback)
        {
            _optionsBox.DisposeAllChildren();
            _optionSelectedCallback = callback;

            foreach (var(displayText, callbackData) in data)
            {
                var button = new SurgeryButton(callbackData);

                button.SetOnToggleBehavior(OnButtonPressed);
                button.SetDisplayText(Loc.GetString(displayText));

                _optionsBox.AddChild(button);
            }
        }
        private void PopulateClientComponents()
        {
            _clientComponents.DisposeAllChildren();

            _clientComponents.AddChild(_clientComponentsSearchBar = new LineEdit
            {
                PlaceHolder      = Loc.GetString("view-variable-instance-entity-client-components-search-bar-placeholder"),
                HorizontalExpand = true,
            });

            _clientComponents.AddChild(_clientComponentsAddButton = new Button()
            {
                Text             = Loc.GetString("view-variable-instance-entity-server-components-add-component-button-placeholder"),
                HorizontalExpand = true,
            });

            _clientComponentsAddButton.OnPressed     += OnClientComponentsAddButtonPressed;
            _clientComponentsSearchBar.OnTextChanged += OnClientComponentsSearchBarChanged;

            var componentList = _entityManager.GetComponents(_entity).OrderBy(c => c.GetType().ToString());

            foreach (var component in componentList)
            {
                var button = new Button {
                    Text = TypeAbbreviation.Abbreviate(component.GetType()), TextAlign = Label.AlignMode.Left
                };
                var removeButton = new TextureButton()
                {
                    StyleClasses        = { DefaultWindow.StyleClassWindowCloseButton },
                    HorizontalAlignment = HAlignment.Right
                };
                button.OnPressed       += _ => ViewVariablesManager.OpenVV(component);
                removeButton.OnPressed += _ => RemoveClientComponent(component);
                button.AddChild(removeButton);
                _clientComponents.AddChild(button);
            }
        }
 public void ClearButtons()
 {
     _vboxContainer.DisposeAllChildren();
 }
        private async void PopulateServerComponents(bool request = true)
        {
            _serverComponents.DisposeAllChildren();

            _serverComponents.AddChild(_serverComponentsSearchBar = new LineEdit
            {
                PlaceHolder      = Loc.GetString("view-variable-instance-entity-server-components-search-bar-placeholder"),
                HorizontalExpand = true,
            });

            _serverComponents.AddChild(_serverComponentsAddButton = new Button()
            {
                Text             = Loc.GetString("view-variable-instance-entity-server-components-add-component-button-placeholder"),
                HorizontalExpand = true,
            });

            _serverComponentsSearchBar.OnTextChanged += OnServerComponentsSearchBarChanged;
            _serverComponentsAddButton.OnPressed     += OnServerComponentsAddButtonPressed;

            if (!request || _entitySession == null)
            {
                return;
            }

            var componentsBlob = await ViewVariablesManager.RequestData <ViewVariablesBlobEntityComponents>(_entitySession, new ViewVariablesRequestEntityComponents());

            componentsBlob.ComponentTypes.Sort();

            var componentTypes = componentsBlob.ComponentTypes.AsEnumerable();

            if (!string.IsNullOrEmpty(_serverComponentsSearchBar.Text))
            {
                componentTypes = componentTypes
                                 .Where(t => t.Stringified.Contains(_serverComponentsSearchBar.Text,
                                                                    StringComparison.InvariantCultureIgnoreCase));
            }

            componentTypes = componentTypes.OrderBy(t => t.Stringified);

            foreach (var componentType in componentTypes)
            {
                var button = new Button {
                    Text = componentType.Stringified, TextAlign = Label.AlignMode.Left
                };
                var removeButton = new TextureButton()
                {
                    StyleClasses        = { DefaultWindow.StyleClassWindowCloseButton },
                    HorizontalAlignment = HAlignment.Right
                };
                button.OnPressed += _ =>
                {
                    ViewVariablesManager.OpenVV(
                        new ViewVariablesComponentSelector(_entity, componentType.FullName));
                };
                removeButton.OnPressed += _ =>
                {
                    // We send a command to remove the component.
                    IoCManager.Resolve <IClientConsoleHost>().RemoteExecuteCommand(null, $"rmcomp {_entity} {componentType.ComponentName}");
                    PopulateServerComponents();
                };
                button.AddChild(removeButton);
                _serverComponents.AddChild(button);
            }
        }