예제 #1
0
        /// <summary>Initializes a new instance of the <see cref="VisualForm" /> class.</summary>
        public VisualForm()
        {
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);

            UpdateStyles();

            _resizeCursors = new[] { Cursors.SizeNESW, Cursors.SizeWE, Cursors.SizeNWSE, Cursors.SizeWE, Cursors.SizeNS };

            _resizedLocationsCommand = new Dictionary <int, int>
            {
                { Constants.HTTOP, Constants.WMSZ_TOP },
                { Constants.HTTOPLEFT, Constants.WMSZ_TOPLEFT },
                { Constants.HTTOPRIGHT, Constants.WMSZ_TOPRIGHT },
                { Constants.HTLEFT, Constants.WMSZ_LEFT },
                { Constants.HTRIGHT, Constants.WMSZ_RIGHT },
                { Constants.HTBOTTOM, Constants.WMSZ_BOTTOM },
                { Constants.HTBOTTOMLEFT, Constants.WMSZ_BOTTOMLEFT },
                { Constants.HTBOTTOMRIGHT, Constants.WMSZ_BOTTOMRIGHT }
            };

            _styleManager = new StyleManager(Settings.DefaultValue.DefaultStyle);

            _border = new Border
            {
                Thickness = 3,
                Type      = ShapeType.Rectangle
            };

            _dropShadow = true;

            FormBorderStyle    = FormBorderStyle.None;
            _magnetic          = false;
            _magneticRadius    = 100;
            Padding            = new Padding(0, 0, 0, 0);
            Sizable            = true;
            _titleAlignment    = Alignment.TextAlignment.Center;
            TransparencyKey    = Color.Fuchsia;
            _windowBarHeight   = 30;
            _previousSize      = Size.Empty;
            _textRectangle     = new Rectangle(0, 7, 0, 0);
            _titleBarRectangle = new Rectangle(0, 0, Width, _windowBarHeight);

            _vsImage = new VisualBitmap(Resources.VisualPlus, new Size(16, 16))
            {
                Visible = true
            };

            _vsImage.Point = new Point(5, (_windowBarHeight / 2) - (_vsImage.Size.Height / 2));

            _visualControlBox = new VisualControlBox();
            Controls.Add(_visualControlBox);
            _visualControlBox.Location = new Point(Width - _visualControlBox.Width - 16, _border.Thickness);

            UpdateTheme(_styleManager.Theme);

            // This enables the form to trigger the MouseMove event even when mouse is over another control
            Application.AddMessageFilter(new MouseMessageFilter());
            MouseMessageFilter.MouseMove += OnGlobalMouseMove;
        }
예제 #2
0
        /// <inheritdoc />
        /// <summary>Initializes a new instance of the <see cref="T:VisualPlus.Toolkit.Controls.Layout.VisualForm" /> class.</summary>
        public VisualForm()
        {
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
            UpdateStyles();
            _styleManager  = new VisualStyleManager(Settings.DefaultValue.DefaultStyle);
            _resizeCursors = new[] { Cursors.SizeNESW, Cursors.SizeWE, Cursors.SizeNWSE, Cursors.SizeWE, Cursors.SizeNS };

            _resizedLocationsCommand = new Dictionary <int, int>
            {
                { HTTOP, WMSZ_TOP },
                { HTTOPLEFT, WMSZ_TOPLEFT },
                { HTTOPRIGHT, WMSZ_TOPRIGHT },
                { HTLEFT, WMSZ_LEFT },
                { HTRIGHT, WMSZ_RIGHT },
                { HTBOTTOM, WMSZ_BOTTOM },
                { HTBOTTOMLEFT, WMSZ_BOTTOMLEFT },
                { HTBOTTOMRIGHT, WMSZ_BOTTOMRIGHT }
            };

            _titleAlignment         = Alignment.TextAlignment.Center;
            FormBorderStyle         = FormBorderStyle.None;
            Sizable                 = true;
            _closeColor             = Color.IndianRed;
            _buttonBackHoverColor   = _styleManager.ControlColorStateStyle.ControlHover;
            _buttonBackPressedColor = _styleManager.ControlColorStateStyle.ControlPressed;
            _buttonState            = ButtonState.None;
            _maxColor               = _styleManager.ControlStyle.FlatButtonEnabled;
            _minColor               = _styleManager.ControlStyle.FlatButtonEnabled;
            _buttonSize             = new Size(25, 25);
            _windowBarColor         = _styleManager.ControlStyle.Background(0);
            _background             = _styleManager.ControlStyle.Background(3);
            _magneticRadius         = 100;
            _magnetic               = true;
            _windowBarHeight        = 30;
            TransparencyKey         = Color.Fuchsia;
            DoubleBuffered          = true;

            Padding = new Padding(0, 0, 0, 0);

            _border = new Border
            {
                Thickness = 3,
                Type      = ShapeType.Rectangle
            };

            _vsImage = new VisualBitmap(Resources.VisualPlus, new Size(16, 16))
            {
                Visible = true
            };
            _vsImage.Point = new Point(5, (_windowBarHeight / 2) - (_vsImage.Size.Height / 2));

            // This enables the form to trigger the MouseMove event even when mouse is over another control
            Application.AddMessageFilter(new MouseMessageFilter());
            MouseMessageFilter.MouseMove += OnGlobalMouseMove;
        }
예제 #3
0
        /// <summary>Initializes a new instance of the <see cref="VisualForm" /> class.</summary>
        public VisualForm()
        {
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);

            UpdateStyles();

            _resizeCursors = new[] { Cursors.SizeNESW, Cursors.SizeWE, Cursors.SizeNWSE, Cursors.SizeWE, Cursors.SizeNS };

            _resizedLocationsCommand = new Dictionary <int, int>
            {
                { FormConstants.HTTOP, FormConstants.WMSZ_TOP },
                { FormConstants.HTTOPLEFT, FormConstants.WMSZ_TOPLEFT },
                { FormConstants.HTTOPRIGHT, FormConstants.WMSZ_TOPRIGHT },
                { FormConstants.HTLEFT, FormConstants.WMSZ_LEFT },
                { FormConstants.HTRIGHT, FormConstants.WMSZ_RIGHT },
                { FormConstants.HTBOTTOM, FormConstants.WMSZ_BOTTOM },
                { FormConstants.HTBOTTOMLEFT, FormConstants.WMSZ_BOTTOMLEFT },
                { FormConstants.HTBOTTOMRIGHT, FormConstants.WMSZ_BOTTOMRIGHT }
            };

            _styleManager = new StyleManager(DefaultConstants.DefaultStyle);

            _border = new Border {
                Thickness = 3, Type = ShapeTypes.Rectangle
            };

            _textPaddingTop = 10;

            _dropShadow            = true;
            _headerMouseDown       = false;
            FormBorderStyle        = FormBorderStyle.None;
            StartPosition          = FormStartPosition.WindowsDefaultLocation;
            _windowTitleBarVisible = true;
            _magnetic                = false;
            _magneticRadius          = 100;
            Padding                  = new Padding(0, 0, 0, 0);
            Sizable                  = true;
            _titleAlignment          = Alignment.TextAlignment.Center;
            TransparencyKey          = Color.Fuchsia;
            _windowBarHeight         = 30;
            _previousSize            = Size.Empty;
            _moveable                = true;
            _windowTitleBarRectangle = new Rectangle(0, 0, Width, _windowBarHeight);

            _vsImage = new VisualBitmap(Resources.VisualPlus, new Size(16, 16))
            {
                Visible = true
            };

            _vsImage.Point = new Point(5, (_windowBarHeight / 2) - (_vsImage.Size.Height / 2));

            VisualControlBox = new VisualControlBox();
            Controls.Add(VisualControlBox);
            VisualControlBox.Location    = new Point(Width - VisualControlBox.Width - 16, _border.Thickness + 1);
            _contextMenuStrip            = null;
            _windowContextMenuStripTitle = null;
            _defaultContextTitle         = true;
            titleMaxLength = 50;
            TitleSuffix    = @"...";

            AcceptButton = new VisualButton();

            // Fixes: The Form from hiding the TaskBar on maximized state.
            MaximizedBounds = Screen.FromHandle(Handle).WorkingArea;

            UpdateContextMenuStripTitle();

            UpdateTheme(_styleManager.Theme);

            // This enables the form to trigger the MouseMove event even when mouse is over another control
            Application.AddMessageFilter(new MouseMessageFilter());
            MouseMessageFilter.MouseMove += OnGlobalMouseMove;
        }