void SearchItemPicker_SelectedIndexChanged(object sender, EventArgs e) { ToggleSearchBtn(); SearchingGraphObject SGObj = (SearchingGraphObject)BindingContext; // change colour of old entry Entry oldEntry = CurrentEntriesOnGraph.Where(p => p.Value == SGObj.SearchItemValue) .FirstOrDefault(); if (!(oldEntry is null)) { oldEntry.Color = SKColor.Parse("#FF1493"); } SGObj.SearchItemValue = searchItemPicker.SelectedIndex; Entry searchItemEntry = CurrentEntriesOnGraph.Where(p => p.Value == SGObj.SearchItemValue) .FirstOrDefault(); int index = CurrentEntriesOnGraph.ToList().IndexOf(searchItemEntry); if (SGObj.SearchItemValue > 0) { CurrentEntriesOnGraph.ToArray()[index].Color = SKColor.Parse("#0000FF"); } DisplayGraph(CurrentEntriesOnGraph); }
private async void CarryOutMergeOperations(List <MergeSortOperation> operations) { foreach (MergeSortOperation operation in operations) { SortingGraphObject SGObj = (SortingGraphObject)BindingContext; int speed = SGObj.SpeedDictionary[SGObj.Speed]; if (!operation.IsFinalMergeOperation) { foreach (Entry entry in operation.LeftEntries) { Entry tempEntry = CurrentEntriesOnGraph.Where(hr => hr.Value == entry.Value).FirstOrDefault(); if (tempEntry != null) { continue; // doesn't f*cking work } } DisplayGraph(CurrentEntriesOnGraph); await Task.Delay(speed); } else { CurrentEntriesOnGraph = operation.LeftEntries .Concat(operation.RightEntries) .ToList(); DisplayGraph(CurrentEntriesOnGraph); await Task.Delay(speed); int resultValue = (int)operation.ResultsEntries.Last().Value; Entry entry = CurrentEntriesOnGraph.Where(hr => hr.Value == resultValue) .FirstOrDefault(); if (entry != null) { List <Entry> entries = CurrentEntriesOnGraph.Select(hr => hr).ToList(); entries.Remove(entry); entries.Add(entry); CurrentEntriesOnGraph = entries; DisplayGraph(CurrentEntriesOnGraph); await Task.Delay(speed); } } } ToggleButtons(); DisplayCaseBtns(); }