Ejemplo n.º 1
0
        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            treeView1.SelectedNode = treeView1.Nodes[0];
            if (e.Result == null)
            {
                populateTabData();
            }
            else
            {
                SwitchInfo sw    = (SwitchInfo)e.Result;
                SwitchForm swFrm = null;
                foreach (Form frm in MdiChildren)
                {
                    if (frm.Name.Equals(sw.Name))
                    {
                        swFrm = (SwitchForm)frm;
                        break;
                    }
                }

                if (swFrm != null)
                {
                    swFrm.AddData();
                }

                treeView1.SelectedNode = treeView1.Nodes[sw.Name];
            }
            waitMode(false);
        }
Ejemplo n.º 2
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (updating)
            {
                return;
            }

            bool found = false;

            foreach (Form frm in MdiChildren)
            {
                if (frm.Text.Equals(e.Node.Name))
                {
                    if (frm.Handle == IntPtr.Zero)
                    {
                        frm.Show();
                    }
                    frm.Focus();
                    found = true;
                }
                else
                {
                    if (!frm.Text.Equals("Search Results"))
                    {
                        frm.Close();
                    }
                }
            }

            if (found)
            {
                return;
            }

            // Form does not exist so create it
            Form form = null;

            if (e.Node.Name.Equals("Search Results"))
            {
                form       = new SearchForm();
                searchForm = (SearchForm)form;
            }
            else
            {
                form = new SwitchForm(getSwitch(e.Node.Name));
            }

            form.MdiParent = this;

            if (form.Handle == IntPtr.Zero)
            {
                form.Show();
            }
            form.Focus();
            form.WindowState = FormWindowState.Maximized;
        }
Ejemplo n.º 3
0
        public void gotoSwitch(string swtch, string port)
        {
            SwitchInfo sw = getSwitch(swtch);

            if (sw == null)
            {
                return;
            }
            SwitchPort prt = sw.getPort(port);

            if (prt == null)
            {
                return;
            }

            treeView1.SelectedNode = null;
            treeView1.SelectedNode = treeView1.Nodes[sw.Name];

            foreach (Form frm in MdiChildren)
            {
                if (frm.Text.Equals(sw.Name))
                {
                    SwitchForm swFrm = (SwitchForm)frm;
                    for (int j = 0; j < swFrm.dgvSwitch.RowCount; j++)
                    {
                        if (swFrm.dgvSwitch.Rows[j].Cells[0].Value.ToString() == prt.Name)
                        {
                            swFrm.dgvSwitch.ClearSelection();
                            swFrm.dgvSwitch.Rows[j].Selected = true;
                            swFrm.dgvSwitch.FirstDisplayedScrollingRowIndex = j;
                            break;
                        }
                    }
                    break;
                }
            }
        }