Page 1 of 1

Chart Bevel Settings Not Working as Expected (Regression)

Posted: Wed Jun 21, 2023 3:17 pm
by 16095093
Hello,

In the attached zip file is a Word doc that contains screen captures showing Bevel settings in two different versions of TeeChart. On the left is from v2009 and on the right is v2023.

Reproducing this is very simple and doesn't warrant a sample project. However, I have attached a sample project anyway.

Kind Regards,

Kris Culin
Bentley Systems, Inc.

Re: Chart Bevel Settings Not Working as Expected (Regression)

Posted: Wed Jun 21, 2023 6:10 pm
by Christopher
Hello Kris,

thank you for reporting this issue to us, I have documented it in id=2617. The git diff is:

Code: Select all

diff --git a/TeeChart.PCL.NET5/TeeChart.WinForm/Drawing/Canvas.cs b/TeeChart.PCL.NET5/TeeChart.WinForm/Drawing/Canvas.cs
index 65717a7d..0e44267f 100644
--- a/TeeChart.PCL.NET5/TeeChart.WinForm/Drawing/Canvas.cs
+++ b/TeeChart.PCL.NET5/TeeChart.WinForm/Drawing/Canvas.cs
@@ -5684,42 +5684,26 @@ System.ComponentModel.Description("Sets the alignment used when displaying text
             Line(b, BottomRight, TopRight);
         }
 
-        private ChartPen a, b;
+        private ChartPen _a = new ChartPen(), _b = new ChartPen();
 
         public void PaintBevel(BevelStyles bevel, Rectangle rect, int width, Color one, Color two)
         {
             if (bevel == BevelStyles.Raised)
             {
-                if (a == null || b == null)
-                {
-                    a = new ChartPen(Chart, one);
-                    b = new ChartPen(Chart, two);
-                }
-                else
-                {
-                    a.Color = one;
-                    b.Color = two;
-                }
+                _a.Color = one;
+                _b.Color = two;
             }
             else
             {
-                if (a == null || b == null)
-                {
-                    a = new ChartPen(Chart, two);
-                    b = new ChartPen(Chart, one);
-                }
-                else
-                {
-                    a.Color = two;
-                    a.Color = one;
-                }
+                _a.Color = two;
+                _b.Color = one;
             }
 
             var tmp = width;
             while (tmp > 0)
             {
                 tmp--;
-                DoBevelRect(rect, a, b);
+                DoBevelRect(rect, _a, _b);
                 Utils.InflateRect(ref rect, -1, -1);
             }
         }
diff --git a/TeeChart/Drawing/Canvas.cs b/TeeChart/Drawing/Canvas.cs
index db0d942a..ce770c14 100644
--- a/TeeChart/Drawing/Canvas.cs
+++ b/TeeChart/Drawing/Canvas.cs
@@ -11831,7 +11831,7 @@ public abstract void Draw(Rectangle destRect, Rectangle srcRect, CGImage image,
             Line(b, BottomRight, TopRight);
         }
 
-        private ChartPen a, b;
+        private ChartPen _a = new ChartPen(), _b = new ChartPen();
 
 #if WPF || SILVERLIGHT || STORE
     public void PaintBevel(BevelStyles bevel, Rect rect, int width, Color one, Color two)
@@ -11841,36 +11841,20 @@ public abstract void Draw(Rectangle destRect, Rectangle srcRect, CGImage image,
         {
             if (bevel == BevelStyles.Raised)
             {
-                if (a == null || b == null)
-                {
-                    a = new ChartPen(one);
-                    b = new ChartPen(two);
-                }
-                else
-                {
-                    a.Color = one;
-                    b.Color = two;
-                }
+                _a.Color = one;
+                _b.Color = two;
             }
             else
             {
-                if (a == null || b == null)
-                {
-                    a = new ChartPen(two);
-                    b = new ChartPen(one);
-                }
-                else
-                {
-                    a.Color = two;
-                    a.Color = one;
-                }
+                _a.Color = two;
+                _b.Color = one;
             }
 
-            int tmp = width;
+            var tmp = width;
             while (tmp > 0)
             {
                 tmp--;
-                DoBevelRect(rect, a, b);
+                DoBevelRect(rect, _a, _b);
                 Utils.InflateRect(ref rect, -1, -1);
             }
         }