Skip to content

Commit

Permalink
Regex fix for html scan
Browse files Browse the repository at this point in the history
* Some UI fixes
  • Loading branch information
Maxx53 committed May 19, 2015
1 parent 4a831c4 commit e025330
Show file tree
Hide file tree
Showing 11 changed files with 509 additions and 474 deletions.
1 change: 0 additions & 1 deletion scr/SCMBot/GraphFrm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

502 changes: 249 additions & 253 deletions scr/SCMBot/Main.Designer.cs

Large diffs are not rendered by default.

78 changes: 52 additions & 26 deletions scr/SCMBot/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public Main()
StatImgLst.Images.Add("Img1", Properties.Resources.ready);
StatImgLst.Images.Add("Img2", Properties.Resources.warning);
StatImgLst.Images.Add("Img3", Properties.Resources.clock);
StatImgLst.Images.Add("Img4", Properties.Resources.warning);
StatImgLst.ColorDepth = ColorDepth.Depth32Bit;
scanListView.SmallImageList = StatImgLst;
recentListView.SmallImageList = StatImgLst;
Expand Down Expand Up @@ -109,8 +110,6 @@ private void Main_Load(object sender, EventArgs e)
if (cook == null)
cook = new CookieContainer();



steam_srch.cookieCont = cook;
steam_srch.scanID = 0;
filterTypeBox.SelectedIndex = 1;
Expand All @@ -122,21 +121,27 @@ private void Main_Load(object sender, EventArgs e)

LoadSettings(true);

if (settings.loginOnstart)
loginButton.PerformClick();

setNotifyText(Strings.NotLogged);


openFileDialog1.FileName = "scmbot_list_";
string AppPath = Path.GetDirectoryName(Application.ExecutablePath);
openFileDialog1.InitialDirectory = AppPath;
saveFileDialog1.InitialDirectory = AppPath;

LoadHosts(hostsPath);

if (File.Exists(hostsPath))
if (settings.loginOnstart)
loginButton.PerformClick();

ListViewHelper.EnableDoubleBuffer(scanListView);
}


private void LoadHosts(string path)
{
if (File.Exists(path))
{
var plines = File.ReadAllLines(hostsPath);
var plines = File.ReadAllLines(path);

ThreadStart readThread = delegate()
{
Expand All @@ -147,31 +152,30 @@ private void Main_Load(object sender, EventArgs e)
Match match = Regex.Match(plines[i], ipPattern);
if (match.Success)
{
Application.DoEvents();
this.Invoke((MethodInvoker)delegate { StatusLabel1.Text = "Loading hosts... " + (i + 1).ToString() + " of " + plines.Length.ToString(); });
Ping ping = new Ping();
PingReply pingReply = ping.Send(plines[i]);
hostList.Add(plines[i], pingReply.RoundtripTime.ToString());
this.Invoke((MethodInvoker)delegate { StatusLabel1.Text = "Loading hosts... " + i.ToString() + " of " + plines.Length.ToString(); });
PingReply pingReply = ping.Send(plines[i], 2000);
//Don't add dead hosts
if (pingReply.RoundtripTime != 0)
{
hostList.Add(plines[i], pingReply.RoundtripTime.ToString());
}
}
}

this.Invoke((MethodInvoker)delegate { StatusLabel1.Text = "Hosts loaded: " + hostList.Count.ToString(); });
this.Invoke((MethodInvoker)delegate
{ StatusLabel1.Text = "Hosts loaded: " + hostList.Count.ToString(); });

};
Thread pTh = new Thread(readThread);
pTh.IsBackground = true;
pTh.Start();



}
else
usingProxyStatuslStrip.Enabled = false;
}


ListViewHelper.EnableDoubleBuffer(scanListView);
}

private void Main_Shown(object sender, EventArgs e)
{
if (settings.firstRun == true)
Expand Down Expand Up @@ -713,6 +717,25 @@ public void Event_Message(object sender, object data, int searchId, flag myflag,

case flag.Scan_cancel:
StatusLabel1.Text = Strings.ScanCancel;
if (isMain)
{
scanItems[searchId].Steam.scanInput.StatId = status.Ready;
setStatImg(searchId, status.Ready, scanListView);
BindToControls(scanListView);
}
else
{
for (int i = 0; i < steam_srch.recentInputList.Count; i++)
{
if (steam_srch.recentInputList[i].StatId == status.Wait)
{
steam_srch.recentInputList[i].StatId = status.Ready;
setStatImg(i, status.Ready, recentListView);
}
}

BindToControls(recentListView);
}
break;
case flag.Resold:
PlaySound(2, settings.playSnd);
Expand Down Expand Up @@ -1534,6 +1557,12 @@ private void setButtText(status stat)
scanButton.Image = Properties.Resources.stop;
scanButton.Enabled = true;
break;

case status.Wait:
scanButton.Text = "Wait";
scanButton.Image = Properties.Resources.clock;
scanButton.Enabled = false;
break;
}

}
Expand Down Expand Up @@ -1630,9 +1659,7 @@ private void scanButton_Click(object sender, EventArgs e)

if (isScanValid(paramItem, true))
{

startScan(false);

}
else
{
Expand All @@ -1641,7 +1668,6 @@ private void scanButton_Click(object sender, EventArgs e)
}

}

else
{
stopScan(false);
Expand Down Expand Up @@ -1839,8 +1865,8 @@ private void stopScan(bool all)
if (steamItem.scaninProg)
{
steamItem.CancelScan();
paramItem.StatId = status.Ready;
setStatImg(id, 0, scanListView);
paramItem.StatId = status.Wait;
setStatImg(id, status.Wait, scanListView);
}
}

Expand All @@ -1862,7 +1888,7 @@ private void stopScan(bool all)
if (steam_srch.recentInputList[i].StatId == status.InProcess)
{
isReady = true;
steam_srch.recentInputList[i].StatId = status.Ready;
steam_srch.recentInputList[i].StatId = status.Wait;
setStatImg(i, steam_srch.recentInputList[i].StatId, recentListView);
}
}
Expand All @@ -1876,7 +1902,7 @@ private void stopScan(bool all)
if (steam_srch.recentInputList[indx].StatId == status.InProcess)
{
isReady = true;
steam_srch.recentInputList[indx].StatId = status.Ready;
steam_srch.recentInputList[indx].StatId = status.Wait;
setStatImg(indx, steam_srch.recentInputList[indx].StatId, recentListView);
}
}
Expand Down
Loading

0 comments on commit e025330

Please sign in to comment.