Exemplo n.º 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;
        }
Exemplo n.º 2
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;
        }