} // end () private void PopulateSectionComboBox(string iniPath) { MOG_Ini ini = new MOG_Ini(iniPath); int sectionCount = ini.CountSections(); // If we are repopulating, clear our old items if (this.SectionComboBox.Items.Count > 0) { this.SectionComboBox.Items.Clear(); } for (int i = 0; i < sectionCount; ++i) { this.SectionComboBox.Items.Add(ini.GetSectionByIndexSLOW(i)); } SectionComboBox.Text = mSelectedSection; }
public PriviledgesForm(BASE mMog) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // mPriviledgesIni = mMog.GetPriviledgesIni(); if (mPriviledgesIni != null && mPriviledgesIni.CountSections() > 0) { PopulatePermissions(); } else { PriviledgesTreeView.Nodes.Clear(); PriviledgesTreeView.Nodes.Add(new TreeNode("No permissions set for this project")); } }
public bool InitializeMogRepository() { // First we are going to attempt to load our loader.ini and check if a Repository path was saved froma previous load // Load system Ini MOG_Ini loader = new MOG_Ini(LoaderConfigFile); if (loader != null && loader.CountSections() > 0) { if (loader.SectionExist("Loader")) { if (loader.KeyExist("Loader", "SystemRepositoryPath")) { // Now double check that the path specified actually has a Repository.ini at that location // Lets verify if the repository that was saved is really still a repository? if (Directory.Exists(loader.GetString("Loader", "SystemRepositoryPath") + "\\Tools") && Directory.Exists(loader.GetString("Loader", "SystemRepositoryPath") + "\\Updates")) { mRepositoryPath = loader.GetString("Loader", "SystemRepositoryPath"); // SECOND make sure that we have the mog.ini saved correctly in the current directory if (File.Exists(Environment.CurrentDirectory + "\\" + LoaderTargetDirectory + "\\MOG.ini")) { // Also make sure it has a valid repository MOG_Ini targetLoader = new MOG_Ini(Environment.CurrentDirectory + "\\" + LoaderTargetDirectory + "\\MOG.ini"); if (targetLoader != null && targetLoader.CountSections() > 0) { if (targetLoader.SectionExist("MOG")) { if (targetLoader.KeyExist("MOG", "SystemRepositoryPath")) { // Lets verify if the repository that was saved is really still a repository? if (Directory.Exists(targetLoader.GetString("MOG", "SystemRepositoryPath") + "\\Tools") && Directory.Exists(targetLoader.GetString("MOG", "SystemRepositoryPath") + "\\Updates")) { return(true); } } } } } } } } } // If any of the above conditions fail, have the user locate our repository path for us MogForm_RepositoryBrowser_ServerLoader form = new MogForm_RepositoryBrowser_ServerLoader(); form.ForceRepositorySelection = true; form.RepositoryViewVisible = false; form.RepositoryViewVisible = false; LocateRepository: try { mSplash.Opacity = 0; this.WindowState = FormWindowState.Minimized; if (form.ShowDialog() == DialogResult.OK) { // Determine if the path selected is valid if (!File.Exists(form.SelectedPath + "\\MogRepository.ini")) { MessageBox.Show(this, "The selected path is not a valid MOG repository.", "Invalid repository"); goto LocateRepository; } else { // Load the MogRepository.ini file found at the location specified by the user MOG_Ini repository = new MOG_Ini(form.SelectedPath + "\\MogRepository.ini"); // Does this MogRepository have at least one valid repository path if (repository.SectionExist("Mog_Repositories")) { // If there is only one specified repository, choose that one if (repository.CountKeys("Mog_Repositories") == 1) { // Get the section string section = repository.GetKeyNameByIndexSLOW("Mog_Repositories", 0); // Get the path from that section if (repository.SectionExist(section) && repository.KeyExist(section, "SystemRepositoryPath")) { mRepositoryPath = repository.GetString(section, "SystemRepositoryPath"); } else { MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository"); goto LocateRepository; } } else if (repository.CountKeys("Mog_Repositories") > 1) { // The user must now choose which repository to use MogForm_MultiRepository multiRep = new MogForm_MultiRepository(); for (int i = 0; i < repository.CountKeys("Mog_Repositories"); i++) { multiRep.RepositoryComboBox.Items.Add(repository.GetKeyNameByIndexSLOW("Mog_Repositories", i)); } multiRep.RepositoryComboBox.SelectedIndex = 0; // Show the form to the user and have him select between the repository sections found if (multiRep.ShowDialog() == DialogResult.OK) { // Get the section string userSection = multiRep.RepositoryComboBox.Text; // Get the path from that section if (repository.SectionExist(userSection) && repository.KeyExist(userSection, "SystemRepositoryPath")) { mRepositoryPath = repository.GetString(userSection, "SystemRepositoryPath"); } else { MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository"); goto LocateRepository; } } else { goto LocateRepository; } } else { MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository"); goto LocateRepository; } } } } else { return(false); } } catch (Exception e) { MessageBox.Show(this, e.Message, "Invalid repository"); goto LocateRepository; } // Double check that we got a valid mog repository path if (mRepositoryPath.Length == 0) { goto LocateRepository; } else { //Warn the user if the repository was on a local drive string drive = Path.GetPathRoot(mRepositoryPath); int type = (int)GetDriveType(drive); if (type != DRIVE_TYPE_NETWORK) { if (MessageBox.Show(this, "It is not recommended to place a MOG Repository on a local drive because it will not be accessible to other users on the network.", "Local Drive Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { goto LocateRepository; } } // Yup, all is well save it out loader.PutString("Loader", "SystemRepositoryPath", mRepositoryPath); loader.Save(); // Save out our MOG.ini SaveMOGConfiguration(); this.Opacity = 0; mSplash.Opacity = 1; this.WindowState = FormWindowState.Normal; return(true); } }