示例#1
0
        static void Main()
        {
            AppHost = new AppHost();
            SquirrelAwareApp.HandleEvents(
                OnInitialInstall,
                OnAppUpdate,
                onAppUninstall: OnAppUninstall,
                onFirstRun: OnFirstRun);

            Cef.EnableHighDPISupport();

            var cacheFolder = Path.Combine(Path.GetTempPath(), "cefsharp-cache");

            Cef.Initialize(new CefSettings
            {
                CachePath = cacheFolder
            });

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

            AppHost.Init().Start("http://*:2337/");
            "ServiceStack SelfHost listening at {0} ".Fmt(HostUrl).Print();
            Form           = new FormMain();
            Form.Disposed += (sender, args) => AppUpdater.Dispose();
            Application.Run(Form);
        }
示例#2
0
 public void PerformUpdate()
 {
     AppUpdater.ApplyUpdates(new AppSettings().GetString("UpdateManagerUrl")).ContinueWith(t =>
     {
         formMain.InvokeOnUiThreadIfRequired(() =>
         {
             formMain.Close();
             UpdateManager.RestartApp();
         });
     });
 }
示例#3
0
        public void Ready()
        {
            //Invoke on DOM ready
            var appSettings     = new AppSettings();
            var checkForUpdates = appSettings.Get <bool>("EnableAutoUpdate");

            if (!checkForUpdates)
            {
                return;
            }

            var releaseFolderUrl = appSettings.GetString("UpdateManagerUrl");

            try
            {
                var updatesAvailableTask = AppUpdater.CheckForUpdates(releaseFolderUrl);
                updatesAvailableTask.ContinueWith(isAvailable =>
                {
                    isAvailable.Wait(TimeSpan.FromMinutes(1));
                    bool updatesAvailable = isAvailable.Result;
                    //Only check once one launch then release UpdateManager.
                    if (!updatesAvailable)
                    {
                        AppUpdater.Dispose();
                        return;
                    }
                    if (formMain == null)
                    {
                        return;
                    }
                    // Notify web client updates are available.
                    formMain.InvokeOnUiThreadIfRequired(() =>
                    {
                        formMain.ChromiumBrowser.GetMainFrame().ExecuteJavaScriptAsync("window.updateAvailable();");
                    });
                });
            }
            catch (Exception e)
            {
                // Error reaching update server
            }
        }
示例#4
0
 public static void OnAppUninstall(Version version)
 {
     // Hook for application uninstall
     AppUpdater.RemoveShortcutForThisExe();
 }
示例#5
0
 public static void OnAppUpdate(Version version)
 {
     // Hook for application update, CheckForUpdates() initiates this.
     AppUpdater.CreateShortcutForThisExe();
 }
示例#6
0
 public static void OnInitialInstall(Version version)
 {
     // Hook for first install
     AppUpdater.CreateShortcutForThisExe();
 }