static PreventPropagation() { jQuery.OnDocumentReady(delegate() { jQuery.Select("#draggablePreventPropagation") .Plugin <DraggableObject>() .Draggable(); DropEventHandler drop = new DropEventHandler(delegate(jQueryEvent e, DropEvent ui) { jQuery.This .AddClass("ui-state-highlight") .Find("> p") .Html("Dropped!"); }); jQuery.Select("#droppablePreventPropagation1, #droppablePreventPropagation1-inner") .Plugin <DroppableObject>() .Droppable(new DroppableOptions("activeClass", "ui-state-hover" , "hoverClass", "ui-state-active" , "drop", drop)); jQuery.Select("#droppablePreventPropagation2, #droppablePreventPropagation2-inner") .Plugin <DroppableObject>() .Droppable(new DroppableOptions("activeClass", "ui-state-hover" , "hoverClass", "ui-state-active" , "greedy", true , "drop", drop)); }); }
static VisualFeedback() { jQuery.OnDocumentReady(delegate() { jQuery.Select("#draggableVisualFeedback1, #draggableVisualFeedback2") .Plugin <DraggableObject>() .Draggable(); DropEventHandler drop = new DropEventHandler(delegate(jQueryEvent e, DropEvent ui) { jQuery.This .AddClass("ui-state-highlight") .Find("p") .Html("Dropped!"); }); jQuery.Select("#droppableVisualFeedback1") .Plugin <DroppableObject>() .Droppable(new DroppableOptions("hoverClass", "ui-state-active" , "drop", drop)); jQuery.Select("#droppableVisualFeedback2") .Plugin <DroppableObject>() .Droppable(new DroppableOptions("accept", "#draggableVisualFeedback2" , "activeClass", "ui-state-hover" , "drop", drop)); }); }
static VisualFeedback() { jQuery.OnDocumentReady(delegate() { jQuery.Select("#draggableVisualFeedback1, #draggableVisualFeedback2") .Plugin<DraggableObject>() .Draggable(); DropEventHandler drop = new DropEventHandler(delegate(jQueryEvent e, DropEvent ui) { jQuery.This .AddClass("ui-state-highlight") .Find("p") .Html("Dropped!"); }); jQuery.Select("#droppableVisualFeedback1") .Plugin<DroppableObject>() .Droppable(new DroppableOptions("hoverClass", "ui-state-active" , "drop", drop)); jQuery.Select("#droppableVisualFeedback2") .Plugin<DroppableObject>() .Droppable(new DroppableOptions("accept", "#draggableVisualFeedback2" , "activeClass", "ui-state-hover" , "drop", drop)); }); }
static PreventPropagation() { jQuery.OnDocumentReady(delegate() { jQuery.Select("#draggablePreventPropagation") .Plugin<DraggableObject>() .Draggable(); DropEventHandler drop = new DropEventHandler(delegate(jQueryEvent e, DropEvent ui) { jQuery.This .AddClass("ui-state-highlight") .Find("> p") .Html("Dropped!"); }); jQuery.Select("#droppablePreventPropagation1, #droppablePreventPropagation1-inner") .Plugin<DroppableObject>() .Droppable(new DroppableOptions( "activeClass", "ui-state-hover" , "hoverClass", "ui-state-active" , "drop", drop)); jQuery.Select("#droppablePreventPropagation2, #droppablePreventPropagation2-inner") .Plugin<DroppableObject>() .Droppable(new DroppableOptions("activeClass", "ui-state-hover" , "hoverClass", "ui-state-active" , "greedy", true , "drop", drop)); }); }
/// <summary> /// Method overrides OnApplyTemplate to add handlers / get references to control in the template /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); // all our controls are inside of a canvas control. Because of this, it doesn't // automatically resize. We need to make sure the parent control is resized properly // get the main control host MainControlHost = (Grid)this.GetTemplateChild("MainControlHost"); // get the ghost control host GhostContentControl = (Grid)this.GetTemplateChild("GhostContentControl"); // get the main content host MainContentControl = (Grid)this.GetTemplateChild("MainContentControl"); // add the content if (plstContent.Children.Count > 0) { DragSource tmp = (DragSource)plstContent.Children[0]; plstContent.Children.Remove(tmp); Content = tmp; //ResetContent(); } // add the ghost? if (GhostVisibility == Visibility.Visible) { if (Ghost != null) { GhostContentControl.Children.Clear(); GhostContentControl.Children.Add(Ghost); } } // get bounding border for hover-effects BoundingBorder = (Border)this.GetTemplateChild("BoundingBorder"); // add handler for droptargetentered DropTargetEntered += new DropEventHandler(DropTargetBase_DropTargetEntered); // add handler for droptargetleft DropTargetLeft += new DropEventHandler(DropTargetBase_DropTargetLeft); // add handler for dragsourcedropped //DragSourceDropped += new DropEventHandler(DropTargetBase_DragSourceDropped); InternalDragSourceDropped += new DropEventHandler(DropTargetBase_InternalDragSourceDropped); if (AllowPositionSave) { (Application.Current.RootVisual as FrameworkElement).SizeChanged += new SizeChangedEventHandler(DropTarget_SizeChanged); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> protected virtual void Dispose(bool disposing) { if (disposing) { MainControlHost = null; GhostContentControl = null; MainContentControl = null; BoundingBorder = null; // remove handlers DropTargetEntered -= new DropEventHandler(DropTargetBase_DropTargetEntered); DropTargetLeft -= new DropEventHandler(DropTargetBase_DropTargetLeft); InternalDragSourceDropped -= new DropEventHandler(DropTargetBase_InternalDragSourceDropped); //if (AllowPositionSave) //{ (Application.Current.RootVisual as FrameworkElement).SizeChanged -= new SizeChangedEventHandler(DropTarget_SizeChanged); //} } // Clean up all native resources }