diff --git a/pollPlugin/ChartBar.xaml b/pollPlugin/ChartBar.xaml
index 4de8116..447fd3e 100644
--- a/pollPlugin/ChartBar.xaml
+++ b/pollPlugin/ChartBar.xaml
@@ -26,7 +26,7 @@
+ Duration="0:0:0.15" />
@@ -34,7 +34,7 @@
+ Duration="0:0:0.15" />
diff --git a/pollPlugin/UserControl1.xaml b/pollPlugin/PollSetup.xaml
similarity index 89%
rename from pollPlugin/UserControl1.xaml
rename to pollPlugin/PollSetup.xaml
index 21663b9..8680463 100644
--- a/pollPlugin/UserControl1.xaml
+++ b/pollPlugin/PollSetup.xaml
@@ -1,4 +1,4 @@
-
+ Title="Setup poll" Height="275" Width="265" ResizeMode="CanMinimize" Closing="Window_Closing">
@@ -85,14 +85,15 @@
-
+
-
+
-
diff --git a/pollPlugin/ResultsWindow.xaml.cs b/pollPlugin/ResultsWindow.xaml.cs
index bca2958..d6c2211 100644
--- a/pollPlugin/ResultsWindow.xaml.cs
+++ b/pollPlugin/ResultsWindow.xaml.cs
@@ -1,16 +1,8 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
using System.Windows.Threading;
using tvdc.EventArguments;
using tvdc.Plugin;
@@ -34,23 +26,28 @@ public partial class ResultsWindow : Window
{ Color.FromRgb(255, 136, 0), Color.FromRgb(255, 165, 61)}
};
- //UIElement[0] = ChartBar, [1] = TextBlock
private Dictionary pollOptions = new Dictionary();
- private Dictionary voters = new Dictionary();
+ private Dictionary> voters = new Dictionary>();
private int totalVotes = 0;
+ private bool multiVote;
private IPluginHost host;
private DispatcherTimer tmr = new DispatcherTimer();
private DateTime startTime;
- public ResultsWindow(IEnumerable options, IPluginHost host)
+ public ResultsWindow(IEnumerable options, IPluginHost host, bool multiVote)
{
InitializeComponent();
+ cbNotify.IsChecked = Properties.Settings.Default.notify;
+
this.host = host;
this.host.IRC_PrivmsgReceived += messageReceived;
+ this.multiVote = multiVote;
+ tbVoteType.Text = multiVote ? "Multi Vote" : "Single Vote";
+
startTime = DateTime.Now;
tmr.Interval = TimeSpan.FromSeconds(1);
tmr.Tick += Tmr_Tick;
@@ -87,10 +84,10 @@ private void Tmr_Tick(object sender, EventArgs e)
{
if (totalVotes == 0)
{
- od.cb.setValue(100);
+ od.cb.setValue(0);
} else
{
- od.cb.setValue((od.voteCount / totalVotes) * 200);
+ od.cb.setValue((od.voteCount / totalVotes * 1.0) * 200);
}
}
}
@@ -121,16 +118,38 @@ public void messageReceived(object sender, PrivmsgReceivedEventArgs e)
string option = e.message.Trim().ToLower();
if (voters.ContainsKey(e.username))
{
- pollOptions[voters[e.username]].voteCount -= 1;
- voters[e.username] = option;
- host.sendMesssage(string.Format("/w {0} You changed your vote to {1}.",
- e.username, option));
+ if (multiVote)
+ {
+ if (voters[e.username].Contains(option) && Properties.Settings.Default.notify)
+ {
+ host.sendMesssage(string.Format("/w {0} You already voted for {1}.",
+ e.username, option));
+ return;
+ } else
+ {
+ voters[e.username].Add(option);
+ totalVotes += 1;
+ if (Properties.Settings.Default.notify)
+ host.sendMesssage(string.Format("/w {0} Thanks for voting! You voted for {1}.",
+ e.username, string.Join(", ", voters[e.username].ToArray())));
+ }
+ } else
+ {
+ pollOptions[voters[e.username][0]].voteCount -= 1;
+ voters[e.username][0] = option;
+ if (Properties.Settings.Default.notify)
+ host.sendMesssage(string.Format("/w {0} You changed your vote to {1}.",
+ e.username, option));
+ }
} else
{
totalVotes += 1;
- voters.Add(e.username, option);
- host.sendMesssage(string.Format("/w {0} Thanks for voting! You voted for {1}.",
- e.username, option));
+ List l = new List();
+ l.Add(option);
+ voters.Add(e.username, l);
+ if (Properties.Settings.Default.notify)
+ host.sendMesssage(string.Format("/w {0} Thanks for voting! You voted for {1}.",
+ e.username, option));
}
pollOptions[option].voteCount += 1;
}
@@ -153,5 +172,17 @@ private void Window_Closed(object sender, EventArgs e)
tmr.Stop();
host.IRC_PrivmsgReceived -= messageReceived;
}
+
+ private void cbNotify_Checked(object sender, RoutedEventArgs e)
+ {
+ Properties.Settings.Default.notify = true;
+ Properties.Settings.Default.Save();
+ }
+
+ private void cbNotify_Unchecked(object sender, RoutedEventArgs e)
+ {
+ Properties.Settings.Default.notify = false;
+ Properties.Settings.Default.Save();
+ }
}
}
diff --git a/pollPlugin/app.config b/pollPlugin/app.config
new file mode 100644
index 0000000..730dfb4
--- /dev/null
+++ b/pollPlugin/app.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+ True
+
+
+
+
\ No newline at end of file
diff --git a/pollPlugin/pollPlugin.csproj b/pollPlugin/pollPlugin.csproj
index 9bbf418..73ece9e 100644
--- a/pollPlugin/pollPlugin.csproj
+++ b/pollPlugin/pollPlugin.csproj
@@ -58,7 +58,7 @@
Designer
MSBuild:Compile
-
+
MSBuild:Compile
Designer
@@ -68,8 +68,8 @@
ResultsWindow.xaml
-
- UserControl1.xaml
+
+ PollSetup.xaml
Code
@@ -91,6 +91,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+
SettingsSingleFileGenerator
Settings.Designer.cs
@@ -111,7 +112,7 @@
- copy $(TargetPath) $(SolutionDir)\tvdc\bin\Debug\
+ copy "$(TargetPath)" "$(SolutionDir)tvdc\bin\Debug\"