Example #1
0
        public override void RunAndWait(ProcessStartInfo path)
        {
            FakeBezelFrm bezel = null;

            var process = Process.Start(path);

            while (process != null)
            {
                if (process.WaitForExit(50))
                {
                    process = null;
                    break;
                }

                var hWnd = User32.FindHwnd(process.Id);
                if (hWnd == IntPtr.Zero)
                {
                    continue;
                }

                var name = User32.GetWindowText(hWnd);
                if (name != null && name.Contains("TSUGARU"))
                {
                    var style = User32.GetWindowStyle(hWnd);
                    if (style.HasFlag(WS.CAPTION))
                    {
                        int resX = (_resolution == null ? Screen.PrimaryScreen.Bounds.Width : _resolution.Width);
                        int resY = (_resolution == null ? Screen.PrimaryScreen.Bounds.Height : _resolution.Height);

                        style &= ~WS.CAPTION;
                        style &= ~WS.THICKFRAME;
                        style &= ~WS.MAXIMIZEBOX;
                        style &= ~WS.MINIMIZEBOX;
                        style &= ~WS.OVERLAPPED;
                        style &= ~WS.SYSMENU;
                        User32.SetWindowStyle(hWnd, style);

                        User32.SetWindowPos(hWnd, IntPtr.Zero, 0, 0, resX, resY, SWP.NOZORDER | SWP.FRAMECHANGED);

                        if (_bezelFileInfo != null)
                        {
                            bezel = _bezelFileInfo.ShowFakeBezel(_resolution);
                        }
                    }

                    break;
                }
            }

            if (process != null)
            {
                process.WaitForExit();
            }

            if (bezel != null)
            {
                bezel.Dispose();
            }
        }
Example #2
0
        public override void RunAndWait(ProcessStartInfo path)
        {
            FakeBezelFrm bezel = null;

            try
            {
                var px = Process.Start(path);

                while (!px.HasExited)
                {
                    if (px.WaitForExit(10))
                    {
                        break;
                    }

                    if (_bezelFileInfo != null)
                    {
                        IntPtr hWnd = User32.FindHwnds(px.Id).FirstOrDefault(h => User32.GetClassName(h) == "MYWIN");
                        if (hWnd != IntPtr.Zero)
                        {
                            var style = User32.GetWindowStyle(hWnd);
                            if (style.HasFlag(WS.CAPTION))
                            {
                                int resX = (_resolution == null ? Screen.PrimaryScreen.Bounds.Width : _resolution.Width);
                                int resY = (_resolution == null ? Screen.PrimaryScreen.Bounds.Height : _resolution.Height);

                                User32.SetWindowStyle(hWnd, style & ~WS.CAPTION);
                                User32.SetWindowPos(hWnd, IntPtr.Zero, 0, 0, resX, resY, SWP.NOZORDER | SWP.FRAMECHANGED);
                                User32.SetMenu(hWnd, IntPtr.Zero);

                                if (_bezelFileInfo != null && bezel == null)
                                {
                                    bezel = _bezelFileInfo.ShowFakeBezel(_resolution);
                                }
                            }
                        }
                    }

                    Application.DoEvents();
                }
            }
            catch { }
            finally
            {
                if (bezel != null)
                {
                    bezel.Dispose();
                }
            }
        }
Example #3
0
        public override void RunAndWait(ProcessStartInfo path)
        {
            FakeBezelFrm bezel = null;

            if (_bezelFileInfo != null)
            {
                bezel = _bezelFileInfo.ShowFakeBezel(_resolution);
            }

            base.RunAndWait(path);

            if (bezel != null)
            {
                bezel.Dispose();
            }
        }
Example #4
0
        public FakeBezelFrm ShowFakeBezel(ScreenResolution resolution)
        {
            int resX = (resolution == null ? Screen.PrimaryScreen.Bounds.Width : resolution.Width);
            int resY = (resolution == null ? Screen.PrimaryScreen.Bounds.Height : resolution.Height);

            var bezel = new FakeBezelFrm();

            bezel.TopMost = true;

            var file = GetStretchedBezel(PngFile, resX, resY);

            if (!bezel.SelectBezel(file, resX, resY))
            {
                bezel.Dispose();
                return(null);
            }

            bezel.Show();
            return(bezel);
        }