Ejemplo n.º 1
0
        /// <summary>
        /// Processing the application start.
        /// </summary>
        /// <param name="e">Argument.</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            GuiDispatcher.InitGlobalDispatcher();
            DispatcherPropertyChangedEventManager.Init();

            //GuiDispatcher.GlobalDispatcher.AddPeriodicalAction(CommandManager.InvalidateRequerySuggested);

            if (!ProxyConfigurationFile.IsEmpty() && File.Exists(ProxyConfigurationFile))
            {
                var settings = new XmlSerializer <SettingsStorage>().Deserialize(ProxyConfigurationFile);

                ProxySettings = new ProxySettings();
                ProxySettings.Load(settings);
                ProxySettings.ApplyProxySettings();
            }
            else
            {
                ProxySettings = ProxySettings.GetProxySettings();
            }

            if (CheckTargetPlatform)
            {
                //если одним из аргументов является путь к самому приложению,
                //то значит оно запущено из под специального загрузчика
                var executablePath = Assembly.GetEntryAssembly().Location;
                if (e.Args.Any(a => a == executablePath) || !Environment.Is64BitOperatingSystem)
                {
                    var language = e.Args.FirstOrDefault(s => s.ContainsIgnoreCase(_langPrefix));

                    LocalizedStrings.ActiveLanguage = language != null
                                                ? language.Replace(_langPrefix, string.Empty).To <Languages>()
                                                : LocalizedStrings.ActiveLanguage;

                    StartApp();

                    return;
                }

                if (!Directory.Exists(AppDataPath))
                {
                    Directory.CreateDirectory(AppDataPath);
                }

                var window = new TargetPlatformWindow();

                if (window.AutoStart || window.ShowDialog() == true)
                {
                    switch (window.SelectedPlatform)
                    {
                    case Platforms.x86:
                        StartX86();
                        Process.GetCurrentProcess().Kill();
                        break;

                    case Platforms.x64:
                        // обнуляем ссылку главного окна, так как она равна TargetPlatformWindow
                        MainWindow = null;

                        StartApp();
                        break;
                    }
                }
                else
                {
                    MainWindow = null;
                    Close();
                }
            }

            base.OnStartup(e);
        }
Ejemplo n.º 2
0
		private void ExecutedTargetPlatformCommand(object sender, ExecutedRoutedEventArgs e)
		{
			var language = LocalizedStrings.ActiveLanguage;
			var platform = Environment.Is64BitProcess ? Platforms.x64 : Platforms.x86;

			var window = new TargetPlatformWindow();

			if (!window.ShowModal(this))
				return;

			if (window.SelectedLanguage == language && window.SelectedPlatform == platform)
				return;

			// temporarily set prev lang for display the followed message
			// and leave all text as is if user will not restart the app
			LocalizedStrings.ActiveLanguage = language;

			var result = new MessageBoxBuilder()
				.Text(LocalizedStrings.Str2952Params.Put(TypeHelper.ApplicationName))
				.Owner(this)
				.Info()
				.YesNo()
				.Show();

			if (result == MessageBoxResult.Yes)
				Application.Current.Restart();
		}
Ejemplo n.º 3
0
		private void ExecutedTargetPlatformCommand(object sender, ExecutedRoutedEventArgs e)
		{
			var window = new TargetPlatformWindow();

			if (!window.ShowModal(this))
				return;

			var message = window.AutoStart
				? LocalizedStrings.Str2952Params.Put(TypeHelper.ApplicationName, window.SelectedPlatform)
				: LocalizedStrings.Str2953.Put(TypeHelper.ApplicationName);

			var result = new MessageBoxBuilder()
				.Text(message)
				.Owner(this)
				.Info()
				.YesNo()
				.Show();

			if (result == MessageBoxResult.Yes)
				Application.Current.Restart();
		}
Ejemplo n.º 4
0
		/// <summary>
		/// Processing the application start.
		/// </summary>
		/// <param name="e">Argument.</param>
		protected override void OnStartup(StartupEventArgs e)
		{
			GuiDispatcher.InitGlobalDispatcher();
			DispatcherPropertyChangedEventManager.Init();

			//GuiDispatcher.GlobalDispatcher.AddPeriodicalAction(CommandManager.InvalidateRequerySuggested);

			if (!ProxyConfigurationFile.IsEmpty() && File.Exists(ProxyConfigurationFile))
			{
				var settings = new XmlSerializer<SettingsStorage>().Deserialize(ProxyConfigurationFile);

				ProxySettings = new ProxySettings();
				ProxySettings.Load(settings);
				ProxySettings.ApplyProxySettings();
			}
			else
				ProxySettings = ProxySettings.GetProxySettings();

			if (CheckTargetPlatform)
			{
				//если одним из аргументов является путь к самому приложению,
				//то значит оно запущено из под специального загрузчика
				var executablePath = Assembly.GetEntryAssembly().Location;
				if (e.Args.Any(a => a == executablePath) || !Environment.Is64BitOperatingSystem)
				{
					var language = e.Args.FirstOrDefault(s => s.ContainsIgnoreCase(_langPrefix));

					LocalizedStrings.ActiveLanguage = language != null
						? language.Replace(_langPrefix, string.Empty).To<Languages>()
						: LocalizedStrings.ActiveLanguage;

					StartApp();

					return;
				}

				if (!Directory.Exists(AppDataPath))
					Directory.CreateDirectory(AppDataPath);

				var window = new TargetPlatformWindow();

				if (window.AutoStart || window.ShowDialog() == true)
				{
					switch (window.SelectedPlatform)
					{
						case Platforms.x86:
							StartX86();
							Process.GetCurrentProcess().Kill();
							break;

						case Platforms.x64:
							// обнуляем ссылку главного окна, так как она равна TargetPlatformWindow
							MainWindow = null;

							StartApp();
							break;
					}
				}
				else
				{
					MainWindow = null;
					Close();
				}
			}

			base.OnStartup(e);
		}