Beispiel #1
0
        private int CalculateTextAlpha(int tabIndex, double animationProgress)
        {
            try
            {
                int primaryA   = SkinManager.ACTION_BAR_TEXT().A;
                int secondaryA = SkinManager.ACTION_BAR_TEXT_SECONDARY().A;

                if (tabIndex == baseTabControl.SelectedIndex && !animationManager.IsAnimating())
                {
                    return(primaryA);
                }
                if (tabIndex != previousSelectedTabIndex && tabIndex != baseTabControl.SelectedIndex)
                {
                    return(secondaryA);
                }
                if (tabIndex == previousSelectedTabIndex)
                {
                    return(primaryA - (int)((primaryA - secondaryA) * animationProgress));
                }

                return(secondaryA + (int)((primaryA - secondaryA) * animationProgress));
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handles the <see cref="E:Paint" /> event.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            if (!Closable)
            {
                g.FillRectangle(SkinManager.ColorScheme.DarkPrimaryBrush, xButtonBounds);
            }

            var downBrush = SkinManager.GetFlatButtonPressedBackgroundBrush();

            if (ReturnButtonState == RetButtonState.ReturnButtonOver)
            {
                g.FillRectangle(downBrush, ReturnButtonBounds);
            }
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            using (var DrawerButtonPen = new Pen(SkinManager.ACTION_BAR_TEXT_SECONDARY(), 2))
            {
                g.DrawLine(
                    DrawerButtonPen,
                    ReturnButtonBounds.X + (int)(ReturnButtonBounds.Width * (0.75)),
                    ReturnButtonBounds.Y + (int)(ReturnButtonBounds.Height * (0.5)),
                    ReturnButtonBounds.X + (int)(ReturnButtonBounds.Width * (0.25)),
                    ReturnButtonBounds.Y + (int)(ReturnButtonBounds.Height * (0.5)));
                g.DrawLine(
                    DrawerButtonPen,
                    ReturnButtonBounds.X + (int)(ReturnButtonBounds.Width * (0.5)),
                    ReturnButtonBounds.Y + (int)(ReturnButtonBounds.Height * (0.3)),
                    ReturnButtonBounds.X + (int)(ReturnButtonBounds.Width * (0.25)),
                    ReturnButtonBounds.Y + (int)(ReturnButtonBounds.Height * (0.5)));
                g.DrawLine(
                    DrawerButtonPen,
                    ReturnButtonBounds.X + (int)(ReturnButtonBounds.Width * 0.5),
                    ReturnButtonBounds.Y + (int)(ReturnButtonBounds.Height * 0.7),
                    ReturnButtonBounds.X + (int)(ReturnButtonBounds.Width * 0.25),
                    ReturnButtonBounds.Y + (int)(ReturnButtonBounds.Height * 0.5));
            }
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            g.Clear(SkinManager.GetApplicationBackgroundColor());
            g.FillRectangle(SkinManager.ColorScheme.DarkPrimaryBrush, statusBarBounds);

            if (_ActionBar == null)
            {
                //Draw border
                using (var borderPen = new Pen(SkinManager.GetDividersColor(), 1))
                {
                    g.DrawLine(borderPen, new Point(0, statusBarBounds.Bottom), new Point(0, Height - 2));
                    g.DrawLine(borderPen, new Point(Width - 1, statusBarBounds.Bottom), new Point(Width - 1, Height - 2));
                    g.DrawLine(borderPen, new Point(0, Height - 1), new Point(Width - 1, Height - 1));
                }
            }

            // Determine whether or not we even should be drawing the buttons.
            bool showMin    = MinimizeBox && ControlBox;
            bool showMax    = MaximizeBox && ControlBox;
            var  hoverBrush = SkinManager.GetFlatButtonHoverBackgroundBrush();
            var  downBrush  = SkinManager.GetFlatButtonPressedBackgroundBrush();

            // When MaximizeButton == false, the minimize button will be painted in its place
            if (buttonState == ButtonState.MinOver && showMin)
            {
                g.FillRectangle(hoverBrush, showMax ? minButtonBounds : maxButtonBounds);
            }

            if (buttonState == ButtonState.MinDown && showMin)
            {
                g.FillRectangle(downBrush, showMax ? minButtonBounds : maxButtonBounds);
            }

            if (buttonState == ButtonState.MaxOver && showMax)
            {
                g.FillRectangle(hoverBrush, maxButtonBounds);
            }

            if (buttonState == ButtonState.MaxDown && showMax)
            {
                g.FillRectangle(downBrush, maxButtonBounds);
            }

            if (buttonState == ButtonState.XOver && ControlBox)
            {
                g.FillRectangle(hoverBrush, xButtonBounds);
            }

            if (buttonState == ButtonState.XDown && ControlBox)
            {
                g.FillRectangle(downBrush, xButtonBounds);
            }

            using (var formButtonsPen = new Pen(SkinManager.ACTION_BAR_TEXT_SECONDARY(), 2))
            {
                // Minimize button.
                if (showMin)
                {
                    int x = showMax ? minButtonBounds.X : maxButtonBounds.X;
                    int y = showMax ? minButtonBounds.Y : maxButtonBounds.Y;

                    g.DrawLine(
                        formButtonsPen,
                        x + (int)(minButtonBounds.Width * 0.33),
                        y + (int)(minButtonBounds.Height * 0.66),
                        x + (int)(minButtonBounds.Width * 0.66),
                        y + (int)(minButtonBounds.Height * 0.66)
                        );
                }

                // Maximize button
                if (showMax)
                {
                    g.DrawRectangle(
                        formButtonsPen,
                        maxButtonBounds.X + (int)(maxButtonBounds.Width * 0.33),
                        maxButtonBounds.Y + (int)(maxButtonBounds.Height * 0.36),
                        (int)(maxButtonBounds.Width * 0.39),
                        (int)(maxButtonBounds.Height * 0.31)
                        );
                }

                // Close button
                if (ControlBox)
                {
                    g.DrawLine(
                        formButtonsPen,
                        xButtonBounds.X + (int)(xButtonBounds.Width * 0.33),
                        xButtonBounds.Y + (int)(xButtonBounds.Height * 0.33),
                        xButtonBounds.X + (int)(xButtonBounds.Width * 0.66),
                        xButtonBounds.Y + (int)(xButtonBounds.Height * 0.66)
                        );

                    g.DrawLine(
                        formButtonsPen,
                        xButtonBounds.X + (int)(xButtonBounds.Width * 0.66),
                        xButtonBounds.Y + (int)(xButtonBounds.Height * 0.33),
                        xButtonBounds.X + (int)(xButtonBounds.Width * 0.33),
                        xButtonBounds.Y + (int)(xButtonBounds.Height * 0.66));
                }
            }

            //Form title
            if (_ActionBar == null)
            {
                g.DrawString(Text, SkinManager.ROBOTO_REGULAR_11, SkinManager.ColorScheme.TextBrush, new Rectangle(SkinManager.FORM_PADDING, 0, Width, STATUS_BAR_HEIGHT), new StringFormat {
                    LineAlignment = StringAlignment.Center
                });
            }

            if (_SideDrawer != null)
            {
                if (!_SideDrawer.SideDrawerFixiert)
                {
                    _SideDrawer.Width = (int)(_SideDrawer.MaximumSize.Width * DrawerAnimationTimer.GetProgress());
                    if (_ActionBar != null)
                    {
                        _ActionBar.setDrawerAnimationProgress((int)(DrawerAnimationTimer.GetProgress() * 100));
                    }
                }
            }

            //Schatten Zeichnen
            GraphicsPath ActionBarShadow = new GraphicsPath();

            ActionBarShadow.AddLine(new Point(0, STATUS_BAR_HEIGHT), new Point(Width, STATUS_BAR_HEIGHT));
            DrawHelper.drawShadow(g, ActionBarShadow, 10, SkinManager.GetApplicationBackgroundColor());

            foreach (Control objChild in Controls)
            {
                if (typeof(IShadowedMaterialControl).IsAssignableFrom(objChild.GetType()))
                {
                    IShadowedMaterialControl objCurrent = (IShadowedMaterialControl)objChild;
                    DrawHelper.drawShadow(g, objCurrent.ShadowBorder, objCurrent.Elevation, SkinManager.GetApplicationBackgroundColor());
                }
            }
        }