Ejemplo n.º 1
0
 private void AddToCollectionButton_Click(object sender, EventArgs e)
 {
     if (EditorUI.GetParentVD2DataIsReadOnly(this))
     {
         return;
     }
     if ((_SelectedCollection != null) && (_ElementType != null))
     {
         VD2Data parentfile = null;
         Control c          = this;
         while (c.Parent != null)
         {
             if (c.Parent is VD2DocumentViewer)
             {
                 VD2DocumentViewer docview = (VD2DocumentViewer)c.Parent;
                 if (docview.Document is VD2Data)
                 {
                     parentfile = (VD2Data)docview.Document;
                 }
             }
             c = c.Parent;
         }
         VD2DataStructure ds = (VD2DataStructure)System.Activator.CreateInstance(_ElementType, parentfile, null);
         _SelectedCollection.Add(ds);
         //
         // _SelectedCollection.Add("");
     }
 }
 private void duplicateToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (EditorUI.GetParentVD2DataIsReadOnly(this))
     {
         return;
     }
     if (Parent != null)
     {
         if (Parent.Parent != null)
         {
             if (Parent.Parent is DataStructureCollectionsEditor)
             {
                 DataStructureCollectionsEditor editorparent = (DataStructureCollectionsEditor)Parent.Parent;
                 if ((_SelectedIndex >= 0) && (_SelectedIndex < editorparent.SelectedCollection.Count))
                 {
                     VD2Data parentfile = null;
                     Control c          = this;
                     while (c.Parent != null)
                     {
                         if (c.Parent is VD2DocumentViewer)
                         {
                             VD2DocumentViewer docview = (VD2DocumentViewer)c.Parent;
                             if (docview.Document is VD2Data)
                             {
                                 parentfile = (VD2Data)docview.Document;
                             }
                         }
                         c = c.Parent;
                     }
                     VD2DataStructure ds = (VD2DataStructure)System.Activator.CreateInstance(editorparent.ElementType, parentfile, editorparent.SelectedCollection[_SelectedIndex].DataNode);
                     ds.CopyFrom(editorparent.SelectedCollection[_SelectedIndex]);
                     editorparent.SelectedCollection.Add(ds);
                 }
             }
         }
     }
 }