public void DeleteUser() { File.textlist file = new PeonLib.File.textlist(definitions.path.UserList); if (file.Items.Count > 1) { forms.UserSelectForm f = new PeonLib.forms.UserSelectForm("Delete User"); f.LoadFile(file); f.ShowDialog(); if (f.DialogResult == DialogResult.OK) { int n = f.ID; User u = new User(file.Items[n]); User.RemoveFromLastUserProfile(u.NAME, ""); if (LoadCurrentUser()) { if (mUser.NAME == u.NAME) { NextCurrentUser(); } } u.DestroyUser(); file.Items.RemoveAt(n); file.WriteList(); UpdateAllUserScript(); } } else { System.Windows.Forms.MessageBox.Show("You cannot delete the last user"); } }
static public void AddToLastUserProfile(string sUser, string sProfile) { File.textlist tx = new PeonLib.File.textlist(definitions.path.LastUsersProfile); List <int> listn = new List <int>(); tx.Items.Add(sUser); tx.Items.Add(sProfile); tx.WriteList(); }
public static void SetUserConfig(string path) { UserConfig = path; File.textlist tx = new PeonLib.File.textlist(Root + nameconst.userconfig); if (tx.Items.Count < 1) { tx.Items.Add(""); } tx.Items[0] = path; tx.WriteList(); ReloadUserPath(); }
public void WriteLastUserProfile() { File.textlist tx = new PeonLib.File.textlist(definitions.path.LastUsersProfile); tx.Items.Clear(); int n = 0; foreach (compte c in mlLastUserProfile) { if (++n <= 8) { tx.Items.Add(c.sUser); tx.Items.Add(c.sProfile); } } tx.WriteList(); }
public Profile CreateProfile(string name) { Profile prof = null; if (!IsProfileNameExist(name)) { prof = AddProfile(name); prof.CreateStandardProfil(); WriteProfileFile(); PeonLib.File.textlist tx = new PeonLib.File.textlist(GetProfileListPath()); tx.Sort(); tx.WriteList(); AddToLastUserProfile(NAME, name); } return(prof); }
static public void RemoveFromLastUserProfile(string sUser, string sProfile) { File.textlist tx = new PeonLib.File.textlist(definitions.path.LastUsersProfile); List <int> listn = new List <int>(); for (int i = 0; i < tx.Items.Count; i = i + 2) { if (tx.Items[i] == sUser && (tx.Items[i + 1] == sProfile || sProfile == "")) { listn.Insert(0, i); } } foreach (int n in listn) { tx.Items.RemoveRange(n, 2); } tx.WriteList(); }