예제 #1
0
        private void Target_Drop(object s, DragEventArgs e)
        {
            if (IsInitialized())
            {
                if (IsDragging)
                {
                    e.Handled = true;
                    if (e.Data.GetDataPresent(Name))
                    {
                        DropEventArgs ea = new DropEventArgs()
                        {
                            Package = e.Data.GetData(Name),
                            Source  = currentSource
                        };

                        // Invoke the CanDrop event again to ask the target if we're allowed to drop
                        CanDrop.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(ea);

                        if (ea.AllowDrop)
                        {
                            Drop.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(ea);
                            // Also fire DragLeave since the system won't do this for us.
                            DragLeave.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke();
                        }
                    }
                }
            }
        }
예제 #2
0
        private void Target_DragOver(object s, DragEventArgs e)
        {
            if (IsInitialized())
            {
                if (IsDragging)
                {
                    e.Handled = true;

                    DropEventArgs ea = new DropEventArgs()
                    {
                        Package = e.Data.GetData(Name),
                        Source  = currentSource
                    };

                    CanDrop.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(ea);

                    if (ea.AllowDrop)
                    {
                        e.Effects = DragDropEffects.Move;
                    }
                    else
                    {
                        e.Effects = DragDropEffects.None;
                    }
                }
            }
        }
예제 #3
0
        private void Target_Drop(object s, DragEventArgs e)
        {
            if (IsInitialized())
            {
                if (IsDragging)
                {
                    e.Handled = true;
                    if (e.Data.GetDataPresent(Name))
                    {
                        DropEventArgs ea = new DropEventArgs()
                        {
                            Package = e.Data.GetData(Name),
                            Source = currentSource
                        };

                        // Invoke the CanDrop event again to ask the target if we're allowed to drop
                        CanDrop.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(ea);

                        if (ea.AllowDrop)
                        {
                            Drop.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(ea);
                            // Also fire DragLeave since the system won't do this for us.
                            DragLeave.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke();
                        }
                    }
                }
            }
        }
예제 #4
0
        private void Target_DragLeave(object s, DragEventArgs e)
        {
            if (IsInitialized())
            {
                if (IsDragging)
                {
                    e.Handled = true;
                    DropEventArgs ea = new DropEventArgs()
                    {
                        Package = e.Data.GetData(Name),
                        Source = currentSource
                    };

                    CanDrop.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke(ea);

                    if (ea.AllowDrop)
                    {
                        DragLeave.GetInvocationList().Where(d => d.Target == s).First().DynamicInvoke();
                    }
                }
            }
        }