public override object GetValue(object component) { if (component is PropProxy) { object obj = (component as PropProxy).ControlledObject; if (obj is DependencyObject) { var events = EventScriptCollection.GetEventScriptCollection(obj as DependencyObject); var callInfo = events.GetAssosiation(name); if (callInfo == null) { return(""); } else { return(callInfo.HandlerName); } } } if (component is IChannel) { var callInfo = Env.Current.ScriptManager.ChannelsHandlers.GetAssosiation(name, component as IChannel); if (callInfo == null) { return(""); } else { return(callInfo.HandlerName); } } return(null); }
public override void SetValue(object component, object value) { if (component is PropProxy) { object obj = (component as PropProxy).ControlledObject; if (obj is DependencyObject) { //TODO: may be need in ubndo redo //var ub = UndoRedoManager.GetUndoBufferFor(obj as System.Windows.FrameworkElement); //ub.AddCommand(new ModifyGraphicsObject(obj as System.Windows.FrameworkElement)); if (string.IsNullOrEmpty(value as string)) { var events = EventScriptCollection.GetEventScriptCollection(obj as DependencyObject); events.RemoveAssociation(name); EventScriptCollection.SetEventScriptCollection(obj as DependencyObject, events); } else { //todo: get rid GetMainCanvas var callInfo = new ScriptCallInfo(); callInfo.HandlerName = value as string; callInfo.ScriptName = (component as PropProxy).Document.Name; //else // callInfo.ScriptName = "unnamed"; var events = EventScriptCollection.GetEventScriptCollection(obj as DependencyObject); events.AddAssociation(name, callInfo); EventScriptCollection.SetEventScriptCollection(obj as DependencyObject, events); var script = Env.Current.ScriptManager.GetScript(callInfo.ScriptName); if (script == null) { script = Env.Current.ScriptManager.CreateNewScript(callInfo.ScriptName); } var evnt = obj.GetType().GetEvent(name); script.AddHandlerTemplate(callInfo.HandlerName, evnt); } } } if (component is IChannel) { if (string.IsNullOrEmpty(value as string)) { Env.Current.ScriptManager.ChannelsHandlers.RemoveAssociation(name, component as IChannel); } else { var callInfo = new ScriptCallInfo(); callInfo.HandlerName = value as string; callInfo.ScriptName = ScriptManager.ChannelsScriptName; Env.Current.ScriptManager.ChannelsHandlers.AddAssociation(name, component as IChannel, callInfo); var script = Env.Current.ScriptManager.GetScript(ScriptManager.ChannelsScriptName); if (script == null) { script = Env.Current.ScriptManager.CreateNewScript(ScriptManager.ChannelsScriptName); } var evnt = component.GetType().GetEvent(name); script.AddHandlerTemplate(value as string, evnt); } } }