public TaskPanel(DetailsPanel detailsPanel, string name, RightPanelCoordinator coordinator)
                {
                      //Setting up properties
                        this.Orientation = System.Windows.Controls.Orientation.Vertical;
                        this.Margin = new System.Windows.Thickness(0, 0, 10, 0);
                        this.Width = Dimensions.GetWidth() * 0.6;
                        this.MinHeight = Dimensions.GetHeight() * 0.8;
                        //this.Background = ThemeSelector.GetPopUpBackground();

                        //Setting up fields
                        _chief = new TaskMasterChief(name);
                        _coordinator = coordinator;
                       
                        _brainstormingList = new List<SingleTaskPanel>();
                        _trainingList = new List<SingleAdvancedTaskPanel>();
                        _assignmentsList = new List<SingleAdvancedTaskPanel>();
                        _maintenancesList = new List<SingleAdvancedTaskPanel>();
                }
Beispiel #2
0
                public List<AdvancedTask> Sort(TaskMasterChief chief, string section)
                {
                        List<AdvancedTask> advancedTasks = new List<AdvancedTask>();

                        if (section == UIStates.ON_TRAINING)
                        {
                                advancedTasks = chief.SelectTrainings();
                        }
                        else if (section == UIStates.ON_ASSIGNMENT)
                        {
                                advancedTasks = chief.SelectAssignments();
                        }
                        else if (section == UIStates.ON_MAINTENANCE)
                        {
                                advancedTasks = chief.SelectMaintenances();
                        }

                        advancedTasks = this.SpecificSorting(advancedTasks);

                        List<AdvancedTask> finalTasks = new List<AdvancedTask>();

                        for (int i = 0; i < advancedTasks.Count; ++i)
                        {

                                if (advancedTasks[i]._state == States.DONE && Preferences.GetShowDone())
                                {
                                        finalTasks.Add(advancedTasks[i]);
                                }
                                else if (advancedTasks[i]._state != States.DONE)
                                {
                                        finalTasks.Add(advancedTasks[i]);

                                }
                        }

                        return finalTasks;

                }
                }//HandleTaskUpdater()


                private bool IsNameValid()
                {
                        if (_coordinator._contentPanel._UIState ==UIStates.ON_BRAINSTORMING )
                        {
                                List<Model.Task> tasks = new TaskMasterChief(_coordinator._contentPanel._projectName).SelectBrainstormings();

                                foreach (Model.Task item in tasks)
                                {
                                        if (item._name.ToLower().Trim().Replace(" ",string.Empty) == _taskUpdater._nameBox.Text.ToLower().Trim().Replace(" ",string.Empty) && item._project == _coordinator._contentPanel._projectName)
                                                return false;
                                }
                        }

                        else if (_coordinator._contentPanel._UIState == UIStates.ON_TRAINING)
                        {
                                List<Model.AdvancedTask> tasks = new TaskMasterChief(_coordinator._contentPanel._projectName).SelectTrainings();

                                foreach (Model.AdvancedTask item in tasks)
                                {
                                        if (item._name.ToLower().Trim() == _taskUpdater._nameBox.Text.ToLower().Trim() && item._project == _coordinator._contentPanel._projectName)
                                                return false;
                                }
                        }

                        else if (_coordinator._contentPanel._UIState == UIStates.ON_ASSIGNMENT)
                        {
                                List<Model.AdvancedTask> tasks = new TaskMasterChief(_coordinator._contentPanel._projectName).SelectAssignments();

                                foreach (Model.AdvancedTask item in tasks)
                                {
                                        if (item._name.ToLower().Trim() == _taskUpdater._nameBox.Text.ToLower().Trim() && item._project == _coordinator._contentPanel._projectName)
                                                return false;
                                }
                        }


                        else if (_coordinator._contentPanel._UIState == UIStates.ON_MAINTENANCE)
                        {
                                List<Model.AdvancedTask> tasks = new TaskMasterChief(_coordinator._contentPanel._projectName).SelectMaintenances();

                                foreach (Model.AdvancedTask item in tasks)
                                {
                                        if (item._name.ToLower().Trim() == _taskUpdater._nameBox.Text.ToLower().Trim() && item._project == _coordinator._contentPanel._projectName)
                                                return false;
                                }
                        }

                        return true;
                }
                /// <summary>
                /// Checking if the task is already defined in the current project
                /// </summary>
                /// <returns></returns>
                private bool IsNameValid()
                {

                        if(_section == ControlsValues.BRAINSTORMING)
                        {
                                List<Model.Task> tasks = new TaskMasterChief(_projectName).SelectBrainstormings();

                                foreach (Model.Task item in tasks)
                                {
                                        if (item._name.ToLower().Trim().Replace(" ",string.Empty) == _nameBox.Text.ToLower().Trim().Replace(" ", string.Empty) && item._project == _projectName)
                                                return false;
                                }
                        }

                        else if(_section ==ControlsValues.TRAINING)
                        {
                                List<Model.AdvancedTask> tasks = new TaskMasterChief(_projectName).SelectTrainings();

                                foreach (Model.AdvancedTask item in tasks)
                                {
                                        if (item._name.ToLower().Trim().Replace(" ", string.Empty) == _nameBox.Text.ToLower().Trim().Replace(" ", string.Empty) && item._project == _projectName)
                                                return false;
                                }
                        }

                        else if( ControlsValues.ASSIGNMENTS.Contains(_section))
                        {
                                List<Model.AdvancedTask> tasks = new TaskMasterChief(_projectName).SelectAssignments();

                                foreach (Model.AdvancedTask item in tasks)
                                {
                                        if (item._name.ToLower().Trim().Replace(" ", string.Empty) == _nameBox.Text.ToLower().Trim().Replace(" ", string.Empty) && item._project == _projectName)
                                                return false;
                                }
                        }


                        else if(_section == ControlsValues.MAINTENANCE)
                        {
                                List<Model.AdvancedTask> tasks = new TaskMasterChief(_projectName).SelectMaintenances();

                                foreach (Model.AdvancedTask item in tasks)
                                {
                                        if (item._name.ToLower().Trim().Replace(" ", string.Empty) == _nameBox.Text.ToLower().Trim().Replace(" ", string.Empty) && item._project == _projectName)
                                                return false;
                                }
                        }

                        return true;
                }