Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
caf45e57ca | ||
|
|
f28ec5216f | ||
|
|
4ce42d18eb | ||
|
|
633862e0bb | ||
|
|
616e32654c |
29
LICENSE
29
LICENSE
@@ -1,16 +1,21 @@
|
|||||||
Copyright (c) 2013 Drew DeVault
|
MIT License
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
Copyright (c) 2016 gardient
|
||||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
||||||
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
The above copyright notice and this permission notice shall be included in all
|
||||||
portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ press the button [Give Me A Random Winner] and the following will happen:
|
|||||||
## Features to come
|
## Features to come
|
||||||
|
|
||||||
- Change to new random.org API (yes this uses the old one)
|
- Change to new random.org API (yes this uses the old one)
|
||||||
- Add minimum value to random number
|
- ~~Add minimum value to random number~~(Done!)
|
||||||
- Add better defined matching if number with which to enter the lottery
|
- Add better defined matching if number with which to enter the lottery
|
||||||
- Number has to be right at the beginning of the comment
|
- Number has to be right at the beginning of the comment
|
||||||
- Dropdown with more options
|
- Dropdown with more options
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||||
|
<section name="RedditRandomNumberGiveawayHelper.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
|
</sectionGroup>
|
||||||
|
</configSections>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
|
||||||
</startup>
|
</startup>
|
||||||
|
<applicationSettings>
|
||||||
|
<RedditRandomNumberGiveawayHelper.Properties.Settings>
|
||||||
|
<setting name="Version" serializeAs="String">
|
||||||
|
<value>V0.3.0</value>
|
||||||
|
</setting>
|
||||||
|
</RedditRandomNumberGiveawayHelper.Properties.Settings>
|
||||||
|
</applicationSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -35,28 +35,34 @@
|
|||||||
this.button1 = new System.Windows.Forms.Button();
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
this.textBox2 = new System.Windows.Forms.TextBox();
|
this.textBox2 = new System.Windows.Forms.TextBox();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.randomMin = new System.Windows.Forms.NumericUpDown();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.randomMax)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.randomMax)).BeginInit();
|
||||||
|
this.menuStrip1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.randomMin)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
this.label1.AutoSize = true;
|
||||||
this.label1.Location = new System.Drawing.Point(12, 15);
|
this.label1.Location = new System.Drawing.Point(33, 41);
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(100, 13);
|
this.label1.Size = new System.Drawing.Size(100, 13);
|
||||||
this.label1.TabIndex = 0;
|
this.label1.TabIndex = 0;
|
||||||
this.label1.Text = "Giveaway Post URI";
|
this.label1.Text = "Giveaway Post URI";
|
||||||
|
this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||||
//
|
//
|
||||||
// textBox1
|
// textBox1
|
||||||
//
|
//
|
||||||
this.textBox1.Location = new System.Drawing.Point(118, 12);
|
this.textBox1.Location = new System.Drawing.Point(139, 38);
|
||||||
this.textBox1.Name = "textBox1";
|
this.textBox1.Name = "textBox1";
|
||||||
this.textBox1.Size = new System.Drawing.Size(463, 20);
|
this.textBox1.Size = new System.Drawing.Size(441, 20);
|
||||||
this.textBox1.TabIndex = 1;
|
this.textBox1.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// randomMax
|
// randomMax
|
||||||
//
|
//
|
||||||
this.randomMax.Location = new System.Drawing.Point(118, 39);
|
this.randomMax.Location = new System.Drawing.Point(220, 64);
|
||||||
this.randomMax.Maximum = new decimal(new int[] {
|
this.randomMax.Maximum = new decimal(new int[] {
|
||||||
100000,
|
100000,
|
||||||
0,
|
0,
|
||||||
@@ -68,7 +74,7 @@
|
|||||||
0,
|
0,
|
||||||
0});
|
0});
|
||||||
this.randomMax.Name = "randomMax";
|
this.randomMax.Name = "randomMax";
|
||||||
this.randomMax.Size = new System.Drawing.Size(115, 20);
|
this.randomMax.Size = new System.Drawing.Size(75, 20);
|
||||||
this.randomMax.TabIndex = 2;
|
this.randomMax.TabIndex = 2;
|
||||||
this.randomMax.Value = new decimal(new int[] {
|
this.randomMax.Value = new decimal(new int[] {
|
||||||
5000,
|
5000,
|
||||||
@@ -79,17 +85,18 @@
|
|||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
this.label2.AutoSize = true;
|
||||||
this.label2.Location = new System.Drawing.Point(12, 41);
|
this.label2.Location = new System.Drawing.Point(11, 67);
|
||||||
this.label2.Name = "label2";
|
this.label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(57, 13);
|
this.label2.Size = new System.Drawing.Size(122, 13);
|
||||||
this.label2.TabIndex = 3;
|
this.label2.TabIndex = 3;
|
||||||
this.label2.Text = "Max Value";
|
this.label2.Text = "Random Number Range";
|
||||||
|
this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||||
//
|
//
|
||||||
// button1
|
// button1
|
||||||
//
|
//
|
||||||
this.button1.Location = new System.Drawing.Point(239, 38);
|
this.button1.Location = new System.Drawing.Point(301, 64);
|
||||||
this.button1.Name = "button1";
|
this.button1.Name = "button1";
|
||||||
this.button1.Size = new System.Drawing.Size(342, 23);
|
this.button1.Size = new System.Drawing.Size(279, 23);
|
||||||
this.button1.TabIndex = 4;
|
this.button1.TabIndex = 4;
|
||||||
this.button1.Text = "Get Me A Random Winner";
|
this.button1.Text = "Get Me A Random Winner";
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
@@ -97,27 +104,68 @@
|
|||||||
//
|
//
|
||||||
// textBox2
|
// textBox2
|
||||||
//
|
//
|
||||||
this.textBox2.Location = new System.Drawing.Point(13, 95);
|
this.textBox2.Location = new System.Drawing.Point(12, 121);
|
||||||
this.textBox2.Multiline = true;
|
this.textBox2.Multiline = true;
|
||||||
this.textBox2.Name = "textBox2";
|
this.textBox2.Name = "textBox2";
|
||||||
this.textBox2.ReadOnly = true;
|
this.textBox2.ReadOnly = true;
|
||||||
this.textBox2.Size = new System.Drawing.Size(568, 140);
|
this.textBox2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||||
|
this.textBox2.Size = new System.Drawing.Size(568, 171);
|
||||||
this.textBox2.TabIndex = 5;
|
this.textBox2.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.label3.AutoSize = true;
|
||||||
this.label3.Location = new System.Drawing.Point(268, 79);
|
this.label3.Location = new System.Drawing.Point(267, 105);
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(37, 13);
|
this.label3.Size = new System.Drawing.Size(37, 13);
|
||||||
this.label3.TabIndex = 6;
|
this.label3.TabIndex = 6;
|
||||||
this.label3.Text = "Result";
|
this.label3.Text = "Result";
|
||||||
//
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.fileToolStripMenuItem});
|
||||||
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
|
this.menuStrip1.Size = new System.Drawing.Size(593, 24);
|
||||||
|
this.menuStrip1.TabIndex = 7;
|
||||||
|
this.menuStrip1.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// fileToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||||
|
this.fileToolStripMenuItem.Size = new System.Drawing.Size(115, 20);
|
||||||
|
this.fileToolStripMenuItem.Text = "Check for updates";
|
||||||
|
this.fileToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// randomMin
|
||||||
|
//
|
||||||
|
this.randomMin.Location = new System.Drawing.Point(139, 64);
|
||||||
|
this.randomMin.Maximum = new decimal(new int[] {
|
||||||
|
100000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.randomMin.Minimum = new decimal(new int[] {
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.randomMin.Name = "randomMin";
|
||||||
|
this.randomMin.Size = new System.Drawing.Size(75, 20);
|
||||||
|
this.randomMin.TabIndex = 8;
|
||||||
|
this.randomMin.Value = new decimal(new int[] {
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(593, 247);
|
this.ClientSize = new System.Drawing.Size(593, 304);
|
||||||
|
this.Controls.Add(this.randomMin);
|
||||||
this.Controls.Add(this.label3);
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.textBox2);
|
this.Controls.Add(this.textBox2);
|
||||||
this.Controls.Add(this.button1);
|
this.Controls.Add(this.button1);
|
||||||
@@ -125,10 +173,15 @@
|
|||||||
this.Controls.Add(this.randomMax);
|
this.Controls.Add(this.randomMax);
|
||||||
this.Controls.Add(this.textBox1);
|
this.Controls.Add(this.textBox1);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.menuStrip1);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.Text = "Reddit random giveaway helper";
|
this.Text = "Reddit random giveaway helper";
|
||||||
((System.ComponentModel.ISupportInitialize)(this.randomMax)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.randomMax)).EndInit();
|
||||||
|
this.menuStrip1.ResumeLayout(false);
|
||||||
|
this.menuStrip1.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.randomMin)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
@@ -143,6 +196,9 @@
|
|||||||
private System.Windows.Forms.Button button1;
|
private System.Windows.Forms.Button button1;
|
||||||
private System.Windows.Forms.TextBox textBox2;
|
private System.Windows.Forms.TextBox textBox2;
|
||||||
private System.Windows.Forms.Label label3;
|
private System.Windows.Forms.Label label3;
|
||||||
|
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.NumericUpDown randomMin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,23 +12,47 @@ using RedditSharp.Things;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Octokit;
|
||||||
|
|
||||||
namespace RedditRandomNumberGiveawayHelper
|
namespace RedditRandomNumberGiveawayHelper
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
//make sure to format with max number
|
//make sure to format with max number
|
||||||
private static string RANDOM_ORG_URI = "https://www.random.org/integers/?num=1&min=1&max={0}&col=1&base=10&format=plain&rnd=new";
|
private static string RANDOM_ORG_URI = "https://www.random.org/integers/?num=1&min={0}&max={1}&col=1&base=10&format=plain&rnd=new";
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DisplayTextbox
|
||||||
|
{
|
||||||
|
private TextBox txtBx;
|
||||||
|
|
||||||
|
public DisplayTextbox(TextBox x)
|
||||||
|
{
|
||||||
|
txtBx = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Write(params object[] strings)
|
||||||
|
{
|
||||||
|
txtBx.Text += string.Join(Environment.NewLine, strings) + Environment.NewLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
txtBx.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void button1_Click(object sender, EventArgs e)
|
private void button1_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//textBox2.Text += string.Format("{0}", Environment.NewLine);
|
DisplayTextbox displayTextBox = new DisplayTextbox(textBox2);
|
||||||
|
|
||||||
|
displayTextBox.Clear();
|
||||||
var reddit = new Reddit();
|
var reddit = new Reddit();
|
||||||
|
|
||||||
Post giveawayPost = null;
|
Post giveawayPost = null;
|
||||||
int? randomNumber = null;
|
int? randomNumber = null;
|
||||||
|
|
||||||
@@ -36,31 +60,26 @@ namespace RedditRandomNumberGiveawayHelper
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
textBox2.Text += string.Format("Getting giveaway post...{0}", Environment.NewLine);
|
displayTextBox.Write("Getting giveaway post...");
|
||||||
giveawayPost = reddit.GetPost(new Uri(textBox1.Text));
|
giveawayPost = reddit.GetPost(new Uri(textBox1.Text));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
textBox2.Text += string.Format("{1}{0}{2}{0}",
|
displayTextBox.Write("Failed getting giveaway post",
|
||||||
Environment.NewLine,
|
|
||||||
"Failed getting giveaway post",
|
|
||||||
"You sure that's the right URI (alsomake sure to get the full uri from the address bar)");
|
"You sure that's the right URI (alsomake sure to get the full uri from the address bar)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
textBox2.Text += string.Format("{1}{2}{0}{3}{4}{0}",
|
displayTextBox.Write("Post title: ",
|
||||||
Environment.NewLine,
|
|
||||||
"Post title: ",
|
|
||||||
giveawayPost.Title,
|
giveawayPost.Title,
|
||||||
"Comment count: ",
|
"Comment count: ",
|
||||||
giveawayPost.CommentCount);
|
giveawayPost.CommentCount);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
textBox2.Text += string.Format("{1}{0}",
|
displayTextBox.Write("Getting random number from random.org...");
|
||||||
Environment.NewLine,
|
|
||||||
"Getting random number from random.org...");
|
WebRequest randomDotOrgRequest = WebRequest.Create(string.Format(RANDOM_ORG_URI, decimal.Round(randomMin.Value, 0), decimal.Round(randomMax.Value, 0)));
|
||||||
WebRequest randomDotOrgRequest = WebRequest.Create(string.Format(RANDOM_ORG_URI, decimal.Round(randomMax.Value, 0)));
|
|
||||||
using (WebResponse resp = randomDotOrgRequest.GetResponse())
|
using (WebResponse resp = randomDotOrgRequest.GetResponse())
|
||||||
{
|
{
|
||||||
using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
|
using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
|
||||||
@@ -71,16 +90,11 @@ namespace RedditRandomNumberGiveawayHelper
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
textBox2.Text += string.Format("{1}{0}{2}{0}",
|
displayTextBox.Write("Failed getting giveaway post", ex);
|
||||||
Environment.NewLine,
|
|
||||||
"Failed getting giveaway post",
|
|
||||||
ex);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
textBox2.Text += string.Format("{1}{2}{0}{3}{4}{0}",
|
displayTextBox.Write("Random Number: ",
|
||||||
Environment.NewLine,
|
|
||||||
"Random Number: ",
|
|
||||||
randomNumber,
|
randomNumber,
|
||||||
"Getting winning comment...",
|
"Getting winning comment...",
|
||||||
"This might take a while...");
|
"This might take a while...");
|
||||||
@@ -95,21 +109,25 @@ namespace RedditRandomNumberGiveawayHelper
|
|||||||
foreach (var x in nums)
|
foreach (var x in nums)
|
||||||
{
|
{
|
||||||
if ((x.Value == randomNumber + i && randomNumber + i < decimal.Round(randomMax.Value, 0))
|
if ((x.Value == randomNumber + i && randomNumber + i < decimal.Round(randomMax.Value, 0))
|
||||||
|| (x.Value == randomNumber - i && randomNumber - i > 0))
|
|| (x.Value == randomNumber - i && randomNumber - i > decimal.Round(randomMin.Value, 0)))
|
||||||
{
|
{
|
||||||
winningNumKey = x.Key;
|
winningNumKey = x.Key;
|
||||||
winningNumVal = x.Value;
|
winningNumVal = x.Value;
|
||||||
diff = i;
|
diff = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//stop if we're out of range
|
||||||
|
if (randomNumber + i > decimal.Round(randomMax.Value, 0) && randomNumber - i < decimal.Round(randomMin.Value, 0))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(winningNumKey) && winningNumVal.HasValue)
|
||||||
|
{
|
||||||
Comment winningComment = giveawayPost.Comments.FirstOrDefault(w => w.Shortlink == winningNumKey);
|
Comment winningComment = giveawayPost.Comments.FirstOrDefault(w => w.Shortlink == winningNumKey);
|
||||||
|
|
||||||
textBox2.Text += string.Format("{1}{2}{0}{3}{4}{0}{5}{6}{0}{7}{8}{0}",
|
displayTextBox.Write("Winning comment (link): ",
|
||||||
Environment.NewLine,
|
|
||||||
"Winning comment (link): ",
|
|
||||||
winningNumKey,
|
winningNumKey,
|
||||||
"Winning comment (body): ",
|
"Winning comment (body): ",
|
||||||
winningComment.Body,
|
winningComment.Body,
|
||||||
@@ -119,5 +137,39 @@ namespace RedditRandomNumberGiveawayHelper
|
|||||||
diff
|
diff
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
displayTextBox.Write("What the heck?? not one post in the range? you sure you have that range right?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var github = new GitHubClient(new ProductHeaderValue("RedditRandomNumberGiveawayHelper"));
|
||||||
|
var releases = await github.Release.GetAll("gardient", "RedditRandomNumberGiveawayHelper");
|
||||||
|
var newestRelease = releases.OrderByDescending(x => x.Id).FirstOrDefault();
|
||||||
|
var versionRegex = new Regex(@"^v(?<major>\d+)\.(?<minor>\d+)(\.(?<patch>\d+))?$", RegexOptions.IgnoreCase);
|
||||||
|
var tagMatch = versionRegex.Match(newestRelease.TagName);
|
||||||
|
if (tagMatch.Success)
|
||||||
|
{
|
||||||
|
var versionMatch = versionRegex.Match(Properties.Settings.Default.Version);
|
||||||
|
if (versionMatch.Success)
|
||||||
|
{
|
||||||
|
if (int.Parse(versionMatch.Result("${major}")) >= int.Parse(tagMatch.Result("${major}"))
|
||||||
|
&& int.Parse(versionMatch.Result("${minor}")) >= int.Parse(tagMatch.Result("${minor}"))
|
||||||
|
&& int.Parse(versionMatch.Result("${patch}") == "" ? "0" : versionMatch.Result("${patch}")) >= int.Parse(tagMatch.Result("${patch}") == "" ? "0" : tagMatch.Result("${patch}")))
|
||||||
|
{
|
||||||
|
MessageBox.Show("You have the latest version");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("There is a new verion available");
|
||||||
|
System.Diagnostics.Process.Start(newestRelease.HtmlUrl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,4 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
@@ -1,30 +1,35 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.34209
|
// Runtime Version:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace RedditRandomNumberGiveawayHelper.Properties
|
namespace RedditRandomNumberGiveawayHelper.Properties {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
{
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
public static Settings Default
|
public static Settings Default {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("V0.3.0")]
|
||||||
|
public string Version {
|
||||||
|
get {
|
||||||
|
return ((string)(this["Version"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="RedditRandomNumberGiveawayHelper.Properties" GeneratedClassName="Settings">
|
||||||
<Profiles>
|
<Profiles />
|
||||||
<Profile Name="(Default)" />
|
<Settings>
|
||||||
</Profiles>
|
<Setting Name="Version" Type="System.String" Scope="Application">
|
||||||
<Settings />
|
<Value Profile="(Default)">V0.3.0</Value>
|
||||||
|
</Setting>
|
||||||
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
@@ -34,6 +34,10 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Octokit, Version=0.14.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Octokit.0.14.0\lib\net45\Octokit.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
@@ -109,8 +113,7 @@
|
|||||||
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System" />
|
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System" />
|
||||||
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.IO" />
|
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.IO" />
|
||||||
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.Xml.Linq" />
|
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.Xml.Linq" />
|
||||||
<Code xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Type="Fragment" Language="cs">
|
<Code xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Type="Fragment" Language="cs"><![CDATA[
|
||||||
<![CDATA[
|
|
||||||
var config = XElement.Load(Config.ItemSpec).Elements("Costura").FirstOrDefault();
|
var config = XElement.Load(Config.ItemSpec).Elements("Costura").FirstOrDefault();
|
||||||
|
|
||||||
if (config == null) return true;
|
if (config == null) return true;
|
||||||
@@ -129,8 +132,8 @@ var filesToCleanup = Files.Select(f => f.ItemSpec).Where(f => !excludedAssemblie
|
|||||||
|
|
||||||
foreach (var item in filesToCleanup)
|
foreach (var item in filesToCleanup)
|
||||||
File.Delete(item);
|
File.Delete(item);
|
||||||
]]>
|
]]></Code>
|
||||||
</Code></Task>
|
</Task>
|
||||||
</UsingTask>
|
</UsingTask>
|
||||||
<Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild;NonWinFodyTarget">
|
<Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild;NonWinFodyTarget">
|
||||||
<CosturaCleanup Config="FodyWeavers.xml" Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
|
<CosturaCleanup Config="FodyWeavers.xml" Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
|
||||||
|
|||||||
28
RedditRandomNumberGiveawayHelper/Settings.cs
Normal file
28
RedditRandomNumberGiveawayHelper/Settings.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
namespace RedditRandomNumberGiveawayHelper.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
// This class allows you to handle specific events on the settings class:
|
||||||
|
// The SettingChanging event is raised before a setting's value is changed.
|
||||||
|
// The PropertyChanged event is raised after a setting's value is changed.
|
||||||
|
// The SettingsLoaded event is raised after the setting values are loaded.
|
||||||
|
// The SettingsSaving event is raised before the setting values are saved.
|
||||||
|
internal sealed partial class Settings {
|
||||||
|
|
||||||
|
public Settings() {
|
||||||
|
// // To add event handlers for saving and changing settings, uncomment the lines below:
|
||||||
|
//
|
||||||
|
// this.SettingChanging += this.SettingChangingEventHandler;
|
||||||
|
//
|
||||||
|
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
|
||||||
|
// Add code to handle the SettingChangingEvent event here.
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||||
|
// Add code to handle the SettingsSaving event here.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,4 +2,5 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net451" developmentDependency="true" />
|
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net451" developmentDependency="true" />
|
||||||
<package id="Fody" version="1.28.3" targetFramework="net451" developmentDependency="true" />
|
<package id="Fody" version="1.28.3" targetFramework="net451" developmentDependency="true" />
|
||||||
|
<package id="Octokit" version="0.14.0" targetFramework="net451" />
|
||||||
</packages>
|
</packages>
|
||||||
Reference in New Issue
Block a user