Exemplo n.º 1
0
        public void addGroupButton_Click(object sender, EventArgs e)
        {
            editGroup editGroup = new editGroup("", "");

            editGroup.Text          = "Add Group";
            editGroup.StartPosition = FormStartPosition.CenterParent;
            if (editGroup.ShowDialog(this) == DialogResult.OK)
            {
                TreeNode groupNode = new TreeNode(editGroup.ReturnValue);
                groupNode.Tag = editGroup.ReturnImage;
                stationTreeView.Nodes.Add(groupNode);
                stationTreeView.Sort();
            }
        }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (stationTreeView.SelectedNode.Level == 0)
     {
         editGroup editGroup = new editGroup(stationTreeView.SelectedNode.Text, stationTreeView.SelectedNode.Tag.ToString());
         editGroup.StartPosition = FormStartPosition.CenterParent;
         if (editGroup.ShowDialog(this) == DialogResult.OK)
         {
             stationTreeView.SelectedNode.Text = editGroup.ReturnValue;
             stationTreeView.SelectedNode.Tag  = editGroup.ReturnImage;
             stationTreeView.SelectedNode      = GetNode(editGroup.ReturnValue);
             stationTreeView.Sort();
         }
     }
     else if (stationTreeView.SelectedNode.Level == 1)
     {
         List <string> groupNames = new List <string>();
         groupNames.Clear();
         TreeNodeCollection groupNodes = stationTreeView.Nodes;
         foreach (TreeNode n in groupNodes)
         {
             groupNames.Add(n.Text);
         }
         var         metainfo    = (StationInfo)stationTreeView.SelectedNode.Tag;
         editStation editStation = new editStation(groupNames, stationTreeView.SelectedNode.Text, metainfo.url, stationTreeView.SelectedNode.Parent.Text, metainfo.img);
         editStation.StartPosition = FormStartPosition.CenterParent;
         if (editStation.ShowDialog(this) == DialogResult.OK)
         {
             if (stationTreeView.SelectedNode.Parent.Text == editStation.ReturnGroup)
             {
                 stationTreeView.SelectedNode.Text = editStation.ReturnName;
                 stationTreeView.SelectedNode.Tag  = new StationInfo {
                     url = editStation.ReturnURL, img = editStation.ReturnImage
                 };
                 stationTreeView.Sort();
                 stationTreeView.SelectedNode = GetNode(editStation.ReturnName);
             }
             else
             {
                 TreeNode newParent = GetNode(editStation.ReturnGroup);
                 if (newParent != null)
                 {
                     stationTreeView.SelectedNode.Remove();
                     TreeNode newStation = new TreeNode(editStation.ReturnName);
                     newStation.Tag = new StationInfo {
                         url = editStation.ReturnURL, img = editStation.ReturnImage
                     };
                     newParent.Nodes.Add(newStation);
                     stationTreeView.Sort();
                     stationTreeView.SelectedNode = newStation;
                     newStation.Parent.Expand();
                 }
                 else
                 {
                     newParent = new TreeNode(editStation.ReturnGroup);
                     stationTreeView.SelectedNode.Remove();
                     TreeNode newStation = new TreeNode(editStation.ReturnName);
                     newStation.Tag = new StationInfo {
                         url = editStation.ReturnURL, img = editStation.ReturnImage
                     };
                     newParent.Nodes.Add(newStation);
                     stationTreeView.Nodes.Add(newParent);
                     stationTreeView.Sort();
                     stationTreeView.SelectedNode = newStation;
                     newStation.Parent.Expand();
                 }
             }
             TrimTree();
         }
     }
 }