SvgElement.cs 39.2 KB
Newer Older
joreg's avatar
joreg committed
1001
        
1002
1003
        //over
        protected void RaiseMouseOver(object sender, MouseArg args)
1004
1005
        {
        	var handler = MouseOver;
1006
1007
            if (handler != null)
            {
Tebjan Halm's avatar
Tebjan Halm committed
1008
                handler(sender, args);
Tebjan Halm's avatar
Tebjan Halm committed
1009
1010
1011
            }
        }

1012
        //out
1013
        protected void RaiseMouseOut(object sender, MouseArg args)
1014
        {
1015
        	var handler = MouseOut;
1016
1017
            if (handler != null)
            {
Tebjan Halm's avatar
Tebjan Halm committed
1018
                handler(sender, args);
1019
1020
            }
        }
joreg's avatar
joreg committed
1021
        
1022
1023
        
        //scroll
1024
        protected void OnMouseScroll(int scroll, bool ctrlKey, bool shiftKey, bool altKey, string sessionID)
joreg's avatar
joreg committed
1025
        {
1026
        	RaiseMouseScroll(this, new MouseScrollArg { Scroll = scroll, AltKey = altKey, ShiftKey = shiftKey, CtrlKey = ctrlKey, SessionID = sessionID});
joreg's avatar
joreg committed
1027
1028
        }
        
1029
        protected void RaiseMouseScroll(object sender, MouseScrollArg e)
joreg's avatar
joreg committed
1030
        {
1031
        	var handler = MouseScroll;
joreg's avatar
joreg committed
1032
1033
            if (handler != null)
            {
1034
                handler(sender, e);
joreg's avatar
joreg committed
1035
1036
            }
        }
1037
        
Tebjan Halm's avatar
Tebjan Halm committed
1038
1039
        #endregion graphical EVENTS
    }
1040
    
Tebjan Halm's avatar
Tebjan Halm committed
1041
1042
1043
1044
1045
1046
    public class SVGArg : EventArgs
    {
    	public string SessionID;
    }
    	
    
1047
1048
1049
    /// <summary>
    /// Describes the Attribute which was set
    /// </summary>
Tebjan Halm's avatar
Tebjan Halm committed
1050
    public class AttributeEventArgs : SVGArg
1051
1052
1053
1054
    {
    	public string Attribute;
    	public object Value;
    }
tebjan's avatar
tebjan committed
1055
    
tebjan's avatar
tebjan committed
1056
1057
1058
1059
1060
1061
1062
1063
    /// <summary>
    /// Content of this whas was set
    /// </summary>
    public class ContentEventArgs : SVGArg
    {
    	public string Content;
    }
    
tebjan's avatar
tebjan committed
1064
1065
1066
1067
1068
1069
    /// <summary>
    /// Describes the Attribute which was set
    /// </summary>
    public class ChildAddedEventArgs : SVGArg
    {
    	public SvgElement NewChild;
1070
    	public SvgElement BeforeSibling;
tebjan's avatar
tebjan committed
1071
    }
Tebjan Halm's avatar
Tebjan Halm committed
1072

Eric Domke's avatar
Eric Domke committed
1073
#if Net4
1074
1075
1076
    //deriving class registers event actions and calls the actions if the event occurs
    public interface ISvgEventCaller
    {
1077
        void RegisterAction(string rpcID, Action action);
1078
1079
1080
1081
        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
1082
        void RegisterAction<T1, T2, T3, T4, T5>(string rpcID, Action<T1, T2, T3, T4, T5> action);
1083
1084
1085
        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);
1086
        void UnregisterAction(string rpcID);
1087
    }
Eric Domke's avatar
Eric Domke committed
1088
#endif
1089

Tebjan Halm's avatar
Tebjan Halm committed
1090
1091
1092
    /// <summary>
    /// Represents the state of the mouse at the moment the event occured.
    /// </summary>
Tebjan Halm's avatar
Tebjan Halm committed
1093
    public class MouseArg : SVGArg
Tebjan Halm's avatar
Tebjan Halm committed
1094
1095
1096
1097
1098
    {
        public float x;
        public float y;

        /// <summary>
1099
        /// 1 = left, 2 = middle, 3 = right
Tebjan Halm's avatar
Tebjan Halm committed
1100
        /// </summary>
1101
        public int Button;
1102
        
1103
1104
1105
        /// <summary>
        /// Amount of mouse clicks, e.g. 2 for double click
        /// </summary>
1106
        public int ClickCount = -1;
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
        
        /// <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;
1122
    }
joreg's avatar
joreg committed
1123
1124
1125
1126
    
    /// <summary>
    /// Represents a string argument
    /// </summary>
Tebjan Halm's avatar
Tebjan Halm committed
1127
    public class StringArg : SVGArg
joreg's avatar
joreg committed
1128
1129
1130
    {
        public string s;
    }
1131
1132
1133
1134
    
    public class MouseScrollArg : SVGArg
    {
    	public int Scroll;
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
    	
    	/// <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;
1150
    }
1151

1152
1153
1154
1155
1156
    public interface ISvgNode
    {
        string Content { get; }
    }

davescriven's avatar
davescriven committed
1157
1158
    internal interface ISvgElement
    {
1159
1160
		SvgElement Parent {get;}
		SvgElementCollection Children { get; }
1161
        IList<ISvgNode> Nodes { get; }
1162

Eric Domke's avatar
Eric Domke committed
1163
        void Render(ISvgRenderer renderer);
davescriven's avatar
davescriven committed
1164
    }
Tebjan Halm's avatar
Tebjan Halm committed
1165
}