private void ApplyCommandExecuted(object sender, ExecutedRoutedEventArgs e)
		{
			var settings = SelectedSettings;

			if (SettingsPanel.IsLocal == settings.UseLocal &&
				//SettingsPanel.IsAlphabetic == settings.IsAlphabetic &&
				(SettingsPanel.IsLocal ? SettingsPanel.Path : SettingsPanel.Address) == settings.Path &&
			    SettingsPanel.Login == settings.Credentials.Login &&
			    SettingsPanel.Password == settings.Credentials.Password)
			{
				return;
			}

			settings.UseLocal = SettingsPanel.IsLocal;
			//settings.IsAlphabetic = SettingsPanel.IsAlphabetic;
			settings.Path = SettingsPanel.IsLocal ? SettingsPanel.Path : SettingsPanel.Address;
			settings.Credentials.Login = SettingsPanel.Login;
			settings.Credentials.Password = SettingsPanel.Password;

			if (SettingsPanel.IsLocal)
			{
				if (!Directory.Exists(settings.Path))
				{
					var res = new MessageBoxBuilder()
						.Owner(this)
						.Text(LocalizedStrings.Str3263)
						.Warning()
						.YesNo()
						.Show();

					if (res != MessageBoxResult.Yes)
						return;
				}
			}
			else
			{
				var wnd = new MarketDataConfirmWindow
				{
					SecurityTypes = new[]
					{
						SecurityTypes.Currency,
						SecurityTypes.Index,
						SecurityTypes.Stock,
						SecurityTypes.Future
					}
				};

				if (wnd.ShowModal(this))
				{
					_isCancelled = false;
					BusyIndicator.IsBusy = true;

					var progress = BusyIndicator.FindVisualChild<ProgressBar>();
                    var cancel = (Button)BusyIndicator.FindVisualChild<CancelButton>();

					var secTypes = wnd.SecurityTypes.ToArray();

					progress.Maximum = secTypes.Length;
					cancel.Click += (s1, e1) =>
					{
						_isCancelled = true;
						BusyIndicator.IsBusy = false;
					};

					new RefreshSecurities(settings, secTypes,
						() => _isCancelled,
						count => this.GuiAsync(() => progress.Value = count),
						count => this.GuiAsync(() =>
						{
							BusyIndicator.IsBusy = false;

							new MessageBoxBuilder()
								.Owner(this)
								.Text(LocalizedStrings.Str3264Params.Put(count))
								.Show();

							RefreshGrid();
						})).Process(this);
				}
			}

			ConfigManager.GetService<MarketDataSettingsCache>().Save();
		}
Ejemplo n.º 2
0
        private void ApplyCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var settings = SelectedSettings;

            if (SettingsPanel.IsLocal == settings.UseLocal &&
                //SettingsPanel.IsAlphabetic == settings.IsAlphabetic &&
                (SettingsPanel.IsLocal ? SettingsPanel.Path : SettingsPanel.Address) == settings.Path &&
                SettingsPanel.Login == settings.Credentials.Login &&
                SettingsPanel.Password == settings.Credentials.Password)
            {
                return;
            }

            settings.UseLocal = SettingsPanel.IsLocal;
            //settings.IsAlphabetic = SettingsPanel.IsAlphabetic;
            settings.Path = SettingsPanel.IsLocal ? SettingsPanel.Path : SettingsPanel.Address;
            settings.Credentials.Login    = SettingsPanel.Login;
            settings.Credentials.Password = SettingsPanel.Password;

            if (SettingsPanel.IsLocal)
            {
                if (!Directory.Exists(settings.Path))
                {
                    var res = new MessageBoxBuilder()
                              .Owner(this)
                              .Text(LocalizedStrings.Str3263)
                              .Warning()
                              .YesNo()
                              .Show();

                    if (res != MessageBoxResult.Yes)
                    {
                        return;
                    }
                }
            }
            else
            {
                var wnd = new MarketDataConfirmWindow
                {
                    SecurityTypes = new[]
                    {
                        SecurityTypes.Currency,
                        SecurityTypes.Index,
                        SecurityTypes.Stock,
                        SecurityTypes.Future
                    }
                };

                if (wnd.ShowModal(this))
                {
                    BusyIndicator.IsBusy = true;

                    var progress = BusyIndicator.FindVisualChild <ProgressBar>();
                    var cancel   = (Button)BusyIndicator.FindVisualChild <StackPanel>().Children[2];

                    var secTypes = wnd.SecurityTypes.ToArray();

                    progress.Maximum = secTypes.Length;
                    cancel.Click    += (s1, e1) =>
                    {
                        _isCancelled         = true;
                        BusyIndicator.IsBusy = false;
                    };

                    new RefreshSecurities(settings, secTypes,
                                          () => _isCancelled,
                                          count => this.GuiAsync(() => progress.Value = count),
                                          count => this.GuiAsync(() =>
                    {
                        BusyIndicator.IsBusy = false;

                        new MessageBoxBuilder()
                        .Owner(this)
                        .Text(LocalizedStrings.Str3264Params.Put(count))
                        .Show();

                        RefreshGrid();
                    })).Process(this);
                }
            }

            ConfigManager.GetService <MarketDataSettingsCache>().Save();
        }
		private void EditCommandExecuted(object sender, ExecutedRoutedEventArgs e)
		{
			var settings = SelectedSettings;

			var settingsWnd = new StorageSettingsWindow
			{
				Settings = settings
			};

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

			if (!settings.UseLocal)
			{
				var wnd = new MarketDataConfirmWindow
				{
					SecurityTypes = new[]
					{
						SecurityTypes.Currency,
						SecurityTypes.Index,
						SecurityTypes.Stock,
						SecurityTypes.Future
					}
				};

				if (wnd.ShowModal(this))
				{
					_isCancelled = false;
					BusyIndicator.IsBusy = true;

					var progress = BusyIndicator.FindVisualChild<ProgressBar>();
					var cancel = (Button)BusyIndicator.FindVisualChild<CancelButton>();

					var secTypes = wnd.SecurityTypes.ToArray();

					progress.Maximum = secTypes.Length;
					cancel.Click += (s1, e1) =>
					{
						_isCancelled = true;
						BusyIndicator.IsBusy = false;
					};

					new RefreshSecurities(settings, secTypes,
						() => _isCancelled,
						count => this.GuiAsync(() => progress.Value = count),
						count => this.GuiAsync(() =>
						{
							BusyIndicator.IsBusy = false;

							new MessageBoxBuilder()
								.Owner(this)
								.Text(LocalizedStrings.Str3264Params.Put(count))
								.Show();

							RefreshGrid();
						})).Process(this);
				}
			}

			ConfigManager.GetService<MarketDataSettingsCache>().Save();
		}
Ejemplo n.º 4
0
        private void EditCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var settings = SelectedSettings;

            var settingsWnd = new StorageSettingsWindow
            {
                Settings = settings
            };

            if (!settingsWnd.ShowModal(this))
            {
                return;
            }

            if (!settings.UseLocal)
            {
                var wnd = new MarketDataConfirmWindow
                {
                    SecurityTypes = new[]
                    {
                        SecurityTypes.Currency,
                        SecurityTypes.Index,
                        SecurityTypes.Stock,
                        SecurityTypes.Future
                    }
                };

                if (wnd.ShowModal(this))
                {
                    _isCancelled         = false;
                    BusyIndicator.IsBusy = true;

                    var progress = BusyIndicator.FindVisualChild <ProgressBar>();
                    var cancel   = (Button)BusyIndicator.FindVisualChild <CancelButton>();

                    var secTypes = wnd.SecurityTypes.ToArray();

                    progress.Maximum = secTypes.Length;
                    cancel.Click    += (s1, e1) =>
                    {
                        _isCancelled         = true;
                        BusyIndicator.IsBusy = false;
                    };

                    new RefreshSecurities(settings, secTypes,
                                          () => _isCancelled,
                                          count => this.GuiAsync(() => progress.Value = count),
                                          count => this.GuiAsync(() =>
                    {
                        BusyIndicator.IsBusy = false;

                        new MessageBoxBuilder()
                        .Owner(this)
                        .Text(LocalizedStrings.Str3264Params.Put(count))
                        .Show();

                        RefreshGrid();
                    })).Process(this);
                }
            }

            ConfigManager.GetService <MarketDataSettingsCache>().Save();
        }