public AboutBox() { InitializeComponent(); Text = String.Format("About {0}", AssemblyTitle); logoPictureBox.Image = ApplicationIcon(); labelProductName.Text = AssemblyProduct; labelVersion.Text = String.Format("Version {0} ({1})", PreferencesFactory.get().getProperty("application.version"), PreferencesFactory.get().getProperty("application.revision")); labelCopyright.Text = Copyright(); Font bigBoldFont = new Font(Font.FontFamily, Font.Size + 4, FontStyle.Bold); labelProductName.Font = bigBoldFont; labelRegistered.Text = RegisteredText(); creditsRichTextBox.Rtf = Credits(); creditsRichTextBox.SelectAll(); creditsRichTextBox.SelectionFont = new Font(Font.FontFamily, 9); creditsRichTextBox.DeselectAll(); creditsRichTextBox.LinkClicked += (sender, e) => BrowserLauncherFactory.get().open(e.LinkText); ackButton.Click += delegate { ApplicationLauncherFactory.get().open(LocalFactory.get("Acknowledgments.rtf")); }; PeriodicUpdateChecker updater = PeriodicUpdateCheckerFactory.get(); updateButton.Enabled = updater.hasUpdatePrivileges(); updateButton.Click += delegate { updater.check(false); }; }
private void InitializeUpdater() { // register callbacks _canShutdownCallback = CanShutdownCallback; _shutdownRequestCallback = ShutdownRequestCallback; WinSparklePeriodicUpdateChecker.SetCanShutdownCallback(_canShutdownCallback); WinSparklePeriodicUpdateChecker.SetShutdownRequestCallback(_shutdownRequestCallback); if (PreferencesFactory.get().getBoolean("update.check")) { _updater = PeriodicUpdateCheckerFactory.get(); if (_updater.hasUpdatePrivileges()) { DateTime lastCheck = new DateTime(PreferencesFactory.get().getLong("update.check.last")); TimeSpan span = DateTime.Now.Subtract(lastCheck); _updater.register(); if (span.TotalSeconds >= PreferencesFactory.get().getLong("update.check.interval")) { _updater.check(true); } } } if (PreferencesFactory.get().getBoolean("profiles.discovery.updater.enable")) { // Synchronize and register timer _profiles.register(); } }
public void setup() { ContextMenuStrip rightMenu = new ContextMenuStrip(); ToolStripMenuItem itemUpdate = new ToolStripMenuItem { Text = LocaleFactory.get().localize("Check for Update…", "Main") }; PeriodicUpdateChecker updater = PeriodicUpdateCheckerFactory.get(); itemUpdate.Enabled = updater.hasUpdatePrivileges(); itemUpdate.Click += delegate { updater.check(false); }; ToolStripMenuItem itemDonate = new ToolStripMenuItem { Text = LocaleFactory.get().localize("Donate…", "Main") }; itemDonate.Click += delegate { BrowserLauncherFactory.get().open(PreferencesFactory.get().getProperty("website.donate")); }; ToolStripMenuItem itemKey = new ToolStripMenuItem { Text = LicenseFactory.find().ToString(), Enabled = false }; ToolStripMenuItem itemExit = new ToolStripMenuItem { Text = LocaleFactory.get().localize("Exit", "Localizable") }; itemExit.Click += delegate { MainController.Exit(false); }; rightMenu.Items.AddRange(new ToolStripItem[] { itemUpdate, new ToolStripSeparator(), itemDonate, itemKey, new ToolStripSeparator(), itemExit }); try { _icon.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); } catch (ArgumentException) { } _icon.Visible = true; _icon.ContextMenuStrip = rightMenu; _icon.MouseClick += delegate(object sender, MouseEventArgs args) { if (args.Button == MouseButtons.Left) { foreach (BrowserController browser in MainController.Browsers) { browser.View.Activate(); browser.View.BringToFront(); } } }; }
/// <summary> /// A normal (non-single-instance) application raises the Startup event every time it starts. /// A single-instance application raises the Startup event when it starts only if the application /// is not already active; otherwise, it raises the StartupNextInstance event. /// </summary> /// <see cref="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.startup.aspx"/> /// <param name="sender"></param> /// <param name="e"></param> private void ApplicationDidFinishLaunching(object sender, StartupEventArgs e) { Logger.debug("ApplicationDidFinishLaunching"); /* UWP Registration, initialize as soon as possible */ if (Utils.IsRunningAsUWP) { InitStoreContext(); } _controller.Background(delegate { var transfers = TransferCollection.defaultCollection(); lock (transfers) { transfers.load(); } transfersSemaphore.Signal(); }, delegate { }); _controller.Background(delegate { HistoryCollection.defaultCollection().load(); }, delegate { }); CommandsAfterLaunch(CommandLineArgs); HistoryCollection.defaultCollection().addListener(this); if (PreferencesFactory.get().getBoolean("browser.serialize")) { _controller.Background(delegate { _sessions.load(); }, delegate { foreach (Host host in _sessions) { Host h = host; _bc.Invoke(delegate { BrowserController bc = NewBrowser(); bc.Mount(h); }); } _sessions.clear(); }); } NotificationServiceFactory.get().setup(); // User bookmarks and thirdparty applications CountdownEvent bookmarksSemaphore = new CountdownEvent(1); CountdownEvent thirdpartySemaphore = new CountdownEvent(1); // Load all bookmarks in background _controller.Background(delegate { BookmarkCollection c = BookmarkCollection.defaultCollection(); c.load(); bookmarksSemaphore.Signal(); }, delegate { if (PreferencesFactory.get().getBoolean("browser.open.untitled")) { if (PreferencesFactory.get().getProperty("browser.open.bookmark.default") != null) { _bc.Invoke(delegate { BrowserController bc = NewBrowser(); OpenDefaultBookmark(bc); }); } } }); if (PreferencesFactory.get().getBoolean("queue.window.open.default")) { _bc.Invoke(delegate { transfersSemaphore.Wait(); TransferController.Instance.View.Show(); }); } // Bonjour initialization ThreadStart start = delegate { try { RendezvousFactory.instance().init(); } catch (COMException) { Logger.warn("No Bonjour support available"); } }; Thread thread = new Thread(start); thread.SetApartmentState(ApartmentState.STA); thread.Start(); if (PreferencesFactory.get().getBoolean("defaulthandler.reminder") && PreferencesFactory.get().getInteger("uses") > 0) { var handler = SchemeHandlerFactory.get(); if ( !handler.isDefaultHandler(Arrays.asList(Scheme.ftp, Scheme.ftps, Scheme.sftp), new Application(System.Windows.Forms.Application.ExecutablePath))) { Core.Utils.CommandBox(LocaleFactory.localizedString("Default Protocol Handler", "Preferences"), LocaleFactory.localizedString( "Set Cyberduck as default application for FTP and SFTP locations?", "Configuration"), LocaleFactory.localizedString( "As the default application, Cyberduck will open when you click on FTP or SFTP links in other applications, such as your web browser. You can change this setting in the Preferences later.", "Configuration"), String.Format("{0}|{1}", LocaleFactory.localizedString("Change", "Configuration"), LocaleFactory.localizedString("Cancel", "Configuration")), false, LocaleFactory.localizedString("Don't ask again", "Configuration"), TaskDialogIcon.Question, delegate(int option, bool verificationChecked) { if (verificationChecked) { // Never show again. PreferencesFactory.get().setProperty("defaulthandler.reminder", false); } switch (option) { case 0: handler.setDefaultHandler(Arrays.asList(Scheme.ftp, Scheme.ftps, Scheme.sftp), new Application(System.Windows.Forms.Application.ExecutablePath)); break; } }); } } // Import thirdparty bookmarks. IList <ThirdpartyBookmarkCollection> thirdpartyBookmarks = GetThirdpartyBookmarks(); _controller.Background(delegate { foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks) { if (!c.isInstalled()) { Logger.info("No application installed for " + c.getBundleIdentifier()); continue; } c.load(); if (c.isEmpty()) { if (!PreferencesFactory.get().getBoolean(c.getConfiguration())) { // Flag as imported PreferencesFactory.get().setProperty(c.getConfiguration(), true); } } } bookmarksSemaphore.Wait(); }, delegate { foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks) { BookmarkCollection bookmarks = BookmarkCollection.defaultCollection(); c.filter(bookmarks); if (!c.isEmpty()) { ThirdpartyBookmarkCollection c1 = c; Core.Utils.CommandBox(LocaleFactory.localizedString("Import", "Configuration"), String.Format(LocaleFactory.localizedString("Import {0} Bookmarks", "Configuration"), c.getName()), String.Format( LocaleFactory.localizedString( "{0} bookmarks found. Do you want to add these to your bookmarks?", "Configuration"), c.size()), String.Format("{0}", LocaleFactory.localizedString("Import", "Configuration")), true, LocaleFactory.localizedString("Don't ask again", "Configuration"), TaskDialogIcon.Question, delegate(int option, bool verificationChecked) { if (verificationChecked) { // Flag as imported PreferencesFactory.get().setProperty(c1.getConfiguration(), true); } switch (option) { case 0: BookmarkCollection.defaultCollection().addAll(c1); // Flag as imported PreferencesFactory.get().setProperty(c1.getConfiguration(), true); break; } }); } else { PreferencesFactory.get().setProperty(c.getConfiguration(), true); } } thirdpartySemaphore.Signal(); }); // register callbacks _canShutdownCallback = CanShutdownCallback; _shutdownRequestCallback = ShutdownRequestCallback; WinSparklePeriodicUpdateChecker.SetCanShutdownCallback(_canShutdownCallback); WinSparklePeriodicUpdateChecker.SetShutdownRequestCallback(_shutdownRequestCallback); if (PreferencesFactory.get().getBoolean("update.check")) { _updater = PeriodicUpdateCheckerFactory.get(); if (_updater.hasUpdatePrivileges()) { DateTime lastCheck = new DateTime(PreferencesFactory.get().getLong("update.check.last")); TimeSpan span = DateTime.Now.Subtract(lastCheck); _updater.register(); if (span.TotalSeconds >= PreferencesFactory.get().getLong("update.check.interval")) { _updater.check(true); } } } }