Skip to content

Commit

Permalink
Don't show the downloading miner page if the selected miner is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
nwoolls committed Aug 12, 2013
1 parent 0ef032c commit 54b5c1e
Showing 1 changed file with 46 additions and 11 deletions.
57 changes: 46 additions & 11 deletions MultiMiner.Win/WizardForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,44 @@ private void SetupWizardTabControl()
}
}

private static bool MinerIsInstalled(MinerBackend minerBackend)
{
string path = MinerPath.GetPathToInstalledMiner(minerBackend);
return File.Exists(path);
}

private void nextButton_Click(object sender, EventArgs e)
{
if (!ValidateInput())
return;

if (wizardTabControl.SelectedIndex < wizardTabControl.TabPages.Count - 1)
wizardTabControl.SelectedIndex += 1;
if (wizardTabControl.SelectedTab == chooseMinerPage)
{
MinerBackend minerBackend = GetSelectedMinerBackend();
if (MinerIsInstalled(minerBackend))
{
wizardTabControl.SelectedIndex += 2;
}
else
{
wizardTabControl.SelectedIndex += 1;
}
}
else
DialogResult = System.Windows.Forms.DialogResult.OK;
{
if (wizardTabControl.SelectedIndex < wizardTabControl.TabPages.Count - 1)
wizardTabControl.SelectedIndex += 1;
else
DialogResult = System.Windows.Forms.DialogResult.OK;
}


if (wizardTabControl.SelectedTab == downloadingMinerPage)
{
if (OSVersionPlatform.GetConcretePlatform() == PlatformID.Unix)
showLinuxInstallationInstructions();
else
downloadChosenMiner();
DownloadChosenMiner();
}
}

Expand Down Expand Up @@ -125,20 +147,26 @@ private bool ValidateInput()

private void backButton_Click(object sender, EventArgs e)
{
if (wizardTabControl.SelectedIndex > 0)
wizardTabControl.SelectedIndex -= 1;
if (wizardTabControl.SelectedTab == chooseCoinPage)
{
//skip the downloading page
wizardTabControl.SelectedIndex -= 2;
}
else
{
if (wizardTabControl.SelectedIndex > 0)
wizardTabControl.SelectedIndex -= 1;
}
}

private void wizardTabControl_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateButtons();
}

private void downloadChosenMiner()
private void DownloadChosenMiner()
{
MinerBackend minerBackend = MinerBackend.Cgminer;
if (minerComboBox.SelectedIndex == 1)
minerBackend = MinerBackend.Bfgminer;
MinerBackend minerBackend = GetSelectedMinerBackend();

string minerName = MinerPath.GetMinerName(minerBackend);
string minerPath = Path.Combine("Miners", minerName);
Expand All @@ -154,6 +182,14 @@ private void downloadChosenMiner()
wizardTabControl.SelectedTab = chooseCoinPage;
}

private MinerBackend GetSelectedMinerBackend()
{
MinerBackend minerBackend = MinerBackend.Cgminer;
if (minerComboBox.SelectedIndex == 1)
minerBackend = MinerBackend.Bfgminer;
return minerBackend;
}

private void UpdateButtons()
{
bool nextButtonEnabled = true;
Expand All @@ -169,7 +205,6 @@ private void UpdateButtons()

if (wizardTabControl.SelectedTab == chooseCoinPage)
{
backButtonEnabled = false; //can't go back to downloading miner
nextButtonEnabled = coinComboBox.Text != "-";
}
else if (wizardTabControl.SelectedTab == configurePoolPage)
Expand Down

0 comments on commit 54b5c1e

Please sign in to comment.