Esempio n. 1
0
 /// <summary>
 /// Floating window constructor.
 /// </summary>
 public FloatingWindow()
 {
     _form     = null;
     _location = new Point();
     _size     = new Size();
     _keys     = new List <Keys>();
 }
Esempio n. 2
0
 /// <summary>
 /// Show the window.
 /// </summary>
 public void show()
 {
     if (_form != null)
     {
         _form.Dispose();
     }
     _form    = new FloatingForm(this);
     _visible = true;
 }
Esempio n. 3
0
 /// <summary>
 /// Hides the window.
 /// </summary>
 public void hide()
 {
     if (_form != null)
     {
         _form.Visible = false;
         _form.Dispose();
         _form = null;
     }
     _visible = false;
 }
Esempio n. 4
0
        void CreateChild()
        {
            if (child != null)
            {
                child.Close();
            }
            Action show;

            var layout = new DynamicLayout();

            layout.Add(null);
            layout.AddCentered(TestChangeSizeButton());
            layout.AddCentered(TestChangeClientSizeButton());
            layout.AddCentered(SendToBackButton());
            layout.AddCentered(CreateCancelClose());
            layout.AddCentered(CloseButton());

            if (typeRadio.SelectedKey == "form")
            {
                var form = new Form();
                child = form;
                show  = form.Show;
                if (showActivatedCheckBox.Checked != null)
                {
                    form.ShowActivated = showActivatedCheckBox.Checked == true;
                }
                if (canFocusCheckBox.Checked != null)
                {
                    form.CanFocus = canFocusCheckBox.Checked == true;
                }
            }
            else if (typeRadio.SelectedKey == "floating")
            {
                var form = new FloatingForm();
                child = form;
                show  = form.Show;
                if (showActivatedCheckBox.Checked != null)
                {
                    form.ShowActivated = showActivatedCheckBox.Checked == true;
                }
                if (canFocusCheckBox.Checked != null)
                {
                    form.CanFocus = canFocusCheckBox.Checked == true;
                }
            }
            else
            {
                var dialog = new Dialog();

                dialog.DefaultButton = new Button {
                    Text = "Default"
                };
                dialog.DefaultButton.Click += (sender, e) => Log.Write(dialog, "Default button clicked");

                dialog.AbortButton = new Button {
                    Text = "Abort"
                };
                dialog.AbortButton.Click += (sender, e) => Log.Write(dialog, "Abort button clicked");

                layout.AddSeparateRow(null, dialog.DefaultButton, dialog.AbortButton, null);

                child = dialog;
                show  = dialog.ShowModal;

                if (dialogDisplayModeDropDown.SelectedValue != null)
                {
                    dialog.DisplayMode = dialogDisplayModeDropDown.SelectedValue ?? DialogDisplayMode.Default;
                }
            }

            layout.Add(null);
            child.Padding = 20;
            child.Content = layout;

            child.OwnerChanged       += child_OwnerChanged;
            child.WindowStateChanged += child_WindowStateChanged;
            child.Closed             += child_Closed;
            child.Closing            += child_Closing;
            child.Shown           += child_Shown;
            child.GotFocus        += child_GotFocus;
            child.LostFocus       += child_LostFocus;
            child.LocationChanged += child_LocationChanged;
            child.SizeChanged     += child_SizeChanged;

            child.Title       = "Child Window";
            child.WindowStyle = styleCombo.SelectedValue;
            child.WindowState = stateCombo.SelectedValue;
            if (topMostCheckBox.Checked != null)
            {
                child.Topmost = topMostCheckBox.Checked ?? false;
            }
            if (resizableCheckBox.Checked != null)
            {
                child.Resizable = resizableCheckBox.Checked ?? false;
            }
            if (maximizableCheckBox.Checked != null)
            {
                child.Maximizable = maximizableCheckBox.Checked ?? false;
            }
            if (minimizableCheckBox.Checked != null)
            {
                child.Minimizable = minimizableCheckBox.Checked ?? false;
            }
            if (showInTaskBarCheckBox.Checked != null)
            {
                child.ShowInTaskbar = showInTaskBarCheckBox.Checked ?? false;
            }
            if (movableByWindowBackgroundCheckBox.Checked != null)
            {
                child.MovableByWindowBackground = movableByWindowBackgroundCheckBox.Checked ?? false;
            }
            if (setInitialLocation)
            {
                child.Location = initialLocation;
            }
            if (setInitialClientSize)
            {
                child.ClientSize = initialClientSize;
            }
            if (setInitialSize)
            {
                child.Size = initialSize;
            }
            if (setInitialMinimumSize)
            {
                child.MinimumSize = initialMinimumSize;
            }
            if (setOwnerCheckBox.Checked ?? false)
            {
                child.Owner = ParentWindow;
            }
            if (createMenuBar.Checked ?? false)
            {
                child.Menu = CreateMenuBar();
            }
            bringToFrontButton.Enabled = true;
            DataContext = child;
            show();
            //visibleCheckBox.Checked = child?.Visible == true; // child will be null after it is shown
            // show that the child is now referenced
            Log.Write(null, "Open Windows: {0}", Application.Instance.Windows.Count());
        }
 private void MainForm_Load(object sender, EventArgs e)
 {
     _floatingForm = new FloatingForm(this);
     _floatingForm.Show();
 }