Esempio n. 1
0
 protected void UnregisterAppBar()
 {
     if (AppBarHelper.appBars.Contains(Handle))
     {
         AppBarHelper.RegisterBar(this, ActualWidth * dpiScale, desiredHeight * dpiScale);
     }
 }
Esempio n. 2
0
 protected void RegisterAppBar()
 {
     if (!Shell.IsCairoRunningAsShell && enableAppBar && !AppBarHelper.appBars.Contains(Handle))
     {
         appbarMessageId = AppBarHelper.RegisterBar(this, ActualWidth * dpiScale, desiredHeight * dpiScale, appBarEdge);
     }
 }
Esempio n. 3
0
        private void OnSourceInitialized(object sender, EventArgs e)
        {
            // set up helper and get handle
            helper = new WindowInteropHelper(this);
            Handle = helper.Handle;

            // set up window procedure
            HwndSource source = HwndSource.FromHwnd(helper.Handle);

            source.AddHook(new HwndSourceHook(WndProc));

            // set initial DPI. We do it here so that we get the correct value when DPI has changed since initial user logon to the system.
            if (Screen.Primary)
            {
                Shell.DpiScale = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice.M11;
            }

            dpiScale = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice.M11;

            setPosition();

            if (Shell.IsCairoRunningAsShell)
            {
                // set position again, on a delay, in case one display has a different DPI. for some reason the system overrides us if we don't wait
                delaySetPosition();
            }

            // register appbar
            if (!Shell.IsCairoRunningAsShell && enableAppBar)
            {
                appbarMessageId = AppBarHelper.RegisterBar(this, ActualWidth * dpiScale, desiredHeight * dpiScale, appBarEdge);
            }

            // hide from alt-tab etc
            Shell.HideWindowFromTasks(Handle);

            // register for full-screen notifications
            FullScreenHelper.Instance.FullScreenApps.CollectionChanged += FullScreenApps_CollectionChanged;

            postInit();
        }
Esempio n. 4
0
        private void OnClosing(object sender, CancelEventArgs e)
        {
            IsClosing = true;

            customClosing();

            if (Startup.IsShuttingDown && Screen.Primary)
            {
                // unregister appbar
                if (AppBarHelper.appBars.Contains(Handle))
                {
                    AppBarHelper.RegisterBar(this, ActualWidth * dpiScale, desiredHeight * dpiScale);
                }

                // unregister full-screen notifications
                FullScreenHelper.Instance.FullScreenApps.CollectionChanged -= FullScreenApps_CollectionChanged;

                // dispose the full screen helper since we are the primary instance
                FullScreenHelper.Instance.Dispose();
            }
            else if (WindowManager.Instance.IsSettingDisplays || Startup.IsShuttingDown)
            {
                // unregister appbar
                if (AppBarHelper.appBars.Contains(Handle))
                {
                    AppBarHelper.RegisterBar(this, ActualWidth * dpiScale, desiredHeight * dpiScale);
                }

                // unregister full-screen notifications
                FullScreenHelper.Instance.FullScreenApps.CollectionChanged -= FullScreenApps_CollectionChanged;
            }
            else
            {
                IsClosing = false;
                e.Cancel  = true;
            }
        }