コード例 #1
0
 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);
     }));
 }
コード例 #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);
            }
        }
コード例 #3
0
 internal WindowWndProcHandler(MainWindow window)
 {
     this.mWindowInstance                    = window;
     this.mWindowInstance.ResizeBegin       += new EventHandler(this.mWindowInstance.MainWindow_ResizeBegin);
     this.mWindowInstance.ResizeEnd         += new EventHandler(this.mWindowInstance.MainWindow_ResizeEnd);
     this.mWindowInstance.SourceInitialized += new EventHandler(this.Instance_SourceInitialized);
     WindowWndProcHandler.SetMenuDropDownAlignment();
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        internal IntPtr WndProc(
            IntPtr hwnd,
            int msg,
            IntPtr wParam,
            IntPtr lParam,
            ref bool handled)
        {
            if (WindowWndProcHandler.isLogWndProc)
            {
                Logger.Info("WndProcMessage: " + msg.ToString() + "~~" + wParam.ToString() + "~~" + lParam.ToString() + "~~");
            }
            switch ((WindowWndProcHandler.WM)msg)
            {
            case WindowWndProcHandler.WM.SETFOCUS:
                ThreadPool.QueueUserWorkItem((WaitCallback)(obj => this.mWindowInstance.Dispatcher.Invoke((Delegate)(() =>
                {
                    try
                    {
                        bool flag2 = true;
                        foreach (Window ownedWindow in this.mWindowInstance.OwnedWindows)
                        {
                            if (ownedWindow is CustomWindow customWindow)
                            {
                                if (!customWindow.IsShowGLWindow && !KMManager.sIsInScriptEditingMode)
                                {
                                    flag2 = false;
                                    Logger.Debug("OnFocusChanged window IsShowGLWindow false: " + customWindow.Name);
                                }
                            }
                            else
                            {
                                Logger.Debug("OnFocusChanged Non Custom window found! " + ownedWindow.Name);
                            }
                        }
                        if (flag2 && !this.mWindowInstance.mIsFocusComeFromImap && this.mWindowInstance.AllowFrontendFocusOnClientClick)
                        {
                            this.mWindowInstance.mFrontendHandler.ShowGLWindow();
                        }
                        this.mWindowInstance.mIsFocusComeFromImap = false;
                    }
                    catch
                    {
                    }
                }))));
                break;

            case WindowWndProcHandler.WM.SYSCOLORCHANGE:
            case WindowWndProcHandler.WM.WININICHANGE:
            case WindowWndProcHandler.WM.DISPLAYCHANGE:
            case WindowWndProcHandler.WM.DEVICECHANGE:
            case WindowWndProcHandler.WM.THEMECHANGED:
                using (new Timer((TimerCallback)(x => WindowWndProcHandler.SetMenuDropDownAlignment()), (object)null, TimeSpan.FromMilliseconds(2.0), TimeSpan.FromMilliseconds(-1.0)))
                    break;

            case WindowWndProcHandler.WM.GETMINMAXINFO:
                this.WmGetMinMaxInfo(hwnd, lParam);
                handled = true;
                break;

            case WindowWndProcHandler.WM.WINDOWPOSCHANGING:
                WindowWndProcHandler.WINDOWPOS structure = (WindowWndProcHandler.WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(WindowWndProcHandler.WINDOWPOS));
                if ((structure.flags & 2) != 0 || (Window)HwndSource.FromHwnd(hwnd).RootVisual == null || this.mWindowInstance.WindowState != WindowState.Normal)
                {
                    return(IntPtr.Zero);
                }
                bool flag1 = true;
                if (this.mWindowInstance.MinWidthScaled > structure.cx)
                {
                    structure.cx = this.mWindowInstance.MinWidthScaled;
                    structure.cy = (int)this.mWindowInstance.GetHeightFromWidth((double)structure.cx, true, false);
                    flag1        = false;
                }
                else if (this.mWindowInstance.MinHeightScaled > structure.cy)
                {
                    structure.cy = this.mWindowInstance.MinHeightScaled;
                    structure.cx = (int)this.mWindowInstance.GetWidthFromHeight((double)structure.cy, true, false);
                    flag1        = false;
                }
                if (structure.cx > this.mWindowInstance.MaxWidthScaled || structure.cy > this.mWindowInstance.MaxHeightScaled)
                {
                    structure.cx = this.mWindowInstance.MaxWidthScaled;
                    structure.cy = this.mWindowInstance.MaxHeightScaled;
                    flag1        = false;
                }
                if (flag1)
                {
                    if (this.mAdjustingWidth)
                    {
                        structure.cy = (int)this.mWindowInstance.GetHeightFromWidth((double)structure.cx, true, false);
                    }
                    else
                    {
                        structure.cx = (int)this.mWindowInstance.GetWidthFromHeight((double)structure.cy, true, false);
                    }
                }
                Marshal.StructureToPtr((object)structure, lParam, true);
                handled = true;
                break;

            case WindowWndProcHandler.WM.INPUT:
                int num = -1;
                if (this.mRawInput != null)
                {
                    num = RawInputClass.GetDeviceID(lParam);
                }
                if (num == 0 && SecurityMetrics.SecurityMetricsInstanceList.ContainsKey(this.mWindowInstance.mVmName))
                {
                    SecurityMetrics.SecurityMetricsInstanceList[this.mWindowInstance.mVmName].AddSecurityBreach(SecurityBreach.SYNTHETIC_INPUT, string.Empty);
                    break;
                }
                break;

            case WindowWndProcHandler.WM.SYSCOMMAND:
                if (wParam == (IntPtr)61696)
                {
                    handled = true;
                    break;
                }
                break;

            case WindowWndProcHandler.WM.ENTERMENULOOP:
                handled = true;
                break;
            }
            return(IntPtr.Zero);
        }