Esempio n. 1
0
        private void ShowNewMdiChild <TForm>() where TForm : Form, new()
        {
            var childForm = new TForm();

            childForm.MdiParent = this;
            childForm.Show();
        }
Esempio n. 2
0
        private void ShowEditor <TForm>() where TForm : Form, new()
        {
            var editor = new TForm {
                MdiParent = this
            };

            editor.Show();
        }
Esempio n. 3
0
        private void ShowChildForm <TForm>() where TForm : Form, new()
        {
            Form childForm = new TForm();

            childForm.MdiParent = this;
            childForm.Name      = "ChildForm - " + DateTime.Now.Millisecond.ToString();
            childForm.Text      = childForm.Name;
            childForm.Show();
        }
Esempio n. 4
0
        private void ShowChildForm <TForm>() where TForm : Form, new()
        {
            TForm childForm = new TForm();

            childForm.MdiParent = this;
            childForm.Parent    = splitContainer.Panel2;

            childForm.WindowState = FormWindowState.Normal;
            childForm.Dock        = DockStyle.Fill;
            childForm.Size        = new Size(splitContainer.Width - splitContainer.SplitterDistance, splitContainer.Height);
            childForm.BringToFront();
            childForm.Show();
        }
Esempio n. 5
0
        public static void Show <TForm>() where TForm : Form, new()
        {
            var form = _activeForms.OfType <TForm>().SingleOrDefault();

            if (form != null)
            {
                form.Activate();
            }
            else
            {
                form = new TForm();
                _activeForms.Add(form);
                form.Show();
            }
        }
Esempio n. 6
0
        public void ShowOrCreate <TForm>() where TForm : Form, new()
        {
            var instance = Application.OpenForms.OfType <TForm>().FirstOrDefault();

            if (instance == null)
            {
                instance           = new TForm();
                instance.MdiParent = FrmMain.ActiveForm;

                instance.Show();
            }
            else
            {
                instance.Focus();
                instance.WindowState = FormWindowState.Normal;
            }
        }
Esempio n. 7
0
        public void OpenControlledMdiChild <TForm>() where TForm : Form, new()
        {
            bool formFound = false;

            foreach (Form form in this.MdiChildren)
            {
                if (form is TForm)
                {
                    form.BringToFront();
                    formFound = true;
                    break;
                }
            }
            if (!formFound)
            {
                TForm form = new TForm();
                form.MdiParent = this;
                form.Show();
            }
        }
Esempio n. 8
0
        void CreateForm <TForm>() where TForm : Form, new()
        {
            // 倒数第二段
            var ss = typeof(TForm).FullName.Split(".");

            if (ss.Length >= 2)
            {
                var name = ss[ss.Length - 2];
                var cfg  = XConfig.Current;
                if (name != cfg.LastTool)
                {
                    cfg.LastTool = name;
                    cfg.Save();
                }
            }

            var frm = new TForm();

            frm.MdiParent   = this;
            frm.WindowState = FormWindowState.Maximized;
            frm.Show();
        }
Esempio n. 9
0
        public void CreateComponents()
        {
            Application = new TApplication(null);
            Application.Initialize();
            Application.Run();

            var el    = Browser.GetElementById("helloWorld");
            var lForm = new TForm(null);

            lForm.Width = 800;
            // el it's a div element in html file, we are using as container for our form
            lForm.Show(el);

            var lFontsPanel = new TPanel(lForm);

            lFontsPanel.Height = 150;
            lFontsPanel.Width  = 800;
            lFontsPanel.Parent = lForm;

            var lFontsCombo = new TComboBox(lForm);

            lFontsCombo.Left  = 30;
            lFontsCombo.Top   = 50;
            lFontsCombo.Width = 130;
            // Add combo inside TPanel
            lFontsCombo.Parent = lFontsPanel;

            lFontsCombo.Items.Add("Arial");
            lFontsCombo.Items.Add("Verdana");
            lFontsCombo.Items.Add("Helvetica");
            lFontsCombo.Items.Add("Times");

            var lFontSize = new TComboBox(lForm);

            lFontSize.Left   = 200;
            lFontSize.Top    = 50;
            lFontSize.Width  = 80;
            lFontSize.Parent = lFontsPanel;
            for (var i = 8; i <= 72; i += 4)
            {
                lFontSize.Items.Add(i.ToString());
            }

            var lLabel = new TLabel(lForm);

            lLabel.Left    = 320;
            lLabel.Top     = 50;
            lLabel.Caption = "Choose font name and size!";
            lLabel.Parent  = lFontsPanel;

            // Assign combo events
            lFontsCombo.OnSelect = (a) => { lLabel.Font.Name = lFontsCombo.Text; };
            lFontSize.OnSelect   = (a) => { lLabel.Font.Size = StrToInt(lFontSize.Text); };

            var lSecondPanel = new TPanel(lForm);

            lSecondPanel.Top    = 220;
            lSecondPanel.Height = 150;
            lSecondPanel.Width  = 800;
            lSecondPanel.Parent = lForm;

            var lCheckBox = new TCheckBox(lForm);

            lCheckBox.Top     = 20;
            lCheckBox.Left    = 30;
            lCheckBox.Caption = "CheckBox control";
            lCheckBox.Parent  = lSecondPanel;

            var lRadioButton = new TRadioButton(lForm);

            lRadioButton.Top     = 80;
            lRadioButton.Left    = 30;
            lRadioButton.Caption = "RadioButton control";
            lRadioButton.Parent  = lSecondPanel;

            var lChangeButton = new TButton(lForm);

            lChangeButton.Left    = 220;
            lChangeButton.Top     = 20;
            lChangeButton.Caption = "Change progress bar mode";
            lChangeButton.Parent  = lSecondPanel;
            lChangeButton.OnClick = @ChangeButtonClick;

            var lIncButton = new TButton(lForm);

            lIncButton.Left    = 220;
            lIncButton.Top     = 80;
            lIncButton.Caption = "Increase progress bar value";
            lIncButton.Parent  = lSecondPanel;
            lIncButton.OnClick = (a) => { fProgress.Position = fProgress.Position + 5; if (fProgress.Position >= fProgress.Max)
                                          {
                                              fProgress.Position = 0;
                                          }
            };

            fProgress        = new TProgressBar(lForm);
            fProgress.Top    = 55;
            fProgress.Left   = 420;
            fProgress.Max    = 100;
            fProgress.Parent = lSecondPanel;
        }
Esempio n. 10
0
        public void HelloWorld()
        {
            Application = new TApplication(null);
            Application.Initialize();
            Application.Run();

            // Create form
            var lForm = new TForm(null);

            lForm.Width = 800;
            // we can display the form in an existing div element. If Show parameter is nil, a new div is created
            lForm.Show(null);

            var lTopLabel = new TLabel(lForm);

            lTopLabel.Left    = 1;
            lTopLabel.Parent  = lForm;
            lTopLabel.Caption = "Write the item caption on the edit and press Add New button to add to ListBox:";

            var lButton = new TButton(lForm);

            lButton.Left    = 50;
            lButton.Top     = 50;
            lButton.Caption = "Add New";
            lButton.Parent  = lForm;

            var lEdit = new TEdit(lForm);

            lEdit.Left   = 150;
            lEdit.Top    = 50;
            lEdit.Parent = lForm;

            var lListBox = new TListBox(lForm);

            lListBox.Left        = 350;
            lListBox.Top         = 50;
            lListBox.Parent      = lForm;
            lListBox.Width       = 250;
            lListBox.MultiSelect = true;

            lButton.OnClick = (s) => { lListBox.Items.Add(lEdit.Text); };

            var lChangeLabel = new TLabel(lForm);

            lChangeLabel.Top     = 165;
            lChangeLabel.Parent  = lForm;
            lChangeLabel.Caption = "Press button to change label font:";

            var lChangeButton = new TButton(lForm);

            lChangeButton.Left    = 50;
            lChangeButton.Top     = 200;
            lChangeButton.Caption = "Change font";
            lChangeButton.Parent  = lForm;

            var lLabel = new TLabel(lForm);

            lLabel.Left    = 150;
            lLabel.Top     = 200;
            lLabel.Caption = "Sample text!";
            lLabel.Parent  = lForm;

            lChangeButton.OnClick = (s) => { lLabel.Font.Name = "Verdana"; lLabel.Font.Size = 24; };

            var lMemo = new TMemo(lForm);

            lMemo.Left   = 50;
            lMemo.Top    = 300;
            lMemo.Width  = 250;
            lMemo.Height = 150;
            lMemo.Parent = lForm;

            var lMemoButton = new TButton(lForm);

            lMemoButton.Left    = 350;
            lMemoButton.Top     = 325;
            lMemoButton.Caption = "Add text";
            lMemoButton.Parent  = lForm;
            var lList = TStringList.Create();

            lList.Add("one line");
            lList.Add("another one");
            lMemoButton.OnClick = (s) => { lMemo.Lines.AddStrings(lList); };

            var lDisplayButton = new TButton(lForm);

            lDisplayButton.Top     = lMemoButton.Top;
            lDisplayButton.Left    = 450;
            lDisplayButton.Caption = "Show memo text";
            lDisplayButton.Parent  = lForm;
            lDisplayButton.OnClick = (s) => { ShowMessage(lMemo.Lines.Text); };
        }