当前位置: 首页>>代码示例>>C#>>正文


C# UpdateManager.CreateShortcutForThisExe方法代码示例

本文整理汇总了C#中Squirrel.UpdateManager.CreateShortcutForThisExe方法的典型用法代码示例。如果您正苦于以下问题:C# UpdateManager.CreateShortcutForThisExe方法的具体用法?C# UpdateManager.CreateShortcutForThisExe怎么用?C# UpdateManager.CreateShortcutForThisExe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Squirrel.UpdateManager的用法示例。


在下文中一共展示了UpdateManager.CreateShortcutForThisExe方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: App_OnStartup

 private void App_OnStartup(object sender, StartupEventArgs e)
 {
     if (e.Args.Length > 0)
     {
         using (var mgr = new UpdateManager("http://zizit.lt"))
         {
             // Note, in most of these scenarios, the app exits after this method
             // completes!
             SquirrelAwareApp.HandleEvents(
                 onInitialInstall: v =>
                 {
                     mgr.CreateShortcutForThisExe();
                     Shutdown();
                 },
                 onAppUpdate: v =>
                 {
                     mgr.CreateShortcutForThisExe();
                     Shutdown();
                 },
                 onAppUninstall: v =>
                 {
                     mgr.RemoveShortcutForThisExe();
                     Shutdown();
                 },
                 onFirstRun: () =>
                 {
                     MessageBox.Show("Success", "Installation successful", MessageBoxButton.OK);
                     Shutdown();
                 });
         }
     }
 }
开发者ID:Rayvid,项目名称:Zizit.Sigils,代码行数:32,代码来源:App.xaml.cs

示例2: RegisterSquirrelEvents

 private void RegisterSquirrelEvents()
 {
     var location = UpdateHelper.AppUpdateCheckLocation;
     var appName = Assembly.GetExecutingAssembly().GetName().Name;
     using (var mgr = new UpdateManager(location, appName, FrameworkVersion.Net45))
     {
         SquirrelAwareApp.HandleEvents(
             onInitialInstall: v => mgr.CreateShortcutForThisExe(),
             onAppUpdate: v => mgr.CreateShortcutForThisExe(),
             onAppUninstall: v => mgr.RemoveShortcutForThisExe()
         );
     }
 }
开发者ID:amazzanti,项目名称:Resquirrelly,代码行数:13,代码来源:App.xaml.cs

示例3: Main

        static void Main()
        {
            try {
                using (var mgr = new UpdateManager("https://s3.amazonaws.com/steamdesktopauthenticator/releases"))
                {
                    // Note, in most of these scenarios, the app exits after this method
                    // completes!
                    SquirrelAwareApp.HandleEvents(
                      onInitialInstall: v => mgr.CreateShortcutForThisExe(),
                      onAppUpdate: v => mgr.CreateShortcutForThisExe(),
                      onAppUninstall: v => mgr.RemoveShortcutForThisExe(),
                      onFirstRun: () => ShowTheWelcomeWizard = true);
                }
            }
            catch
            {
                // Not using a squirrel app
            }

            // run the program only once
            if (PriorProcess() != null)
            {
                MessageBox.Show("Another instance of the app is already running.");
                return;
            }

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

            Manifest man = Manifest.GetManifest();
            if(man.FirstRun)
            {
                // Install VC++ Redist and wait
                new InstallRedistribForm().ShowDialog();

                if (man.Entries.Count > 0)
                {
                    // Already has accounts, just run
                    Application.Run(new MainForm());
                }
                else
                {
                    // No accounts, run welcome form
                    Application.Run(new WelcomeForm());
                }
            }
            else
            {
                Application.Run(new MainForm());
            }
        }
开发者ID:Dabann,项目名称:SteamDesktopAuthenticator,代码行数:51,代码来源:Program.cs

示例4: Main

        private static void Main()
        {
            Task.Run(async () =>
            {
                var upgraded = false;
                while (!upgraded)
                {
                    await Task.Delay(TimeSpan.FromSeconds(5));

                    using (
                        var mgr = new UpdateManager(@"http://distribute.klonmaschine.de/metrothing/", "metrothing",
                            FrameworkVersion.Net45))
                    {
                        SquirrelAwareApp.HandleEvents(
                            v => mgr.CreateShortcutForThisExe(),
                            v => mgr.CreateShortcutForThisExe(),
                            onAppUninstall: v => mgr.RemoveShortcutForThisExe());

                        // Try the update
                        try
                        {
                            var updateInfo = await mgr.CheckForUpdate();

                            if (updateInfo != null && updateInfo.ReleasesToApply.Count > 0)
                            {
            #if !DEBUG
                                await mgr.UpdateApp();
            #endif

                                upgraded = true;
                                Singleton<InstallationManager>.Instance.Updated(
                                    updateInfo.FutureReleaseEntry.Version.ToString(),
                                    String.Join("", updateInfo.FetchReleaseNotes().Values));
                            }
                        }
                        catch (Exception e)
                        {
                            Trace.WriteLine("Squirrel update failed: " + e.Message);
                        }
                    }

                    if (!upgraded)
                        await Task.Delay(TimeSpan.FromHours(12));
                }
            });

            MetroThing.Program.Main();
        }
开发者ID:kreischweide,项目名称:metrothing,代码行数:48,代码来源:Program.cs

示例5: AppBootstrapper

        public AppBootstrapper()
        {
            using (var mgr = new UpdateManager(AppInfo.UpdatePath, "Espera", FrameworkVersion.Net45))
            {
                // We have to re-implement the things Squirrel does for normal applications, because
                // we're marked as Squirrel-aware
                SquirrelAwareApp.HandleEvents(
                    onInitialInstall: v => mgr.CreateShortcutForThisExe(),
                    onAppUpdate: v =>
                    {
                        mgr.CreateShortcutForThisExe();
                        // Update the shortcut for the portable version
                        mgr.CreateShortcutsForExecutable("Espera.exe", ShortcutLocation.AppRoot, false);
                    },
                    onAppUninstall: v => mgr.RemoveShortcutForThisExe());
            }

            this.Initialize();
        }
开发者ID:reactiveui-forks,项目名称:Espera,代码行数:19,代码来源:AppBootstrapper.cs

示例6: App

 public App()
 {
     try
     {
         using (var mgr = new UpdateManager(ConfigurationManager.AppSettings["UpdatePath"]))
         {
             // Note, in most of these scenarios, the app exits after this method
             // completes!
             
             SquirrelAwareApp.HandleEvents(
                 onInitialInstall: v => mgr.CreateShortcutForThisExe(),
                 onAppUpdate: v => mgr.CreateShortcutForThisExe(),
                 onAppUninstall: v => mgr.RemoveShortcutForThisExe());
         }
     }
     catch (Exception)
     {
         
     }
    
 }
开发者ID:ledgarl,项目名称:Samples,代码行数:21,代码来源:App.xaml.cs

示例7: CheckForUpdates

        private async void CheckForUpdates()
        {
            using (var mgr = new UpdateManager("http://arkmanager.teamitf.co.uk/iNGen/Releases/", "iNGen"))
            {
                SquirrelAwareApp.HandleEvents(
                    onInitialInstall: v => mgr.CreateShortcutForThisExe(),
                    onAppUpdate: v => mgr.CreateShortcutForThisExe(),
                    onAppUninstall: v => mgr.RemoveShortcutForThisExe());

                try
                {
                    UpdateInfo updateInfo = await mgr.CheckForUpdate();
                    if (updateInfo.FutureReleaseEntry != null)
                    {
                        if (updateInfo.CurrentlyInstalledVersion != null)
                        {
                            XElement xelement = XElement.Load("http://arkmanager.teamitf.co.uk/iNGen/version.xml");
                            StringReader reader = new StringReader(xelement.ToString());
                            System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Models.AppUpdates));
                            Models.AppUpdates appUpdates = (Models.AppUpdates)xmlSerializer.Deserialize(reader);
                            string changes = MakeChangeLog(appUpdates);
                            if (updateInfo.CurrentlyInstalledVersion.Version == updateInfo.FutureReleaseEntry.Version) return;
                            var updateDialog = new Views.AppUpdate(updateInfo, changes) { Owner = this };
                            var result = updateDialog.ShowDialog();
                            if (result == false) return;
                            await mgr.UpdateApp();
                            var oldPath = System.IO.Path.Combine(mgr.RootAppDirectory, "app-" + updateInfo.CurrentlyInstalledVersion.Version.ToString(), "UserData");
                            var newPath = System.IO.Path.Combine(mgr.RootAppDirectory, "app-" + updateInfo.FutureReleaseEntry.Version.ToString(), "UserData");
                            DirectoryInfo d = new DirectoryInfo(oldPath);
                            var files = d.GetFiles();
                            foreach (var file in files)
                            {
                                file.CopyTo(System.IO.Path.Combine(newPath, file.Name), true);
                            }

                            MessageBox.Show("iNGen Has been Updated. Please Re-Launch It.");
                            Application.Current.Shutdown(0);
                        }
                        else
                        {
                            await mgr.UpdateApp();
                            MessageBox.Show("iNGen Has been Updated. Please Re-Launch It.");
                            Application.Current.Shutdown(0);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Checking for Updates Failed: " + ex.Message);
                }
            }
        }
开发者ID:prom3theu5,项目名称:iNGEN-Ark-RCON-Desktop,代码行数:52,代码来源:MainWindow.xaml.cs

示例8: OnStartup

        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            base.OnStartup(sender, e);

            if (!Directory.Exists(AppConfig.DownloadPath))
                Directory.CreateDirectory(AppConfig.DownloadPath);

            var logConfig = new LoggingConfiguration();

            var target = new FileTarget
            {
                FileName = Path.Combine(AppConfig.LogPath, "Log.txt"),
                Layout = @"${longdate}|${level}|${message} ${exception:format=ToString,StackTrace}",
                ArchiveAboveSize = 1024 * 1024 * 2,
                ArchiveNumbering = ArchiveNumberingMode.Sequence
            };

            logConfig.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, target));
            LogManager.Configuration = logConfig;

            Locator.CurrentMutable.RegisterConstant(new NLogLogger(LogManager.GetCurrentClassLogger()), typeof(ILogger));
            this.Log().Info("Flashbang is starting...");

            #if !DEBUG

                using (var mgr = new UpdateManager(AppConfig.UpdatePath, "Flashbang", FrameworkVersion.Net45))
                {
                    SquirrelAwareApp.HandleEvents(v => mgr.CreateShortcutForThisExe(), v =>
                        {
                            mgr.CreateShortcutForThisExe();
                            mgr.CreateShortcutsForExecutable("Flashbang.exe", ShortcutLocation.AppRoot, false);
                        },
                        onAppUninstall: v => mgr.RemoveShortcutForThisExe());
                }

            #endif
        }
开发者ID:dbeattie71,项目名称:flashbang,代码行数:37,代码来源:Bootsrapper.cs

示例9: Update

 static void Update(UpdateManager mgr) {
     mgr.CreateShortcutForThisExe();
     RunVcRedist();
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:4,代码来源:Entrypoint.cs

示例10: CustomSquirrelSetup

        /// <summary>
        /// This code has to exist in order for Squirrel to work its magic.
        /// What it does, is hook methods to the install/uninstall events.
        /// Basic functionality includes: Create and remove shortcut upon install/uninstall,
        /// as well as when updating.
        /// </summary>
        public static void CustomSquirrelSetup()
        {
            var appName = SquirrelHelper.GetAppName();
            var updateLocation = SquirrelHelper.GetUpdateLocation();

            using (var mgr = new UpdateManager(updateLocation, appName, FrameworkVersion.Net45))
            {
                SquirrelAwareApp.HandleEvents(
                    onInitialInstall: v =>
                    {
                        _log.Warn(Utilities.GetCallerName() + ": Installation in progress.");

                        CreateOrUpdateCustomRegistryEntries(mgr.RootAppDirectory);
                        RegisterShellExtension(mgr.RootAppDirectory);
                        mgr.CreateShortcutForThisExe();
                    },
                    onAppUpdate: v =>
                    {
                        _log.Warn(Utilities.GetCallerName() + ": Update in progress.");
                        
                        mgr.CreateShortcutForThisExe();
                        CreateOrUpdateCustomRegistryEntries(mgr.RootAppDirectory, v.ToString());
                        RegisterShellExtension(mgr.RootAppDirectory);
                    },
                    onAppUninstall: v =>
                    {
                        _log.Warn(Utilities.GetCallerName() + ": Uninstall in progress.");

                        UnregisterShellExtension(mgr.RootAppDirectory);
                        RemoveCustomRegistryEntries(mgr.RootAppDirectory);
                        mgr.RemoveShortcutForThisExe();
                        StopBigStashOnUninstall();
                        CallBatchDelete(mgr.RootAppDirectory);
                    });
            }
        }
开发者ID:yovannyr,项目名称:bigstash-windows,代码行数:42,代码来源:SquirrelHelper.cs

示例11: OnInitialInstall

        /// <summary>
        /// Execute when app is installing
        /// </summary>
        /// <param name="version"><see cref="Version"/> version</param>
        private static void OnInitialInstall(Version version)
        {
            using (var manager = new UpdateManager(Constants.UpdateServerUrl))
            {
                manager.CreateShortcutForThisExe();

                manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.Desktop, false);
                manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.StartMenu, false);
                manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.AppRoot, false);

                manager.CreateUninstallerRegistryEntry();
            }
        }
开发者ID:bbougot,项目名称:Popcorn,代码行数:17,代码来源:App.xaml.cs

示例12: HandleSquirrelInstallEvent

        internal static void HandleSquirrelInstallEvent(string[] args)
        {
            #if __MonoCS__
            Debug.Fail("HandleSquirrelInstallEvent should not run on Linux!");	// and the code below doesn't compile on Linux
            return;
            #else
            bool firstTime = false;
            var updateUrlResult = LookupUrlOfSquirrelUpdate();
            // Should only be null if we're not online. Not sure how squirrel will handle that,
            // but at least one of these operations is responsible for setting up shortcuts to the program,
            // which we'd LIKE to work offline. Passing it a plausible url, even though it will presumably fail,
            // seems less likely to cause problems than passing null.
            if(string.IsNullOrEmpty(updateUrlResult.URL))
                updateUrlResult.URL = @"https://s3.amazonaws.com/bloomlibrary.org/squirrel";
            if (args[0] == "--squirrel-uninstall")
            {
                RemoveBloomRegistryEntries();
            }
            if (args[0] == "--squirrel-updated")
            {
                var props = new Dictionary<string, string>();
                if (args.Length > 1)
                    props["newVersion"] = args[1];
                props["channel"] = ApplicationUpdateSupport.ChannelName;
                Analytics.Track("Update Version", props);
            }
            string iconPath = null;
            if (args[0] == "--squirrel-install")
            {
                //Using an icon in the root folder fixes the problem of losing the shortcut icon when we
                //upgrade, lose the original, and eventually the windows explorer cache loses it.
                //There was another attempt at fixing this by finding all the shortcuts and updating them, but that didn't work in our testing and this seems simpler and more robust.
                //There may be some other reason for the old approach of pointing at the icon of the app itself (e.g. could be a different icon)?
                var exePath = Application.ExecutablePath;
                var rootAppDirectory = Path.GetDirectoryName(Path.GetDirectoryName(exePath));
                // directory that holds e.g. /3.6/Bloom.exe
                var versionIconPath = Path.ChangeExtension(exePath, "ico"); // where this installation has icon
                iconPath = Path.ChangeExtension(Path.Combine(rootAppDirectory, Path.GetFileName(exePath)), "ico");
                // where we will put a version-independent icon
                try
                {
                    if (RobustFile.Exists(versionIconPath))
                        RobustFile.Copy(versionIconPath, iconPath, true);
                }
                catch (Exception)
                {
                    // ignore...most likely some earlier version of the icon is locked somehow, fairly harmless.
                }
                // Normally this is done on every run of the program, but if we're doing a silent allUsers install,
                // this is our only time running with admin privileges so we can actually make the entries for all users.
                MakeBloomRegistryEntries(args);
            }
            switch (args[0])
            {
                // args[1] is version number
                case "--squirrel-install": // (first?) installed
                case "--squirrel-updated": // updated to specified version
                case "--squirrel-obsolete": // this version is no longer newest
                case "--squirrel-uninstall": // being uninstalled
                    using (var mgr = new UpdateManager(updateUrlResult.URL, Application.ProductName))
                    {
                        // WARNING, in most of these scenarios, the app exits at the end of HandleEvents;
                        // thus, the method call does not return and nothing can be done after it!
                        // We replace two of the usual calls in order to take control of where shortcuts are installed.
                        SquirrelAwareApp.HandleEvents(

                            onInitialInstall: v =>
                            {
                                mgr.CreateShortcutsForExecutable(Path.GetFileName(Assembly.GetEntryAssembly().Location),
                                    StartMenuLocations,
                                    false, // not just an update, since this is case initial install
                                    null, // can provide arguments to pass to Update.exe in shortcut, defaults are OK
                                    iconPath,
                                    SharedByAllUsers());
                                // Normally we can't do this in our quick silent run as part of install, because of the need to escalate
                                // privilege. But if we're being installed for all users we must already be running as admin.
                                // We don't need to do an extra restart of Bloom because this install-setup run of Bloom will finish
                                // right away anyway. We do this last because we've had some trouble (BL-3342) with timeouts
                                // if this install somehow ties up the CPU until Squirrel thinks Bloom is taking too long to do its
                                // install-only run.
                                if (SharedByAllUsers())
                                    FontInstaller.InstallFont("AndikaNewBasic", needsRestart: false);
                            },
                            onAppUpdate: v => mgr.CreateShortcutForThisExe(),
                            onAppUninstall: v => mgr.RemoveShortcutsForExecutable(Path.GetFileName(Assembly.GetEntryAssembly().Location), StartMenuLocations, SharedByAllUsers()),
                            onFirstRun: () => firstTime = true,
                            arguments: args);
                    }
                    break;
            }
            #endif
        }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:92,代码来源:InstallerSupport.cs


注:本文中的Squirrel.UpdateManager.CreateShortcutForThisExe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。