Choose a directory for the users files

This commit is contained in:
Tim Young 2017-08-02 11:25:26 -05:00
parent b1e015e624
commit 0ba762fe01
3 changed files with 40 additions and 6 deletions

View File

@ -994,5 +994,20 @@ namespace EduNetworkBuilder
return ValidateString(password, AllowedUsernameCharacters + " ");
}
public static OpenFileDialog SelectDirectoryDialog(string Title, string InitialDirectory="")
{
OpenFileDialog OFD = new OpenFileDialog();
OFD.Title = Title;
if (InitialDirectory != "")
OFD.InitialDirectory = InitialDirectory;
OFD.ValidateNames = false;
OFD.CheckFileExists = false;
OFD.CheckPathExists = true;
OFD.FileName = NB.Translate("PPF_SelectThisFolder");
DialogResult answer = OFD.ShowDialog();
if (answer == DialogResult.Cancel) OFD.FileName = ""; //This is how we cancel out
return OFD;
}
}
}

View File

@ -100,12 +100,8 @@ namespace EduNetworkBuilder
//Find a directory for it.
CurrentUser = new PersonClass(Dest, true); //Make an admin person class
//Choose an initial folder for the file:
OpenFileDialog OFD = new OpenFileDialog();
OFD.ValidateNames = false;
OFD.CheckFileExists = false;
OFD.CheckPathExists = true;
OFD.FileName = NB.Translate("PPF_SelectThisFolder");
OFD.ShowDialog();
OpenFileDialog OFD = NB.SelectDirectoryDialog(NB.Translate("PPF_UserDirectory"),CurrentUser.filepath);
if (OFD.FileName == "") return;//we cancel out
CurrentUser.filepath = Path.GetDirectoryName(OFD.FileName);
CurrentUser.UserSettings.AutoStartPuzzles = false;
CurrentUser.UserSettings.ChosenLanguage = oldsettings.ChosenLanguage;
@ -655,8 +651,23 @@ namespace EduNetworkBuilder
MessageBox.Show(message);
}
/// <summary>
/// Generate The student files for all the students.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnGenerateStudentFiles_Click(object sender, EventArgs e)
{
//Verify (choose) student file directory
//Loop through all the students
//Calculate the filename for the student file
//See if the file exists. If not, gen a new file
//Keep track of total # students, # new files, # skipped because they existed
OpenFileDialog OFD = NB.SelectDirectoryDialog(NB.Translate("PPF_SelectStudentDir"),CurrentUser.StudentFilePath);
if (OFD.FileName == "") return;//we cancel out
CurrentUser.StudentFilePath = Path.GetDirectoryName(OFD.FileName);
}
}

View File

@ -1817,4 +1817,12 @@
<value>Error. Could not import students. List of invalid</value>
<comment>PPF_NoImportInvalid = Error. Could not import students. List of invalid</comment>
</data>
<data name="PPF_SelectStudentDir" xml:space="preserve">
<value>Student Files Directory</value>
<comment> PPF_SelectStudentDir = Stdent Files Directory</comment>
</data>
<data name="PPF_UserDirectory" xml:space="preserve">
<value>User File Directory</value>
<comment>PPF_UserDirectory</comment>
</data>
</root>