اخواني قمت بتركيب عدة ثيمات لمشروعي ولكن تواجهني مشكلة وهي عند تحويل اتجاه اداة موجوده بالثيم من اليسار الى اليمين يصبح النص معكوس وللتوضيح سوف ارفق صورتين للتوضيح
عندما يكون اتجاه الاداه على اليسار يكون النص تمام كما بالصوره
المشكله عند تحويل الاداه الى الجهة اليمنى يصبح النص كما بالصوره معكوس
29-12-15, 07:10 AM (آخر تعديل لهذه المشاركة : 29-12-15, 02:11 PM {2} بواسطة silverlight.)
لازم تستخدم +GDI لكي ترسم التكست في الحدث Paint عند استخدام RightToLeft ومن الواضح ان الكونترول المستخدم لا يدعم هذه الخاصية
عموما إن لم تكن تجيد عمليات الرسم
حاول أن تقوم بخداع نظام التشغيل حين يقوم بعملية الرسم .... لكني لا أعلم هل هذا سيفلح معك ام لا .... لكن الفكرة تكمن في أن تقوم بعمل Reverse للحروف قبل الانتقال من اليسار الي اليمين
ايضا يمكنك ان تقوم بتعديل اماكن الكونترول برمجيا LayoutControl بأنك تحسب مكان كل كوترول ثم تقوم بتغير Location الخاص به و من الواضح انك فقط تحتاج الي تعديل location للنقطة X لا غير
29-12-15, 02:41 PM (آخر تعديل لهذه المشاركة : 29-12-15, 03:02 PM {2} بواسطة sami2015.)
[/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)
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
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
29-12-15, 06:12 PM (آخر تعديل لهذه المشاركة : 29-12-15, 06:15 PM {2} بواسطة silverlight.)
اذا كنت ترييد التغيير في الكونترول الخاص بك عليك ان ترفع الكود لكي نستطيع ضبط عملية الرسم الخاصة به
لأنكــ ف النهاية ستحتاج للتعديل علي الكونترول حتي تتم عملية الرسم بالشكل المناسب
,أو لو كان الكود الخاص بالاخ Sami2105 يناسبك فاستخدم الكونترول الخاص به
#Region "SLCTabControl"
Class SLCTabControl
Inherits TabControl
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
DoubleBuffered = True
SizeMode = TabSizeMode.Fixed
ItemSize = New Size(30, 120)
End Sub
Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
Alignment = TabAlignment.Left
End Sub
Public Function Borderpts() As GraphicsPath
Dim P As New GraphicsPath()
Dim PS As New List(Of Point)
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(TabPages(i).Text, Font, New SolidBrush(Color.FromArgb(56, 106, 137)), rec, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
g.ResetTransform()
Else
g.DrawString(TabPages(i).Text, Font, New SolidBrush(Color.FromArgb(56, 106, 137)), rec, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End If
Next
e.Graphics.DrawImage(b.Clone, 0, 0)
g.Dispose()
b.Dispose()
MyBase.OnPaint(e)
End Sub
End Class
#End Region