C# Class Dev2.CustomControls.Panels.DragCanvas

A Canvas which manages dragging of the UIElements it contains.
Documentation: http://www.codeproject.com/KB/WPF/DraggingElementsInCanvas.aspx
Inheritance: System.Windows.Controls.Canvas
显示文件 Open project: Warewolf-ESB/Warewolf

Public Properties

Property Type Description
AllowDragOutOfViewProperty System.Windows.DependencyProperty
AllowDraggingProperty System.Windows.DependencyProperty
CanBeDraggedProperty System.Windows.DependencyProperty

Public Methods

Method Description
BringToFront ( UIElement element ) : void

Assigns the element a z-index which will ensure that it is in front of every other element in the Canvas. The z-index of every element whose z-index is between the element's old and new z-index will have its z-index decremented by one.

FindCanvasChild ( DependencyObject depObj ) : UIElement

Walks up the visual tree starting with the specified DependencyObject, looking for a UIElement which is a child of the Canvas. If a suitable element is not found, null is returned. If the 'depObj' object is a UIElement in the Canvas's Children collection, it will be returned.

GetCanBeDragged ( UIElement uiElement ) : bool

Returns true if the specified UIElement is allowed to be dragged, else false.

SendToBack ( UIElement element ) : void

Assigns the element a z-index which will ensure that it is behind every other element in the Canvas. The z-index of every element whose z-index is between the element's old and new z-index will have its z-index incremented by one.

SetCanBeDragged ( UIElement uiElement, bool value ) : void

Sets the CanBeDragged attached property for the specified UIElement.

Protected Methods

Method Description
OnPreviewMouseLeftButtonDown ( System.Windows.Input.MouseButtonEventArgs e ) : void

Overrides base implementation to support element dragging.

OnPreviewMouseLeftButtonUp ( System.Windows.Input.MouseButtonEventArgs e ) : void

Release item being dragged once the mouse is up

OnPreviewMouseMove ( System.Windows.Input.MouseEventArgs e ) : void

Overrides base implementation to support element dragging.

OnPreviewMouseUp ( System.Windows.Input.MouseButtonEventArgs e ) : void

Overrides base implementation to support element dragging.

Private Methods

Method Description
CalculateDragElementRect ( double newHorizOffset, double newVertOffset ) : Rect

Returns a Rect which describes the bounds of the element being dragged.

DragCanvas ( ) : System
ResolveOffset ( double side1, double side2, bool &useSide1 ) : double

Determines one component of a UIElement's location within a Canvas (either the horizontal or vertical offset).

UpdateZOrder ( UIElement element, bool bringToFront ) : void

Helper method used by the BringToFront and SendToBack methods.

Method Details

BringToFront() public method

Assigns the element a z-index which will ensure that it is in front of every other element in the Canvas. The z-index of every element whose z-index is between the element's old and new z-index will have its z-index decremented by one.
public BringToFront ( UIElement element ) : void
element UIElement /// The element to be sent to the front of the z-order. ///
return void

FindCanvasChild() public method

Walks up the visual tree starting with the specified DependencyObject, looking for a UIElement which is a child of the Canvas. If a suitable element is not found, null is returned. If the 'depObj' object is a UIElement in the Canvas's Children collection, it will be returned.
public FindCanvasChild ( DependencyObject depObj ) : UIElement
depObj System.Windows.DependencyObject /// A DependencyObject from which the search begins. ///
return UIElement

GetCanBeDragged() public static method

Returns true if the specified UIElement is allowed to be dragged, else false.
public static GetCanBeDragged ( UIElement uiElement ) : bool
uiElement UIElement The UIElement to check for dragging permission.
return bool

OnPreviewMouseLeftButtonDown() protected method

Overrides base implementation to support element dragging.
protected OnPreviewMouseLeftButtonDown ( System.Windows.Input.MouseButtonEventArgs e ) : void
e System.Windows.Input.MouseButtonEventArgs
return void

OnPreviewMouseLeftButtonUp() protected method

Release item being dragged once the mouse is up
protected OnPreviewMouseLeftButtonUp ( System.Windows.Input.MouseButtonEventArgs e ) : void
e System.Windows.Input.MouseButtonEventArgs
return void

OnPreviewMouseMove() protected method

Overrides base implementation to support element dragging.
protected OnPreviewMouseMove ( System.Windows.Input.MouseEventArgs e ) : void
e System.Windows.Input.MouseEventArgs
return void

OnPreviewMouseUp() protected method

Overrides base implementation to support element dragging.
protected OnPreviewMouseUp ( System.Windows.Input.MouseButtonEventArgs e ) : void
e System.Windows.Input.MouseButtonEventArgs
return void

SendToBack() public method

Assigns the element a z-index which will ensure that it is behind every other element in the Canvas. The z-index of every element whose z-index is between the element's old and new z-index will have its z-index incremented by one.
public SendToBack ( UIElement element ) : void
element UIElement /// The element to be sent to the back of the z-order. ///
return void

SetCanBeDragged() public static method

Sets the CanBeDragged attached property for the specified UIElement.
public static SetCanBeDragged ( UIElement uiElement, bool value ) : void
uiElement UIElement The UIElement to set the property for.
value bool Pass true if the element can be dragged, else false.
return void

Property Details

AllowDragOutOfViewProperty public_oe static_oe property

Identifies the DragCanvas's AllowDragOutOfView dependency property. This field is read-only.
public static DependencyProperty,System.Windows AllowDragOutOfViewProperty
return System.Windows.DependencyProperty

AllowDraggingProperty public_oe static_oe property

Identifies the DragCanvas's AllowDragging dependency property. This field is read-only.
public static DependencyProperty,System.Windows AllowDraggingProperty
return System.Windows.DependencyProperty

CanBeDraggedProperty public_oe static_oe property

Identifies the RegexValidator's ErrorMessage attached property. This field is read-only.
public static DependencyProperty,System.Windows CanBeDraggedProperty
return System.Windows.DependencyProperty