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

added missing raise event methods

parent 23a53f05
...@@ -417,6 +417,7 @@ namespace Svg ...@@ -417,6 +417,7 @@ namespace Svg
//events //events
if(AutoPublishEvents) if(AutoPublishEvents)
{
foreach (var attr in _svgEventAttributes) foreach (var attr in _svgEventAttributes)
{ {
var evt = attr.Event.GetValue(this); var evt = attr.Event.GetValue(this);
...@@ -426,6 +427,7 @@ namespace Svg ...@@ -426,6 +427,7 @@ namespace Svg
writer.WriteAttributeString(attr.Attribute.Name, this.ID + "/" + attr.Attribute.Name); writer.WriteAttributeString(attr.Attribute.Name, this.ID + "/" + attr.Attribute.Name);
} }
} }
}
//add the custom attributes //add the custom attributes
foreach (var item in this._customAttributes) foreach (var item in this._customAttributes)
...@@ -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);
} }
} }
...@@ -670,24 +672,31 @@ namespace Svg ...@@ -670,24 +672,31 @@ namespace Svg
[SvgAttribute("onmouseup")] [SvgAttribute("onmouseup")]
public event EventHandler<MouseArg> MouseUp; public event EventHandler<MouseArg> MouseUp;
[SvgAttribute("onmouseover")]
public event EventHandler MouseOver;
[SvgAttribute("onmousemove")] [SvgAttribute("onmousemove")]
public event EventHandler<PointArg> MouseMove; public event EventHandler<PointArg> MouseMove;
[SvgAttribute("onmouseover")]
public event EventHandler MouseOver;
[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)
{
RaiseMouseClick(this, new MouseArg { x = x, y = y, Button = button, ClickCount = clickCount});
}
protected void RaiseMouseClick(object sender, MouseArg e)
{ {
var handler = Click; var handler = Click;
if(handler != null) if (handler != null)
{ {
handler(this, new MouseArg { x = x, y = y, Button = button, ClickCount = clickCount}); 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});
...@@ -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)
{
RaiseMouseUp(this, new MouseArg { x = x, y = y, Button = button});
}
protected void RaiseMouseUp(object sender, MouseArg e)
{ {
var handler = MouseUp; 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()
{ {
var handler = MouseMove; RaiseMouseOut(this);
}
protected void RaiseMouseOut(object sender)
{
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