Esempio 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;
        }
        /// <summary>Draws the internal text and image content.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        /// <param name="text">The string to draw.</param>
        /// <param name="font">The font to use in the string.</param>
        /// <param name="foreColor">The color of the string.</param>
        /// <param name="image">The image to draw.</param>
        /// <param name="textImageRelation">The text image relation.</param>
        public static void DrawInternalContent(Graphics graphics, Rectangle rectangle, string text, Font font, Color foreColor, VisualBitmap image, TextImageRelation textImageRelation)
        {
            image.Point = GDI.ApplyTextImageRelation(graphics, textImageRelation, new Rectangle(image.Point, image.Size), text, font, rectangle, true);
            Point textPoint = GDI.ApplyTextImageRelation(graphics, textImageRelation, new Rectangle(image.Point, image.Size), text, font, rectangle, false);

            VisualBitmap.DrawImage(graphics, image.Border, image.Point, image.Image, image.Size, image.Visible);
            graphics.DrawString(text, font, new SolidBrush(foreColor), textPoint);
        }
Esempio n. 3
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;
        }
Esempio n. 4
0
        /// <inheritdoc />
        /// <summary>
        ///     Initializes a new instance of the <see cref="T:VisualPlus.Toolkit.Controls.Interactivity.VisualButton" />
        ///     class.
        /// </summary>
        public VisualButton()
        {
            Size               = new Size(140, 45);
            _animation         = Settings.DefaultValue.Animation;
            _border            = new Border();
            _textImageRelation = TextImageRelation.Overlay;
            _backColorState    = new ControlColorState();
            _visualBitmap      = new VisualBitmap(Resources.VisualPlus, new Size(24, 24))
            {
                Visible = false,
                Image   = Resources.VisualPlus
            };
            _visualBitmap.Point = new Point(0, (Height / 2) - (_visualBitmap.Size.Height / 2));

            ConfigureAnimation(new[] { 0.03, 0.07 }, new[] { EffectType.EaseOut, EffectType.EaseInOut });
            UpdateTheme(Settings.DefaultValue.DefaultStyle);
        }
Esempio n. 5
0
 private void DrawIcon(Graphics graphics)
 {
     VisualBitmap.DrawImage(graphics, _vsImage.Border, _vsImage.Point, _vsImage.Image, _vsImage.Size, _vsImage.Visible);
 }
Esempio n. 6
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;
        }
        /// <summary>Draws a button control.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        /// <param name="backColor">The BackColor of the button.</param>
        /// <param name="backgroundImage">The background image for the button.</param>
        /// <param name="border">The border.</param>
        /// <param name="mouseState">The mouse State.</param>
        /// <param name="text">The string to draw.</param>
        /// <param name="font">The font to use in the string.</param>
        /// <param name="foreColor">The color of the string.</param>
        /// <param name="image">The image to draw.</param>
        /// <param name="textImageRelation">The text image relation.</param>
        public static void DrawButton(Graphics graphics, Rectangle rectangle, Color backColor, Image backgroundImage, Border border, MouseStates mouseState, string text, Font font, Color foreColor, VisualBitmap image, TextImageRelation textImageRelation)
        {
            GraphicsPath _controlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            VisualBackgroundRenderer.DrawBackground(graphics, backColor, backgroundImage, mouseState, rectangle, border);
            DrawInternalContent(graphics, rectangle, text, font, foreColor, image, textImageRelation);
            VisualBorderRenderer.DrawBorderStyle(graphics, border, _controlGraphicsPath, mouseState);
        }