private void PasteSubRecord() { if (!this.ValidateMakeChange()) { return; } if (!MainView.HasClipboardData <SubRecord[]>()) { return; } try { BaseRecord br = this.Selection.Record; int insertIdx = this.listSubrecord.SelectedIndices.Count == 0 ? -1 : this.listSubrecord.GetFocusedItem(); var nodes = MainView.GetClipboardData <SubRecord[]>(); foreach (var clipSr in insertIdx < 0 ? nodes : nodes.Reverse()) { // insert in revers var sr = clipSr.Clone() as SubRecord; if (sr == null) { return; } if (br is Record) { try { if (insertIdx >= 0 && insertIdx < this.listSubrecord.Items.Count) { br.InsertRecord(insertIdx, sr); } else { br.AddRecord(sr); } } catch (TESParserException ex) { MessageBox.Show(ex.Message); } } } this.RebuildSelection(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal void PasteFromClipboard(bool recordOnly) { if (!MainView.HasClipboardData()) { MainView.PostStatusWarning(Resources.TheClipboardIsEmpty); return; } var clipboardObject = MainView.Clipboard; bool isRec = clipboardObject is Record || clipboardObject is GroupRecord; bool isRecList = clipboardObject is BaseRecord[]; if (recordOnly && !(isRec || isRecList)) { return; } if (isRec) { BaseRecord node = PluginTree.SelectedRecord; try { var dstNode = PluginTree.SelectedRecord; var br = ((BaseRecord)clipboardObject).Clone(); node.AddRecord(br); RebuildSelection(); } catch (TESParserException ex) { MessageBox.Show(ex.Message); } } else if (isRecList) { var gr = PluginTree.SelectedRecord as IGroupRecord; if (gr != null) { foreach (var rec in (BaseRecord[])clipboardObject) { gr.AddRecord(rec); } RefreshObject(gr as BaseRecord); } } }