Exemplo n.º 1
0
 public ApplicationViewModel(ITaskboardService taskboardService, IStatusService statusService)
 {
     TaskboardService = taskboardService;
     //TaskboardService.Connected += HandleTaskboardServiceConnected;
     TaskboardService.ConnectionFailed      += HandleConnectionFailed;
     TaskboardService.TfsCommunicationError += HandleTfsCommunicationError;
     TaskboardService.ConfigurationApplied  += HandleConfigurationApplied;
     MruFileManager  = new MruFileManager();
     StatusViewModel = new StatusViewModel(TaskboardService, statusService, null, WorkItemTemplateProvider, Logger);
     ShowPopupWindow = false;
     ShowEditbar     = true;
 }
Exemplo n.º 2
0
        public void EnsureConfigurationModel()
        {
            if (string.IsNullOrEmpty(ConfigurationFileName))
            {
                // Reset all Models
                StatusViewModel = new StatusViewModel(TaskboardService, StatusService, null, WorkItemTemplateProvider,
                                                      Logger);
                ReportViewModel = new ReportViewModel(TaskboardService, ConfigurationService, null)
                {
                    HideReports = false
                };
                ConfigurationViewModel = new ConfigurationViewModel(TaskboardService, ConfigurationService,
                                                                    StatusService, Factory, Logger);
                LinkedWorkItemViewModel = new LinkedWorkItemViewModel(TaskboardService, Logger);
            }
            else
            {
                // Ensure to setup the configuration view model
                ConfigurationViewModel = new ConfigurationViewModel(TaskboardService, ConfigurationService,
                                                                    StatusService, Factory, Logger)
                {
                    ConfigurationData = ConfigurationFileName
                };
                LinkedWorkItemViewModel = new LinkedWorkItemViewModel(TaskboardService, Logger);
                //listen for PropertyChanged event so that we know when CustomStates was updated
                ConfigurationViewModel.PropertyChanged += ConfigurationViewModel_PropertyChanged;
                try
                {
                    ConfigurationViewModel.LoadConfiguration();

                    if (ShowReportViewBarChangedFromUI)
                    {
                        ConfigurationViewModel.HideReportViewer = ShowReportViewerBar;
                        ShowReportViewBarChangedFromUI          = false;
                    }
                    else
                    {
                        if (!CreateNewConfigurationFromExisting)
                        {
                            ShowReportViewerBar = ConfigurationViewModel.HideReportViewer;
                        }
                        else
                        {
                            CreateNewConfigurationFromExisting = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                    StatusService.DequeueStatusItem("ApplyConfiguration");
                    var errorMessage = StatusService.EnqueueStatusItem("ConfigurationError");
                    errorMessage.Message = "Configuration could not be loaded";
                    return;
                }
                ConfigurationViewModel.PropertyChanged -= ConfigurationViewModel_PropertyChanged;

                // Build a report view model that fits to the current configuration
                ReportViewModel = new ReportViewModel(TaskboardService, ConfigurationService,
                                                      ConfigurationViewModel.Configuration)
                {
                    ConfigurationData = ConfigurationFileName,
                    HideReports       = ConfigurationViewModel.HideReportViewer
                };
                // Build a status view model that fits to the current configuration
                StatusViewModel = new StatusViewModel(TaskboardService, StatusService,
                                                      ConfigurationViewModel.Configuration,
                                                      WorkItemTemplateProvider, Logger);
                RefreshFilter();
                //check if configuration size is valid. otherwise revert to default
            }
            OnPropertyChanged("ConfigurationViewModel");
            OnPropertyChanged("StatusViewModel");
            OnPropertyChanged("ReportViewModel");

            StatusService.DequeueStatusItem("ApplyConfiguration");
            SyncService.BeginInvoke(DispatcherPriority.Background, new Action <bool>(ConfigurationViewModel.Commit),
                                    false);

            OnSelectFilterItem();
        }