Attempting to make msi installer using WiX
This commit is contained in:
parent
400a246d0b
commit
568dc54a8d
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
|
||||
namespace EduNetworkBuilder
|
||||
{
|
||||
@ -32,7 +34,7 @@ namespace EduNetworkBuilder
|
||||
/// <summary>
|
||||
/// Used to determine if the user we are working with is the admin account.
|
||||
/// </summary>
|
||||
public bool isAdmin { get; private set; }
|
||||
public bool isAdmin { get; protected set; }
|
||||
/// <summary>
|
||||
/// EverCompletedPuzzles is a list of puzzles that they have completed once.
|
||||
/// </summary>
|
||||
@ -40,12 +42,20 @@ namespace EduNetworkBuilder
|
||||
|
||||
List<SchoolworkClass> Projects = new List<SchoolworkClass>();
|
||||
|
||||
private PersonClass()
|
||||
{ }
|
||||
|
||||
public PersonClass(String User, bool MakeAdmin)
|
||||
{
|
||||
_UserName = User;
|
||||
isAdmin = MakeAdmin;
|
||||
}
|
||||
|
||||
public PersonClass(string Filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Password(int index = 0)
|
||||
{
|
||||
if (Passwords.Count == 0) return "";
|
||||
@ -63,5 +73,105 @@ namespace EduNetworkBuilder
|
||||
for (int a = Passwords.Count - 1; a >= maxPWs; a--)
|
||||
Passwords.RemoveAt(a); //Remove all but the one password
|
||||
}
|
||||
|
||||
#region Load and Save
|
||||
//Load and save functions
|
||||
public void Load()
|
||||
{
|
||||
Load(@"C:\Users\tyoung\Desktop\Test.enbx");
|
||||
}
|
||||
|
||||
public void Load(string filename)
|
||||
{
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
xmlDoc.Load(filename);
|
||||
Load(xmlDoc, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(XmlNode TheNode, string Name)
|
||||
{
|
||||
foreach (XmlNode Individual in TheNode.ChildNodes)
|
||||
{
|
||||
XmlNodeType myNodetype = Individual.NodeType;
|
||||
if (myNodetype == XmlNodeType.Element)
|
||||
{
|
||||
switch (Individual.Name.ToLower())
|
||||
{
|
||||
case "username":
|
||||
_UserName = Individual.InnerText;
|
||||
break;
|
||||
case "fullname":
|
||||
FullName = Individual.InnerText;
|
||||
break;
|
||||
case "passwordhint":
|
||||
PasswordHint = Individual.InnerText;
|
||||
break;
|
||||
case "altpassword":
|
||||
AltPassword = Individual.InnerText;
|
||||
break;
|
||||
case "isadmin":
|
||||
bool isadmin = false;
|
||||
bool.TryParse(Individual.InnerText, out isadmin);
|
||||
isAdmin = isadmin;
|
||||
break;
|
||||
case "password":
|
||||
Passwords.Add(Individual.InnerText);
|
||||
break;
|
||||
case "project":
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Save()
|
||||
{
|
||||
Save(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test.enbx"));
|
||||
}
|
||||
|
||||
public void Save(string filename)
|
||||
{
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
settings.Indent = true;
|
||||
settings.NewLineOnAttributes = true;
|
||||
XmlWriter writer = XmlWriter.Create(filename, settings);
|
||||
|
||||
//Now we write the file:
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("EduNetworkBuilder");
|
||||
writer.WriteComment("This is a network file for EduNetworkBuilder.");
|
||||
Save(writer);
|
||||
writer.WriteEndElement();
|
||||
writer.WriteEndDocument();
|
||||
writer.Flush();
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
|
||||
public void Save(XmlWriter writer)
|
||||
{
|
||||
//Save the language name
|
||||
//save the number of items
|
||||
//Save all the items
|
||||
writer.WriteStartElement("User");
|
||||
writer.WriteElementString("UserName", UserName);
|
||||
writer.WriteElementString("FullName", FullName);
|
||||
writer.WriteElementString("PasswordHint", PasswordHint);
|
||||
writer.WriteElementString("AltPassword", AltPassword);
|
||||
writer.WriteElementString("IsAdmin", isAdmin.ToString());
|
||||
foreach(string One in Passwords)
|
||||
writer.WriteElementString("Password", One);
|
||||
//Save all the devices
|
||||
foreach (SchoolworkClass One in Projects)
|
||||
{
|
||||
//One.Save(writer);
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -63,10 +63,27 @@ namespace EduNetworkBuilder
|
||||
if (Dest[0] != '_') Dest = "_Teacher_" + Dest; //Make sure it begins with _
|
||||
//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();
|
||||
Console.WriteLine(Path.GetDirectoryName(OFD.FileName));
|
||||
}
|
||||
else if (CurrentUser == null)
|
||||
{
|
||||
//Try to load the file. Close form & give error if it fails
|
||||
try
|
||||
{
|
||||
//Load in from the file
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
CurrentUser = null;
|
||||
Close(); //we did not succeed. Exit out
|
||||
}
|
||||
}
|
||||
|
||||
//Make sure we update any profile settings they change
|
||||
|
@ -1725,6 +1725,10 @@
|
||||
<value>Passwords did not match. Please try again.</value>
|
||||
<comment>PPF_PassValidateMismatch = Passwords did not match. Please try again.</comment>
|
||||
</data>
|
||||
<data name="PPF_SelectThisFolder" xml:space="preserve">
|
||||
<value>Select This Folder</value>
|
||||
<comment>PPF_SelectThisFolder = Select This Folder</comment>
|
||||
</data>
|
||||
<data name="PPF_TabClasswork" xml:space="preserve">
|
||||
<value>Classwork</value>
|
||||
<comment>PPF_TabClasswork = Classwork</comment>
|
||||
|
Loading…
Reference in New Issue
Block a user