protected override void OnPaint(PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.Clear(BackColor);

            switch (_ControlButton)
            {
            case Button.Minimize:
                DrawMinimize(3, 10);
                break;

            case Button.MaximizeRestore:
                if (FindForm().WindowState == FormWindowState.Normal)
                {
                    DrawMaximize(3, 5);
                }
                else
                {
                    DrawRestore(3, 4);
                }
                break;

            case Button.Close:
                DrawClose(4, 5);
                break;
            }
        }
        private void DrawClose(int x, int y)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = this.CreateGraphics();

            //ClosePath = new GraphicsPath();

            if (ClosePath == null)
            {
                ClosePath = new GraphicsPath();
                ClosePath.AddLine(x + 1, y, x + 3, y);
                ClosePath.AddLine(x + 5, y + 2, x + 7, y);
                ClosePath.AddLine(x + 9, y, x + 10, y + 1);
                ClosePath.AddLine(x + 7, y + 4, x + 7, y + 5);
                ClosePath.AddLine(x + 10, y + 8, x + 9, y + 9);
                ClosePath.AddLine(x + 7, y + 9, x + 5, y + 7);
                ClosePath.AddLine(x + 3, y + 9, x + 1, y + 9);
                ClosePath.AddLine(x + 0, y + 8, x + 3, y + 5);
                ClosePath.AddLine(x + 3, y + 4, x + 0, y + 1);
            }
            G.FillPath(Brushes.WhiteSmoke, ClosePath);
            G.DrawPath(Pens.Black, ClosePath);
        }
        private void DrawMinimize(int x, int y)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G.FillRectangle(Brushes.WhiteSmoke, x, y, 12, 5);
            G.DrawRectangle(Pens.Black, x, y, 11, 4);
        }
        private void DrawMaximize(int x, int y)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G.DrawRectangle(new Pen(Color.FromArgb(235, 235, 235), 2), x + 2, y + 2, 8, 6);
            G.DrawRectangle(Pens.Black, x, y, 11, 9);
            G.DrawRectangle(Pens.Black, x + 3, y + 3, 5, 3);
        }
Example #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.Clear(BackColor);

            G.DrawLine(P1, 0, 5, Width, 5);
            G.DrawLine(P2, 0, 6, Width, 6);
        }
        private void DrawRestore(int x, int y)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G.FillRectangle(Brushes.WhiteSmoke, x + 3, y + 1, 8, 4);
            G.FillRectangle(Brushes.WhiteSmoke, x + 7, y + 5, 4, 4);
            G.DrawRectangle(Pens.Black, x + 2, y + 0, 9, 9);

            G.FillRectangle(Brushes.WhiteSmoke, x + 1, y + 3, 2, 6);
            G.FillRectangle(Brushes.WhiteSmoke, x + 1, y + 9, 8, 2);
            G.DrawRectangle(Pens.Black, x, y + 2, 9, 9);
            G.DrawRectangle(Pens.Black, x + 3, y + 5, 3, 3);
        }
Example #7
0
        private static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // If an error happens before we had a chance to init the environment information
            // the call to GetInformation() from BugReporter.ShowNBug() will fail.
            // There's no perf hit calling Initialise() multiple times.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            ThemeModule.Load();
            Application.ApplicationExit += (s, e) => ThemeModule.Unload();

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);

                if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => BugReporter.Report((Exception)e.ExceptionObject, e.IsTerminating);
                    Application.ThreadException += (s, e) => BugReporter.Report(e.Exception, isTerminating: false);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException != null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            // This is done here so these values can be used in the GitGui project but this project is the authority of the values.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);
            AppTitleGenerator.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.Branch);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
Example #8
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;

            G.Clear(BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            GP1 = theme.CreateRound(0, 5, Width - 1, 10, 5);
            GP2 = theme.CreateRound(1, 6, Width - 3, 8, 5);

            R1  = new Rectangle(0, 7, Width - 1, 5);
            GB1 = new LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90f);

            I1 = Convert.ToInt32((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11));
            R2 = new Rectangle(I1, 0, 10, 20);

            G.SetClip(GP2);
            G.FillRectangle(GB1, R1);

            R3  = new Rectangle(1, 7, R2.X + R2.Width - 2, 8);
            GB2 = new LinearGradientBrush(R3, Color.FromArgb(51, 181, 229), Color.FromArgb(0, 153, 204), 90f);

            G.SmoothingMode = SmoothingMode.None;
            G.FillRectangle(GB2, R3);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            for (int I = 0; I <= R3.Width - 15; I += 5)
            {
                G.DrawLine(P1, I, 0, I + 15, Height);
            }

            G.ResetClip();

            G.DrawPath(P2, GP1);
            G.DrawPath(P3, GP2);

            GP3 = theme.CreateRound(R2, 5);
            GP4 = theme.CreateRound(R2.X + 1, R2.Y + 1, R2.Width - 2, R2.Height - 2, 5);
            GB3 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);

            G.FillPath(GB3, GP3);
            G.DrawPath(P3, GP3);
            G.DrawPath(P4, GP4);
        }
Example #9
0
        private void DrawBox(int x, int index, bool leftEllipse, bool rightEllipse)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            R1 = new Rectangle(x, 0, ItemWidth - 4, Height - 1);

            GP1 = theme.CreateRound(R1, 7);
            GP2 = theme.CreateRound(R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2, 7);

            string T = Convert.ToString(index + 1);

            if (leftEllipse)
            {
                T = ".. " + T;
            }
            if (rightEllipse)
            {
                T = T + " ..";
            }

            SZ1 = G.MeasureString(T, Font).ToSize();
            PT1 = new Point(R1.X + (R1.Width / 2 - SZ1.Width / 2), R1.Y + (R1.Height / 2 - SZ1.Height / 2));

            if (index == _SelectedIndex)
            {
                G.FillPath(B1, GP1);

                Font F = new Font(Font, FontStyle.Underline);
                G.DrawString(T, F, Brushes.Black, PT1.X + 1, PT1.Y + 1);
                G.DrawString(T, F, Brushes.WhiteSmoke, PT1);
                F.Dispose();

                G.DrawPath(P1, GP2);
                G.DrawPath(P2, GP1);
            }
            else
            {
                G.FillPath(B2, GP1);

                G.DrawString(T, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
                G.DrawString(T, Font, Brushes.WhiteSmoke, PT1);

                G.DrawPath(P3, GP2);
                G.DrawPath(P1, GP1);
            }
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();


            theme.G = e.Graphics;
            theme.G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            theme.G.Clear(BackColor);
            theme.G.SmoothingMode = SmoothingMode.AntiAlias;

            GP1 = theme.CreateRound(0, 0, Width - 1, Height - 1, 7);
            GP2 = theme.CreateRound(1, 1, Width - 3, Height - 3, 7);

            if (IsMouseDown)
            {
                PB1                = new PathGradientBrush(GP1);
                PB1.CenterColor    = Color.FromArgb(60, 60, 60);
                PB1.SurroundColors = new Color[] { Color.FromArgb(55, 55, 55) };
                PB1.FocusScales    = new PointF(0.8f, 0.5f);

                theme.G.FillPath(PB1, GP1);
            }
            else
            {
                GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
                theme.G.FillPath(GB1, GP1);
            }

            theme.G.DrawPath(P1, GP1);
            theme.G.DrawPath(P2, GP2);

            SZ1 = theme.G.MeasureString(Text, Font);
            PT1 = new PointF(5, Height / 2 - SZ1.Height / 2);

            if (IsMouseDown)
            {
                PT1.X += 1f;
                PT1.Y += 1f;
            }

            theme.G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
            theme.G.DrawString(Text, Font, Brushes.WhiteSmoke, PT1);
        }
Example #11
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();

            theme.G = e.Graphics;

            theme.G.Clear(BackColor);
            theme.G.SmoothingMode = SmoothingMode.AntiAlias;

            GP1 = theme.CreateRound(0, 0, Width - 1, Height - 1, 7);
            GP2 = theme.CreateRound(1, 1, Width - 3, Height - 3, 7);

            R1  = new Rectangle(0, 2, Width - 1, Height - 1);
            GB1 = new LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90f);

            theme.G.SetClip(GP1);
            theme.G.FillRectangle(GB1, R1);

            I1 = Convert.ToInt32((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3));

            if (I1 > 1)
            {
                GP3 = theme.CreateRound(1, 1, I1, Height - 3, 7);

                R2  = new Rectangle(1, 1, I1, Height - 3);
                GB2 = new LinearGradientBrush(R2, Color.FromArgb(51, 181, 229), Color.FromArgb(0, 153, 204), 90f);

                theme.G.FillPath(GB2, GP3);
                theme.G.DrawPath(P1, GP3);

                theme.G.SetClip(GP3);
                theme.G.SmoothingMode = SmoothingMode.None;

                theme.G.FillRectangle(B1, R2.X, R2.Y + 1, R2.Width, R2.Height / 2);

                theme.G.SmoothingMode = SmoothingMode.AntiAlias;
                theme.G.ResetClip();
            }

            theme.G.DrawPath(P2, GP1);
            theme.G.DrawPath(P1, GP2);
        }
        private void DrawArrow(Color color, int rx, int ry)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            Rectangle R = new Rectangle(rx + 8, ry + 8, 16, 16);

            G.SmoothingMode = SmoothingMode.AntiAlias;

            Pen P = new Pen(color, 1);
            AdjustableArrowCap C = new AdjustableArrowCap(3, 2);

            P.CustomEndCap = C;

            G.DrawArc(P, R, 0f, 290f);

            P.Dispose();
            C.Dispose();
            G.SmoothingMode = SmoothingMode.None;
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.Clear(BackColor);

            GP1 = DrawArrow(4, 6, false);
            GP2 = DrawArrow(5, 7, false);

            G.FillPath(B1, GP2);
            G.FillPath(B2, GP1);

            GP3 = DrawArrow(4, Height - 11, true);
            GP4 = DrawArrow(5, Height - 10, true);

            G.FillPath(B1, GP4);
            G.FillPath(B2, GP3);

            if (ShowThumb)
            {
                G.FillRectangle(B1, Thumb);
                G.DrawRectangle(P1, Thumb);
                G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2);

                int Y  = 0;
                int LY = Thumb.Y + (Thumb.Height / 2) - 3;

                for (int I = 0; I <= 2; I++)
                {
                    Y = LY + (I * 3);

                    G.DrawLine(P1, Thumb.X + 5, Y, Thumb.Right - 5, Y);
                    G.DrawLine(P2, Thumb.X + 5, Y + 1, Thumb.Right - 5, Y + 1);
                }
            }

            G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1);
            G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3);
        }
Example #14
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.Clear(BackColor);

            GP1 = DrawArrow(6, 4, false);
            GP2 = DrawArrow(7, 5, false);

            G.FillPath(B1, GP2);
            G.FillPath(B2, GP1);

            GP3 = DrawArrow(Width - 11, 4, true);
            GP4 = DrawArrow(Width - 10, 5, true);

            G.FillPath(B1, GP4);
            G.FillPath(B2, GP3);

            if (ShowThumb)
            {
                G.FillRectangle(B1, Thumb);
                G.DrawRectangle(P1, Thumb);
                G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2);

                int X  = 0;
                int LX = Thumb.X + (Thumb.Width / 2) - 3;

                for (int I = 0; I <= 2; I++)
                {
                    X = LX + (I * 3);

                    G.DrawLine(P1, X, Thumb.Y + 5, X, Thumb.Bottom - 5);
                    G.DrawLine(P2, X + 1, Thumb.Y + 5, X + 1, Thumb.Bottom - 5);
                }
            }

            G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1);
            G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3);
        }
Example #15
0
        protected override void OnPaint(PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            G.Clear(BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            GP1 = theme.CreateRound(0, 0, Width - 1, Height - 1, 7);
            GP2 = theme.CreateRound(1, 1, Width - 3, Height - 3, 7);

            GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
            G.SetClip(GP1);
            G.FillRectangle(GB1, ClientRectangle);
            G.ResetClip();

            G.DrawPath(P1, GP1);
            G.DrawPath(P4, GP2);

            SZ1 = G.MeasureString(Text, Font);
            PT1 = new PointF(5, Height / 2 - SZ1.Height / 2);

            G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
            G.DrawString(Text, Font, Brushes.WhiteSmoke, PT1);

            G.DrawLine(P3, Width - 15, 10, Width - 11, 13);
            G.DrawLine(P3, Width - 7, 10, Width - 11, 13);
            G.DrawLine(Pens.Black, Width - 11, 13, Width - 11, 14);

            G.DrawLine(P2, Width - 16, 9, Width - 12, 12);
            G.DrawLine(P2, Width - 8, 9, Width - 12, 12);
            G.DrawLine(Pens.WhiteSmoke, Width - 12, 12, Width - 12, 13);

            G.DrawLine(P1, Width - 22, 0, Width - 22, Height);
            G.DrawLine(P4, Width - 23, 1, Width - 23, Height - 2);
            G.DrawLine(P4, Width - 21, 1, Width - 21, Height - 2);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;

            G.Clear(BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            GP1 = theme.CreateRound(0, 0, Width - 1, Height - 1, 7);
            GP2 = theme.CreateRound(1, 1, Width - 3, Height - 3, 7);

            PB1                = new PathGradientBrush(GP1);
            PB1.CenterColor    = Color.FromArgb(50, 50, 50);
            PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
            PB1.FocusScales    = new PointF(0.9f, 0.5f);

            G.FillPath(PB1, GP1);

            G.DrawPath(P1, GP1);
            G.DrawPath(P2, GP2);

            G.SmoothingMode = SmoothingMode.None;

            for (int I = 0; I <= Table.Length - 1; I++)
            {
                int C = Math.Max((int)Table[I], (int)75);

                int X = ((I % RowSize) * ItemSize) + WA.X;
                int Y = ((I / RowSize) * ItemSize) + WA.Y;

                B2 = new SolidBrush(Color.FromArgb(C, C, C));

                G.FillRectangle(B1, X + 1, Y + 1, DrawSize, DrawSize);
                G.FillRectangle(B2, X, Y, DrawSize, DrawSize);

                B2.Dispose();
            }
        }
Example #17
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            G.Clear(BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            bool LeftEllipse  = false;
            bool RightEllipse = false;

            if (_SelectedIndex < 4)
            {
                for (int I = 0; I <= Math.Min(MaximumIndex, 4); I++)
                {
                    RightEllipse = (I == 4) && (MaximumIndex > 4);
                    DrawBox(I * ItemWidth, I, false, RightEllipse);
                }
            }
            else if (_SelectedIndex > 3 && _SelectedIndex < (MaximumIndex - 3))
            {
                for (int I = 0; I <= 4; I++)
                {
                    LeftEllipse  = (I == 0);
                    RightEllipse = (I == 4);
                    DrawBox(I * ItemWidth, _SelectedIndex + I - 2, LeftEllipse, RightEllipse);
                }
            }
            else
            {
                for (int I = 0; I <= 4; I++)
                {
                    LeftEllipse = (I == 0) && (MaximumIndex > 4);
                    DrawBox(I * ItemWidth, MaximumIndex - (4 - I), LeftEllipse, false);
                }
            }
        }
Example #18
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ThemeModule.Load();
            Application.ApplicationExit += (s, e) => ThemeModule.Unload();

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);

                if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => ReportBug((Exception)e.ExceptionObject);
                    Application.ThreadException += (s, e) => ReportBug(e.Exception);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException != null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            // This is done here so these values can be used in the GitGui project but this project is the authority of the values.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            G.Clear(BackColor);

            SZ1 = G.MeasureString(Value1, Font, Width, StringFormat.GenericTypographic);
            SZ2 = G.MeasureString(Value2, Font, Width, StringFormat.GenericTypographic);

            PT1 = new PointF(0, Height / 2 - SZ1.Height / 2);
            PT2 = new PointF(SZ1.Width + 1, Height / 2 - SZ1.Height / 2);

            G.DrawString(Value1, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
            G.DrawString(Value1, Font, Brushes.WhiteSmoke, PT1);

            G.DrawString(Value2, Font, Brushes.Black, PT2.X + 1, PT2.Y + 1);
            G.DrawString(Value2, Font, B1, PT2);
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            G.Clear(BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            GP1 = theme.CreateRound(0, 2, Height - 5, Height - 5, 5);
            GP2 = theme.CreateRound(1, 3, Height - 7, Height - 7, 5);

            PB1                = new PathGradientBrush(GP1);
            PB1.CenterColor    = Color.FromArgb(50, 50, 50);
            PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
            PB1.FocusScales    = new PointF(0.3f, 0.3f);

            G.FillPath(PB1, GP1);
            G.DrawPath(P11, GP1);
            G.DrawPath(P22, GP2);

            if (_Checked)
            {
                G.DrawLine(P3, 5, Height - 9, 8, Height - 7);
                G.DrawLine(P3, 7, Height - 7, Height - 8, 7);

                G.DrawLine(P4, 4, Height - 10, 7, Height - 8);
                G.DrawLine(P4, 6, Height - 8, Height - 9, 6);
            }

            SZ1 = G.MeasureString(Text, Font);
            PT1 = new PointF(Height - 3, Height / 2 - SZ1.Height / 2);

            G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
            G.DrawString(Text, Font, Brushes.WhiteSmoke, PT1);
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;

            G.Clear(BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            GP1 = theme.CreateRound(0, 0, Width - 1, Height - 1, 7);
            GP2 = theme.CreateRound(1, 1, Width - 3, Height - 3, 7);

            PB1                = new PathGradientBrush(GP1);
            PB1.CenterColor    = Color.FromArgb(50, 50, 50);
            PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
            PB1.FocusScales    = new PointF(0.9f, 0.5f);

            G.FillPath(PB1, GP1);

            G.DrawPath(P2, GP1);
            G.DrawPath(P1, GP2);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            G.Clear(BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            GP1 = theme.CreateRound(0, 0, Width - 1, Height - 1, 7);
            GP2 = theme.CreateRound(1, 1, Width - 3, Height - 3, 7);

            G.DrawPath(P1, GP1);
            G.DrawPath(P2, GP2);

            SZ1 = G.MeasureString(_Title, _TitleFont, Width, StringFormat.GenericTypographic);
            SZ2 = G.MeasureString(_SubTitle, _SubTitleFont, Width, StringFormat.GenericTypographic);

            G.DrawString(_Title, _TitleFont, Brushes.Black, 6, 6);
            G.DrawString(_Title, _TitleFont, B1, 5, 5);

            PT1 = new PointF(6f, SZ1.Height + 4f);

            G.DrawString(_SubTitle, _SubTitleFont, Brushes.Black, PT1.X + 1, PT1.Y + 1);
            G.DrawString(_SubTitle, _SubTitleFont, Brushes.WhiteSmoke, PT1.X, PT1.Y);

            if (_DrawSeperator)
            {
                int Y = Convert.ToInt32(PT1.Y + SZ2.Height) + 8;

                G.DrawLine(P1, 4, Y, Width - 5, Y);
                G.DrawLine(P2, 4, Y + 1, Width - 5, Y + 1);
            }
        }
 private void BtnTheme_Click(object sender, EventArgs e)
 {
     ThemeModule.ShowEditor();
 }
        //I am so sorry you have to witness this. I tried warning you. ;.;

        protected override void OnPaint(PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;


            G = e.Graphics;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            G.Clear(BackColor);

            int   X = 0;
            int   Y = 0;
            float H = 0;

            G.DrawRectangle(P1, 1, 1, Width - 3, Height - 3);

            Rectangle      R1 = default(Rectangle);
            NSListViewItem CI = null;

            int Offset = Convert.ToInt32(VS.Percent * (VS.Maximum - (Height - (ItemHeight * 2))));

            int StartIndex = 0;

            if (Offset == 0)
            {
                StartIndex = 0;
            }
            else
            {
                StartIndex = (Offset / ItemHeight);
            }

            int EndIndex = Math.Min(StartIndex + (Height / ItemHeight), _Items.Count - 1);

            for (int I = StartIndex; I <= EndIndex; I++)
            {
                CI = Items[I];

                R1 = new Rectangle(0, ItemHeight + (I * ItemHeight) + 1 - Offset, Width, ItemHeight - 1);

                H = G.MeasureString(CI.Text, Font).Height;
                Y = R1.Y + Convert.ToInt32((ItemHeight / 2) - (H / 2));

                if (_SelectedItems.Contains(CI))
                {
                    if (I % 2 == 0)
                    {
                        G.FillRectangle(B1, R1);
                    }
                    else
                    {
                        G.FillRectangle(B2, R1);
                    }
                }
                else
                {
                    if (I % 2 == 0)
                    {
                        G.FillRectangle(B3, R1);
                    }
                    else
                    {
                        G.FillRectangle(B4, R1);
                    }
                }

                G.DrawLine(P2, 0, R1.Bottom, Width, R1.Bottom);

                if (Columns.Length > 0)
                {
                    R1.Width = Columns[0].Width;
                    G.SetClip(R1);
                }

                //TODO: Ellipse text that overhangs seperators.
                G.DrawString(CI.Text, Font, Brushes.Black, 10, Y + 1);
                G.DrawString(CI.Text, Font, Brushes.WhiteSmoke, 9, Y);

                if (CI.SubItems != null)
                {
                    for (int I2 = 0; I2 <= Math.Min(CI.SubItems.Count, _Columns.Count) - 1; I2++)
                    {
                        X = ColumnOffsets[I2 + 1] + 4;

                        R1.X     = X;
                        R1.Width = Columns[I2].Width;
                        G.SetClip(R1);

                        G.DrawString(CI.SubItems[I2].Text, Font, Brushes.Black, X + 1, Y + 1);
                        G.DrawString(CI.SubItems[I2].Text, Font, Brushes.WhiteSmoke, X, Y);
                    }
                }

                G.ResetClip();
            }

            R1 = new Rectangle(0, 0, Width, ItemHeight);

            GB1 = new LinearGradientBrush(R1, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
            G.FillRectangle(GB1, R1);
            G.DrawRectangle(P3, 1, 1, Width - 22, ItemHeight - 2);

            int LH = Math.Min(VS.Maximum + ItemHeight - Offset, Height);

            NSListViewColumnHeader CC = null;

            for (int I = 0; I <= _Columns.Count - 1; I++)
            {
                CC = Columns[I];

                H = G.MeasureString(CC.Text, Font).Height;
                Y = Convert.ToInt32((ItemHeight / 2) - (H / 2));
                X = ColumnOffsets[I];
                G.DrawString(CC.Text, Font, Brushes.Black, X + 1, Y + 1);
                G.DrawString(CC.Text, Font, Brushes.WhiteSmoke, X, Y);

                G.DrawLine(P2, X - 3, 0, X - 3, LH);
                G.DrawLine(P3, X - 2, 0, X - 2, ItemHeight);
            }

            G.DrawRectangle(P2, 0, 0, Width - 1, Height - 1);

            G.DrawLine(P2, 0, ItemHeight, Width, ItemHeight);
            G.DrawLine(P2, VS.Location.X - 1, 0, VS.Location.X - 1, Height);
        }
Example #25
0
        private static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // If an error happens before we had a chance to init the environment information
            // the call to GetInformation() from BugReporter.ShowNBug() will fail.
            // There's no perf hit calling Initialise() multiple times.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            AppSettings.SetDocumentationBaseUrl(ThisAssembly.Git.Branch);

#if SUPPORT_THEMES
            ThemeModule.Load();
            Application.ApplicationExit += (s, e) => ThemeModule.Unload();

            SystemEvents.UserPreferenceChanged += (s, e) =>
            {
                // Whenever a user changes monitor scaling (e.g. 100%->125%) unload and
                // reload the theme, and repaint all forms
                if (e.Category == UserPreferenceCategory.Desktop || e.Category == UserPreferenceCategory.VisualStyle)
                {
                    ThemeModule.ReloadWin32ThemeData();
                    foreach (Form form in Application.OpenForms)
                    {
                        form.BeginInvoke((MethodInvoker)(() => form.Invalidate()));
                    }
                }
            };
#endif

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);

                // If you want to suppress the BugReportInvoker when debugging and exit quickly, uncomment the condition:
                ////if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => BugReportInvoker.Report((Exception)e.ExceptionObject, e.IsTerminating);
                    Application.ThreadException += (s, e) => BugReportInvoker.Report(e.Exception, isTerminating: false);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException is not null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            AppTitleGenerator.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.Branch);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            G.Clear(Color.FromArgb(50, 50, 50));
            G.SmoothingMode = SmoothingMode.AntiAlias;

            ItemHeight = ItemSize.Height + 2;

            GP1 = theme.CreateRound(0, 0, ItemHeight + 3, Height - 1, 7);
            GP2 = theme.CreateRound(1, 1, ItemHeight + 3, Height - 3, 7);

            PB1                = new PathGradientBrush(GP1);
            PB1.CenterColor    = Color.FromArgb(50, 50, 50);
            PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
            PB1.FocusScales    = new PointF(0.8f, 0.95f);

            G.FillPath(PB1, GP1);

            G.DrawPath(P1, GP1);
            G.DrawPath(P2, GP2);

            for (int I = 0; I <= TabCount - 1; I++)
            {
                R1         = GetTabRect(I);
                R1.Y      += 2;
                R1.Height -= 3;
                R1.Width  += 1;
                R1.X      -= 1;

                TP1    = TabPages[I];
                Offset = 0;

                if (SelectedIndex == I)
                {
                    G.FillRectangle(B1, R1);

                    for (int J = 0; J <= 1; J++)
                    {
                        G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9);

                        G.SmoothingMode = SmoothingMode.None;
                        G.FillRectangle(B3, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9);
                        G.SmoothingMode = SmoothingMode.AntiAlias;

                        Offset += 5;
                    }

                    G.DrawRectangle(P3, R1.X + 1, R1.Y - 1, R1.Width, R1.Height + 2);
                    G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2);
                    G.DrawRectangle(P2, R1);
                }
                else
                {
                    for (int J = 0; J <= 1; J++)
                    {
                        G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9);

                        G.SmoothingMode = SmoothingMode.None;
                        G.FillRectangle(B4, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9);
                        G.SmoothingMode = SmoothingMode.AntiAlias;

                        Offset += 5;
                    }
                }

                R1.X += 5 + Offset;

                R2    = R1;
                R2.Y += 1;
                R2.X += 1;

                G.DrawString(TP1.Text, Font, Brushes.Black, R2, SF1);
                G.DrawString(TP1.Text, Font, Brushes.WhiteSmoke, R1, SF1);
            }

            GP3 = theme.CreateRound(ItemHeight, 0, Width - ItemHeight - 1, Height - 1, 7);
            GP4 = theme.CreateRound(ItemHeight + 1, 1, Width - ItemHeight - 3, Height - 3, 7);

            G.DrawPath(P2, GP3);
            G.DrawPath(P1, GP4);
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            G.Clear(BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            GP1 = theme.CreateRound(0, 0, Width - 1, Height - 1, 7);
            GP2 = theme.CreateRound(1, 1, Width - 3, Height - 3, 7);

            PB1                = new PathGradientBrush(GP1);
            PB1.CenterColor    = Color.FromArgb(50, 50, 50);
            PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
            PB1.FocusScales    = new PointF(0.3f, 0.3f);

            G.FillPath(PB1, GP1);
            G.DrawPath(P1, GP1);
            G.DrawPath(P2, GP2);

            R1 = new Rectangle(5, 0, Width - 10, Height + 2);
            R2 = new Rectangle(6, 1, Width - 10, Height + 2);

            R3 = new Rectangle(1, 1, (Width / 2) - 1, Height - 3);

            if (_Checked)
            {
                G.DrawString("On", Font, Brushes.Black, R2, SF1);
                G.DrawString("On", Font, Brushes.WhiteSmoke, R1, SF1);

                R3.X += (Width / 2) - 1;
            }
            else
            {
                G.DrawString("Off", Font, B1, R2, SF2);
                G.DrawString("Off", Font, B2, R1, SF2);
            }

            GP3 = theme.CreateRound(R3, 7);
            GP4 = theme.CreateRound(R3.X + 1, R3.Y + 1, R3.Width - 2, R3.Height - 2, 7);

            GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);

            G.FillPath(GB1, GP3);
            G.DrawPath(P2, GP3);
            G.DrawPath(P3, GP4);

            Offset = R3.X + (R3.Width / 2) - 3;

            for (int I = 0; I <= 1; I++)
            {
                if (_Checked)
                {
                    G.FillRectangle(B1, Offset + (I * 5), 7, 2, Height - 14);
                }
                else
                {
                    G.FillRectangle(B3, Offset + (I * 5), 7, 2, Height - 14);
                }

                G.SmoothingMode = SmoothingMode.None;

                if (_Checked)
                {
                    G.FillRectangle(B4, Offset + (I * 5), 7, 2, Height - 14);
                }
                else
                {
                    G.FillRectangle(B5, Offset + (I * 5), 7, 2, Height - 14);
                }

                G.SmoothingMode = SmoothingMode.AntiAlias;
            }
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            ThemeModule theme = new ThemeModule();
            var         G     = theme.G;

            G = e.Graphics;
            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            G.Clear(BackColor);

            Rectangle R = new Rectangle(0, 0, Width, Height);

            int Offset = 0;

            G.DrawRectangle(P1, 0, 0, (12 * 32) + 1, (5 * 32) + 1);

            for (int I = 0; I <= Buttons.Length - 1; I++)
            {
                R = Buttons[I];

                Offset = 0;
                if (I == Pressed)
                {
                    Offset = 1;

                    GP1 = new GraphicsPath();
                    GP1.AddRectangle(R);

                    PB1                = new PathGradientBrush(GP1);
                    PB1.CenterColor    = Color.FromArgb(60, 60, 60);
                    PB1.SurroundColors = new Color[] { Color.FromArgb(55, 55, 55) };
                    PB1.FocusScales    = new PointF(0.8f, 0.5f);

                    G.FillPath(PB1, GP1);
                }
                else
                {
                    GB1 = new LinearGradientBrush(R, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
                    G.FillRectangle(GB1, R);
                }

                switch (I)
                {
                case 48:
                case 49:
                case 50:
                    SZ1 = G.MeasureString(Other[I - 48], Font);
                    G.DrawString(Other[I - 48], Font, Brushes.Black, R.X + (R.Width / 2 - SZ1.Width / 2) + Offset + 1, R.Y + (R.Height / 2 - SZ1.Height / 2) + Offset + 1);
                    G.DrawString(Other[I - 48], Font, Brushes.WhiteSmoke, R.X + (R.Width / 2 - SZ1.Width / 2) + Offset, R.Y + (R.Height / 2 - SZ1.Height / 2) + Offset);
                    break;

                case 47:
                    //DrawArrow(Color.Black, /*R.X +*/ /*Offset +*/ 1, /*R.Y +*/ /*Offset*/ + 1);
                    //DrawArrow(Color.FromArgb(235, 235, 235), R.X + Offset, R.Y + Offset);
                    break;

                default:
                    if (Shift)
                    {
                        G.DrawString(Upper[I].ToString(), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1);
                        G.DrawString(Upper[I].ToString(), Font, Brushes.WhiteSmoke, R.X + 3 + Offset, R.Y + 2 + Offset);

                        if (!char.IsLetter(Lower[I]))
                        {
                            PT1 = LowerCache[I];
                            G.DrawString(Lower[I].ToString(), Font, B1, PT1.X + Offset, PT1.Y + Offset);
                        }
                    }
                    else
                    {
                        G.DrawString(Lower[I].ToString(), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1);
                        G.DrawString(Lower[I].ToString(), Font, Brushes.WhiteSmoke, R.X + 3 + Offset, R.Y + 2 + Offset);

                        if (!char.IsLetter(Upper[I]))
                        {
                            PT1 = UpperCache[I];
                            G.DrawString(Upper[I].ToString(), Font, B1, PT1.X + Offset, PT1.Y + Offset);
                        }
                    }
                    break;
                }

                G.DrawRectangle(P2, R.X + 1 + Offset, R.Y + 1 + Offset, R.Width - 2, R.Height - 2);
                G.DrawRectangle(P3, R.X + Offset, R.Y + Offset, R.Width, R.Height);

                if (I == Pressed)
                {
                    G.DrawLine(P1, R.X, R.Y, R.Right, R.Y);
                    G.DrawLine(P1, R.X, R.Y, R.X, R.Bottom);
                }
            }
        }