private void mnuInsertItem_Click(object sender, EventArgs e) { int idx = lstItems.SelectedIndex; try { if (idx >= 0 && idx < lstItems.Items.Count) { GenericQbItem qbi = QbFile.CreateGenericArrayItem(base.QbItem); qbi.ConvertTo(_currentEditType); _gItems.Insert(idx, qbi); lstItems.Items.Insert(idx, qbi.Value); enableItems(); lstItems.SelectedIndex = idx; txtItem.SelectAll(); txtItem.Focus(); } } catch (Exception ex) { base.ShowException("Simple Array Insert Item Error", ex); } }
private void btnImport_Click(object sender, EventArgs e) { try { string fname = string.Empty; // string.Format("{0}_{1}.array.txt", base.QbItem.Root.Filename.Replace('\\', '#').Replace('/', '#').Replace('.', '#'), base.QbItem.ItemQbKey.Crc.ToString("X").PadLeft(8, '0')); if (AppState.LastArrayPath.Length == 0) { fname = Path.Combine(AppState.LastArrayPath, fname); } fname = getBestFullFilename(fname); import.Filter = string.Format("{0} (*.{0})|*.{0}|All files (*.*)|*.*", _fileExt); import.Title = string.Format("Import {0} file", _fileExt); import.CheckFileExists = true; import.CheckPathExists = true; import.FileName = fname; if (import.ShowDialog(this) != DialogResult.Cancel) { fname = import.FileName; using (FileStream fs = new FileStream(fname, FileMode.Open, FileAccess.Read)) { using (TextReader tr = new StreamReader(fs)) { lstItems.Items.Clear(); _gItems.Clear(); string s; while ((s = tr.ReadLine()) != null) { GenericQbItem qbi = QbFile.CreateGenericArrayItem(base.QbItem); qbi.ConvertTo(_currentEditType); _gItems.Add(qbi); qbi.Value = s; lstItems.Items.Add(qbi.Value); } } } if (lstItems.Items.Count > 1) { lstItems.SelectedIndex = 0; } btnUpdate_Click(this, e); } } catch (Exception ex) { base.ShowException("Script Import Error", ex); } }