コード例 #1
0
ファイル: OobeWindow.xaml.cs プロジェクト: royvou/PowerToys
        public OobeWindow(PowerToysModules initialModule)
        {
            this.InitializeComponent();

            // Set window icon
            _hWnd      = WinRT.Interop.WindowNative.GetWindowHandle(this);
            _windowId  = Win32Interop.GetWindowIdFromWindow(_hWnd);
            _appWindow = AppWindow.GetFromWindowId(_windowId);
            _appWindow.SetIcon("icon.ico");

            OverlappedPresenter presenter = _appWindow.Presenter as OverlappedPresenter;

            presenter.IsResizable   = false;
            presenter.IsMinimizable = false;
            presenter.IsMaximizable = false;

            var dpi = NativeMethods.GetDpiForWindow(_hWnd);

            _currentDPI = dpi;
            float scalingFactor = (float)dpi / DefaultDPI;
            int   width         = (int)(ExpectedWidth * scalingFactor);
            int   height        = (int)(ExpectedHeight * scalingFactor);

            SizeInt32 size;

            size.Width  = width;
            size.Height = height;
            _appWindow.Resize(size);

            this.initialModule = initialModule;

            this.SizeChanged += OobeWindow_SizeChanged;

            ResourceLoader loader = ResourceLoader.GetForViewIndependentUse();

            Title = loader.GetString("OobeWindow_Title");

            if (shellPage != null)
            {
                shellPage.NavigateToModule(this.initialModule);
            }

            OobeShellPage.SetRunSharedEventCallback(() =>
            {
                return(Constants.PowerLauncherSharedEvent());
            });

            OobeShellPage.SetColorPickerSharedEventCallback(() =>
            {
                return(Constants.ShowColorPickerSharedEvent());
            });

            OobeShellPage.SetOpenMainWindowCallback((Type type) =>
            {
                App.OpenSettingsWindow(type);
            });
        }
コード例 #2
0
        private static void ResizeWindow(Window window, int width, int height)
        {
            IntPtr    hWnd      = WinRT.Interop.WindowNative.GetWindowHandle(window);
            WindowId  windowId  = Win32Interop.GetWindowIdFromWindow(hWnd);
            AppWindow appWindow = AppWindow.GetFromWindowId(windowId);

            var size = new SizeInt32(width, height);

            appWindow.Resize(size);
        }
コード例 #3
0
        private void InitWindow()
        {
            IntPtr    hWnd      = WinRT.Interop.WindowNative.GetWindowHandle(this);
            WindowId  windowId  = Win32Interop.GetWindowIdFromWindow(hWnd);
            AppWindow appWindow = AppWindow.GetFromWindowId(windowId);
            var       size      = new Windows.Graphics.SizeInt32();

            size.Width  = 1280;
            size.Height = 960;
            appWindow.Resize(size);
            appWindow.SetIcon("icon.ico");
            this.Title = "LR(1)语义分析过程表";
        }
コード例 #4
0
        public OobeWindow(PowerToysModules initialModule)
        {
            this.InitializeComponent();

            // Set window icon
            var       hWnd      = WinRT.Interop.WindowNative.GetWindowHandle(this);
            WindowId  windowId  = Win32Interop.GetWindowIdFromWindow(hWnd);
            AppWindow appWindow = AppWindow.GetFromWindowId(windowId);

            appWindow.SetIcon("icon.ico");

            OverlappedPresenter presenter = appWindow.Presenter as OverlappedPresenter;

            presenter.IsResizable   = false;
            presenter.IsMinimizable = false;
            presenter.IsMaximizable = false;

            SizeInt32 size;

            size.Width  = 1650;
            size.Height = 1050;
            appWindow.Resize(size);

            this.initialModule = initialModule;

            ResourceLoader loader = ResourceLoader.GetForViewIndependentUse();

            Title = loader.GetString("OobeWindow_Title");

            if (shellPage != null)
            {
                shellPage.NavigateToModule(this.initialModule);
            }

            OobeShellPage.SetRunSharedEventCallback(() =>
            {
                return(Constants.PowerLauncherSharedEvent());
            });

            OobeShellPage.SetColorPickerSharedEventCallback(() =>
            {
                return(Constants.ShowColorPickerSharedEvent());
            });

            OobeShellPage.SetOpenMainWindowCallback((Type type) =>
            {
                App.OpenSettingsWindow(type);
            });
        }
コード例 #5
0
ファイル: OobeWindow.xaml.cs プロジェクト: jsoref/PowerToys
        private void OobeWindow_SizeChanged(object sender, WindowSizeChangedEventArgs args)
        {
            var dpi = NativeMethods.GetDpiForWindow(_hWnd);

            if (_currentDPI != dpi)
            {
                // Reacting to a DPI change. Should not cause a resize -> sizeChanged loop.
                _currentDPI = dpi;
                float     scalingFactor = (float)dpi / DefaultDPI;
                int       width         = (int)(ExpectedWidth * scalingFactor);
                int       height        = (int)(ExpectedHeight * scalingFactor);
                SizeInt32 size;
                size.Width  = width;
                size.Height = height;
                _appWindow.Resize(size);
            }
        }
コード例 #6
0
        private void InitWindow()
        {
            IntPtr    hWnd      = WinRT.Interop.WindowNative.GetWindowHandle(this);
            WindowId  windowId  = Win32Interop.GetWindowIdFromWindow(hWnd);
            AppWindow appWindow = AppWindow.GetFromWindowId(windowId);
            var       size      = new Windows.Graphics.SizeInt32();

            size.Width  = 710;
            size.Height = 850;
            appWindow.Resize(size);
            appWindow.SetIcon("icon.ico");
            this.Title   = "C--文法产生式";
            this.Closed += (o, e) =>
            {
                MainWebView.Close();
            };
            LoadedWebview();
        }
コード例 #7
0
        public App()
        {
            InitializeComponent();

            Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) =>
            {
#if WINDOWS
                handler.PlatformView.Activate();

                IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(handler.PlatformView);
                AppWindow appWindow = AppWindow.GetFromWindowId(Win32Interop.GetWindowIdFromWindow(windowHandle));

                appWindow.Resize(new SizeInt32(WindowWidth, WindowHeight));
#endif
            });

            MainPage = new NavigationPage(new MainPage());
        }
コード例 #8
0
        private void SizeBtn_Click(object sender, RoutedEventArgs e)
        {
            int windowWidth  = 0;
            int windowHeight = 0;

            try
            {
                windowWidth  = int.Parse(WidthTextBox.Text);
                windowHeight = int.Parse(HeightTextBox.Text);
            }
            catch (FormatException)
            {
                // Silently ignore invalid input...
            }

            if (windowHeight > 0 && windowWidth > 0)
            {
                _mainAppWindow.Resize(new Windows.Graphics.SizeInt32(windowWidth, windowHeight));
            }
        }
コード例 #9
0
        public MainWindow()
        {
            this.InitializeComponent();
            IntPtr    hWnd      = WinRT.Interop.WindowNative.GetWindowHandle(this);
            WindowId  windowId  = Win32Interop.GetWindowIdFromWindow(hWnd);
            AppWindow appWindow = AppWindow.GetFromWindowId(windowId);
            var       size      = new Windows.Graphics.SizeInt32();

            size.Width  = 1280;
            size.Height = 960;
            appWindow.Resize(size);
            appWindow.SetIcon("icon.ico");

            this.Title          = "C--编译器";
            Lexcial.IsEnabled   = false;
            Syntactic.IsEnabled = false;
            Semantic.IsEnabled  = false;
            Mips.IsEnabled      = false;
            LoadedWebview();
            this.Closed += (o, e) =>
            {
                MainWebView.Close();
            };
        }