SvgElement.cs 41.2 KB
Newer Older
1001
        }
Eric Domke's avatar
Eric Domke committed
1002
1003
#endif

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

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

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

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

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

Eric Domke's avatar
Eric Domke committed
1114
#if Net4
1115
1116
1117
    //deriving class registers event actions and calls the actions if the event occurs
    public interface ISvgEventCaller
    {
1118
        void RegisterAction(string rpcID, Action action);
1119
1120
1121
1122
        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
1123
        void RegisterAction<T1, T2, T3, T4, T5>(string rpcID, Action<T1, T2, T3, T4, T5> action);
1124
1125
1126
        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);
1127
        void UnregisterAction(string rpcID);
1128
    }
Eric Domke's avatar
Eric Domke committed
1129
#endif
1130

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

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

1193
1194
1195
1196
1197
    public interface ISvgNode
    {
        string Content { get; }
    }

1198
1199
1200
1201
    /// <summary>This interface mostly indicates that a node is not to be drawn when rendering the SVG.</summary>
    public interface ISvgDescriptiveElement {
    }

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

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