public HelpDeskViewModel([Import] ScrumFactory.Composition.IEventAggregator aggregator)
        {
            this.aggregator = aggregator;

            aggregator.Subscribe<string>(ScrumFactoryEvent.ConfigChanged, c => {
                if (c == "TicketProjectsEnabled")
                    OnPropertyChanged("PanelPlacement");

            });

            OnLoadCommand = new ScrumFactory.Composition.DelegateCommand(() => { if (NeedRefresh) LoadData(); });

            RefreshCommand = new ScrumFactory.Composition.DelegateCommand(LoadData);

            ShowItemCommand = new ScrumFactory.Composition.DelegateCommand<BacklogItem>(ShowItem);

            AddJobCommand = new ScrumFactory.Composition.DelegateCommand(AddJob);

            delayFilter = new DelayAction(800, new DelayAction.ActionDelegate(() => { ticketsSource.View.Refresh(); }));

            ticketsSource = new System.Windows.Data.CollectionViewSource();
            ticketsSource.Filter += new System.Windows.Data.FilterEventHandler(ticketsSource_Filter);

            NeedRefresh = true;
        }
        public SizeListViewModel(
            [Import] IBacklogService backlogService,
            [Import] IBackgroundExecutor backgroundExecutor,
            [Import] IEventAggregator eventAggregator,
            [Import] IDialogService dialogs,
            [Import] IAuthorizationService authorizator)
        {
            this.backlogService = backlogService;
            this.executor = backgroundExecutor;
            this.aggregator = eventAggregator;
            this.authorizator = authorizator;
            this.dialogs = dialogs;

            AddNewSizeCommand = new DelegateCommand(CanEditItemSizes, AddNewSize);
            CloseWindowCommand = new DelegateCommand(CloseWindow);
            DeleteSizeCommand = new DelegateCommand<SizeViewModel>(CanEditItemSizes, DeleteSize);
            SetAsPlanningItemCommand = new DelegateCommand<SizeViewModel>(CanEditItemSizes, size => SetItemOccurrenceContraint(size, ItemOccurrenceContraints.PLANNING_OCC));
            SetAsDeliveryItemCommand = new DelegateCommand<SizeViewModel>(CanEditItemSizes, size => SetItemOccurrenceContraint(size, ItemOccurrenceContraints.DELIVERY_OCC));

            sizesViewSource = new System.Windows.Data.CollectionViewSource();
            sizesViewSource.Filter += new System.Windows.Data.FilterEventHandler(sizesViewSource_Filter);
            delayFilter = new DelayAction(1200, new DelayAction.ActionDelegate(() => { FilteredSizes.Refresh(); }));

            aggregator.Subscribe<MemberProfile>(ScrumFactoryEvent.SignedMemberChanged,
                m => {
                    RefreshCommands();
                    if (m == null) return;
                    if (Sizes!=null) return;
                    LoadItemSizes();
                });
        }
        public MembersListViewModel(
            [Import] IBackgroundExecutor backgroundExecutor,
            [Import] IEventAggregator eventAggregator,
            [Import] IAuthorizationService authorizator,
            [Import] IDialogService dialogService,
            [Import] ITeamService teamService,
            [Import] IProjectsService projectService)
        {
            this.aggregator = eventAggregator;
                this.executor = backgroundExecutor;
                this.authorizator = authorizator;
                this.dialogs = dialogService;

                this.teamService = teamService;
                this.projectService = projectService;

                membersViewSource = new System.Windows.Data.CollectionViewSource();
                membersViewSource.SortDescriptions.Add(new SortDescription("MemberProfile.FullName", ListSortDirection.Ascending));

                membersViewSource.Filter += new FilterEventHandler(membersViewSource_Filter);
                delayFilter = new DelayAction(500, new DelayAction.ActionDelegate(() => { if (FilteredMembers != null) FilteredMembers.Refresh(); }));

                aggregator.Subscribe<MemberProfile>(ScrumFactoryEvent.SignedMemberChanged, OnSignedMemberChanged);

                aggregator.Subscribe<MemberProfile>(ScrumFactoryEvent.ShowMemberDetail,
                    member => {
                        dialogs.SelectTopMenu(this);
                        ShowDetail(member);
                    });

                OnLoadCommand = new DelegateCommand(() => { if (NeedRefresh) LoadMembers(); });
                RefreshCommand = new DelegateCommand(LoadMembers);
                ShowDetailWindowCommand = new DelegateCommand<MemberViewModel>(ShowDetail);

                AddNewMemberCommand = new DelegateCommand(CanAddMember, AddMember);

                OnlyActiveMembers = true;

                NeedRefresh = true;
        }
        public BacklogViewModel(
            [Import] IBacklogService backlogService,
            [Import] ITasksService tasksService,
            [Import] IBackgroundExecutor backgroundExecutor,
            [Import] IEventAggregator eventAggregator,
            [Import] IDialogService dialogService,
            [Import] IAuthorizationService authorizationService)
        {
            this.backlogService = backlogService;
            this.tasksService = tasksService;
            this.executor = backgroundExecutor;
            this.aggregator = eventAggregator;
            this.dialogs = dialogService;
            this.authorizator = authorizationService;

            aggregator.Subscribe<string>(ScrumFactoryEvent.ConfigChanged, OnConfigChanged);

            aggregator.Subscribe<Project>(ScrumFactoryEvent.ViewProjectDetails, OnViewProjectDetails, 10);

            aggregator.Subscribe <ICollection<Role>>(ScrumFactoryEvent.ProjectRolesChanged, SyncPlannedHours);

            aggregator.Subscribe<Sprint>(ScrumFactoryEvent.SprintAdded, s => { AskForRefresh(); });
            aggregator.Subscribe<ICollection<Sprint>>(ScrumFactoryEvent.SprintsDateChanged, s => { AskForRefresh(); });
            aggregator.Subscribe(ScrumFactoryEvent.SprintsShifted, AskForRefresh);

            aggregator.Subscribe(ScrumFactoryEvent.BacklogReplannedByTask, AskForRefresh);

            aggregator.Subscribe<BacklogItem[]>(ScrumFactoryEvent.BacklogItemsChanged, UpdateChangedItems);

            aggregator.Subscribe<BacklogItem>(ScrumFactoryEvent.ShowItemDetail, ShowDetailWindow);

            aggregator.Subscribe<BacklogItem>(ScrumFactoryEvent.BacklogItemSelectedChanged, OnItemsSelectedChanged);

            LoadDataCommand = new DelegateCommand(() => { if (NeedRefresh) LoadData(); });
            ShowDetailWindowCommand = new DelegateCommand<BacklogItemViewModel>(ShowDetailWindow);
            CreateNewBacklogItemCommand = new DelegateCommand(CreateNewBacklogItem);

            DeleteBacklogItemCommand = new DelegateCommand<BacklogItemViewModel>(CanRemoveBacklogItem, RemoveBacklogItem);

            EditItemSizesCommand = new DelegateCommand(CanEditItemSizes, EditItemSizes);
            PlanAllLateItemsCommand = new DelegateCommand(CanPlanAllLateItems, PlanAllLateItems);

            MoveItemToCommand = new DelegateCommand<Windows.Helpers.DragDrop.DropCommandParameter>(MoveItemTo);

            CopyItemsCommand = new DelegateCommand(CopyItemsToClipboard);
            PasteItemsCommand = new DelegateCommand(PasteItems);
            SelectAllItemsCommand = new DelegateCommand(SelectAllItems);

            FilterByMonthCommand = new DelegateCommand<DateTime>(FilterByMonth);

            backlogViewSource = new System.Windows.Data.CollectionViewSource();
            backlogViewSource.SortDescriptions.Add(new SortDescription("Item.SprintNumber", ListSortDirection.Ascending));
            backlogViewSource.SortDescriptions.Add(new SortDescription("Item.OccurrenceConstraint", ListSortDirection.Ascending));
            backlogViewSource.SortDescriptions.Add(new SortDescription("Item.BusinessPriority", ListSortDirection.Ascending));
            backlogViewSource.SortDescriptions.Add(new SortDescription("Item.BacklogItemNumber", ListSortDirection.Ascending));

            backlogViewSource.Filter += new System.Windows.Data.FilterEventHandler(backlogViewSource_Filter);
            delayFilter = new DelayAction(800, new DelayAction.ActionDelegate(() => { FilteredBacklog.Refresh(); }));

            // just to show group list at screens with 1024 or more pixels width
            OnPropertyChanged("ShowGroupList");
        }
        public TasksListViewModel(
            [Import] ITasksService tasksService,
            [Import] IBacklogService backlogService,
            [Import] IBackgroundExecutor backgroundExecutor,
            [Import] IEventAggregator eventAggregator,
            [Import] IDialogService dialogService,
            [Import] IAuthorizationService authorizationService)
        {
            this.tasksService = tasksService;
                this.backlogService = backlogService;
                this.executor = backgroundExecutor;
                this.aggregator = eventAggregator;
                this.dialogs = dialogService;
                this.authorizator = authorizationService;

            tasksViewSource = new System.Windows.Data.CollectionViewSource();

            tasksViewSource.SortDescriptions.Add(new SortDescription("Task.Priority", ListSortDirection.Descending));
            tasksViewSource.SortDescriptions.Add(new SortDescription("Task.TaskType", ListSortDirection.Descending));
            tasksViewSource.SortDescriptions.Add(new SortDescription("Task.TaskNumber", ListSortDirection.Descending));

            tasksViewSource.Filter += new System.Windows.Data.FilterEventHandler(tasksViewSource_Filter);
            delayFilter = new DelayAction(500, new DelayAction.ActionDelegate(Refresh));

            backlogViewSource = new System.Windows.Data.CollectionViewSource();
            backlogViewSource.SortDescriptions.Add(new SortDescription("SprintNumber", ListSortDirection.Ascending));
            backlogViewSource.SortDescriptions.Add(new SortDescription("OccurrenceConstraint", ListSortDirection.Ascending));
            backlogViewSource.SortDescriptions.Add(new SortDescription("BusinessPriority", ListSortDirection.Ascending));
            backlogViewSource.SortDescriptions.Add(new SortDescription("BacklogItemNumber", ListSortDirection.Ascending));

            clockUpdate = new DelayAction(1000, new DelayAction.ActionDelegate(UpdateClock), false);

            player = new System.Media.SoundPlayer();
            player.Stream = Properties.Resources.whistles;
            player.Load();

            ListMode = ListModes.POST_IT_MODE;

            NewTaskType = (short)TaskTypes.DEVELOPMENT_TASK;

            OnLoadCommand = new DelegateCommand(() => { if (NeedRefresh) LoadData(); });

            ShowDetailWindowCommand = new DelegateCommand<TaskViewModel>(ShowDetail);

            CreateTaskCommand = new DelegateCommand(CanCreateTask, CreateTask);
            CreateEmptyTaskCommand = new DelegateCommand(CanCreateEmptyTask, CreateTask);

            ChangeListModeCommand = new DelegateCommand(ChangeListMode);

            MoveTaskCommand = new DelegateCommand<Windows.Helpers.DragDrop.DropCommandParameter>(MoveTask);

            ChangeTaskItemCommand = new DelegateCommand<Windows.Helpers.DragDrop.DropCommandParameter>(ChangeTaskItem);

            ShowJoinDialogCommand = new DelegateCommand(CanJoinProject, ShowJoinDialog);

            StartStopClockCommand = new DelegateCommand(StartStopClock);

            SetNewTaskTypeCommand = new DelegateCommand<Int16>(t => { NewTaskType = t; });

            CopyTasksCommand = new DelegateCommand(CopyTasksToClipboard);
            PasteTasksCommand = new DelegateCommand(PasteTasks);
            SelectAllTasksCommand = new DelegateCommand(SelectAllTasks);

            CloseItemCommand = new DelegateCommand<BacklogItem>(CloseItem);

            AddNewTagCommand = new DelegateCommand(CanAddTags, AddNewTag);
            RemoveTagCommand = new DelegateCommand<TaskTag>(CanAddTags, RemoveTag);
            UpdateTagCommand = new DelegateCommand<TaskTag>(CanAddTags, UpdateTag);

            aggregator.Subscribe<Project>(ScrumFactoryEvent.ViewProjectDetails, p => {
                Project = p;
                StopClock();
                OnPropertyChanged("CurrentSprintLabel");
            });

            aggregator.Subscribe<ICollection<MemberProfile>>(ScrumFactoryEvent.ProjectMembersChanged, OnMembersChanged);

            aggregator.Subscribe<ICollection<Role>>(ScrumFactoryEvent.ProjectRolesChanged, OnRolesChanged);
            aggregator.Subscribe<Task>(ScrumFactoryEvent.TaskChanged, OnTaskChanged);

            aggregator.Subscribe(ScrumFactoryEvent.ApplicationWhentForeground, OnAppForeground);

            aggregator.Subscribe<BacklogItem>(ScrumFactoryEvent.ShowTasksForItem, ShowTasksForItem);

            aggregator.Subscribe<BacklogItem[]>(ScrumFactoryEvent.BacklogItemsChanged, UpdateChangedItems);
            aggregator.Subscribe(ScrumFactoryEvent.SprintsShifted, AskForRefresh);

            aggregator.Subscribe<Project>(ScrumFactoryEvent.ProjectStatusChanged, SetReplanItemWhenChanged);

            aggregator.Subscribe<Task>(ScrumFactoryEvent.TaskSelectedChanged, OnTaskSelectedChanged);
        }
        public ProjectsListViewModel(
            [Import] IEventAggregator aggregator,
            [Import] IProjectsService projectsService,
            [Import] IBackgroundExecutor executor,
            [Import] IDialogService dialogs,
            [Import] IAuthorizationService authorizator)
        {
            this.aggregator = aggregator;
            this.projectsService = projectsService;
            this.executor = executor;
            this.dialogs = dialogs;
            this.authorizator = authorizator;

            projectsViewSource = new System.Windows.Data.CollectionViewSource();
            projectsViewSource.SortDescriptions.Add(new SortDescription("Status", ListSortDirection.Ascending));
            projectsViewSource.SortDescriptions.Add(new SortDescription("TotalDayAllocation", ListSortDirection.Descending));
            projectsViewSource.SortDescriptions.Add(new SortDescription("ProjectNumber", ListSortDirection.Descending));

            projectsViewSource.Filter += new System.Windows.Data.FilterEventHandler(FilteredProjects_Filter);
            delayFilter = new DelayAction(500, new DelayAction.ActionDelegate(() => {
                if (allDataLoaded && FilteredProjects != null) {
                    FilteredProjects.Refresh();
                    SetGroupCount();
                } else {
                    LoadProjectList();
                }
            }));

            aggregator.Subscribe<Project>(ScrumFactoryEvent.ProjectStatusChanged, OnProjectStatusChanged);

            aggregator.Subscribe<Project>(ScrumFactoryEvent.ProjectCreated, OnProjectCreated);

            aggregator.Subscribe<MemberProfile>(ScrumFactoryEvent.SignedMemberChanged,
                m => {
                    ((DelegateCommand)CreateProjectCommand).NotifyCanExecuteChanged();
                    if (m == null) {
                        OnProjectListLoaded(new List<Project>());
                        SelectedProject = null;
                        aggregator.Publish<Project>(ScrumFactoryEvent.ViewProjectDetails, SelectedProject);
                        return;
                    }
                    LoadProjectList();
                    ShowDetailOnInit();
                });

            aggregator.Subscribe<Project>(ScrumFactoryEvent.ViewProjectDetails, p => {
                if (SelectedProject != p)
                    SelectedProject = p;
            });

            aggregator.Subscribe(ScrumFactoryEvent.CreateNewProject, () => {
                dialogs.SelectTopMenu(this);
                OpenCreateProjectWindow();
            });

            aggregator.Subscribe<int>(ScrumFactoryEvent.ProjectArgOnInit, OnProjectArgOnInit);

            OnLoadCommand = new DelegateCommand(() => { if (NeedRefresh) LoadProjectList(); });

            RefreshProjectListCommand = new DelegateCommand(() => { LoadProjectList(); });
            ShowDetailWindowCommand = new DelegateCommand<Project>(p => { ShowDetailWindow(p.ProjectUId); });
            CreateProjectCommand = new DelegateCommand(CanCreateProject, OpenCreateProjectWindow);

            CopyToClipboardCommand = new DelegateCommand(CopyToClipboard);

            LoadMoreCommand = new DelegateCommand(() => { LoadProjectList(false); });

            NeedRefresh = true;
        }