Example #1
0
        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);
        }
Example #2
0
        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());
        }
Example #3
0
        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());
        }
Example #4
0
        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());
        }
Example #5
0
 static public void AddInputBinding(this FrameworkElement item, FunctionSyncro function_syncro, InputGesture gesture)
 {
     item.AddInputBinding(function_syncro.GetCommand(), gesture);
 }
Example #6
0
 public void SetOnDrop(FunctionSyncro f)
 {
     on_drop = f;
 }
Example #7
0
 public void SetOnLeave(FunctionSyncro f)
 {
     on_leave = f;
 }
Example #8
0
 public void SetOnOver(FunctionSyncro f)
 {
     on_over = f;
 }
Example #9
0
 public void SetOnEnter(FunctionSyncro f)
 {
     on_enter = f;
 }
Example #10
0
 static public void AddKeyBinding(this Control item, FunctionSyncro function_syncro, Key key, KeyModifiers modifiers)
 {
     item.AddKeyBinding(function_syncro, new KeyGesture(key, modifiers));
 }
Example #11
0
 static public MouseEventHandler GetMouseEventHandler(this FunctionSyncro item)
 {
     return(item.GetMouseEventHandler(e => true));
 }
Example #12
0
 static public EventHandler <T> GetRoutedEventHandler <T>(this FunctionSyncro item) where T : RoutedEventArgs
 {
     return(item.GetRoutedEventHandler <T>(e => true));
 }
Example #13
0
 static public RoutedEventHandler GetRoutedEventHandler(this FunctionSyncro item)
 {
     return(item.GetRoutedEventHandler(e => true));
 }
Example #14
0
 static public void AddInputBinding(this FrameworkElement item, FunctionSyncro function_syncro, MouseAction mouse_action, ModifierKeys modifiers)
 {
     item.AddInputBinding(function_syncro, new MouseGesture(mouse_action, modifiers));
 }
Example #15
0
 static public void Register(this Control item, RoutedEvent routed_event, FunctionSyncro function, RoutingStrategies routes = RoutingStrategies.Bubble)
 {
     item.AddHandler(routed_event, function.GetRoutedEventHandler <RoutedEventArgs>(), routes);
 }
Example #16
0
 static public void AddInputBinding(this FrameworkElement item, FunctionSyncro function_syncro, Key key, ModifierKeys modifiers)
 {
     item.AddInputBinding(function_syncro, new KeyGesture(key, modifiers));
 }
Example #17
0
 static public void AddKeyBinding(this Control item, FunctionSyncro function_syncro, KeyGesture gesture)
 {
     item.AddKeyBinding(function_syncro.GetCommand(), gesture);
 }