コード例 #1
0
        public MainWindow(PersistentWindowProcessor pwp)
        {
            this.Pwp = pwp;
            this.DiagnosticsModel = new DiagnosticsViewModel();

            InitializeComponent();
        }
コード例 #2
0
        static void Main(string[] args)
        {
#if (!DEBUG)
            Mutex singleInstMutex = new Mutex(true, Application.ProductName);
            if (!singleInstMutex.WaitOne(TimeSpan.Zero, true))
            {
                MessageBox.Show($"Only one instance of {Application.ProductName} can be run!");
                return;
            }
            else
            {
                singleInstMutex.ReleaseMutex();
            }
#endif

            using (PersistentWindowProcessor pwp = new PersistentWindowProcessor())
            {
                pwp.Start();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                using (new SystrayForm(pwp))
                {
                    Application.Run();
                }
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            bool no_splash  = false;
            bool dry_run    = false;
            bool fix_zorder = false;

            foreach (var arg in args)
            {
                switch (arg)
                {
                case "-silent":
                    silent    = true;
                    no_splash = true;
                    break;

                case "-splash_off":
                    no_splash = true;
                    break;

                case "-notification_on":
                    notification_on = true;
                    break;

                case "-dry_run":
                    Log.Trace("dry_run mode");
                    dry_run = true;
                    break;

                case "-fix_zorder":
                    fix_zorder = true;
                    break;
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            systrayForm = new SystrayForm();

            pwp                   = new PersistentWindowProcessor();
            pwp.dryRun            = dry_run;
            pwp.fixZorder         = fix_zorder;
            pwp.showRestoreTip    = ShowRestoreTip;
            pwp.hideRestoreTip    = HideRestoreTip;
            pwp.enableRestoreMenu = EnableRestoreMenu;

            if (!pwp.Start())
            {
                return;
            }

            if (!no_splash)
            {
                StartSplashForm();
            }

            Application.Run();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: lukefor/persistentwindows
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var persistentWindowProcessor = new PersistentWindowProcessor();

            persistentWindowProcessor.Start();
            new SystrayForm(persistentWindowProcessor);
            Application.Run();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            bool no_splash = false;

            foreach (var arg in args)
            {
                switch (arg)
                {
                case "-silent":
                    no_splash = true;
                    break;
                }
            }

/*
 *          Mutex singleInstMutex = new Mutex(true, Application.ProductName);
 *          if (!singleInstMutex.WaitOne(TimeSpan.Zero, true))
 *          {
 *              MessageBox.Show($"Only one inst of {Application.ProductName} can be run!");
 *              //Application.Exit();
 *              return;
 *          }
 *          else
 *          {
 *              singleInstMutex.ReleaseMutex();
 *          }
 */

            pwp = new PersistentWindowProcessor();
            pwp.showRestoreTip = ShowRestoreTip;
            pwp.hideRestoreTip = HideRestoreTip;

            if (!pwp.Start())
            {
                return;
            }

            if (!no_splash)
            {
                StartSplashForm();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            systrayForm = new SystrayForm();
            Application.Run();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: garyd9/PersistentWindows
        static void Main(string[] args)
        {
            bool splash                 = true;
            bool dry_run                = false; //dry run mode without real restore, for debug purpose only
            bool fix_zorder             = false;
            bool fix_zorder_specified   = false;
            bool delay_start            = false;
            bool redraw_desktop         = false;
            bool redirect_appdata       = false; // use "." instead of appdata/local/PersistentWindows to store db file
            bool offscreen_fix          = true;
            bool enhanced_offscreen_fix = false;
            bool prompt_session_restore = false;
            bool check_upgrade          = true;

            foreach (var arg in args)
            {
                if (delay_start)
                {
                    delay_start = false;
                    int seconds = Int32.Parse(arg);
                    Thread.Sleep(1000 * seconds);
                    continue;
                }

                switch (arg)
                {
                case "-silent":
                    silent = true;
                    splash = false;
                    break;

                case "-splash_off":
                case "-splash=0":
                    splash = false;
                    break;

                case "-notification_on":
                case "-notification=1":
                    notification = true;
                    break;

                case "-dry_run":
                    dry_run = true;
                    break;

                case "-fix_zorder=0":
                    fix_zorder           = false;
                    fix_zorder_specified = true;
                    break;

                case "-fix_zorder":
                case "-fix_zorder=1":
                    fix_zorder           = true;
                    fix_zorder_specified = true;
                    break;

                case "-delay_start":
                    delay_start = true;
                    break;

                case "-redraw_desktop":
                    redraw_desktop = true;
                    break;

                case "-redirect_appdata":
                    redirect_appdata = true;
                    break;

                case "-enhanced_offscreen_fix":
                    enhanced_offscreen_fix = true;
                    break;

                case "-disable_offscreen_fix":
                    offscreen_fix = false;
                    break;

                case "-offscreen_fix=0":
                    offscreen_fix = false;
                    break;

                case "-prompt_session_restore":
                    prompt_session_restore = true;
                    break;

                case "-check_upgrade=0":
                    check_upgrade = false;
                    break;
                }
            }

            while (String.IsNullOrEmpty(PersistentWindowProcessor.GetDisplayKey()))
            {
                Thread.Sleep(5000);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string productName   = System.Windows.Forms.Application.ProductName;
            string appDataFolder = redirect_appdata ? "." :
                                   Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                                productName);

#if DEBUG
            //avoid db path conflict with release version
            //appDataFolder = ".";
            appDataFolder = AppDomain.CurrentDomain.BaseDirectory;
#endif
            string icon_path = Path.Combine(appDataFolder, "pwIcon.ico");
            if (File.Exists(icon_path))
            {
                IdleIcon = new System.Drawing.Icon(icon_path);
            }
            else
            {
                IdleIcon = Properties.Resources.pwIcon;
            }

            icon_path = Path.Combine(appDataFolder, "pwIconBusy.ico");
            if (File.Exists(icon_path))
            {
                BusyIcon = new System.Drawing.Icon(icon_path);
            }
            else
            {
                BusyIcon = Properties.Resources.pwIconBusy;
            }

            systrayForm = new SystrayForm();
            systrayForm.enableUpgradeNotice = check_upgrade;
            if (check_upgrade)
            {
                systrayForm.upgradeNoticeMenuItem.Text = "Disable upgrade notice";
            }
            else
            {
                systrayForm.upgradeNoticeMenuItem.Text = "Enable upgrade notice";
            }

            pwp        = new PersistentWindowProcessor();
            pwp.dryRun = dry_run;
            if (fix_zorder_specified)
            {
                if (fix_zorder)
                {
                    pwp.fixZorder = 2; //force z-order recovery for all
                }
                else
                {
                    pwp.fixZorder = 0; //no z-order recovery at all
                }
            }
            else
            {
                // pwp.fixZorder = 1 //do z-order recovery only for snapshot
            }

            pwp.showRestoreTip        = ShowRestoreTip;
            pwp.hideRestoreTip        = HideRestoreTip;
            pwp.enableRestoreMenu     = EnableRestoreMenu;
            pwp.redrawDesktop         = redraw_desktop;
            pwp.redirectAppDataFolder = redirect_appdata;
            pwp.enhancedOffScreenFix  = enhanced_offscreen_fix;
            pwp.enableOffScreenFix    = offscreen_fix;
            pwp.promptSessionRestore  = prompt_session_restore;

            if (!pwp.Start())
            {
                systrayForm.notifyIconMain.Visible = false;
                return;
            }

            if (splash)
            {
                StartSplashForm();
            }

            Application.Run();
        }
コード例 #7
0
 public SystrayForm(PersistentWindowProcessor persistentWindowProcessor)
 {
     m_persistentWindowProcessor = persistentWindowProcessor;
     InitializeComponent();
 }
コード例 #8
0
 public SystrayForm(PersistentWindowProcessor processor)
     : this()
 {
     _processor = processor;
 }
コード例 #9
0
        static void Main(string[] args)
        {
            bool no_splash      = false;
            bool dry_run        = false;
            bool fix_zorder     = false;
            bool delay_start    = false;
            bool redraw_desktop = false;

            foreach (var arg in args)
            {
                if (delay_start)
                {
                    delay_start = false;
                    int seconds = Int32.Parse(arg);
                    Thread.Sleep(1000 * seconds);
                    continue;
                }

                switch (arg)
                {
                case "-silent":
                    silent    = true;
                    no_splash = true;
                    break;

                case "-splash_off":
                    no_splash = true;
                    break;

                case "-notification_on":
                    notification_on = true;
                    break;

                case "-dry_run":
                    Log.Trace("dry_run mode");
                    dry_run = true;
                    break;

                case "-fix_zorder":
                    fix_zorder = true;
                    break;

                case "-delay_start":
                    delay_start = true;
                    break;

                case "-redraw_desktop":
                    redraw_desktop = true;
                    break;
                }
            }

            while (String.IsNullOrEmpty(PersistentWindowProcessor.GetDisplayKey()))
            {
                Thread.Sleep(5000);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            systrayForm = new SystrayForm();

            pwp                   = new PersistentWindowProcessor();
            pwp.dryRun            = dry_run;
            pwp.fixZorder         = fix_zorder;
            pwp.showRestoreTip    = ShowRestoreTip;
            pwp.hideRestoreTip    = HideRestoreTip;
            pwp.enableRestoreMenu = EnableRestoreMenu;
            pwp.redrawDesktop     = redraw_desktop;

            if (!pwp.Start())
            {
                return;
            }

            if (!no_splash)
            {
                StartSplashForm();
            }

            Application.Run();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: g0fish/PersistentWindows
        static void Main(string[] args)
        {
            bool splash                 = true;
            bool dry_run                = false; //dry run mode without real restore, for debug purpose only
            bool fix_zorder             = false;
            bool fix_zorder_specified   = false;
            bool delay_start            = false;
            bool redraw_desktop         = false;
            bool redirect_appdata       = false; // use "." instead of appdata/local/PersistentWindows to store db file
            bool offscreen_fix          = true;
            bool enhanced_offscreen_fix = false;
            bool prompt_session_restore = false;
            bool check_upgrade          = true;

            foreach (var arg in args)
            {
                if (delay_start)
                {
                    delay_start = false;
                    int seconds = Int32.Parse(arg);
                    Thread.Sleep(1000 * seconds);
                    continue;
                }

                switch (arg)
                {
                case "-silent":
                    silent = true;
                    splash = false;
                    break;

                case "-splash_off":
                case "-splash=0":
                    splash = false;
                    break;

                case "-notification_on":
                case "-notification=1":
                    notification = true;
                    break;

                case "-dry_run":
                    dry_run = true;
                    break;

                case "-fix_zorder=0":
                    fix_zorder           = false;
                    fix_zorder_specified = true;
                    break;

                case "-fix_zorder":
                case "-fix_zorder=1":
                    fix_zorder           = true;
                    fix_zorder_specified = true;
                    break;

                case "-delay_start":
                    delay_start = true;
                    break;

                case "-redraw_desktop":
                    redraw_desktop = true;
                    break;

                case "-redirect_appdata":
                    redirect_appdata = true;
                    break;

                case "-enhanced_offscreen_fix":
                    enhanced_offscreen_fix = true;
                    break;

                case "-disable_offscreen_fix":
                    offscreen_fix = false;
                    break;

                case "-offscreen_fix=0":
                    offscreen_fix = false;
                    break;

                case "-prompt_session_restore":
                    prompt_session_restore = true;
                    break;

                case "-check_upgrade=0":
                    check_upgrade = false;
                    break;
                }
            }

            while (String.IsNullOrEmpty(PersistentWindowProcessor.GetDisplayKey()))
            {
                Thread.Sleep(5000);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            systrayForm = new SystrayForm();
            systrayForm.enableUpgradeNotice = check_upgrade;
            if (check_upgrade)
            {
                systrayForm.upgradeNoticeMenuItem.Text = "Disable upgrade notice";
            }
            else
            {
                systrayForm.upgradeNoticeMenuItem.Text = "Enable upgrade notice";
            }

            pwp        = new PersistentWindowProcessor();
            pwp.dryRun = dry_run;
            if (fix_zorder_specified)
            {
                if (fix_zorder)
                {
                    pwp.fixZorder = 2; //force z-order recovery for all
                }
                else
                {
                    pwp.fixZorder = 0; //no z-order recovery at all
                }
            }
            else
            {
                // pwp.fixZorder = 1 //do z-order recovery only for snapshot
            }

            pwp.showRestoreTip        = ShowRestoreTip;
            pwp.hideRestoreTip        = HideRestoreTip;
            pwp.enableRestoreMenu     = EnableRestoreMenu;
            pwp.redrawDesktop         = redraw_desktop;
            pwp.redirectAppDataFolder = redirect_appdata;
            pwp.enhancedOffScreenFix  = enhanced_offscreen_fix;
            pwp.enableOffScreenFix    = offscreen_fix;
            pwp.promptSessionRestore  = prompt_session_restore;

            if (!pwp.Start())
            {
                systrayForm.notifyIconMain.Visible = false;
                return;
            }

            if (splash)
            {
                StartSplashForm();
            }

            Application.Run();
        }
コード例 #11
0
 public SystrayForm(PersistentWindowProcessor pwp)
 {
     this.pwp = pwp;
     InitializeComponent();
 }
コード例 #12
0
ファイル: Program.cs プロジェクト: shana/PersistentWindows
        static void Main(string[] args)
        {
            bool no_splash              = false;
            bool dry_run                = false;
            bool fix_zorder             = false;
            bool delay_start            = false;
            bool redraw_desktop         = false;
            bool redirect_appdata       = false; // use "." instead of appdata/local/PersistentWindows to store db file
            bool enhanced_offscreen_fix = false;
            bool disable_offscreen_fix  = false;

            foreach (var arg in args)
            {
                if (delay_start)
                {
                    delay_start = false;
                    int seconds = Int32.Parse(arg);
                    Thread.Sleep(1000 * seconds);
                    continue;
                }

                switch (arg)
                {
                case "-silent":
                    silent    = true;
                    no_splash = true;
                    break;

                case "-splash_off":
                    no_splash = true;
                    break;

                case "-notification_on":
                    notification_on = true;
                    break;

                case "-dry_run":
                    Log.Trace("dry_run mode");
                    dry_run = true;
                    break;

                case "-fix_zorder":
                    fix_zorder = true;
                    break;

                case "-delay_start":
                    delay_start = true;
                    break;

                case "-redraw_desktop":
                    redraw_desktop = true;
                    break;

                case "-redirect_appdata":
                    redirect_appdata = true;
                    break;

                case "-enhanced_offscreen_fix":
                    enhanced_offscreen_fix = true;
                    break;

                case "-disable_offscreen_fix":
                    disable_offscreen_fix = true;
                    break;
                }
            }

            while (String.IsNullOrEmpty(PersistentWindowProcessor.GetDisplayKey()))
            {
                Thread.Sleep(5000);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            systrayForm = new SystrayForm();

            pwp                       = new PersistentWindowProcessor();
            pwp.dryRun                = dry_run;
            pwp.fixZorder             = fix_zorder;
            pwp.showRestoreTip        = ShowRestoreTip;
            pwp.hideRestoreTip        = HideRestoreTip;
            pwp.enableRestoreMenu     = EnableRestoreMenu;
            pwp.redrawDesktop         = redraw_desktop;
            pwp.redirectAppDataFolder = redirect_appdata;
            pwp.enhancedOffScreenFix  = enhanced_offscreen_fix;
            pwp.disableOffScreenFix   = disable_offscreen_fix;

            if (!pwp.Start())
            {
                systrayForm.notifyIconMain.Visible = false;
                return;
            }

            if (!no_splash)
            {
                StartSplashForm();
            }

            Application.Run();
        }
コード例 #13
0
        static void Main(string[] args)
        {
            bool splash                          = true;
            int  delay_start                     = 0;
            bool redirect_appdata                = false; // use "." instead of appdata/local/PersistentWindows to store db file
            bool prompt_session_restore          = false;
            int  halt_restore                    = 0;     //seconds to wait before trying restore again, due to frequent monitor config changes
            bool halt_restore_specified          = false;
            bool dry_run                         = false; //dry run mode without real restore, for debug purpose only
            bool fix_zorder                      = false;
            bool fix_zorder_specified            = false;
            bool show_desktop                    = false; //show desktop when display changes
            bool redraw_desktop                  = false;
            bool offscreen_fix                   = true;
            bool fix_unminimized_window          = true;
            bool enhanced_offscreen_fix          = false;
            bool auto_restore_missing_windows    = false;
            bool auto_restore_from_db_at_startup = false;
            bool restore_one_window_per_process  = false;
            bool check_upgrade                   = true;
            bool auto_upgrade                    = false;

            foreach (var arg in args)
            {
                CmdArgs += arg + " ";

                if (halt_restore_specified)
                {
                    halt_restore_specified = false;
                    halt_restore           = Int32.Parse(arg);
                    continue;
                }
                else if (delay_start != 0)
                {
                    delay_start = 0;
                    Thread.Sleep(Int32.Parse(arg) * 1000);
                    continue;
                }

                switch (arg)
                {
                case "-silent":
                    silent = true;
                    splash = false;
                    break;

                case "-splash_off":
                case "-splash=0":
                    splash = false;
                    break;

                case "-delay_start":
                    delay_start = 1;
                    break;

                case "-redirect_appdata":
                    redirect_appdata = true;
                    break;

                case "-show_desktop_when_display_changes":
                    LogEvent("show desktop = 1");
                    show_desktop = true;
                    break;

                case "-enhanced_offscreen_fix":
                    enhanced_offscreen_fix = true;
                    break;

                case "-disable_offscreen_fix":
                    offscreen_fix = false;
                    break;

                case "-offscreen_fix=0":
                case "-fix_offscreen=0":
                case "-fix_offscreen_window=0":
                    offscreen_fix = false;
                    break;

                case "-fix_unminimized=0":
                case "-fix_unminimized_window=0":
                    fix_unminimized_window = false;
                    break;

                case "-prompt_session_restore":
                    prompt_session_restore = true;
                    break;

                case "-halt_restore":
                    halt_restore_specified = true;
                    break;

                case "-notification_on":
                case "-notification=1":
                    notification = true;
                    break;

                case "-dry_run":
                    dry_run = true;
                    break;

                case "-fix_zorder=0":
                    fix_zorder           = false;
                    fix_zorder_specified = true;
                    break;

                case "-fix_zorder":
                case "-fix_zorder=1":
                    fix_zorder           = true;
                    fix_zorder_specified = true;
                    break;

                case "-redraw_desktop":
                    redraw_desktop = true;
                    break;

                case "-auto_restore_missing_windows":
                case "-auto_restore_missing_windows=1":
                    auto_restore_missing_windows = true;
                    break;

                case "-auto_restore_missing_windows=2":
                    auto_restore_from_db_at_startup = true;
                    break;

                case "-auto_restore_missing_windows=3":
                    auto_restore_from_db_at_startup = true;
                    auto_restore_missing_windows    = true;
                    break;

                case "-restore_one_window_per_process=1":
                    restore_one_window_per_process = true;
                    break;

                case "-check_upgrade=0":
                    check_upgrade = false;
                    break;

                case "-auto_upgrade=1":
                    auto_upgrade = true;
                    break;
                }
            }

            while (String.IsNullOrEmpty(PersistentWindowProcessor.GetDisplayKey()))
            {
                Thread.Sleep(5000);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string productName   = System.Windows.Forms.Application.ProductName;
            string appDataFolder = redirect_appdata ? "." :
                                   Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                                productName);

#if DEBUG
            //avoid db path conflict with release version
            //appDataFolder = ".";
            appDataFolder = AppDomain.CurrentDomain.BaseDirectory;
#endif
            AppdataFolder = appDataFolder;

            string icon_path = Path.Combine(appDataFolder, "pwIcon.ico");
            if (File.Exists(icon_path))
            {
                IdleIcon = new System.Drawing.Icon(icon_path);
            }
            else
            {
                IdleIcon = Properties.Resources.pwIcon;
            }

            icon_path = Path.Combine(appDataFolder, "pwIconBusy.ico");
            if (File.Exists(icon_path))
            {
                BusyIcon = new System.Drawing.Icon(icon_path);
            }
            else
            {
                BusyIcon = Properties.Resources.pwIconBusy;
            }

            systrayForm = new SystrayForm();
            systrayForm.enableUpgradeNotice = check_upgrade;
            systrayForm.autoUpgrade         = auto_upgrade;
            if (check_upgrade)
            {
                systrayForm.upgradeNoticeMenuItem.Text = "Disable upgrade notice";
            }
            else
            {
                systrayForm.upgradeNoticeMenuItem.Text = "Enable upgrade notice";
            }

            pwp        = new PersistentWindowProcessor();
            pwp.icon   = IdleIcon;
            pwp.dryRun = dry_run;
            if (fix_zorder_specified)
            {
                if (fix_zorder)
                {
                    pwp.fixZorder = 2; //force z-order recovery for all
                }
                else
                {
                    pwp.fixZorder = 0; //no z-order recovery at all
                }
            }
            else
            {
                // pwp.fixZorder = 1 //do z-order recovery only for snapshot
            }

            pwp.showRestoreTip             = ShowRestoreTip;
            pwp.hideRestoreTip             = HideRestoreTip;
            pwp.enableRestoreMenu          = EnableRestoreMenu;
            pwp.showDesktop                = show_desktop;
            pwp.redrawDesktop              = redraw_desktop;
            pwp.redirectAppDataFolder      = redirect_appdata;
            pwp.enhancedOffScreenFix       = enhanced_offscreen_fix;
            pwp.enableOffScreenFix         = offscreen_fix;
            pwp.fixUnminimizedWindow       = fix_unminimized_window;
            pwp.promptSessionRestore       = prompt_session_restore;
            pwp.autoRestoreMissingWindows  = auto_restore_missing_windows;
            pwp.restoreOneWindowPerProcess = restore_one_window_per_process;
            pwp.haltRestore                = halt_restore;

            if (!pwp.Start(auto_restore_from_db_at_startup))
            {
                systrayForm.notifyIconMain.Visible = false;
                return;
            }

            if (splash)
            {
                StartSplashForm();
            }

            Application.Run();
        }