Beispiel #1
0
        public void OpenTab(Func <Screen> content)
        {
            var s    = content.Invoke();
            var view = _viewManager.CreateViewForModel(s);

            _viewManager.BindViewToModel(view, s);
            TabContents.Add(new TabContent(s.DisplayName, view));
        }
Beispiel #2
0
        private async Task <object> ShowDialog(string identifier, DialogViewModelBase viewModel)
        {
            var view = _viewManager.CreateViewForModel(viewModel);

            _viewManager.BindViewToModel(view, viewModel);

            if (identifier == null)
            {
                return(await DialogHost.Show(view, viewModel.OnDialogOpened, viewModel.OnDialogClosed));
            }
            return(await DialogHost.Show(view, identifier, viewModel.OnDialogOpened, viewModel.OnDialogClosed));
        }
        public void SelectDevice()
        {
            _deviceViewModel.ToggleSingleSelectionMode();
            var view = _viewManager.CreateViewForModel(_deviceViewModel);

            _viewManager.BindViewToModel(view, _deviceViewModel);
            _windowManager.ShowDialog(_deviceViewModel);

            var device = _deviceViewModel.GetSelectedDevice();

            CurrentDeviceData = device.Count == 0 ? null : _deviceViewModel.GetSelectedDevice()[0];
            GetPortForwardingInfo();
        }
Beispiel #4
0
        private async Task <object> ShowDialog(string identifier, DialogViewModelBase viewModel)
        {
            Task <object> result = null;
            await Execute.OnUIThreadAsync(() =>
            {
                UIElement view = _viewManager.CreateViewForModel(viewModel);
                _viewManager.BindViewToModel(view, viewModel);

                if (identifier == null)
                {
                    result = DialogHost.Show(view, viewModel.OnDialogOpened, viewModel.OnDialogClosed);
                }
                else
                {
                    result = DialogHost.Show(view, identifier, viewModel.OnDialogOpened, viewModel.OnDialogClosed);
                }
            });

            return(await result);
        }
Beispiel #5
0
        private async Task <object?> ShowDialog(string?identifier, DialogViewModelBase viewModel)
        {
            Task <object?>?result = null;
            await Execute.OnUIThreadAsync(() =>
            {
                UIElement view = _viewManager.CreateViewForModel(viewModel);
                _viewManager.BindViewToModel(view, viewModel);

                if (identifier == null)
                {
                    result = DialogHost.Show(view, viewModel.OnDialogOpened, viewModel.OnDialogClosed);
                }
                else
                {
                    result = DialogHost.Show(view, identifier, viewModel.OnDialogOpened, viewModel.OnDialogClosed);
                }
            });

            if (result == null)
            {
                throw new ArtemisSharedUIException("Failed to show dialog host");
            }
            return(await result);
        }
Beispiel #6
0
        public UIElement GetViewForDialogScreen <T>(DialogScreen <T> dialogScreen)
        {
            var dialogScreenType = dialogScreen.GetType();

            if (_dialogScreenViewCache.TryGetValue(dialogScreenType, out var cachedView))
            {
                _viewManager.BindViewToModel(cachedView, dialogScreen);
                return(cachedView);
            }
            else
            {
                var view = _viewManager.CreateAndBindViewForModelIfNecessary(dialogScreen);

                // This warms up the view and triggers all bindings.
                // We need to do this, as the view may have nested model-bound ContentControls
                // which take a very long time to load.
                // By pre-loading them as early as possible, we avoid doing it when the dialog
                // actually pops up, which improves user experience.
                // Ideally, the whole view cache should be populated at application startup.
                view.Arrange(new Rect(0, 0, 500, 500));

                return(_dialogScreenViewCache[dialogScreenType] = view);
            }
        }