Skip to content

Commit

Permalink
Store manually entered tasks, and use them in creating the initial co…
Browse files Browse the repository at this point in the history
…ntext menu.
  • Loading branch information
Kinematics committed Jul 28, 2015
1 parent 3e839c4 commit 257bac7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions NetTally/MergeVotesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public partial class ManageVotesWindow : Window, INotifyPropertyChanged
List<MenuItem> ContextMenuCommands = new List<MenuItem>();
List<MenuItem> ContextMenuTasks = new List<MenuItem>();

HashSet<string> ManualTasks { get; }

ListBox newTaskBox = null;


Expand All @@ -52,6 +54,7 @@ public ManageVotesWindow(Tally tally)
InitializeComponent();

VoteCounter = tally.VoteCounter;
ManualTasks = tally.ManualTasks;

// Gets the lists of all current votes and ranked votes that can be shown.
List<string> votes = VoteCounter.VotesWithSupporters.Keys
Expand Down Expand Up @@ -536,9 +539,11 @@ private void CreateContextMenuCommands()
/// </summary>
private void InitTasksFromVoteCounter()
{
var voteTasks = VoteCounter.GetVotesCollection(CurrentVoteType).Keys.
Select(v => VoteString.GetVoteTask(v)).Distinct().
Where(v => v != string.Empty).OrderBy(v => v);
var voteTasks = VoteCounter.GetVotesCollection(CurrentVoteType).Keys
.Select(v => VoteString.GetVoteTask(v))
.Concat(ManualTasks.ToList())
.Distinct(StringComparer.OrdinalIgnoreCase)
.Where(v => v != string.Empty);

foreach (var task in voteTasks)
ContextMenuTasks.Add(CreateContextMenuItem(task));
Expand Down Expand Up @@ -596,6 +601,8 @@ private void AddTaskToContextMenu(string task)
if (ContextMenuTasks.Any(t => t.Header.ToString() == task))
return;

ManualTasks.Add(task);

ContextMenuTasks.Add(CreateContextMenuItem(task));

UpdateContextMenu();
Expand Down

0 comments on commit 257bac7

Please sign in to comment.