public void AddToDoResult(SpectreToDoResult stdr) { this.ToDoResults.Add(stdr.stdd); increaseIndex(); }
//adds the results according to their index after they have been loaded or reordered private void addResults() { //resetting the rows this.Controls.Clear(); this.RowStyles.Clear(); this.RowCount = 0; //define the total amount of results that need to be added int totalAmountResults = GeneralResults.Count + NoteResults.Count + ToDoResults.Count; //adding error results to the result pane foreach (var errorResult in GeneralResults) { if (errorResult.Index == -1) { SpectreGeneralResult ssr = new SpectreGeneralResult(errorResult); this.RowCount++; this.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Absolute, ssr.srd.Button ? 175f : 145f)); this.Controls.Add(ssr); this.Width = this.Width - 15; } } //lastMinimum defines the last min that needs to be compared --> to get to the next "level" of smallest number int lastMinimum = -1; //circles through all results as long as every result is added for (int i = 0; i < totalAmountResults; i++) { //define the min index in each array int generalMin = Int32.MaxValue; int todoMin = Int32.MaxValue; int noteMin = Int32.MaxValue; //defines the index of the result with the lowest index in each array int generalMinIndex = -1; int todoMinIndex = -1; int noteMinIndex = -1; int index = -1; //defines the index which we are currently checking //looking in GeneralResults foreach (SpectreResultData srd in GeneralResults) { index++; if (srd.Index != -1) { if (srd.Index < generalMin && srd.Index > lastMinimum) { generalMin = srd.Index; generalMinIndex = index; } } } index = 0; //resetting the index //looking in ToDoResults foreach (SpectreToDoData stdd in ToDoResults) { if (stdd.Index < todoMin && stdd.Index > lastMinimum) { todoMin = stdd.Index; todoMinIndex = index; } } index = 0; //resetting the index //looking in NoteResults foreach (SpectreResultData srd in NoteResults) { if (srd.Index < todoMin && srd.Index > lastMinimum) { noteMin = srd.Index; noteMinIndex = index; } } //checking wich one has the smallest index and finally adding it and increasing the lastMinimum if (generalMin < todoMin && generalMin < noteMin) { //adding general result SpectreGeneralResult ssr = new SpectreGeneralResult(GeneralResults[generalMinIndex]); this.RowCount++; this.RowStyles.Add(new System.Windows.Forms.RowStyle(SizeType.Absolute, ssr.srd.Button ? 175f : 145f)); this.Controls.Add(ssr); this.Width = this.Width - 15; lastMinimum = generalMin; } else if (todoMin < noteMin) { //adding a todo result SpectreToDoResult stdr = new SpectreToDoResult(ToDoResults[todoMinIndex]); //calculate the height needed for the todolist int height = 75; List<string> names = stdr.GetNames(); for (int j = 0; j < stdr.GetData().entries.Count; j++) { if (names[j].Length >= 53) { height += ((names[j].Length / 53) * 25); } else { height += 28; } } this.RowCount++; this.RowStyles.Add(new RowStyle(SizeType.Absolute, height)); this.Controls.Add(stdr); lastMinimum = todoMin; } else { //adding note result SpectreNoteResult snr = new SpectreNoteResult(NoteResults[noteMinIndex]); int height = 75 + (snr.tb_content.Text.Length / 55) * 20; this.RowCount++; this.RowStyles.Add(new RowStyle(SizeType.Absolute, height)); this.Controls.Add(snr); lastMinimum = noteMin; } } //for loop }