private void ShowSources(object sender, RoutedEventArgs e)
        {
            var sourcesWindow = new SourcesWindow {
                DataContext = DataContext
            };

            sourcesWindow.ShowDialog();
        }
		private void ExecutedAddSourcesCommand(object sender, ExecutedRoutedEventArgs e)
		{
			var wnd = new SourcesWindow { AvailableTasks = _availableTasks.Where(t => !t.IsCategoryOf(TaskCategories.Tool)).ToArray() };

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

			AddTasks(wnd.SelectedTasks);
		}
Example #3
0
        // создает окно управления источниками
        public static void CreateSourcesView()
        {
            var view      = new SourcesWindow();
            var viewModel = new SourcesWindowViewModel();

            if (viewModel.CloseAction == null)
            {
                viewModel.CloseAction = new Action(view.Close);
            }
            view.DataContext = viewModel;
            view.ShowDialog();
        }
Example #4
0
        private void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            BusyIndicator.BusyContent = LocalizedStrings.Str2941;
            BusyIndicator.IsBusy      = true;

            Task.Factory.StartNew(() =>
            {
                InitializeDataSource();

                var tasks = InitializeTasks();

                GuiDispatcher.GlobalDispatcher.AddSyncAction(() => BusyIndicator.BusyContent = LocalizedStrings.Str2942.Put(LocalizedStrings.Securities));
                ConfigManager.RegisterService <ISecurityProvider>(new FilterableSecurityProvider(_entityRegistry.Securities));

                return(tasks);
            })
            .ContinueWith(res =>
            {
                BusyIndicator.IsBusy = false;

                if (res.IsFaulted && res.Exception != null)
                {
                    var ex = res.Exception.InnerException;

                    ex.LogError();

                    Mouse.OverrideCursor = null;

                    new MessageBoxBuilder()
                    .Caption(ex is DbException ? LocalizedStrings.Str2943 : LocalizedStrings.Str2915)
                    .Text(ex.ToString())
                    .Error()
                    .Owner(this)
                    .Show();

                    Close();

                    return;
                }

                Tasks.AddRange(res.Result);

                var collectionView = (AutoRefreshCollectionViewSource)FindResource("SortedSources");
                if (collectionView != null)
                {
                    var view        = (ListCollectionView)collectionView.View;
                    view.CustomSort = new LanguageSorter();
                }

                HydraEntityRegistry = _entityRegistry;

                var settings = _entityRegistry.Settings;

                try
                {
                    _customAutorization = ConfigManager.TryGetService <IRemoteStorageAuthorization>();
                }
                catch (Exception ex)
                {
                    ex.LogError();
                }

                if (_customAutorization == null)
                {
                    _customAutorization = new DummyRemoteStorageAuthorization();
                }

                ApplySettings();

                InitializeGuiEnvironment();

                if (settings.AutoStart)
                {
                    Start(true);
                }

                AutomaticUpdater.ForceCheckForUpdate(true);

                if (Tasks.Count == 0)
                {
                    var newTasks = new List <Type>();

                    var sourcesWnd = new SourcesWindow {
                        AvailableTasks = _availableTasks.Where(t => !t.IsCategoryOf(TaskCategories.Tool)).ToArray()
                    };

                    if (sourcesWnd.ShowModal(this))
                    {
                        newTasks.AddRange(sourcesWnd.SelectedTasks);
                    }

                    var toolsWnd = new ToolsWindow {
                        AvailableTasks = _availableTasks.Where(t => t.IsCategoryOf(TaskCategories.Tool)).ToArray()
                    };

                    if (toolsWnd.ShowModal(this))
                    {
                        newTasks.AddRange(toolsWnd.SelectedTasks);
                    }

                    if (newTasks.Any())
                    {
                        AddTasks(newTasks);
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            try
            {
                AdvertisePanel.Client = new NotificationClient();
            }
            catch (Exception ex)
            {
                ex.LogError();
            }
        }