예제 #1
0
        private void BtnRunTest_Click(object sender, EventArgs e)
        {
            VisualForm _formToOpen;

            switch (_unitTest)
            {
            case UnitTests.VisualFormEmpty:
            {
                _formToOpen = new VisualForm(Application.ProductName);
                break;
            }

            case UnitTests.VisualFormTest:
            {
                _formToOpen = new FormTest();
                break;
            }

            case UnitTests.VisualListViewExtended:
            {
                _formToOpen = new VisualListViewTest();
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }

            _formToOpen.ShowDialog();
        }
예제 #2
0
        public ShadowManager(VisualForm kryptonForm, ShadowValues shadowValues)
        {
            _parentForm   = kryptonForm;
            _shadowValues = shadowValues;

            _parentForm.Closing += KryptonFormOnClosing;
            _parentForm.Load    += FormLoaded;

            shadowValues.EnableShadowsChanged += ShadowValues_EnableShadowsChanged;
            shadowValues.MarginsChanged       += ShadowValues_MarginsChanged;
            shadowValues.BlurDistanceChanged  += ShadowValues_BlurDistanceChanged;
            shadowValues.ColourChanged        += ShadowValues_ColourChanged;
            shadowValues.OpacityChanged       += ShadowValues_OpacityChanged;
        }
예제 #3
0
        public BlurManager(VisualForm kryptonForm, BlurValues blurValues)
        {
            _parentForm = kryptonForm;
            _blurValues = blurValues;

            _parentForm.Closing += KryptonFormOnClosing;
            _detectIsActiveTimer = new System.Windows.Forms.Timer {
                Enabled = false, Interval = 200
            };
            _detectIsActiveTimer.Tick += DetectIsTopMost;

            _blurValues.BlurWhenFocusLostChanged += BlurValues_EnableBlurChanged;
            _blurValues.OpacityChanged           += BlurValuesOnOpacityChanged;
        }
예제 #4
0
        public BlurManager(VisualForm kryptonForm, BlurValues blurValues)
        {
            _parentForm = kryptonForm;
            _blurValues = blurValues;

            _parentForm.Closing += KryptonFormOnClosing;
            _detectIsActiveTimer = new Timer {
                Enabled = false, Interval = 200
            };
            _detectIsActiveTimer.Tick += DetectIsTopMost;

            _blurValues.EnableBlurChanged += BlurValues_EnableBlurChanged;
            _blurValues.RadiusChanged     += BlurValuesOnRadiusChanged;
            _blurValues.OpacityChanged    += BlurValuesOnOpacityChanged;
        }
예제 #5
0
        /// <summary>Creates a default window context menu.</summary>
        /// <param name="form">The form.</param>
        /// <returns>The <see cref="VisualContextMenu" />.</returns>
        public static VisualContextMenu WindowContextMenu(VisualForm form)
        {
            VisualContextMenu _contextMenu = new VisualContextMenu
            {
                Name = Application.ProductName
            };

            ToolStripMenuItem _restore = new ToolStripMenuItem("Restore", null, (sender, args) => form.ControlBox.RestoreFormWindow(form));

            if ((form.WindowState == FormWindowState.Maximized) && form.MaximizeBox)
            {
                _restore.Enabled = true;
            }
            else
            {
                _restore.Enabled = false;
            }

            _restore.Image = DrawControlBoxIcon(new Size(20, 20), ControlBoxConstants.RestoreText);

            ToolStripMenuItem _move = new ToolStripMenuItem("Move", null, (sender, args) => Move(form))
            {
                Enabled = form.Moveable
            };

            ToolStripMenuItem _size = new ToolStripMenuItem("Size", null, (sender, args) => Sizing(form))
            {
                Enabled = form.Sizable
            };

            ToolStripMenuItem _minimize = new ToolStripMenuItem("Minimize", null, (sender, args) => form.ControlBox.MinimizeForm(form));

            if ((form.WindowState != FormWindowState.Minimized) && form.MinimizeBox)
            {
                _minimize.Enabled = true;
            }
            else
            {
                _minimize.Enabled = false;
            }

            _minimize.Image = DrawControlBoxIcon(new Size(20, 20), ControlBoxConstants.MinimizeText);

            ToolStripMenuItem _maximize = new ToolStripMenuItem("Maximize", null, (sender, args) => form.ControlBox.MaximizeForm(form));

            if ((form.WindowState == FormWindowState.Normal) && form.MaximizeBox)
            {
                _maximize.Enabled = true;
            }
            else
            {
                _maximize.Enabled = false;
            }

            _maximize.Image = DrawControlBoxIcon(new Size(20, 20), ControlBoxConstants.MaximizeText);

            ToolStripSeparator _separator = new ToolStripSeparator();

            ToolStripMenuItem _close = new ToolStripMenuItem("Close", null, (sender, args) => form.ControlBox.CloseForm(form))
            {
                Image = DrawControlBoxIcon(new Size(20, 20), ControlBoxConstants.CloseText)
            };

            // Fix: shortcut keys drawing.
            // _close.ShortcutKeys = Keys.Alt | Keys.F4;
            _contextMenu.Items.Add(_restore);
            _contextMenu.Items.Add(_move);
            _contextMenu.Items.Add(_size);
            _contextMenu.Items.Add(_minimize);
            _contextMenu.Items.Add(_maximize);
            _contextMenu.Items.Add(_separator);
            _contextMenu.Items.Add(_close);

            return(_contextMenu);
        }
예제 #6
0
        /// <summary>Creates a default window context menu.</summary>
        /// <param name="form">The form.</param>
        /// <returns>The <see cref="ContextMenuStrip" />.</returns>
        public static ContextMenuStrip WindowContextMenu(VisualForm form)
        {
            ContextMenuStrip _contextMenu = new ContextMenuStrip {
                Name = Application.ProductName
            };

            ToolStripMenuItem _restore = new ToolStripMenuItem("Restore", null, (sender, args) => form.ControlBox.RestoreFormWindow(form));

            if ((form.WindowState == FormWindowState.Maximized) && form.MaximizeBox)
            {
                _restore.Enabled = true;
            }
            else
            {
                _restore.Enabled = false;
            }

            _restore.Image = VisualControlBoxRenderer.RenderControlBoxIcon(new Size(20, 20), VisualForm.ControlBoxIcons.Restore, Color.Black);

            ToolStripMenuItem _move = new ToolStripMenuItem("Move", null, (sender, args) => Move(form))
            {
                Enabled = form.Moveable
            };

            ToolStripMenuItem _size = new ToolStripMenuItem("Size", null, (sender, args) => Sizing(form))
            {
                Enabled = form.Sizable
            };

            ToolStripMenuItem _minimize = new ToolStripMenuItem("Minimize", null, (sender, args) => form.ControlBox.MinimizeForm(form));

            if ((form.WindowState != FormWindowState.Minimized) && form.MinimizeBox)
            {
                _minimize.Enabled = true;
            }
            else
            {
                _minimize.Enabled = false;
            }

            _minimize.Image = VisualControlBoxRenderer.RenderControlBoxIcon(new Size(20, 20), VisualForm.ControlBoxIcons.Minimize, Color.Black);

            ToolStripMenuItem _maximize = new ToolStripMenuItem("Maximize", null, (sender, args) => form.ControlBox.MaximizeForm(form));

            if ((form.WindowState == FormWindowState.Normal) && form.MaximizeBox)
            {
                _maximize.Enabled = true;
            }
            else
            {
                _maximize.Enabled = false;
            }

            _maximize.Image = VisualControlBoxRenderer.RenderControlBoxIcon(new Size(20, 20), VisualForm.ControlBoxIcons.Maximize, Color.Black);

            ToolStripSeparator _separator = new ToolStripSeparator();

            ToolStripMenuItem _close = new ToolStripMenuItem("Close", null, (sender, args) => form.ControlBox.CloseForm(form))
            {
                Image = VisualControlBoxRenderer.RenderControlBoxIcon(new Size(20, 20), VisualForm.ControlBoxIcons.Close, Color.Black), ShortcutKeys = Keys.Alt | Keys.F4
            };

            _contextMenu.Items.Add(_restore);
            _contextMenu.Items.Add(_move);
            _contextMenu.Items.Add(_size);
            _contextMenu.Items.Add(_minimize);
            _contextMenu.Items.Add(_maximize);
            _contextMenu.Items.Add(_separator);
            _contextMenu.Items.Add(_close);

            return(_contextMenu);
        }
예제 #7
0
        private void BtnRunTest_Click(object sender, EventArgs e)
        {
            VisualForm _formToOpen;

            switch (_unitTest)
            {
            case UnitTests.VisualForm:
            {
                _formToOpen = new VisualForm($@"{nameof(VisualForm)} Test");
                _formToOpen.ShowDialog();
                break;
            }

            case UnitTests.VisualControlBox:
            {
                _formToOpen = new VisualControlBoxTest();
                _formToOpen.ShowDialog();
                break;
            }

            case UnitTests.VisualListView:
            {
                _formToOpen = new VisualListViewTest();
                _formToOpen.ShowDialog();
                break;
            }

            case UnitTests.VisualMessageBox:
            {
                _formToOpen = new VisualMessageBoxTest();
                _formToOpen.ShowDialog();
                break;
            }

            case UnitTests.VisualInputDialog:
            {
                VisualInputDialog inputDialog = new VisualInputDialog($@"{nameof(VisualInputDialog)} Test");

                if (inputDialog.ShowDialog() == DialogResult.OK)
                {
                    ConsoleEx.WriteDebug(inputDialog.InputResult);
                }

                break;
            }

            case UnitTests.VisualExceptionDialog:
            {
                VisualExceptionDialog.Show(new Exception("Your custom exception message."));
                break;
            }

            case UnitTests.VisualColorDialog:
            {
                VisualColorDialog colorDialog = new VisualColorDialog();

                if (colorDialog.ShowDialog() == DialogResult.OK)
                {
                    ConsoleEx.WriteDebug(colorDialog.Color);
                }

                break;
            }

            case UnitTests.ClipboardTest:
            {
                _formToOpen = new ClipboardTest();
                _formToOpen.ShowDialog();
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException();
            }
            }
        }