Commit 88f9340e authored by Tebjan Halm's avatar Tebjan Halm
Browse files

added missing raise event methods

parent 23a53f05
...@@ -417,14 +417,16 @@ namespace Svg ...@@ -417,14 +417,16 @@ namespace Svg
//events //events
if(AutoPublishEvents) if(AutoPublishEvents)
foreach (var attr in _svgEventAttributes)
{ {
var evt = attr.Event.GetValue(this); foreach (var attr in _svgEventAttributes)
{
if (evt != null && !string.IsNullOrWhiteSpace(this.ID)) var evt = attr.Event.GetValue(this);
{
writer.WriteAttributeString(attr.Attribute.Name, this.ID + "/" + attr.Attribute.Name); if (evt != null && !string.IsNullOrWhiteSpace(this.ID))
} {
writer.WriteAttributeString(attr.Attribute.Name, this.ID + "/" + attr.Attribute.Name);
}
}
} }
//add the custom attributes //add the custom attributes
...@@ -655,9 +657,9 @@ namespace Svg ...@@ -655,9 +657,9 @@ namespace Svg
caller.RegisterAction<float, float, int, int>(rpcID + "onclick", OnClick); caller.RegisterAction<float, float, int, int>(rpcID + "onclick", OnClick);
caller.RegisterAction<float, float, int, int>(rpcID + "onmousedown", OnMouseDown); caller.RegisterAction<float, float, int, int>(rpcID + "onmousedown", OnMouseDown);
caller.RegisterAction<float, float, int>(rpcID + "onmouseup", OnMouseUp); caller.RegisterAction<float, float, int>(rpcID + "onmouseup", OnMouseUp);
caller.RegisterAction<float, float>(rpcID + "onmousemove", OnMouseMove);
caller.RegisterAction(rpcID + "onmouseover", OnMouseOver); caller.RegisterAction(rpcID + "onmouseover", OnMouseOver);
caller.RegisterAction(rpcID + "onmouseout", OnMouseOut); caller.RegisterAction(rpcID + "onmouseout", OnMouseOut);
caller.RegisterAction<float, float>(rpcID + "onmousemove", OnMouseMove);
} }
} }
...@@ -669,28 +671,35 @@ namespace Svg ...@@ -669,28 +671,35 @@ namespace Svg
[SvgAttribute("onmouseup")] [SvgAttribute("onmouseup")]
public event EventHandler<MouseArg> MouseUp; public event EventHandler<MouseArg> MouseUp;
[SvgAttribute("onmousemove")]
public event EventHandler<PointArg> MouseMove;
[SvgAttribute("onmouseover")] [SvgAttribute("onmouseover")]
public event EventHandler MouseOver; public event EventHandler MouseOver;
[SvgAttribute("onmousemove")]
public event EventHandler<PointArg> MouseMove;
[SvgAttribute("onmouseout")] [SvgAttribute("onmouseout")]
public event EventHandler MouseOut; public event EventHandler MouseOut;
//click
protected void OnClick(float x, float y, int button, int clickCount) protected void OnClick(float x, float y, int button, int clickCount)
{ {
var handler = Click; RaiseMouseClick(this, new MouseArg { x = x, y = y, Button = button, ClickCount = clickCount});
if(handler != null) }
{
handler(this, new MouseArg { x = x, y = y, Button = button, ClickCount = clickCount}); protected void RaiseMouseClick(object sender, MouseArg e)
{
var handler = Click;
if (handler != null)
{
handler(sender, e);
} }
} }
//down
protected void OnMouseDown(float x, float y, int button, int clickCount) protected void OnMouseDown(float x, float y, int button, int clickCount)
{ {
RaiseMouseDown(this, new MouseArg { x = x, y = y, Button = button, ClickCount = clickCount}); RaiseMouseDown(this, new MouseArg { x = x, y = y, Button = button, ClickCount = clickCount});
} }
protected void RaiseMouseDown(object sender, MouseArg e) protected void RaiseMouseDown(object sender, MouseArg e)
...@@ -702,39 +711,63 @@ namespace Svg ...@@ -702,39 +711,63 @@ namespace Svg
} }
} }
//up
protected void OnMouseUp(float x, float y, int button) protected void OnMouseUp(float x, float y, int button)
{ {
var handler = MouseUp; RaiseMouseUp(this, new MouseArg { x = x, y = y, Button = button});
}
protected void RaiseMouseUp(object sender, MouseArg e)
{
var handler = MouseUp;
if (handler != null) if (handler != null)
{ {
handler(this, new MouseArg { x = x, y = y, Button = button}); handler(sender, e);
} }
} }
protected void OnMouseOver() //move
protected void OnMouseMove(float x, float y)
{ {
var handler = MouseOver; RaiseMouseMove(this, new PointArg { x = x, y = y});
}
protected void RaiseMouseMove(object sender, PointArg e)
{
var handler = MouseMove;
if (handler != null) if (handler != null)
{ {
handler(this, new EventArgs()); handler(sender, e);
} }
} }
protected void OnMouseOut() //over
protected void OnMouseOver()
{ {
var handler = MouseOut; RaiseMouseOver(this);
}
protected void RaiseMouseOver(object sender)
{
var handler = MouseOver;
if (handler != null) if (handler != null)
{ {
handler(this, new EventArgs()); handler(sender, new EventArgs());
} }
} }
protected void OnMouseMove(float x, float y) //out
protected void OnMouseOut()
{
RaiseMouseOut(this);
}
protected void RaiseMouseOut(object sender)
{ {
var handler = MouseMove; var handler = MouseOut;
if (handler != null) if (handler != null)
{ {
handler(this, new PointArg { x = x, y = y}); handler(sender, new EventArgs());
} }
} }
......
...@@ -47,5 +47,10 @@ namespace Svg ...@@ -47,5 +47,10 @@ namespace Svg
} }
} }
public static bool HasNonEmptyCustomAttribute(this SvgElement element, string name)
{
return element.CustomAttributes.ContainsKey(name) && !string.IsNullOrEmpty(element.CustomAttributes[name]);
}
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment