Badges - removing unnecessary allocation when comparing triangle vertices
This commit is contained in:
1 parent
24290ddb27
commit
3d7e04ded1
1 file changed
+3
-4
@@ -36,7 +36,7 @@ namespace mbts.ui.controls {
|
||||
Brush _background, _foreground, _border_brush, _parent_algo_type_brush;
|
||||
bool _is_exchange_order, _has_multiple_orders_at_level, _is_hedge_order;
|
||||
CustomOrderDefinition.CustomOneofCase _parent_algo_type;
|
||||
Tuple<Point, Point, Point> _current_triangle_vertices;
|
||||
(Point p1, Point p2, Point p3) _current_triangle_vertices;
|
||||
StreamGeometry _triangle_geometry;
|
||||
|
||||
|
||||
@@ -331,14 +331,13 @@ namespace mbts.ui.controls {
|
||||
dc.DrawGlyphRun(_foreground, gr);
|
||||
|
||||
void _draw_triangle(Point p1, Point p2, Point p3, Brush b) {
|
||||
Tuple<Point, Point, Point> new_vertices = new Tuple<Point, Point, Point>(p1, p2, p3);
|
||||
if (!new_vertices.Equals(_current_triangle_vertices)) {
|
||||
if (!(p1 == _current_triangle_vertices.p1 && p2 == _current_triangle_vertices.p2 && p3 == _current_triangle_vertices.p3)) {
|
||||
_triangle_geometry = new StreamGeometry();
|
||||
using (var sgc = _triangle_geometry.Open()) {
|
||||
sgc.BeginFigure(p1, true, true);
|
||||
sgc.PolyLineTo(new Point[] { p2, p3 }, true, true);
|
||||
}
|
||||
_current_triangle_vertices = new_vertices;
|
||||
_current_triangle_vertices = (p1, p2, p3);
|
||||
_triangle_geometry.Freeze();
|
||||
}
|
||||
(pen = new Pen(b, 1)).Freeze();
|
||||
|
||||
Reference in new issue
Block a user