Skip to content

Commit 0dc8c45

Browse files
committed
#893 fix to address Text sizing and Rotary Switch labels and strokes.
1 parent f6eac34 commit 0dc8c45

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Helios/Controls/RotarySwitchRenderer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected override void OnRender(System.Windows.Media.DrawingContext drawingCont
6767
DrawingContext tempDrawingContext = visual.RenderOpen();
6868
tempDrawingContext.DrawDrawing(_lines);
6969
tempDrawingContext.Close();
70-
RenderVisual(drawingContext, visual, _imageRect);
70+
RenderVisual(drawingContext, visual, !visual.ContentBounds.IsEmpty ? visual.ContentBounds : _imageRect);
7171
}
7272
}
7373
if (!needsEffect)
@@ -82,10 +82,10 @@ protected override void OnRender(System.Windows.Media.DrawingContext drawingCont
8282
DrawingContext tempDrawingContext = visual.RenderOpen();
8383
foreach (SwitchPositionLabel label in _labels)
8484
{
85-
tempDrawingContext.DrawText(label.Text, new Point(label.Location.X * 1.25, label.Location.Y * 1.25));
85+
tempDrawingContext.DrawText(label.Text, new Point(label.Location.X, label.Location.Y));
8686
}
8787
tempDrawingContext.Close();
88-
RenderVisual(drawingContext, visual, new Rect(_imageRect.X - (_imageRect.Width * 0.25), _imageRect.Y - (_imageRect.Height * 0.25), _imageRect.Width * 1.5, _imageRect.Height * 1.5));
88+
RenderVisual(drawingContext, visual, !visual.ContentBounds.IsEmpty ? visual.ContentBounds : _imageRect);
8989
}
9090

9191
drawingContext.PushTransform(new RotateTransform(rotarySwitch.KnobRotation, _center.X, _center.Y));

Helios/HeliosVisualRenderer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ protected void DrawImage(DrawingContext drawingContext, ImageSource image, Rect
226226
DrawingContext tempDrawingContext = visual.RenderOpen();
227227
tempDrawingContext.DrawImage(image, rectangle);
228228
tempDrawingContext.Close();
229-
RenderVisual(drawingContext, visual, rectangle);
229+
RenderVisual(drawingContext, visual, !visual.ContentBounds.IsEmpty ? visual.ContentBounds : rectangle);
230230
}
231231

232232
}
@@ -253,7 +253,7 @@ protected void DrawGeometry(DrawingContext drawingContext, Brush brush, Pen pen,
253253
DrawingContext tempDrawingContext = visual.RenderOpen();
254254
tempDrawingContext.DrawGeometry(brush, pen, path);
255255
tempDrawingContext.Close();
256-
RenderVisual(drawingContext, visual, rectangle);
256+
RenderVisual(drawingContext, visual, !visual.ContentBounds.IsEmpty ? visual.ContentBounds : rectangle);
257257
}
258258
}
259259
/// <summary>
@@ -278,7 +278,7 @@ protected void DrawRectangle(DrawingContext drawingContext, Brush brush, Pen pen
278278
DrawingContext tempDrawingContext = visual.RenderOpen();
279279
tempDrawingContext.DrawRectangle(brush, pen, rectangle);
280280
tempDrawingContext.Close();
281-
RenderVisual(drawingContext, visual, rectangle);
281+
RenderVisual(drawingContext, visual, !visual.ContentBounds.IsEmpty ? visual.ContentBounds : rectangle);
282282
}
283283
}
284284
/// <summary>
@@ -303,7 +303,7 @@ protected void DrawRoundedRectangle(DrawingContext drawingContext, Brush brush,
303303
DrawingContext tempDrawingContext = visual.RenderOpen();
304304
tempDrawingContext.DrawRoundedRectangle(brush, pen, rectangle, radiusX, radiusY);
305305
tempDrawingContext.Close();
306-
RenderVisual(drawingContext, visual, rectangle);
306+
RenderVisual(drawingContext, visual, !visual.ContentBounds.IsEmpty ? visual.ContentBounds : rectangle);
307307
}
308308
}
309309
/// <summary>
@@ -331,7 +331,7 @@ protected void DrawText(DrawingContext drawingContext, ITextControl textVisual,
331331
DrawingContext tempDrawingContext = visual.RenderOpen();
332332
textVisual.TextFormat.RenderText(tempDrawingContext, brush, text, rectangle);
333333
tempDrawingContext.Close();
334-
RenderVisual(drawingContext, visual, rectangle);
334+
RenderVisual(drawingContext, visual, !visual.ContentBounds.IsEmpty ? visual.ContentBounds : rectangle);
335335
}
336336
}
337337
#endregion Draw Proxies

0 commit comments

Comments
 (0)