SvgElement.cs 41 KB
Newer Older
Tebjan Halm's avatar
Tebjan Halm committed
1001
        {
1002
1003
        	return (x, y, button, clickCount, altKey, shiftKey, ctrlKey, sessionID) =>
        		eventRaiser(this, new MouseArg { x = x, y = y, Button = button, ClickCount = clickCount, AltKey = altKey, ShiftKey = shiftKey, CtrlKey = ctrlKey, SessionID = sessionID });
1004
        }
Eric Domke's avatar
Eric Domke committed
1005
1006
#endif

1007
        //click
1008
1009
1010
1011
1012
1013
        protected void RaiseMouseClick(object sender, MouseArg e)
        {
        	var handler = Click;
        	if (handler != null)
        	{
        		handler(sender, e);
1014
1015
1016
            }
        }

1017
        //down
Tebjan Halm's avatar
Tebjan Halm committed
1018
1019
1020
        protected void RaiseMouseDown(object sender, MouseArg e)
        {
        	var handler = MouseDown;
1021
1022
            if (handler != null)
            {
Tebjan Halm's avatar
Tebjan Halm committed
1023
                handler(sender, e);
1024
1025
1026
            }
        }

1027
1028
1029
1030
        //up
        protected void RaiseMouseUp(object sender, MouseArg e)
        {
        	var handler = MouseUp;
1031
1032
            if (handler != null)
            {
1033
                handler(sender, e);
1034
1035
            }
        }
1036
1037

        protected void RaiseMouseMove(object sender, MouseArg e)
1038
1039
        {
        	var handler = MouseMove;
1040
1041
            if (handler != null)
            {
1042
                handler(sender, e);
1043
1044
            }
        }
joreg's avatar
joreg committed
1045
        
1046
1047
        //over
        protected void RaiseMouseOver(object sender, MouseArg args)
1048
1049
        {
        	var handler = MouseOver;
1050
1051
            if (handler != null)
            {
Tebjan Halm's avatar
Tebjan Halm committed
1052
                handler(sender, args);
Tebjan Halm's avatar
Tebjan Halm committed
1053
1054
1055
            }
        }

1056
        //out
1057
        protected void RaiseMouseOut(object sender, MouseArg args)
1058
        {
1059
        	var handler = MouseOut;
1060
1061
            if (handler != null)
            {
Tebjan Halm's avatar
Tebjan Halm committed
1062
                handler(sender, args);
1063
1064
            }
        }
joreg's avatar
joreg committed
1065
        
1066
1067
        
        //scroll
1068
        protected void OnMouseScroll(int scroll, bool ctrlKey, bool shiftKey, bool altKey, string sessionID)
joreg's avatar
joreg committed
1069
        {
1070
        	RaiseMouseScroll(this, new MouseScrollArg { Scroll = scroll, AltKey = altKey, ShiftKey = shiftKey, CtrlKey = ctrlKey, SessionID = sessionID});
joreg's avatar
joreg committed
1071
1072
        }
        
1073
        protected void RaiseMouseScroll(object sender, MouseScrollArg e)
joreg's avatar
joreg committed
1074
        {
1075
        	var handler = MouseScroll;
joreg's avatar
joreg committed
1076
1077
            if (handler != null)
            {
1078
                handler(sender, e);
joreg's avatar
joreg committed
1079
1080
            }
        }
1081
        
Tebjan Halm's avatar
Tebjan Halm committed
1082
1083
        #endregion graphical EVENTS
    }
1084
    
Tebjan Halm's avatar
Tebjan Halm committed
1085
1086
1087
1088
1089
1090
    public class SVGArg : EventArgs
    {
    	public string SessionID;
    }
    	
    
1091
1092
1093
    /// <summary>
    /// Describes the Attribute which was set
    /// </summary>
Tebjan Halm's avatar
Tebjan Halm committed
1094
    public class AttributeEventArgs : SVGArg
1095
1096
1097
1098
    {
    	public string Attribute;
    	public object Value;
    }
tebjan's avatar
tebjan committed
1099
    
tebjan's avatar
tebjan committed
1100
1101
1102
1103
1104
1105
1106
1107
    /// <summary>
    /// Content of this whas was set
    /// </summary>
    public class ContentEventArgs : SVGArg
    {
    	public string Content;
    }
    
tebjan's avatar
tebjan committed
1108
1109
1110
1111
1112
1113
    /// <summary>
    /// Describes the Attribute which was set
    /// </summary>
    public class ChildAddedEventArgs : SVGArg
    {
    	public SvgElement NewChild;
1114
    	public SvgElement BeforeSibling;
tebjan's avatar
tebjan committed
1115
    }
Tebjan Halm's avatar
Tebjan Halm committed
1116

Eric Domke's avatar
Eric Domke committed
1117
#if Net4
1118
1119
1120
    //deriving class registers event actions and calls the actions if the event occurs
    public interface ISvgEventCaller
    {
1121
        void RegisterAction(string rpcID, Action action);
1122
1123
1124
1125
        void RegisterAction<T1>(string rpcID, Action<T1> action);
        void RegisterAction<T1, T2>(string rpcID, Action<T1, T2> action);
        void RegisterAction<T1, T2, T3>(string rpcID, Action<T1, T2, T3> action);
        void RegisterAction<T1, T2, T3, T4>(string rpcID, Action<T1, T2, T3, T4> action);
Tebjan Halm's avatar
Tebjan Halm committed
1126
        void RegisterAction<T1, T2, T3, T4, T5>(string rpcID, Action<T1, T2, T3, T4, T5> action);
1127
1128
1129
        void RegisterAction<T1, T2, T3, T4, T5, T6>(string rpcID, Action<T1, T2, T3, T4, T5, T6> action);
        void RegisterAction<T1, T2, T3, T4, T5, T6, T7>(string rpcID, Action<T1, T2, T3, T4, T5, T6, T7> action);
        void RegisterAction<T1, T2, T3, T4, T5, T6, T7, T8>(string rpcID, Action<T1, T2, T3, T4, T5, T6, T7, T8> action);
1130
        void UnregisterAction(string rpcID);
1131
    }
Eric Domke's avatar
Eric Domke committed
1132
#endif
1133

Tebjan Halm's avatar
Tebjan Halm committed
1134
1135
1136
    /// <summary>
    /// Represents the state of the mouse at the moment the event occured.
    /// </summary>
Tebjan Halm's avatar
Tebjan Halm committed
1137
    public class MouseArg : SVGArg
Tebjan Halm's avatar
Tebjan Halm committed
1138
1139
1140
1141
1142
    {
        public float x;
        public float y;

        /// <summary>
1143
        /// 1 = left, 2 = middle, 3 = right
Tebjan Halm's avatar
Tebjan Halm committed
1144
        /// </summary>
1145
        public int Button;
1146
        
1147
1148
1149
        /// <summary>
        /// Amount of mouse clicks, e.g. 2 for double click
        /// </summary>
1150
        public int ClickCount = -1;
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
        
        /// <summary>
        /// Alt modifier key pressed
        /// </summary>
        public bool AltKey;
        
        /// <summary>
        /// Shift modifier key pressed
        /// </summary>
        public bool ShiftKey;
        
        /// <summary>
        /// Control modifier key pressed
        /// </summary>
        public bool CtrlKey;
1166
    }
joreg's avatar
joreg committed
1167
1168
1169
1170
    
    /// <summary>
    /// Represents a string argument
    /// </summary>
Tebjan Halm's avatar
Tebjan Halm committed
1171
    public class StringArg : SVGArg
joreg's avatar
joreg committed
1172
1173
1174
    {
        public string s;
    }
1175
1176
1177
1178
    
    public class MouseScrollArg : SVGArg
    {
    	public int Scroll;
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
    	
    	/// <summary>
        /// Alt modifier key pressed
        /// </summary>
        public bool AltKey;
        
        /// <summary>
        /// Shift modifier key pressed
        /// </summary>
        public bool ShiftKey;
        
        /// <summary>
        /// Control modifier key pressed
        /// </summary>
        public bool CtrlKey;
1194
    }
1195

1196
1197
1198
1199
1200
    public interface ISvgNode
    {
        string Content { get; }
    }

davescriven's avatar
davescriven committed
1201
1202
    internal interface ISvgElement
    {
1203
1204
		SvgElement Parent {get;}
		SvgElementCollection Children { get; }
1205
        IList<ISvgNode> Nodes { get; }
1206

Eric Domke's avatar
Eric Domke committed
1207
        void Render(ISvgRenderer renderer);
davescriven's avatar
davescriven committed
1208
    }
Tebjan Halm's avatar
Tebjan Halm committed
1209
}