تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
استفسار عن اتجاه النص في ثيم
#4
[/php]

#Region "MephTabcontrol"
Class MephTabcontrol : Inherits TabControl

   Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
       Dim P As GraphicsPath = New GraphicsPath()
       Dim ArcRectangleWidth As Integer = Curve * 2
       P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
       P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
       P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
       P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
       P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
       Return P
   End Function
   Public Function RoundRect(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Curve As Integer) As GraphicsPath
       Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
       Dim P As GraphicsPath = New GraphicsPath()
       Dim ArcRectangleWidth As Integer = Curve * 2
       P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
       P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
       P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
       P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
       P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
       Return P
   End Function
   Sub New()
       SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
       DoubleBuffered = True
       SizeMode = TabSizeMode.Fixed
       ItemSize = New Size(35, 85)
   End Sub
   Protected Overrides Sub CreateHandle()
       MyBase.CreateHandle()
       Alignment = TabAlignment.Left
   End Sub

   Function ToPen(ByVal color As Color) As Pen
       Return New Pen(color)
   End Function

   Function ToBrush(ByVal color As Color) As Brush
       Return New SolidBrush(color)
   End Function

   Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       Dim B As New Bitmap(Width, Height)
       Dim G As Graphics = Graphics.FromImage(B)
       Dim FF As New Font("Verdana", 8, FontStyle.Regular)
       Try : SelectedTab.BackColor = Color.FromArgb(50, 50, 50) : Catch : End Try
       G.Clear(Parent.FindForm.BackColor)

       G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), New Rectangle(0, 0, ItemSize.Height + 3, Height - 1)) 'Full Tab Background

       For i = 0 To TabCount - 1
           If i = SelectedIndex Then
               Dim x2 As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), New Size(GetTabRect(i).Width + 3, GetTabRect(i).Height - 1))
               Dim myBlend As New ColorBlend()
               myBlend.Colors = {Color.FromArgb(50, 50, 50), Color.FromArgb(50, 50, 50), Color.FromArgb(50, 50, 50)} 'Full Tab Background Gradient Accents
               myBlend.Positions = {0.0F, 0.5F, 1.0F}
               Dim lgBrush As New LinearGradientBrush(x2, Color.Black, Color.Black, 90.0F)
               lgBrush.InterpolationColors = myBlend
               G.FillRectangle(lgBrush, x2)
               'G.DrawRectangle(New Pen(Color.FromArgb(20, 20, 20)), x2) 'Full Tab Highlight Outline
               Dim tabRect As New Rectangle(GetTabRect(i).Location.X + 4, GetTabRect(i).Location.Y + 2, GetTabRect(i).Size.Width + 10, GetTabRect(i).Size.Height - 11)
               G.FillPath(New SolidBrush(Color.FromArgb(50, 50, 50)), RoundRect(tabRect, 4)) 'Highlight Fill Background

               Dim cFull As Color() = New Color() {Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
               Draw.InnerGlow(G, New Rectangle(0, 0, ItemSize.Height + 3, Height - 1), cFull) ' Main Left Box Outline

               Dim cHighlight As Color() = New Color() {Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
               Draw.InnerGlowRounded(G, tabRect, 4, cHighlight) ' Fill HighLight Inner

               G.SmoothingMode = SmoothingMode.HighQuality
               'Dim p() As Point = {New Point(ItemSize.Height - 3, GetTabRect(i).Location.Y + 20), New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 14), New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 27)}
               'G.FillPolygon(Brushes.White, p)

               If ImageList IsNot Nothing Then
                   Try
                       If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then

                           G.DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(x2.Location.X + 8, x2.Location.Y + 6))
                           DrawString(G, "      " & TabPages(i).Text.ToUpper, FF, Brushes.White, x2)
                       Else
                           DrawString(G, TabPages(i).Text, FF, Brushes.White, x2)
                       End If
                   Catch ex As Exception
                       DrawString(G, TabPages(i).Text, FF, Brushes.White, x2)
                   End Try
               Else
                   DrawString(G, TabPages(i).Text, FF, Brushes.White, x2)
               End If

               G.DrawLine(New Pen(Color.FromArgb(96, 110, 121)), New Point(x2.Location.X - 1, x2.Location.Y - 1), New Point(x2.Location.X, x2.Location.Y))
               G.DrawLine(New Pen(Color.FromArgb(96, 110, 121)), New Point(x2.Location.X - 1, x2.Bottom - 1), New Point(x2.Location.X, x2.Bottom))
           Else
               Dim x2 As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), New Size(GetTabRect(i).Width + 3, GetTabRect(i).Height + 1))
               'G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), x2) 'Tab Highlight
               G.DrawLine(New Pen(Color.FromArgb(96, 110, 121)), New Point(x2.Right, x2.Top), New Point(x2.Right, x2.Bottom))
               If ImageList IsNot Nothing Then
                   Try
                       If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
                           G.DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(x2.Location.X + 8, x2.Location.Y + 6))
                           DrawString(G, TabPages(i).Text, FF, Brushes.White, x2)
                       Else
                           DrawString(G, TabPages(i).Text, FF, New SolidBrush(Color.FromArgb(210, 220, 230)), x2)
                       End If
                   Catch ex As Exception
                       DrawString(G, TabPages(i).Text, FF, New SolidBrush(Color.FromArgb(210, 220, 230)), x2)
                   End Try
               Else
                   DrawString(G, TabPages(i).Text, FF, New SolidBrush(Color.FromArgb(210, 220, 230)), x2)
               End If
           End If
           G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), New Rectangle(86, -1, Width - 86, Height + 1)) 'Page Fill Full

           Dim c As Color() = New Color() {Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
           Draw.InnerGlowRounded(G, New Rectangle(86, 0, Width - 87, Height - 1), 3, c) ' Fill Page
       Next

       G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(50, 50, 50))), New Rectangle(0, 0, ItemSize.Height + 4, Height - 1)) 'Full Tab Outer Outline
       G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(20, 20, 20))), New Rectangle(1, 0, ItemSize.Height + 3, Height - 2)) 'Full Tab Inner Outline

       e.Graphics.DrawImage(B.Clone, 0, 0)
       'e.Graphics.DrawImage(B.Clone, New Rectangle(0, 0, Me.Width + 1, Me.Height))
       G.Dispose() : B.Dispose()
   End Sub
   Protected Sub DrawString(ByVal g As Graphics, ByVal txt As String, ByVal fnt As Font, ByVal clr As Brush, ByVal rec As Rectangle)
       If Me.RightToLeft = Windows.Forms.RightToLeft.Yes And Me.RightToLeftLayout = True Then
           g.MultiplyTransform(New System.Drawing.Drawing2D.Matrix(-1, 0, 0, 1, rec.Width, 0))
           g.DrawString(txt, fnt, New SolidBrush(Color.FromArgb(210, 220, 230)), New Rectangle(rec.X, rec.Y - 1, rec.Width, rec.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
           g.ResetTransform()
       Else
           g.DrawString(txt, fnt, New SolidBrush(Color.FromArgb(210, 220, 230)), New Rectangle(rec.X, rec.Y - 1, rec.Width, rec.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
       End If
   End Sub
End Class
#End Region

[/php]
الرد }}}
تم الشكر بواسطة: نسيم الترك1


الردود في هذا الموضوع
RE: استفسار عن اتجاه النص في ثيم - بواسطة sami2015 - 29-12-15, 02:41 PM


التنقل السريع :


يقوم بقرائة الموضوع: