Пример #1
0
        internal void RaiseOnPaint(PaintEventArgs e)
        {
            e.Graphics.Control = this;
            Batches            = 0;

            if (ShadowBox)
            {
                if (ShadowHandler == null)
                {
                    int shX = e.ClipRectangle.X + 6;
                    int shY = e.ClipRectangle.Y + 6;
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(12, 64, 64, 64)), shX + 6, shY + 6, Width - 12, Height - 12);
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(12, 64, 64, 64)), shX + 5, shY + 5, Width - 10, Height - 10);
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(12, 64, 64, 64)), shX + 4, shY + 4, Width - 8, Height - 8);
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(12, 64, 64, 64)), shX + 3, shY + 3, Width - 6, Height - 6);
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(12, 64, 64, 64)), shX + 2, shY + 2, Width - 4, Height - 4);
                }
                else
                {
                    ShadowHandler.Invoke(e);
                }
            }

            if (UserGroup)
            {
                e.Graphics.Group = new Drawing.Rectangle(e.ClipRectangle.X, e.ClipRectangle.Y, Width, Height);
                e.Graphics.GroupBegin(this);
            }
            OnPaintBackground(e);
            OnPaint(e);
            if (Controls != null)
            {
                for (int i = 0; i < Controls.Count; i++)
                {
                    if (Application.ControlIsVisible(Controls[i]) == false)
                    {
                        continue;
                    }

                    var currentAbspos = Controls[i].PointToScreen(System.Drawing.Point.Zero);
                    if (currentAbspos.X + Controls[i].Width <0 || currentAbspos.X> UnityEngine.Screen.width ||
                        currentAbspos.Y + Controls[i].Height <0 || currentAbspos.Y> UnityEngine.Screen.height)
                    {
                        continue;
                    }
                    e.Graphics.Control = Controls[i];
                    Controls[i].RaiseOnPaint(e);
                }
            }
            e.Graphics.Control = this;
            if (Application.Debug)
            {
                e.Graphics.DrawString(GetType().Name, Font, Brushes.White, 3, 1, 256, 32);
                e.Graphics.DrawString(GetType().Name, Font, Brushes.White, 5, 3, 256, 32);
                e.Graphics.DrawString(GetType().Name, Font, Brushes.DarkRed, 4, 2, 256, 32);
                e.Graphics.DrawRectangle(Pens.DarkRed, 0, 0, Width, Height);
            }
            OnLatePaint(e);
            if (UserGroup)
            {
                e.Graphics.GroupEnd();
            }
            Batched = true;

            e.Graphics.Control = null;
        }
Пример #2
0
        internal void RaiseOnPaint(PaintEventArgs e)
        {
            e.Graphics.Control = this;
            Batches            = 0;

            if (ShadowBox)
            {
                if (ShadowHandler == null)
                {
                    ShadowHandler = (pArgs) =>
                    {
                        var psLoc       = PointToScreen(Point.Zero);
                        int shX         = psLoc.X + 6;
                        int shY         = psLoc.Y + 6;
                        var shadowColor = defaultShadowColor;
                        pArgs.Graphics.FillRectangle(shadowColor, shX + 6, shY + 6, Width - 12, Height - 12);
                        pArgs.Graphics.FillRectangle(shadowColor, shX + 5, shY + 5, Width - 10, Height - 10);
                        pArgs.Graphics.FillRectangle(shadowColor, shX + 4, shY + 4, Width - 8, Height - 8);
                        pArgs.Graphics.FillRectangle(shadowColor, shX + 3, shY + 3, Width - 6, Height - 6);
                        pArgs.Graphics.FillRectangle(shadowColor, shX + 2, shY + 2, Width - 4, Height - 4);
                    };
                }

                ShadowHandler.Invoke(e);
            }

            if (AutoGroup)
            {
                int gx = e.ClipRectangle.X;
                int gy = e.ClipRectangle.Y;

                if (gx != 0 && gy != 9) // Reset?
                {
                    e.ClipRectangle = new Rectangle(0, 0, Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
                }

                e.Graphics.Group = new Drawing.Rectangle(gx, gy, Width, Height);
                e.Graphics.GroupBegin(this);
            }
            OnPaintBackground(e);
            OnPaint(e);
            if (Controls != null)
            {
                for (int i = 0; i < Controls.Count; i++)
                {
                    if (Application.ControlIsVisible(Controls[i]) == false)
                    {
                        continue;
                    }

                    var currentAbspos = Controls[i].PointToScreen(System.Drawing.Point.Zero);
                    if (currentAbspos.X + Controls[i].Width <0 || currentAbspos.X> Screen.PrimaryScreen.WorkingArea.Width ||
                        currentAbspos.Y + Controls[i].Height <0 || currentAbspos.Y> Screen.PrimaryScreen.WorkingArea.Height)
                    {
                        continue;
                    }

                    e.Graphics.Control = Controls[i];
                    Controls[i].RaiseOnPaint(e);
                }
            }
            e.Graphics.Control = this;
            if (Application.Debug)
            {
                e.Graphics.DrawString(GetType().Name, Font, Brushes.White, 3, 1, 256, 32);
                e.Graphics.DrawString(GetType().Name, Font, Brushes.White, 5, 3, 256, 32);
                e.Graphics.DrawString(GetType().Name, Font, Brushes.DarkRed, 4, 2, 256, 32);
                e.Graphics.DrawRectangle(Pens.DarkRed, 0, 0, Width, Height);
            }
            OnLatePaint(e);
            if (AutoGroup)
            {
                e.Graphics.GroupEnd();
            }

            e.Graphics.Control = null;
        }