Tuesday, 29 May 2012

21. Trader - New navigation among forms

There is new navigation in place. Now, once activated forms, stayed alive in background and can be invoked by click in Active form list (it is listBox ListActiveForms). Active form can be hidden and still be activated. List item is added with form name after new indice is chosen and form was created. There is checking of only one form per indice can be created.



Code is changed under Menu item "Patterns":

private void patternsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormCollection fC = Application.OpenForms;
            string ait = activeIndice.Text;
            if (ait == "") { goto kraj; }
            int i = Application.OpenForms.Count;
            if (i == 1)
            {
                fPatterns ff = new fPatterns();
                ff.Text = ait;
                ff.Name = ait;
                ff.Show();
                goto kraj;
            }

            foreach (Form f in fC)
            {
                if (f.Text == ait) {
                    goto kraj; }
            }
            {
                fPatterns ff = new fPatterns();
                ff.Text = ait;
                ff.Name = ait;
                ff.Show();
            }
        kraj: ;
        listActiveForms.Items.Clear();
        foreach (Form f in fC) { listActiveForms.Items.Add(f.Name); }
        }


This code is activated on click (selection) on ListBox labeled "Active form list":

       private void listActiveForms_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listActiveForms.SelectedItem.ToString() == "") { goto kraj; }
            string fS = listActiveForms.SelectedItem.ToString(); // Value.ToString(); // form selected
            Form form = Application.OpenForms[fS];
            form.Visible = true;
            form.Activate();
        kraj: ;
        }


Code under menu item Hide is:

private void hideToolStripMenuItem_Click(object sender, EventArgs e)
        {
           fPatterns.ActiveForm.Visible=false;
        }

No comments:

Post a Comment