SvgElement.cs 41 KB
Newer Older
1001
1002
1003
1004
1005
        {
        	var handler = Click;
        	if (handler != null)
        	{
        		handler(sender, e);
1006
1007
1008
            }
        }

1009
        //down
Tebjan Halm's avatar
Tebjan Halm committed
1010
1011
1012
        protected void RaiseMouseDown(object sender, MouseArg e)
        {
        	var handler = MouseDown;
1013
1014
            if (handler != null)
            {
Tebjan Halm's avatar
Tebjan Halm committed
1015
                handler(sender, e);
1016
1017
1018
            }
        }

1019
1020
1021
1022
        //up
        protected void RaiseMouseUp(object sender, MouseArg e)
        {
        	var handler = MouseUp;
1023
1024
            if (handler != null)
            {
1025
                handler(sender, e);
1026
1027
            }
        }
1028
1029

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

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

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

Tebjan Halm's avatar
Tebjan Halm committed
1126
1127
1128
    /// <summary>
    /// Represents the state of the mouse at the moment the event occured.
    /// </summary>
Tebjan Halm's avatar
Tebjan Halm committed
1129
    public class MouseArg : SVGArg
Tebjan Halm's avatar
Tebjan Halm committed
1130
1131
1132
1133
1134
    {
        public float x;
        public float y;

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

1188
1189
1190
1191
1192
    public interface ISvgNode
    {
        string Content { get; }
    }

1193
1194
1195
1196
    /// <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
1197
1198
    internal interface ISvgElement
    {
1199
1200
		SvgElement Parent {get;}
		SvgElementCollection Children { get; }
1201
        IList<ISvgNode> Nodes { get; }
1202

Eric Domke's avatar
Eric Domke committed
1203
        void Render(ISvgRenderer renderer);
davescriven's avatar
davescriven committed
1204
    }
Tebjan Halm's avatar
Tebjan Halm committed
1205
}