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"); } }
public void LoadData(bool bisCurrentProfile) { PeonLib.File.textlist tx = new PeonLib.File.textlist(GetProfileListPath()); string sCurrentName = GetCurrentProfileName(); mlProfile.Clear(); foreach (string s in tx.Items) { if (s != sCurrentName) { AddProfile(s); } else { mCurrentProfile = AddProfile(s); } } mCurrentProfile.LoadData(); if (bisCurrentProfile) { LoadLastUserProfile(); } }
public void ChangeUser() { LoadCurrentUser(); File.textlist file = new PeonLib.File.textlist(definitions.path.UserList); forms.UserSelectForm f = new PeonLib.forms.UserSelectForm("Change User"); int i = 0; foreach (string s in file.Items) { if (s == mUser.NAME) { file.Items.RemoveAt(i); break; } ++i; } if (file.Items.Count == 0) { MessageBox.Show("There is no other user"); return; } f.LoadFile(file); f.ShowDialog(); if (f.DialogResult == DialogResult.OK) { int n = f.ID; mUser.PushFrontLastUserProfile(); mUser.WriteLastUserProfile(); SetCurrentUser(file.Items[n], true); mUser.WriteLastUserProfile(); } }
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 void AskToChangeCurrentProfile() { PeonLib.File.textlist file = new PeonLib.File.textlist(GetProfileListPath()); forms.UserSelectForm f = new PeonLib.forms.UserSelectForm("Change profile"); f.LoadFile(file); f.ShowDialog(); if (f.DialogResult == DialogResult.OK) { int n = f.ID; ChangeCurrentProfile(file.Items[n], true); } }
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 LoadLastUserProfile() { File.textlist tx = new PeonLib.File.textlist(definitions.path.LastUsersProfile); mlLastUserProfile.Clear(); for (int i = 0; i < tx.Items.Count; i = i + 2) { compte o = new compte(); o.sUser = tx.Items[i]; o.sProfile = tx.Items[i + 1]; mlLastUserProfile.Add(o); } RemoveFromLastUserProfile(); }
public static void LoadUserConfig() { File.textlist tx = new PeonLib.File.textlist(Root + nameconst.userconfig); if (tx.Items.Count > 0) { UserConfig = tx.Items[0]; } else { UserConfig = Root; } 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); }
private bool LoadCurrentUser() { File.textlist f = new PeonLib.File.textlist(definitions.path.UserCurrent); if (f.Items.Count == 0) { return(false); } if (f.Items[0] == "") { return(false); } mUser = new User(f.Items[0]); mUser.LoadData(true); return(true); }
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(); }
public void LoadFile(PeonLib.File.textlist f) { comboBox1.Items.Clear(); Data.IDList l = new PeonLib.Data.IDList(); m_nElem = 0; foreach (string s in f.Items) { if (s != "") { comboBox1.Items.Add(m_nElem); l.PushBack(s); m_nElem++; } } dataGridView1.Rows.Clear(); dataGridView1.DataSource = l; dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; comboBox1.SelectedIndex = 0; }
public void DeleteProfile() { if (mlProfile.Count > 1) { PeonLib.File.textlist file = new PeonLib.File.textlist(GetProfileListPath()); forms.UserSelectForm f = new PeonLib.forms.UserSelectForm("Delete profile"); f.LoadFile(file); f.ShowDialog(); if (f.DialogResult == DialogResult.OK) { int n = f.ID; bool bIsCurrentProf = (n == GetProfileCase(mCurrentProfile.Name)); User.RemoveFromLastUserProfile(NAME, mlProfile[n].Name); mlProfile[n].DestroyProfile(); if (bIsCurrentProf) { if (n == 0) { SetCurrentProfile(mlProfile[1].Name); } else { SetCurrentProfile(mlProfile[0].Name); } TransferCurrentProfileInCurrentScript(); } mlProfile.RemoveAt(n); WriteProfileFile(); } } else { System.Windows.Forms.MessageBox.Show("you cannot delete the last profile"); } }
//Cette fonction est demeure dans user private string GetCurrentProfileName() { PeonLib.File.textlist tx = new PeonLib.File.textlist(GetCurrentProfilePath()); return(tx.Items[0]); }