public void SelectTeamProject()
        {
            var picker = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);

            if (TeamProjectCollectionUri != null)
            {
                try
                {
                    picker.SelectedTeamProjectCollection = new TfsTeamProjectCollection(TeamProjectCollectionUri);
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
            }
            // TODO: Set Team Project according to the login data
            WinForms.DialogResult result = picker.ShowDialog();
            if (result == WinForms.DialogResult.OK)
            {
                TaskBoardService.LoginData.TeamProjectName          = picker.SelectedProjects[0].Name;
                TaskBoardService.LoginData.TeamProjectCollectionUri = picker.SelectedTeamProjectCollection.Uri;
                TaskBoardService.Connect();
                LoadConfiguration(ConfigurationService.GetDefaultConfiguration());

                RefreshQueryItems();
                SetQueryItem(CopiedQueryHierarchy);

                TeamProjectCollectionUri = picker.SelectedTeamProjectCollection.Uri;
                TeamProjectName          = picker.SelectedProjects[0].Name;

                OnPropertyChanged("TeamProjectName");
            }
        }
        private void LoadWorkItemTypes()
        {
            WorkItemTypeCollection typesFromServer = TaskBoardService.GetWorkItemTypes();

            WorkItemTypes = typesFromServer;
            OnPropertyChanged("WorkItemTypes");
            LoadWorkItemStates();
        }
 public void RefreshQueryItems()
 {
     if (TaskBoardService != null)
     {
         QueryHierarchy = TaskBoardService.GetWorkItemQueries(true);
         //we need to copy the hierarchy to another object and bind the TreeView to that object
         //otherwise, the TreeView will show the old hierarchy even if it was updated
         CopiedQueryHierarchy = QueryHierarchy;
     }
 }
        public void SetQueryItem(object queryItem)
        {
            var newQueryItem = queryItem as QueryItem;

            if (newQueryItem != null)
            {
                // Remember the selected query.
                QueryItem = newQueryItem;
                OnPropertyChanged("QueryItem");
                // Configure the fields available for Summary and sorting
                PossibleSummaryFields = TaskBoardService.GetPossibleSummaryFields(newQueryItem);
                PossibleSortFields    = TaskBoardService.GetPossibleSortFields(newQueryItem);
                OnPropertyChanged("PossibleSummaryFields");
                OnPropertyChanged("PossibleSortFields");
            }
        }
 public void RefreshConfiguration()
 {
     TaskBoardService.ApplyConfiguration(Configuration);
 }
        public void LoadConfiguration(IConfiguration config)
        {
            Configuration = config;
            LinkTypes     = TaskBoardService.GetLinkTypes();
            OnPropertyChanged("LinkTypes");

            if (Configuration.QueryId != Guid.Empty)
            {
                try
                {
                    SetQueryItem(TaskBoardService.GetQueryItem(Configuration.QueryId));
                    CurrentSortField          = PossibleSortFields.SingleOrDefault(sf => sf.Name == Configuration.SortFieldName);
                    CurrentRowSummaryField    = PossibleSummaryFields.SingleOrDefault(sf => sf.Name == Configuration.RowSummaryFieldName);
                    CurrentColumnSummaryField = PossibleSummaryFields.SingleOrDefault(sf => sf.Name == Configuration.ColumnSummaryFieldName);
                    OnPropertyChanged("CurrentSortField");
                    OnPropertyChanged("CurrentRowSummaryField");
                    OnPropertyChanged("CurrentColumnSummaryField");
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                    var statusItem = StatusService.EnqueueStatusItem("InvalidQueryId");
                    statusItem.Message = "The configured query is invalid. Please edit the configuration.";
                }
            }

            CurrentSortDirection       = Configuration.SortDirection;
            HideColumnSummaryFieldname = Configuration.HideColumnSummaryFieldName;
            WorkItemSize            = Configuration.WorkItemSize;
            HideReportViewer        = Configuration.HideReportViewer;
            CurrentLinkType         = LinkTypes.FirstOrDefault(linkType => linkType.ReferenceName == Configuration.LinkType);
            CurrentAutoRefreshDelay = Configuration.AutoRefreshDelay;
            OnPropertyChanged("CurrentSortDirection");
            OnPropertyChanged("HideColumnSummaryFieldname");
            OnPropertyChanged("WorkItemSize");
            OnPropertyChanged("CurrentLinkType");
            OnPropertyChanged("CurrentAutoRefreshDelay");
            QueryHierarchy = TaskBoardService.GetWorkItemQueries(true);
            var clonedStates = (from state in Configuration.States select state.Clone() as ICustomState).ToList();

            CustomStates = new ObservableCollection <ICustomState>(clonedStates);
            OnPropertyChanged("CustomStates");

            if (Configuration.ChildItems != null)
            {
                ChildItems = new List <string>(Configuration.ChildItems);
            }
            if (Configuration.BacklogItems != null)
            {
                BacklogItems = new List <string>(Configuration.BacklogItems);
            }

            LoadWorkItemTypes();
            SortDirections = new List <SortDirection>((IEnumerable <SortDirection>)Enum.GetValues(typeof(SortDirection)));
            if (!String.IsNullOrEmpty(Configuration.TeamProject))
            {
                TeamProjectName = Configuration.TeamProject;
            }
            if (!String.IsNullOrEmpty(Configuration.TeamProjectCollection))
            {
                TeamProjectCollectionUri = new Uri(Configuration.TeamProjectCollection);
            }

            TaskBoardService.ApplyConfiguration(Configuration);
            OnPropertyChanged("CustomStates");
            IsConfigurationLoaded = true;
        }