using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BulkTap3
{
    public partial class Goto : Form
    {
        TreeView maintree;
        public Goto()
        {
            InitializeComponent();
            numericUpDown1.Select(0, numericUpDown1.Text.Length);
           
        }


        public void Set_tree(TreeView tree)
        {
            maintree = tree;
            
            numericUpDown1.Maximum = tree.Nodes[0].Nodes[3].GetNodeCount(true);
        }
  
        private void Goto_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int num = int.Parse(numericUpDown1.Value.ToString());
            if (maintree.Nodes.Count > 0 && maintree.Nodes[0].Nodes[3].GetNodeCount(false) > 0)
            {
                if (maintree.Nodes[0].Nodes[3].GetNodeCount(true) < 5000)
                    maintree.SelectedNode = maintree.Nodes[0].Nodes[3].Nodes[num - 1];
                else
                {
                    int SubnodeNum = num / 5000;
                    maintree.SelectedNode = maintree.Nodes[0].Nodes[3].Nodes[SubnodeNum].Nodes[num - (5000 * SubnodeNum) - 1];
                }
            }
            maintree.Focus();
            this.Hide();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

    }
}
