Skip to content

Commit d359e7f

Browse files
committed
Update SvgDrawingCanvas.cs
Turing off the current cursor handling until a property hit-test handling is restored. Issue #60
1 parent 4af546f commit d359e7f

File tree

1 file changed

+44
-38
lines changed

1 file changed

+44
-38
lines changed

Source/SharpVectorRuntimeWpf/SvgDrawingCanvas.cs

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -76,48 +76,48 @@ static SvgDrawingCanvas()
7676

7777
public SvgDrawingCanvas()
7878
{
79-
_drawForInteractivity = true;
79+
_drawForInteractivity = true;
8080

81-
_appTitle = DefaultTitle;
81+
_appTitle = DefaultTitle;
8282

83-
_drawObjects = new List<Drawing>();
84-
_linkObjects = new List<Drawing>();
83+
_drawObjects = new List<Drawing>();
84+
_linkObjects = new List<Drawing>();
8585

86-
_displayTransform = Transform.Identity;
86+
_displayTransform = Transform.Identity;
8787

8888
// Create a tooltip and set its position.
89-
_tooltip = new ToolTip();
90-
_tooltip.Placement = PlacementMode.MousePoint;
89+
_tooltip = new ToolTip();
90+
_tooltip.Placement = PlacementMode.MousePoint;
9191
_tooltip.PlacementRectangle = new Rect(50, 0, 0, 0);
92-
_tooltip.HorizontalOffset = 20;
93-
_tooltip.VerticalOffset = 20;
92+
_tooltip.HorizontalOffset = 20;
93+
_tooltip.VerticalOffset = 20;
9494

95-
_tooltipText = new TextBlock();
96-
_tooltipText.Text = string.Empty;
97-
_tooltipText.Margin = new Thickness(6, 0, 0, 0);
95+
_tooltipText = new TextBlock();
96+
_tooltipText.Text = string.Empty;
97+
_tooltipText.Margin = new Thickness(6, 0, 0, 0);
9898

9999
//Create BulletDecorator and set it as the tooltip content.
100-
Ellipse bullet = new Ellipse();
101-
bullet.Height = 10;
102-
bullet.Width = 10;
103-
bullet.Fill = Brushes.LightCyan;
100+
Ellipse bullet = new Ellipse();
101+
bullet.Height = 10;
102+
bullet.Width = 10;
103+
bullet.Fill = Brushes.LightCyan;
104104

105-
BulletDecorator decorator = new BulletDecorator();
106-
decorator.Bullet = bullet;
107-
decorator.Margin = new Thickness(0, 0, 10, 0);
108-
decorator.Child = _tooltipText;
105+
BulletDecorator decorator = new BulletDecorator();
106+
decorator.Bullet = bullet;
107+
decorator.Margin = new Thickness(0, 0, 10, 0);
108+
decorator.Child = _tooltipText;
109109

110-
_tooltip.Content = decorator;
111-
_tooltip.IsOpen = false;
112-
_tooltip.Visibility = Visibility.Hidden;
110+
_tooltip.Content = decorator;
111+
_tooltip.IsOpen = false;
112+
_tooltip.Visibility = Visibility.Hidden;
113113

114114
//Finally, set tooltip on this canvas
115-
this.ToolTip = _tooltip;
116-
this.Background = Brushes.Transparent;
115+
this.ToolTip = _tooltip;
116+
this.Background = Brushes.Transparent;
117117

118-
_animationCanvas = new SvgAnimationLayer(this);
118+
_animationCanvas = new SvgAnimationLayer(this);
119119

120-
this.SnapsToDevicePixels = true;
120+
this.SnapsToDevicePixels = true;
121121
}
122122

123123
#endregion
@@ -274,8 +274,7 @@ public void LoadDiagrams(string fileName)
274274
{
275275
using (FileStream fileStream = File.OpenRead(fileName))
276276
{
277-
using (GZipStream zipStream =
278-
new GZipStream(fileStream, CompressionMode.Decompress))
277+
using (GZipStream zipStream = new GZipStream(fileStream, CompressionMode.Decompress))
279278
{
280279
xamlObject = XamlReader.Load(zipStream);
281280
}
@@ -366,8 +365,7 @@ public void RenderDiagrams(DrawingGroup renderedGroup)
366365
Drawing drawing = drawings[i];
367366
//string drawingName = SvgObject.GetName(drawing);
368367
string drawingName = SvgLink.GetKey(drawing);
369-
if (!string.IsNullOrWhiteSpace(drawingName) &&
370-
string.Equals(drawingName, SvgObject.DrawLayer))
368+
if (!string.IsNullOrWhiteSpace(drawingName) && string.Equals(drawingName, SvgObject.DrawLayer))
371369
{
372370
drawIndex = i;
373371
}
@@ -421,8 +419,6 @@ protected override Visual GetVisualChild(int index)
421419

422420
protected override Size MeasureOverride(Size constraint)
423421
{
424-
//return base.MeasureOverride(constraint);
425-
426422
if (_wholeDrawing != null)
427423
{
428424
Rect rectBounds = _wholeDrawing.Bounds;
@@ -447,7 +443,17 @@ protected override Size MeasureOverride(Size constraint)
447443
}
448444
}
449445

450-
return new Size(320, 240);
446+
var sizeCtrl = base.MeasureOverride(constraint);
447+
if ((!Double.IsNaN(sizeCtrl.Width) && !Double.IsInfinity(sizeCtrl.Width)) &&
448+
(!Double.IsNaN(sizeCtrl.Height) && !Double.IsInfinity(sizeCtrl.Height)))
449+
{
450+
if (sizeCtrl.Width != 0 && sizeCtrl.Height != 0)
451+
{
452+
return sizeCtrl;
453+
}
454+
}
455+
456+
return new Size(120, 120);
451457
}
452458

453459
protected override void OnMouseDown(MouseButtonEventArgs e)
@@ -470,7 +476,7 @@ protected override void OnMouseDown(MouseButtonEventArgs e)
470476
_tooltip.Visibility = Visibility.Hidden;
471477
}
472478

473-
this.Cursor = Cursors.Arrow;
479+
// this.Cursor = Cursors.Arrow;
474480
return;
475481
}
476482

@@ -538,7 +544,7 @@ protected override void OnMouseMove(MouseEventArgs e)
538544

539545
if (hitVisual == null)
540546
{
541-
this.Cursor = Cursors.Arrow;
547+
// this.Cursor = Cursors.Arrow;
542548

543549
if (_hitVisual != null)
544550
{
@@ -566,7 +572,7 @@ protected override void OnMouseMove(MouseEventArgs e)
566572
}
567573
else
568574
{
569-
this.Cursor = Cursors.Hand;
575+
// this.Cursor = Cursors.Hand;
570576

571577
if (hitVisual == _hitVisual)
572578
{
@@ -672,7 +678,7 @@ protected override void OnMouseLeave(MouseEventArgs e)
672678
//}
673679
_hitVisual = null;
674680

675-
this.Cursor = Cursors.Arrow;
681+
// this.Cursor = Cursors.Arrow;
676682
}
677683

678684
protected virtual void OnHandleAlert(string message)

0 commit comments

Comments
 (0)