コード例 #1
0
ファイル: CapturedScenario.cs プロジェクト: lamezcua/WatinXml
 /// <summary>
 /// Remove TreeNode and associated event
 /// </summary>
 /// <param name="treeNode"></param>
 internal void Remove(TreeNode treeNode, TreeView tvTests)
 {
     if (treeNode.Tag is wxPage)
     {
         wxPage p = treeNode.Tag as wxPage;
         scenario.Pages.Remove(p);
     }
     else if (treeNode.Tag is wxTest)
     {
         wxTest t = treeNode.Tag as wxTest;
         scenario.Pages[0].Tests.Remove(t);
     }
     else if (treeNode.Tag is wxAction)
     {
         wxTest t = treeNode.Parent.Tag as wxTest;
         if (t != null)
         {
             wxAction a = treeNode.Tag as wxAction;
             t.Actions.Remove(a);
         }
     }
     else
     {
         throw new ApplicationException("Not able to remove thang");
     }
     // If everything is ok, remove
     tvTests.Nodes.Remove(treeNode);
 }
コード例 #2
0
ファイル: CapturedScenario.cs プロジェクト: lamezcua/WatinXml
 internal void RemoveAllBut(TreeNode treeNode, TreeView tvTests)
 {
     if (treeNode.Tag is wxPage)
     {
         wxBasePage page = treeNode.Tag as wxBasePage;
         for (int i = scenario.Pages.Count - 1; i >= 0; i--)
         {
             if (page != scenario.Pages[i])
             {
                 scenario.Pages.RemoveAt(i);
             }
         }
         for (int i = tvTests.Nodes.Count - 1; i >= 0; i--)
         {
             if (treeNode != tvTests.Nodes[i])
             {
                 tvTests.Nodes.Remove(tvTests.Nodes[i]);
             }
         }
     }
     else if (treeNode.Tag is wxTest)
     {
         return; // cuz we will always have only one test per page (in recorder)
         //wxTest test = treeNode.Tag as wxTest;
         //wxBasePage page = treeNode.Parent.Tag as wxBasePage;
         //for (int i = scenario.Pages.Count - 1; i >= 0; i--)
         //{
         //    if (page != scenario.Pages[i])
         //        scenario.Pages.RemoveAt(i);
         //}
         //for (int i = tvTests.Nodes.Count - 1; i >= 0; i--)
         //{
         //    if (treeNode != tvTests.Nodes[i])
         //        tvTests.Nodes.Remove(tvTests.Nodes[i]);
         //}
     }
     else if (treeNode.Tag is wxAction)
     {
         wxAction a = treeNode.Tag as wxAction;
         wxTest   t = treeNode.Parent.Tag as wxTest;
         for (int i = t.Actions.Count - 1; i >= 0; i--)
         {
             if (t.Actions[i] != a)
             {
                 t.Actions.RemoveAt(i);
             }
         }
         for (int i = treeNode.Parent.Nodes.Count - 1; i >= 0; i--)
         {
             if (treeNode != treeNode.Parent.Nodes[i])
             {
                 treeNode.Parent.Nodes.RemoveAt(i);
             }
         }
     }
     else
     {
         throw new ApplicationException("Not able to remove thang");
     }
 }