private bool Execute(FunctionSyncro syncro, Point point, object obj) { if (syncro != null) { Type type = syncro.GetFunction().GetParameterType(0); object converted_obj = obj.ConvertEX(type); if (converted_obj != null) { if (syncro.GetFunction().CanParametersHold(type)) { syncro.Execute(new object[] { converted_obj }); return(true); } if (syncro.GetFunction().CanParametersHold(type, typeof(Point))) { syncro.Execute(new object[] { converted_obj, point }); return(true); } throw new UnexpectedSignatureException(syncro.GetFunction().GetParameterTypes()); } } return(false); }
static public MouseEventHandler GetMouseEventHandler(this FunctionSyncro item, Predicate <MouseEventArgs> predicate) { if (item.GetFunction().HasNoParameters()) { return(delegate(object sender, MouseEventArgs e) { if (predicate(e)) { item.Execute(); } }); } if (item.GetFunction().CanParametersHold <object, MouseEventArgs>()) { return(delegate(object sender, MouseEventArgs e) { if (predicate(e)) { item.Execute(new object[] { sender, e }); } }); } if (item.GetFunction().CanParametersHold <MouseEventArgs>()) { return(delegate(object sender, MouseEventArgs e) { if (predicate(e)) { item.Execute(new object[] { e }); } }); } throw new UnexpectedSignatureException(item.GetFunction().GetParameterTypes()); }
static public ICommand GetCommand(this FunctionSyncro item) { if (item.GetFunction().HasNoParameters()) { return(new ProcessCommand(delegate(object obj) { item.Execute(); })); } if (item.GetFunction().CanParametersHold <object>()) { return(new ProcessCommand(delegate(object obj) { item.Execute(new object[] { obj }); })); } throw new UnexpectedSignatureException(item.GetFunction().GetParameterTypes()); }
static public EventHandler <T> GetRoutedEventHandler <T>(this FunctionSyncro item, Predicate <T> predicate) where T : RoutedEventArgs { if (item.GetFunction().HasNoParameters()) { return(delegate(object sender, T e) { if (predicate(e)) { item.Execute(); e.Handled = true; } }); } if (item.GetFunction().GetNumberParameters() == 1) { return(delegate(object sender, T e) { if (predicate(e)) { item.Execute(new object[] { e }); e.Handled = true; } }); } if (item.GetFunction().GetNumberParameters() == 2) { return(delegate(object sender, T e) { if (predicate(e)) { item.Execute(new object[] { sender, e }); e.Handled = true; } }); } throw new UnexpectedSignatureException(item.GetFunction().GetParameterTypes()); }
static public void AddInputBinding(this FrameworkElement item, FunctionSyncro function_syncro, InputGesture gesture) { item.AddInputBinding(function_syncro.GetCommand(), gesture); }
public void SetOnDrop(FunctionSyncro f) { on_drop = f; }
public void SetOnLeave(FunctionSyncro f) { on_leave = f; }
public void SetOnOver(FunctionSyncro f) { on_over = f; }
public void SetOnEnter(FunctionSyncro f) { on_enter = f; }
static public void AddKeyBinding(this Control item, FunctionSyncro function_syncro, Key key, KeyModifiers modifiers) { item.AddKeyBinding(function_syncro, new KeyGesture(key, modifiers)); }
static public MouseEventHandler GetMouseEventHandler(this FunctionSyncro item) { return(item.GetMouseEventHandler(e => true)); }
static public EventHandler <T> GetRoutedEventHandler <T>(this FunctionSyncro item) where T : RoutedEventArgs { return(item.GetRoutedEventHandler <T>(e => true)); }
static public RoutedEventHandler GetRoutedEventHandler(this FunctionSyncro item) { return(item.GetRoutedEventHandler(e => true)); }
static public void AddInputBinding(this FrameworkElement item, FunctionSyncro function_syncro, MouseAction mouse_action, ModifierKeys modifiers) { item.AddInputBinding(function_syncro, new MouseGesture(mouse_action, modifiers)); }
static public void Register(this Control item, RoutedEvent routed_event, FunctionSyncro function, RoutingStrategies routes = RoutingStrategies.Bubble) { item.AddHandler(routed_event, function.GetRoutedEventHandler <RoutedEventArgs>(), routes); }
static public void AddInputBinding(this FrameworkElement item, FunctionSyncro function_syncro, Key key, ModifierKeys modifiers) { item.AddInputBinding(function_syncro, new KeyGesture(key, modifiers)); }
static public void AddKeyBinding(this Control item, FunctionSyncro function_syncro, KeyGesture gesture) { item.AddKeyBinding(function_syncro.GetCommand(), gesture); }