private void ShowSideHtmlWidgetWindow()
 {
     this.ParentWindow.Dispatcher.BeginInvoke((Delegate)(() =>
     {
         this.mBrowser.Visibility = Visibility.Visible;
         this.mCloseButton.Visibility = Visibility.Visible;
         this.Visibility = Visibility.Visible;
         this.Activate();
         if (this.ParentWindow.WindowState == WindowState.Maximized || this.ParentWindow.mIsFullScreen)
         {
             IntereopRect fullscreenMonitorSize = WindowWndProcHandler.GetFullscreenMonitorSize(this.ParentWindow.Handle, true);
             this.Left = (double)(fullscreenMonitorSize.Left + fullscreenMonitorSize.Width) / MainWindow.sScalingFactor - this.Width + 30.0 - (this.ParentWindow.mIsFullScreen || !this.ParentWindow.EngineInstanceRegistry.IsSidebarVisible ? 0.0 : 62.0);
             this.Top = (double)(fullscreenMonitorSize.Top + fullscreenMonitorSize.Height) / MainWindow.sScalingFactor - this.Height + 30.0;
         }
         else
         {
             this.Left = this.ParentWindow.Left + this.ParentWindow.Width - this.Width + 30.0 - (this.ParentWindow.EngineInstanceRegistry.IsSidebarVisible ? 62.0 : 0.0);
             this.Top = this.ParentWindow.Top + this.ParentWindow.Height - this.Height + 30.0;
         }
         if (this.ParentWindow != null)
         {
             this.ParentWindow.Activated -= new EventHandler(this.ParentWindow_Activated);
             this.ParentWindow.Activated += new EventHandler(this.ParentWindow_Activated);
         }
         SystemEvents.DisplaySettingsChanged -= new EventHandler(this.DisplaySettingsChanged);
         SystemEvents.DisplaySettingsChanged += new EventHandler(this.DisplaySettingsChanged);
     }));
 }
Example #2
0
        internal void InitLayout()
        {
            MainWindow parentWindow  = this.ParentWindow;
            Grid       mFrontendGrid = parentWindow.mFrontendGrid;
            Point      point1        = mFrontendGrid.TranslatePoint(new Point(), (UIElement)parentWindow);

            if (this.IsInOverlayMode)
            {
                this.Background          = (Brush)Brushes.Transparent;
                this.mCanvas.Background  = (Brush)Brushes.Transparent;
                this.mCanvas2.Background = (Brush)Brushes.Transparent;
                this.mCanvas.Margin      = new Thickness();
                if (Oem.IsOEMDmm)
                {
                    this.Opacity = RegistryManager.Instance.TranslucentControlsTransparency;
                }
                else
                {
                    string path = Path.Combine(Path.Combine(RegistryManager.Instance.ClientInstallDir, "ImapImages"), this.ParentWindow.mTopBar.mAppTabButtons.SelectedTab.PackageName + ".png");
                    if (File.Exists(path))
                    {
                        this.mCanvasImage.ImageName = path;
                        this.mCanvas.Opacity        = 0.0;
                    }
                    else
                    {
                        this.mCanvas.Opacity = 1.0;
                    }
                }
                this.Handle = WindowInteropHelperExtensions.EnsureHandle(new WindowInteropHelper((Window)this));
                InteropWindow.SetWindowLong(this.Handle, -16, 1207959552);
            }
            else
            {
                IntereopRect fullscreenMonitorSize = WindowWndProcHandler.GetFullscreenMonitorSize(this.ParentWindow.Handle, true);
                double       width = (double)fullscreenMonitorSize.Width - (double)this.mSidebarWidth * MainWindow.sScalingFactor;
                if (!this.ParentWindow.EngineInstanceRegistry.IsSidebarVisible)
                {
                    width -= this.ParentWindow.mSidebar.Width * MainWindow.sScalingFactor;
                }
                double height = this.ParentWindow.GetHeightFromWidth(width, true, false);
                if (height > (double)fullscreenMonitorSize.Height)
                {
                    height = (double)fullscreenMonitorSize.Height;
                    width  = this.ParentWindow.GetWidthFromHeight(height, true, false);
                }
                double top  = this.ParentWindow.Top * MainWindow.sScalingFactor + height <= (double)(fullscreenMonitorSize.Y + fullscreenMonitorSize.Height) ? this.ParentWindow.Top * MainWindow.sScalingFactor : (double)fullscreenMonitorSize.Y + ((double)fullscreenMonitorSize.Height - height) / 2.0;
                double left = this.ParentWindow.Left * MainWindow.sScalingFactor + width + (double)this.mSidebarWidth * MainWindow.sScalingFactor <= (double)(fullscreenMonitorSize.X + fullscreenMonitorSize.Width) ? this.ParentWindow.Left * MainWindow.sScalingFactor : (double)fullscreenMonitorSize.X + ((double)fullscreenMonitorSize.Width - width - (double)this.mSidebarWidth * MainWindow.sScalingFactor) / 2.0;
                this.ParentWindow.ChangeHeightWidthTopLeft(width, height, top, left);
                this.Width          = this.ParentWindow.ActualWidth;
                this.Height         = this.ParentWindow.ActualHeight;
                this.Top            = this.ParentWindow.Top;
                this.Left           = this.ParentWindow.Left;
                this.mCanvas.Width  = this.ParentWindow.mFullScreenRestoredButNotSidebar ? mFrontendGrid.ActualWidth - this.ParentWindow.mSidebar.Width : mFrontendGrid.ActualWidth;
                this.mCanvas.Height = mFrontendGrid.ActualHeight;
                Point point2 = new Point(parentWindow.ActualWidth - (this.mCanvas.Width + point1.X), parentWindow.ActualHeight - (mFrontendGrid.ActualHeight + point1.Y));
                this.mCanvas.Margin = new Thickness(point1.X, point1.Y, point2.X, point2.Y);
            }
        }
        private void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            WindowWndProcHandler.MINMAXINFO structure = (WindowWndProcHandler.MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(WindowWndProcHandler.MINMAXINFO));
            IntPtr hmonitor = NativeMethods.MonitorFromWindow(hwnd, 1);

            if (hmonitor != IntPtr.Zero)
            {
                WindowWndProcHandler.MONITORINFOEX info = new WindowWndProcHandler.MONITORINFOEX()
                {
                    cbSize = Marshal.SizeOf(typeof(MONITORINFO))
                };
                NativeMethods.GetMonitorInfo(hmonitor, info);
                IntereopRect rcWork    = info.rcWork;
                IntereopRect rcMonitor = info.rcMonitor;
                WindowWndProcHandler.TaskbarLocation taskbarPosition = WindowWndProcHandler.GetTaskbarPosition();
                if (!this.mWindowInstance.mIsFullScreen)
                {
                    structure.ptMaxPosition.X = Math.Abs(rcWork.Left - rcMonitor.Left);
                    structure.ptMaxPosition.Y = Math.Abs(rcWork.Top - rcMonitor.Top);
                    structure.ptMaxSize.X     = Math.Abs(rcWork.Width);
                    structure.ptMaxSize.Y     = Math.Abs(rcWork.Height);
                    if (rcWork == rcMonitor)
                    {
                        switch (taskbarPosition)
                        {
                        case WindowWndProcHandler.TaskbarLocation.Left:
                            structure.ptMaxPosition.X += 2;
                            break;

                        case WindowWndProcHandler.TaskbarLocation.Top:
                            structure.ptMaxPosition.Y += 2;
                            break;

                        case WindowWndProcHandler.TaskbarLocation.Right:
                            structure.ptMaxSize.X -= 2;
                            break;

                        case WindowWndProcHandler.TaskbarLocation.Bottom:
                            structure.ptMaxSize.Y -= 2;
                            break;
                        }
                    }
                }
                else
                {
                    structure.ptMaxPosition.X = 0;
                    structure.ptMaxPosition.Y = 0;
                    structure.ptMaxSize.X     = Math.Abs(rcMonitor.Width);
                    structure.ptMaxSize.Y     = Math.Abs(rcMonitor.Height);
                }
                structure.ptMaxTrackSize.X = structure.ptMaxSize.X;
                structure.ptMaxTrackSize.Y = structure.ptMaxSize.Y;
            }
            Marshal.StructureToPtr((object)structure, lParam, true);
        }