private void addNodeToolStripMenuItem_Click(object sender, EventArgs e) { dynamic target = treeView1.SelectedNode == null ? byml : treeView1.SelectedNode.Tag; var targetNodeCollection = treeView1.SelectedNode == null ? treeView1.Nodes : treeView1.SelectedNode.Nodes; if (target is EditableNode) { if (treeView1.SelectedNode.Parent == null) { target = byml; targetNodeCollection = treeView1.Nodes; } else { target = treeView1.SelectedNode.Parent.Tag; targetNodeCollection = treeView1.SelectedNode.Parent.Nodes; } } var newProp = AddBymlPropertyDialog.newProperty(!(target is IList <dynamic>)); if (newProp == null) { return; } bool clone = newProp.Item2 is IDictionary <string, dynamic> || newProp.Item2 is IList <dynamic>; //reference types must be manually cloned var toAdd = clone ? DeepCloneDictArr.DeepClone(newProp.Item2) : newProp.Item2; targetNodeCollection.Clear(); if (target is IList <dynamic> ) { ((IList <dynamic>)target).Insert(((IList <dynamic>)target).Count, toAdd); parseArrayNode((IList <dynamic>)target, targetNodeCollection); } else if (target is IDictionary <string, dynamic> ) { ((IDictionary <string, dynamic>)target).Add(newProp.Item1, toAdd); parseDictNode((IDictionary <string, dynamic>)target, targetNodeCollection); } else { throw new Exception(); } ResetValues(); }
private void CloneScenarioBtn_Click(object sender, EventArgs e) { var lev = (Level)ViewForm.LoadedLevel; var s = new EditorForms.CloneScenarioDialog(lev.CurScenario, lev.ScenarioCount); s.ShowDialog(); if (s.result == null) { return; } foreach (int i in s.result) { lev.LoadedLevelData[i] = s.clone ? DeepCloneDictArr.DeepClone((Dictionary <string, dynamic>)lev.LoadedLevelData[lev.CurScenario]) : lev.LoadedLevelData[lev.CurScenario]; } }
public LinksNode Clone() { return(new LinksNode(DeepCloneDictArr.DeepClone(this))); }