SvgElement.cs 40.7 KB
Newer Older
1001
1002
        }

1003
        //down
Tebjan Halm's avatar
Tebjan Halm committed
1004
1005
1006
        protected void RaiseMouseDown(object sender, MouseArg e)
        {
        	var handler = MouseDown;
1007
1008
            if (handler != null)
            {
Tebjan Halm's avatar
Tebjan Halm committed
1009
                handler(sender, e);
1010
1011
1012
            }
        }

1013
1014
1015
1016
        //up
        protected void RaiseMouseUp(object sender, MouseArg e)
        {
        	var handler = MouseUp;
1017
1018
            if (handler != null)
            {
1019
                handler(sender, e);
1020
1021
            }
        }
1022
1023

        protected void RaiseMouseMove(object sender, MouseArg e)
1024
1025
        {
        	var handler = MouseMove;
1026
1027
            if (handler != null)
            {
1028
                handler(sender, e);
1029
1030
            }
        }
joreg's avatar
joreg committed
1031
        
1032
1033
        //over
        protected void RaiseMouseOver(object sender, MouseArg args)
1034
1035
        {
        	var handler = MouseOver;
1036
1037
            if (handler != null)
            {
Tebjan Halm's avatar
Tebjan Halm committed
1038
                handler(sender, args);
Tebjan Halm's avatar
Tebjan Halm committed
1039
1040
1041
            }
        }

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

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

Tebjan Halm's avatar
Tebjan Halm committed
1120
1121
1122
    /// <summary>
    /// Represents the state of the mouse at the moment the event occured.
    /// </summary>
Tebjan Halm's avatar
Tebjan Halm committed
1123
    public class MouseArg : SVGArg
Tebjan Halm's avatar
Tebjan Halm committed
1124
1125
1126
1127
1128
    {
        public float x;
        public float y;

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

1182
1183
1184
1185
1186
    public interface ISvgNode
    {
        string Content { get; }
    }

1187
1188
1189
1190
    /// <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
1191
1192
    internal interface ISvgElement
    {
1193
1194
		SvgElement Parent {get;}
		SvgElementCollection Children { get; }
1195
        IList<ISvgNode> Nodes { get; }
1196

Eric Domke's avatar
Eric Domke committed
1197
        void Render(ISvgRenderer renderer);
davescriven's avatar
davescriven committed
1198
    }
Tebjan Halm's avatar
Tebjan Halm committed
1199
}