ShiftSweeper right click flagging

This commit is contained in:
pfg 2017-03-05 09:49:47 -08:00
parent f3af198849
commit 99ba9c1f9c
3 changed files with 27 additions and 8 deletions

View file

@ -299,6 +299,7 @@ namespace ShiftOS.WinForms.Applications
this.Controls.Add(this.pictureBox1);
this.Name = "ShiftSweeper";
this.Size = new System.Drawing.Size(596, 426);
this.Load += new System.EventHandler(this.ShiftSweeper_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.flagButton)).EndInit();
this.ResumeLayout(false);

View file

@ -205,8 +205,9 @@ namespace ShiftOS.WinForms.Applications
return bttn;
}
private void bttnOnclick(object sender, EventArgs e)
private void bttnOnclick(object sender, EventArgs ee)
{
MouseEventArgs e = (MouseEventArgs)ee;
if (!ticking.Enabled) return;
PictureBox bttnClick = sender as PictureBox;
@ -218,8 +219,9 @@ namespace ShiftOS.WinForms.Applications
int x = System.Convert.ToInt32(split[0]);
int y = System.Convert.ToInt32(split[1]);
if (!flagtime)
if (!flagtime && e.Button == MouseButtons.Left)
{
if (minemap[x, y] == -1)
{
@ -249,7 +251,7 @@ namespace ShiftOS.WinForms.Applications
else if (minemap[x, y] < -1) return;
else removeBlank(x, y);
}
else
else if(flagtime || e.Button == MouseButtons.Right)
{
if (!bttnClick.Enabled) return;
@ -364,5 +366,9 @@ namespace ShiftOS.WinForms.Applications
flagtime = true;
}
}
private void ShiftSweeper_Load(object sender, EventArgs e) {
}
}
}

View file

@ -39,8 +39,13 @@ namespace ShiftOS.WinForms
{
get
{
var wc = new System.Net.WebClient();
return JsonConvert.DeserializeObject<List<string>>(wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack")).Count;
System.Net.WebClient wc = new System.Net.WebClient();
try {
string result = wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack");
return JsonConvert.DeserializeObject<List<string>>(result).Count;
} catch {
return JsonConvert.DeserializeObject<List<string>>("[]").Count;
}
}
}
@ -73,10 +78,17 @@ namespace ShiftOS.WinForms
public byte[] GetTrack(int index)
{
var wc = new System.Net.WebClient();
var st = JsonConvert.DeserializeObject<List<string>>(wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack"));
System.Net.WebClient wc = new System.Net.WebClient();
return wc.DownloadData(st[index]);
try {
string result = wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack");
var st = JsonConvert.DeserializeObject<List<string>>(result);
return wc.DownloadData(st[index]);
} catch {
return null;
}
}
}