public SelectFolderOrFile() { this.InitializeComponent(); this.ReturnPath = ""; this.ReturnFile = ""; this.fileSystemTreeView1.WantClose += new EventHandler <FileSystemTreeView.WantCloseEventArgs>(this.fileSystemTreeView1_WantClose); this.fileSystemTreeView1.SelectionChanged += new EventHandler <FileSystemTreeView.SelectionChangedEventArgs>(this.fileSystemTreeView1_SelectionChanged); this.fileSystemTreeView1.NetworkScanProgress += new EventHandler <FileSystemTreeView.NetworkScanEventArgs>(this.fileSystemTreeView1_NetworkScanProgress); this.progressBar1.Step = 1; this.progressBar1.Value = 0; GrzTools.IniFile ini = new GrzTools.IniFile(System.Windows.Forms.Application.ExecutablePath + ".ini"); for (int i = 0; i < 5; i++) { string tmp = ini.IniReadValue("cfw", "selectFolder" + i.ToString(), ""); if (tmp.Length > 0) { this.comboBoxFolderHistory.Items.Add(tmp); } } if (this.comboBoxFolderHistory.Items.Count > 0) { this.comboBoxFolderHistory.SelectedIndex = 0; } // add left double click behaviour to combobox' textbox this.comboBoxFolderHistory.Tag = DateTime.MinValue; }
// read from INI on load form private void ReadINI() { // INI: read GrzTools.IniFile ini = new GrzTools.IniFile(System.Windows.Forms.Application.ExecutablePath + ".ini"); for (int i = 0; i < 20; i++) { string tmp = ini.IniReadValue("cfw", "filter" + i.ToString(), ""); if (tmp.Length > 0) { this.comboBoxFilter.Items.Add(tmp); } } }
// INI: write void SaveINI() { GrzTools.IniFile ini = new GrzTools.IniFile(System.Windows.Forms.Application.ExecutablePath + ".ini"); for (int i = 0; i < 20; i++) { if (i < this.comboBoxFilter.Items.Count) { ini.IniWriteValue("cfw", "filter" + i.ToString(), this.comboBoxFilter.GetItemText(this.comboBoxFilter.Items[i])); } else { ini.IniWriteValue("cfw", "filter" + i.ToString(), null); } } }
// save ini private void NetworkMapping_FormClosing(object sender, FormClosingEventArgs e) { GrzTools.IniFile ini = new GrzTools.IniFile(System.Windows.Forms.Application.ExecutablePath + ".ini"); for (int i = 0; i < 10; i++) { if (i < this.comboBoxNetworkFolder.Items.Count) { ini.IniWriteValue("cfw", "mapping" + i.ToString(), this.comboBoxNetworkFolder.GetItemText(this.comboBoxNetworkFolder.Items[i])); } else { ini.IniWriteValue("cfw", "mapping" + i.ToString(), null); } } }
public NetworkMapping(string sFolderToMap) { this.InitializeComponent(); // render drives this.RenderDrives("C"); // INI: read GrzTools.IniFile ini = new GrzTools.IniFile(System.Windows.Forms.Application.ExecutablePath + ".ini"); for (int i = 0; i < 10; i++) { string tmp = ini.IniReadValue("cfw", "mapping" + i.ToString(), ""); if (tmp.Length > 0) { int ndx = this.comboBoxNetworkFolder.FindStringExact(tmp); if (ndx == -1) { this.comboBoxNetworkFolder.Items.Add(tmp); } } } // in case the network folder to map is already known int index = -1; if (sFolderToMap.Length > 0) { string value = ""; for (int i = 0; i < this.comboBoxDrive.Items.Count; i++) { value = this.comboBoxDrive.GetItemText(this.comboBoxDrive.Items[i]); if (value.StartsWith(sFolderToMap)) { index = i; } } } // select 1st combobox item if (this.comboBoxDrive.Items.Count > 0) { this.comboBoxDrive.SelectedIndex = 0; if (index != -1) { this.comboBoxDrive.SelectedIndex = index; } } }
// save folder history to ini private void saveFolderHistory() { GrzTools.IniFile ini = new GrzTools.IniFile(System.Windows.Forms.Application.ExecutablePath + ".ini"); for (int i = 0; i < 5; i++) { string tmp = ""; if (i < this.comboBoxFolderHistory.Items.Count) { tmp = (string)this.comboBoxFolderHistory.Items[i]; } else { tmp = null; } ini.IniWriteValue("cfw", "selectFolder" + i.ToString(), tmp); } }