Exemplo n.º 1
0
        public DevToolsViewModel(IControl root)
        {
            _root        = root;
            _logicalTree = new TreePageViewModel(LogicalTreeNode.Create(root));
            _visualTree  = new TreePageViewModel(VisualTreeNode.Create(root));

            this.WhenAnyValue(x => x.SelectedTab).Subscribe(index =>
            {
                switch (index)
                {
                case 0:
                    Content = _logicalTree;
                    break;

                case 1:
                    Content = _visualTree;
                    break;
                }
            });

            _focusedControl = KeyboardDevice.Instance
                              .WhenAnyValue(x => x.FocusedElement)
                              .Select(x => x?.GetType().Name)
                              .ToProperty(this, x => x.FocusedControl);

            _pointerOverElement = root.GetObservable(TopLevel.PointerOverElementProperty)
                                  .Select(x => x?.GetType().Name)
                                  .ToProperty(this, x => x.PointerOverElement);
        }
Exemplo n.º 2
0
        public MainViewModel(AvaloniaObject root)
        {
            _root        = root;
            _logicalTree = new TreePageViewModel(this, LogicalTreeNode.Create(root));
            _visualTree  = new TreePageViewModel(this, VisualTreeNode.Create(root));
            _events      = new EventsPageViewModel(this);

            UpdateFocusedControl();

            if (KeyboardDevice.Instance is not null)
            {
                KeyboardDevice.Instance.PropertyChanged += KeyboardPropertyChanged;
            }
            SelectedTab = 0;
            if (root is TopLevel topLevel)
            {
                _pointerOverSubscription = topLevel.GetObservable(TopLevel.PointerOverElementProperty)
                                           .Subscribe(x => PointerOverElement = x);
            }
            else
            {
#nullable disable
                _pointerOverSubscription = InputManager.Instance.PreProcess
                                           .OfType <Input.Raw.RawPointerEventArgs>()
                                           .Subscribe(e =>
                {
                    PointerOverRoot    = e.Root;
                    PointerOverElement = e.Root.GetInputElementsAt(e.Position).FirstOrDefault();
                });
#nullable restore
            }
Exemplo n.º 3
0
        public MainViewModel(TopLevel root)
        {
            _root        = root;
            _logicalTree = new TreePageViewModel(this, LogicalTreeNode.Create(root));
            _visualTree  = new TreePageViewModel(this, VisualTreeNode.Create(root));
            _events      = new EventsPageViewModel(root);

            UpdateFocusedControl();
            KeyboardDevice.Instance.PropertyChanged += KeyboardPropertyChanged;
            SelectedTab = 0;
            _pointerOverSubscription = root.GetObservable(TopLevel.PointerOverElementProperty)
                                       .Subscribe(x => PointerOverElement = x?.GetType().Name);
            Console = new ConsoleViewModel(UpdateConsoleContext);
        }
        public DevToolsViewModel(IControl root)
        {
            _logicalTree = new TreePageViewModel(LogicalTreeNode.Create(root));
            _visualTree  = new TreePageViewModel(VisualTreeNode.Create(root));

            UpdateFocusedControl();
            KeyboardDevice.Instance.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(KeyboardDevice.Instance.FocusedElement))
                {
                    UpdateFocusedControl();
                }
            };

            root.GetObservable(TopLevel.PointerOverElementProperty)
            .Subscribe(x => PointerOverElement = x?.GetType().Name);
        }
Exemplo n.º 5
0
        public MainViewModel(IControl root)
        {
            _root        = root;
            _logicalTree = new TreePageViewModel(LogicalTreeNode.Create(root));
            _visualTree  = new TreePageViewModel(VisualTreeNode.Create(root));
            _events      = new EventsPageViewModel(root);

            UpdateFocusedControl();
            KeyboardDevice.Instance.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(KeyboardDevice.Instance.FocusedElement))
                {
                    UpdateFocusedControl();
                }
            };

            SelectedTab = 0;
            root.GetObservable(TopLevel.PointerOverElementProperty)
            .Subscribe(x => PointerOverElement = x?.GetType().Name);
            Console = new ConsoleViewModel(UpdateConsoleContext);
        }
Exemplo n.º 6
0
        public DevToolsViewModel(IControl root)
        {
            Tools = new ObservableCollection <IDevToolViewModel>
            {
                new TreePageViewModel(LogicalTreeNode.Create(root), "Logical Tree"),
                new TreePageViewModel(VisualTreeNode.Create(root), "Visual Tree"),
                new EventsViewModel(root)
            };

            SelectedTool = Tools.First();

            UpdateFocusedControl();

            KeyboardDevice.Instance.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(KeyboardDevice.Instance.FocusedElement))
                {
                    UpdateFocusedControl();
                }
            };

            root.GetObservable(TopLevel.PointerOverElementProperty)
            .Subscribe(x => PointerOverElement = x?.GetType().Name);
        }