Ejemplo n.º 1
0
        //</SNIPPET8>

        //<SNIPPET9>
        private void DownloadFileGroupSync(string fileGroup)
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

                if (deployment.IsFirstRun)
                {
                    try
                    {
                        if (deployment.IsFileGroupDownloaded(fileGroup))
                        {
                            deployment.DownloadFileGroup(fileGroup);
                        }
                    }
                    catch (InvalidOperationException ioe)
                    {
                        MessageBox.Show("This application is not a ClickOnce application. Error: " + ioe.Message);
                        return;
                    }

                    downloadStatus.Text = String.Format("Download of file group {0} complete.", fileGroup);
                }
            }
        }
Ejemplo n.º 2
0
 static void DownloadDebugSymbols(object sender, EventArgs e)
 {
     if (ApplicationDeployment.IsNetworkDeployed)
     {
         ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
         if (!ad.IsFileGroupDownloaded("PDB"))
         {
             try
             {
                 using (ManualResetEvent updateCompleted = new ManualResetEvent(false))
                 {
                     using (Unit.frmProgress)
                     {
                         TApplication.Instance.CreateForm(out Unit.frmProgress);
                         Unit.frmProgress.ControlBox          = false;
                         ad.DownloadFileGroupProgressChanged += (sender2, e2) =>
                         {
                             if (Unit.frmProgress.pbBar.InvokeRequired)
                             {
                                 Unit.frmProgress.pbBar.Invoke(new Action <int>(v => Unit.frmProgress.pbBar.Value = v), e2.ProgressPercentage);
                             }
                             else
                             {
                                 Unit.frmProgress.pbBar.Value = e2.ProgressPercentage;
                             }
                         };
                         ad.DownloadFileGroupCompleted += (sender2, e2) =>
                         {
                             updateCompleted.Set();
                             if (Unit.frmProgress.InvokeRequired)
                             {
                                 Unit.frmProgress.Invoke(new Action(Unit.frmProgress.Close));
                             }
                             else
                             {
                                 Unit.frmProgress.Close();
                             }
                         };
                         ad.DownloadFileGroupAsync("PDB");
                         Unit.frmProgress.ShowDialog();
                     }
                     updateCompleted.WaitOne();
                 }
             }
             catch (DeploymentDownloadException /*dde*/)
             {
                 /*string msg = _("Die aktuellste Version kann nicht installiert werden.") + Environment.NewLine +
                  *  _("Bitte überprüfen Sie Ihre Netzwerkverbindung oder versuchen Sie es später noch einmal.") + Environment.NewLine +
                  *  _("Fehler: ") + dde.Message;
                  * string title = _("Fehler");
                  * MessageBox.Show(msg, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                  * return;*/
             }
         }
     }
 }
Ejemplo n.º 3
0
 // Checks if group is already local.
 private bool IsLocal(string groupName)
 {
     try
     {
         if (_appDeployment.IsFileGroupDownloaded(groupName))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public ClickOnceLanguagePackProvider()
        {
            ApplicationDeployment d = ApplicationDeployment.CurrentDeployment;

            var doc    = XDocument.Load(Assembly.GetEntryAssembly().Location + ".manifest");
            var ns     = XNamespace.Get("urn:schemas-microsoft-com:asm.v2");
            var files  = doc.Root.Descendants(ns + "file");
            var groups = files.Where(x => x.Attribute("group") != null).Select(x => x.Attribute("group").Value).Distinct().OrderBy(x => x.ToLowerInvariant());

            foreach (var g in groups)
            {
                if (d.IsFileGroupDownloaded(g))
                {
                    this.locals.Add(new AssemblyFileLanguagePack(GroupNameToDllLocation(g)));
                }
                else
                {
                    this.remotes.Add(new RemotePack(g));
                }
            }
        }
Ejemplo n.º 5
0
        //</SNIPPET7>

        //<SNIPPET8>
        private void DownloadFileGroupAsync(string fileGroup)
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

                try
                {
                    if (!deployment.IsFileGroupDownloaded(fileGroup))
                    {
                        deployment.DownloadFileGroupProgressChanged += new DeploymentProgressChangedEventHandler(deployment_DownloadFileGroupProgressChanged);
                        deployment.DownloadFileGroupCompleted       += new DownloadFileGroupCompletedEventHandler(deployment_DownloadFileGroupCompleted);

                        deployment.DownloadFileGroupAsync(fileGroup);
                    }
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("This application is not a ClickOnce application. Error: " + ioe.Message);
                    return;
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Called after OnStartup()
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnApplicationStartup(object sender, StartupEventArgs e)
        {
            if (Tobi.Common.Settings.Default.UpgradeSettings)
            {
                if (!ApplicationDeployment.IsNetworkDeployed)
                {
                    // ClickOnce automatically Upgrades.

                    Settings.Default.Upgrade();
                    Tobi.Common.Settings.Default.Upgrade();
                }

                Tobi.Common.Settings.Default.UpgradeSettings = true; // ensure settings aggregator does its job of upgrading the other providers
            }

            try
            {
                SettingsPropertyCollection col1 = Settings.Default.Properties;
                IEnumerator enume1 = col1.GetEnumerator();
                while (enume1.MoveNext())
                {
                    var current = (SettingsProperty)enume1.Current;
                    Console.WriteLine("--- " + current.Name + ":");
                    Console.WriteLine(current.DefaultValue);
                    Console.WriteLine(Settings.Default[current.Name]);
                }
                //Settings.Default.Reload();
            }
            catch (ConfigurationErrorsException ex)
            {
                HandleConfigurationErrorsException(ex);
            }

            Console.WriteLine("<RESOURCE SET LANGs>");
            var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);

            foreach (var culture in cultures)
            {
                try
                {
                    var rs = Tobi_Lang.ResourceManager.GetResourceSet(culture, true, false);
                    if (rs != null)
                    {
                        Console.WriteLine(culture.Name + " ==> " + culture.NativeName);
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
            }
            Console.WriteLine("</RESOURCE SET LANGs>");

#if DEBUG
            var keys = Tobi_Lang.ResourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, true)
                       .Cast <DictionaryEntry>()
                       .Select(entry => entry.Key)
                       .Cast <string>();
            var resources = keys.ToDictionary(key => key, key => Tobi_Lang.ResourceManager.GetString(key, CultureInfo.GetCultureInfo("fr")));

            var str = Tobi_Lang.LangStringKey1;
#endif
            try
            {
#if DEBUG
                SetCulture("fr");
                str = Tobi_Lang.LangStringKey1;

                SetCulture("hi");
                str = Tobi_Lang.LangStringKey1;
#endif
                SetCulture(Settings.Default.Lang);
            }
            catch (ConfigurationErrorsException ex)
            {
                HandleConfigurationErrorsException(ex);
#if DEBUG
                MessageBox.Show(ex.Message);

                Process.GetCurrentProcess().Kill();
                return;
#endif
            }
#if NET40
            catch (CultureNotFoundException ex2)
            {
#if DEBUG
                Debugger.Break();
#endif
                Settings.Default.Lang = "en";
                SetCulture(Settings.Default.Lang);
            }
#else
            catch (ArgumentException ex2)
            {
#if DEBUG
                Debugger.Break();
#endif
                Settings.Default.Lang = "en";
                SetCulture(Settings.Default.Lang);
            }
#endif

#if DEBUG
            str = Tobi_Lang.LangStringKey1;
#endif
            if (false && ApplicationDeployment.IsNetworkDeployed)
            {
                string lang = Thread.CurrentThread.CurrentUICulture.ToString();

                ApplicationDeployment deploy = ApplicationDeployment.CurrentDeployment;
                try
                {
                    if (!deploy.IsFileGroupDownloaded(lang)) //deploy.IsFirstRun
                    {
                        deploy.DownloadFileGroup(lang);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);

                    MessageBox.Show(ex.Message);

                    // Log error. Do not report this error to the user, because a satellite
                    // assembly may not exist if the user's culture and the application's
                    // default culture match.
                }
            }

            //to use on individual forms: this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag);
            FrameworkElement.LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(
                    XmlLanguage.GetLanguage(
                        CultureInfo.CurrentUICulture.IetfLanguageTag)));

            Timeline.DesiredFrameRateProperty.OverrideMetadata(
                typeof(Timeline),
                new FrameworkPropertyMetadata {
                DefaultValue = 20
            }
                );

            //AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;

            SplashScreen = new SplashScreen(Assembly.GetExecutingAssembly(), "TobiSplashScreen.png");
            SplashScreen.Show(false);

            ShutdownMode = ShutdownMode.OnMainWindowClose;

            runBootstrapper();
        }