/// <summary>
		/// Initializes a new instance of the <see cref="ProxyEditorWindow"/>.
		/// </summary>
		public ProxyEditorWindow()
		{
			InitializeComponent();
			ProxySettings = ProxySettings.GetProxySettings();
		}
Beispiel #2
0
		/// <summary>
		/// To get proxy settings.
		/// </summary>
		/// <returns>Proxy-server settings.</returns>
		public static ProxySettings GetProxySettings()
		{
			var proxySettings = new ProxySettings();

			var proxy = (WebRequest.DefaultWebProxy ?? WebRequest.GetSystemWebProxy()) as WebProxy;

			if (proxy == null)
				return proxySettings;

			proxySettings.UseProxy = true;
			proxySettings.Address = "{0}:{1}".Put(proxy.Address.Host, proxy.Address.Port).To<EndPoint>();
			proxySettings.ByPassOnLocal = proxy.BypassProxyOnLocal;
			proxySettings.UseCredentials = !proxy.UseDefaultCredentials;

			if (proxy.UseDefaultCredentials)
				return proxySettings;

			var credentials = proxy.Credentials as NetworkCredential;

			if (credentials == null)
				return proxySettings;

			proxySettings.Login = credentials.UserName;
			proxySettings.Password = credentials.SecurePassword;

			return proxySettings;
		}
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProxyEditorWindow"/>.
 /// </summary>
 public ProxyEditorWindow()
 {
     InitializeComponent();
     ProxySettings = ProxySettings.GetProxySettings();
 }
		/// <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);
		}
Beispiel #5
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);
        }