private void TrcnItemAdd() { bool savedstate = internalchg; internalchg = true; try { wrapper.Add(new TrcnItem(wrapper)); this.lvTrcnItem.Items.Add(new ListViewItem(trcnItemToStringArray(wrapper.Count - 1))); } catch { } internalchg = savedstate; setIndex(lvTrcnItem.Items.Count - 1); }
private void TRCNMaker() { bconPanel.Cursor = Cursors.WaitCursor; Application.UseWaitCursor = true; try { int minArgc = 0; Trcn trcn = (Trcn)wrapper.SiblingResource(Trcn.Trcntype); // find Trcn for this Bcon wrapper.Package.BeginUpdate(); if (trcn != null && trcn.TextOnly) { // if it exists but is unreadable, as if user wants to overwrite DialogResult dr = MessageBox.Show( pjse.Localization.GetString("ml_overwriteduff") , btnTRCNMaker.Text , MessageBoxButtons.OKCancel , MessageBoxIcon.Warning); if (dr != DialogResult.OK) { return; } wrapper.Package.Remove(trcn.FileDescriptor); trcn = null; } if (trcn != null) { // if it exists ask if user wants to preserve content DialogResult dr = MessageBox.Show( pjse.Localization.GetString("ml_keeplabels") , btnTRCNMaker.Text , MessageBoxButtons.YesNoCancel , MessageBoxIcon.Warning); if (dr == DialogResult.Cancel) { return; } if (!trcn.Package.Equals(wrapper.Package)) { // Clone the original into this package if (dr == DialogResult.Yes) { Wait.MaxProgress = trcn.Count; } SimPe.Interfaces.Files.IPackedFileDescriptor npfd = trcn.FileDescriptor.Clone(); Trcn ntrcn = new Trcn(); ntrcn.FileDescriptor = npfd; wrapper.Package.Add(npfd, true); ntrcn.ProcessData(npfd, wrapper.Package); if (dr == DialogResult.Yes) { foreach (TrcnItem item in trcn) { ntrcn.Add(item); Wait.Progress++; } } trcn = ntrcn; trcn.SynchronizeUserData(); Wait.MaxProgress = 0; } if (dr == DialogResult.Yes) { minArgc = trcn.Count; } else { trcn.Clear(); } } else { // create a new Trcn file SimPe.Interfaces.Files.IPackedFileDescriptor npfd = wrapper.FileDescriptor.Clone(); trcn = new Trcn(); npfd.Type = Trcn.Trcntype; trcn.FileDescriptor = npfd; wrapper.Package.Add(npfd, true); trcn.SynchronizeUserData(); } Wait.MaxProgress = wrapper.Count - minArgc; trcn.FileName = wrapper.FileName; for (int arg = minArgc; arg < wrapper.Count; arg++) { trcn.Add(new TrcnItem(trcn)); trcn[arg].ConstId = (uint)arg; trcn[arg].ConstName = "Label " + arg.ToString(); trcn[arg].DefValue = trcn[arg].MaxValue = trcn[arg].MinValue = 0; Wait.Progress++; } trcn.SynchronizeUserData(); wrapper.Package.EndUpdate(); } finally { Wait.SubStop(); bconPanel.Cursor = Cursors.Default; Application.UseWaitCursor = false; } MessageBox.Show( pjse.Localization.GetString("ml_done") , btnTRCNMaker.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); }