Ejemplo n.º 1
0
        private void OpenPreviewWindow(object sender, RoutedEventArgs e)
        {
            _preWindow?.Close();

            var sidemargin = 20;
            var topmargin  = 30;

            _preWindow        = new PreviewWindow(new PreviewWindowViewModel());
            _preWindow.Height = Math.Max(164, TokenControl.ImageResolutionHeight) + topmargin * 2;
            _preWindow.Width  = Math.Max(164, TokenControl.ImageResolutionWidth) + sidemargin * 2;

            //Undo dpi-scaling that will be applied by Windows to the window size, so that when Windows
            // applies its dpi-scaling, the resulting window size is the intended number of pizels.
            var dpiInfo = VisualTreeHelper.GetDpi(this);

            _preWindow.Width  = _preWindow.Width / dpiInfo.DpiScaleX;
            _preWindow.Height = _preWindow.Height / dpiInfo.DpiScaleY;

            _preWindow.Closed += (o, args) =>
            {
                _preWindow = null;
                _vm.OpenPreviewWindow.OnCanExecuteChanged(sender);
                _vm.UpdatePreview.OnCanExecuteChanged(sender);
            };
            _preWindow.Show();
            _preWindow.Topmost = _vm.KeepPreviewOnTop;

            _vm.OpenPreviewWindow.OnCanExecuteChanged(sender);
            _vm.UpdatePreview.OnCanExecuteChanged(sender);
            RenderUsingDispatcher();
        }
Ejemplo n.º 2
0
        private void OpenPreviewWindow(object sender, RoutedEventArgs e)
        {
            _preWindow?.Close();

            var sidemargin = 20;
            var topmargin  = 30;

            _preWindow         = new PreviewWindow(new PreviewWindowViewModel());
            _preWindow.Height  = Math.Max(164, TokenControl.ImageResolutionHeight) + topmargin * 2;
            _preWindow.Width   = Math.Max(164, TokenControl.ImageResolutionWidth) + sidemargin * 2;
            _preWindow.Closed += (o, args) =>
            {
                _preWindow = null;
                _vm.OpenPreviewWindow.OnCanExecuteChanged(sender);
                _vm.UpdatePreview.OnCanExecuteChanged(sender);
            };
            _preWindow.Show();
            _preWindow.Topmost = _vm.KeepPreviewOnTop;

            _vm.OpenPreviewWindow.OnCanExecuteChanged(sender);
            _vm.UpdatePreview.OnCanExecuteChanged(sender);
            RenderUsingDispatcher();
        }