本文整理汇总了C#中System.Windows.Controls.Primitives.DragDeltaEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DragDeltaEventArgs类的具体用法?C# DragDeltaEventArgs怎么用?C# DragDeltaEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DragDeltaEventArgs类属于System.Windows.Controls.Primitives命名空间,在下文中一共展示了DragDeltaEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: headerThumb_DragDelta
private void headerThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
var parentWindow = Window.GetWindow(this);
if (parentWindow == null) return;
parentWindow.Left += e.HorizontalChange;
parentWindow.Top += e.VerticalChange;
}
示例2: ResizeThumb_DragDelta
private void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.designerItem != null && this.designerCanvas != null && this.designerItem.IsSelected)
{
double minLeft = double.MaxValue;
double minTop = double.MaxValue;
double minDeltaHorizontal = double.MaxValue;
double minDeltaVertical = double.MaxValue;
double dragDeltaVertical, dragDeltaHorizontal;
foreach (DesignerItem item in this.designerCanvas.SelectedItems)
{
if (!item.CanResize)
continue;
minLeft = Math.Min(Canvas.GetLeft(item), minLeft);
minTop = Math.Min(Canvas.GetTop(item), minTop);
minDeltaVertical = Math.Min(minDeltaVertical, item.ActualHeight - item.MinHeight);
minDeltaHorizontal = Math.Min(minDeltaHorizontal, item.ActualWidth - item.MinWidth);
}
foreach (DesignerItem item in this.designerCanvas.SelectedItems)
{
if (!item.CanResize)
continue;
switch (VerticalAlignment)
{
case VerticalAlignment.Bottom:
dragDeltaVertical = Math.Min(-e.VerticalChange, minDeltaVertical);
item.Height = item.ActualHeight - dragDeltaVertical;
break;
case VerticalAlignment.Top:
dragDeltaVertical = Math.Min(Math.Max(-minTop, e.VerticalChange), minDeltaVertical);
Canvas.SetTop(item, Canvas.GetTop(item) + dragDeltaVertical);
item.Height = item.ActualHeight - dragDeltaVertical;
break;
}
switch (HorizontalAlignment)
{
case HorizontalAlignment.Left:
dragDeltaHorizontal = Math.Min(Math.Max(-minLeft, e.HorizontalChange), minDeltaHorizontal);
Canvas.SetLeft(item, Canvas.GetLeft(item) + dragDeltaHorizontal);
item.Width = item.ActualWidth - dragDeltaHorizontal;
break;
case HorizontalAlignment.Right:
dragDeltaHorizontal = Math.Min(-e.HorizontalChange, minDeltaHorizontal);
item.Width = item.ActualWidth - dragDeltaHorizontal;
break;
}
item.Width = (double)MathHelper.Clamp((float)item.Width, (float)item.MinWidth, (float)Math.Min(item.MaxWidth, designerCanvas.ActualWidth - Canvas.GetLeft(item)));
item.Height = (double)MathHelper.Clamp((float)item.Height, (float)item.MinHeight, (float)Math.Min(item.MaxHeight, designerCanvas.ActualHeight - Canvas.GetTop(item)));
}
e.Handled = true;
}
}
示例3: MoveThumb_DragDelta
private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.designerItem != null && this.designerCanvas != null && this.designerItem.IsSelected)
{
double minLeft = double.MaxValue;
double minTop = double.MaxValue;
foreach (DesignerItem item in this.designerCanvas.SelectedItems)
{
minLeft = Math.Min(Canvas.GetLeft(item), minLeft);
minTop = Math.Min(Canvas.GetTop(item), minTop);
}
double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
double deltaVertical = Math.Max(-minTop, e.VerticalChange);
foreach (DesignerItem item in this.designerCanvas.SelectedItems)
{
Canvas.SetLeft(item, Canvas.GetLeft(item) + deltaHorizontal);
Canvas.SetTop(item, Canvas.GetTop(item) + deltaVertical);
}
this.designerCanvas.InvalidateMeasure();
e.Handled = true;
}
}
示例4: DragDeltaHandle
private void DragDeltaHandle(object sender, DragDeltaEventArgs e)
{
var control = this.TemplatedParent as DiagramItem;
if (control != null) {
var diagram = VisualTreeHelper.GetParent(control) as DiagramCanvas;
if (diagram != null) {
double hDelta = control.ParentDiagram.StickToDiagramGrid ? 10 * Math.Ceiling(e.HorizontalChange / 10) : e.HorizontalChange;
double vDelta = control.ParentDiagram.StickToDiagramGrid ? 10 * Math.Ceiling(e.VerticalChange / 10) : e.VerticalChange;
bool isHorizontalMove = !control.ParentDiagram.StickToDiagramGrid || Math.Abs(e.HorizontalChange) > 5.0;
bool isVerticalMove = !control.ParentDiagram.StickToDiagramGrid || Math.Abs(e.VerticalChange) > 5.0;
foreach (var item in diagram.Children.OfType<DiagramItem>()) {
if (!item.IsSelected) continue;
double left = Canvas.GetLeft(item);
double top = Canvas.GetTop(item);
if (isHorizontalMove && left + hDelta > 0)
Canvas.SetLeft(item, left + hDelta);
if (isVerticalMove && top + vDelta > 0)
Canvas.SetTop(item, top + vDelta);
}
diagram.InvalidateMeasure();
}
}
}
示例5: MoveThumb_DragDelta
private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.element != null && this.canvasWorkspace != null && this.element.IsSelected)
{
double minLeft = double.MaxValue;
double minTop = double.MaxValue;
foreach (BaseObject item in this.canvasWorkspace.SelectedElements)
{
minLeft = Math.Min(Canvas.GetLeft(item), minLeft);
minTop = Math.Min(Canvas.GetTop(item), minTop);
}
double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
double deltaVertical = Math.Max(-minTop, e.VerticalChange);
foreach (BaseObject item in this.canvasWorkspace.SelectedElements)
{
Canvas.SetLeft(item, Canvas.GetLeft(item) + deltaHorizontal);
Canvas.SetTop(item, Canvas.GetTop(item) + deltaVertical);
}
this.canvasWorkspace.InvalidateMeasure();
e.Handled = true;
}
}
示例6: MoveThumbDragDelta
private void MoveThumbDragDelta(object sender, DragDeltaEventArgs e)
{
var designerItem = DataContext as Control;
var contentControl = DataContext as ContentControl;
if (contentControl != null)
{
var displayItem = contentControl.Content as DisplayItem;
if (displayItem != null)
{
if (!displayItem.IsUnlocked)
{
return;
}
}
}
if (designerItem != null)
{
var left = Canvas.GetLeft(designerItem);
var top = Canvas.GetTop(designerItem);
Canvas.SetLeft(designerItem, left + e.HorizontalChange);
Canvas.SetTop(designerItem, top + e.VerticalChange);
}
}
示例7: MoveThumb_DragDelta
private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.designerItem != null)
{
Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
if (this.rotateTransform != null)
{
dragDelta = this.rotateTransform.Transform(dragDelta);
}
Canvas canvas = this.designerItem.Parent as Canvas;
if (canvas == null)
return;
Canvas.SetLeft(this.designerItem, Canvas.GetLeft(this.designerItem) + dragDelta.X);
Canvas.SetTop(this.designerItem, Canvas.GetTop(this.designerItem) + dragDelta.Y);
if (Canvas.GetLeft(this.designerItem) < 0)
Canvas.SetLeft(this.designerItem, 0);
if (Canvas.GetLeft(this.designerItem) + this.ActualWidth > canvas.ActualWidth)
Canvas.SetLeft(this.designerItem, canvas.ActualWidth - this.ActualWidth);
if (Canvas.GetTop(this.designerItem) < 0)
Canvas.SetTop(this.designerItem, 0);
if (Canvas.GetTop(this.designerItem) + this.ActualHeight > canvas.ActualHeight)
Canvas.SetTop(this.designerItem, canvas.ActualHeight - this.ActualHeight);
}
}
示例8: MoveThumb_DragDelta
private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
Control tv = this.DataContext as Control;
Canvas tvship = VisualTreeHelper.GetParent(tv) as Canvas;
if (tv != null)
{
double left = Canvas.GetLeft(tv);
double top = Canvas.GetTop(tv);
double minLeft = double.IsNaN(left) ? 0 : left;
double minTop = double.IsNaN(top) ? 0 : top;
double deltaHorizontal = System.Math.Max(-minLeft, e.HorizontalChange);
double deltaVertical = System.Math.Max(-minTop, e.VerticalChange);
if (tvship != null && !double.IsNaN(tvship.Width) && !double.IsNaN(tvship.Height))
{
deltaHorizontal = System.Math.Min(tvship.Width - left - tv.Width, deltaHorizontal);
deltaVertical = System.Math.Min(tvship.Height - top - tv.Height, deltaVertical);
}
Canvas.SetLeft(tv, left + deltaHorizontal);
Canvas.SetTop(tv, top + deltaVertical);
}
}
示例9: ThumbOnDragDelta
private void ThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs)
{
var thumb = (Thumb)sender;
var hook = GetHookPointFromAlignments(thumb.HorizontalAlignment, thumb.VerticalAlignment);
if (IsASideHook(hook))
{
designable.AnchorPoint = hook;
if (IsHorizontalHook(hook))
{
var widthDelta = (0.5 - hook.X) * 2 * dragDeltaEventArgs.HorizontalChange;
designable.Width += widthDelta ;
}
if (IsVerticalHook(hook))
{
var heightDelta = (0.5 - hook.Y) * 2 * dragDeltaEventArgs.VerticalChange;
designable.Height += heightDelta;
}
}
else
{
var leftDelta = dragDeltaEventArgs.HorizontalChange;
var topDelta = dragDeltaEventArgs.VerticalChange;
designable.Left += leftDelta;
designable.Top += topDelta;
}
dragDeltaEventArgs.Handled = true;
}
示例10: DragThumb_DragDelta
void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
DesignerItemViewModelBase designerItem = this.DataContext as DesignerItemViewModelBase;
if (designerItem != null && designerItem.IsSelected)
{
double minLeft = double.MaxValue;
double minTop = double.MaxValue;
// we only move DesignerItems
var designerItems = designerItem.SelectedItems;
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
{
double left = item.Left;
double top = item.Top;
minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
minTop = double.IsNaN(top) ? 0 : Math.Min(top, minTop);
double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
double deltaVertical = Math.Max(-minTop, e.VerticalChange);
item.Left += deltaHorizontal;
item.Top += deltaVertical;
}
e.Handled = true;
}
}
示例11: DragThumb_DragDelta
void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
ItemsControl item = this.DataContext as ItemsControl;
ContentPresenter contentPresenter = VisualTreeHelper.GetParent(item) as ContentPresenter;
double minLeft = double.MaxValue;
double minTop = double.MaxValue;
double left = Canvas.GetLeft(contentPresenter);
double top = Canvas.GetTop(contentPresenter);
minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
minTop = double.IsNaN(top) ? 0 : Math.Min(top, minTop);
double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
double deltaVertical = Math.Max(-minTop, e.VerticalChange);
if (double.IsNaN(left)) left = 0;
if (double.IsNaN(top)) top = 0;
Canvas.SetLeft(contentPresenter, left + deltaHorizontal);
Canvas.SetTop(contentPresenter, top + deltaVertical);
e.Handled = false;
}
示例12: DragablzDragDeltaEventArgs
public DragablzDragDeltaEventArgs(DragablzItem dragablzItem, DragDeltaEventArgs dragDeltaEventArgs)
: base(dragablzItem)
{
if (dragDeltaEventArgs == null) throw new ArgumentNullException("dragDeltaEventArgs");
_dragDeltaEventArgs = dragDeltaEventArgs;
}
示例13: PART_RESIZE_BOTRIGHT_DragDelta
private void PART_RESIZE_BOTRIGHT_DragDelta(object sender, DragDeltaEventArgs e)
{
Thumb _thumb = (Thumb)sender;
if (_thumb != null)
{
Window _window = Window.GetWindow(_thumb);
if (_window != null && _window.IsInitialized)
{
double _newWidth = _window.Width + e.HorizontalChange;
if (_newWidth > 0)
{
_window.Width = _newWidth > _window.MinWidth ? _newWidth : _window.MinWidth;
}
double _newHeight = _window.Height + e.VerticalChange;
if (_newHeight > 0)
{
_window.Height = _newHeight > _window.MinHeight ? _newHeight : _window.MinHeight;
}
}
}
}
示例14: ResizeThumb_DragDelta
private void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
var designerItem = DataContext as DesignerItem;
var designer = VisualTreeHelper.GetParent(designerItem) as DesignerCanvas;
if (designerItem != null && designer != null && designerItem.IsSelected)
{
double minLeft, minTop, minDeltaHorizontal, minDeltaVertical;
double dragDeltaVertical, dragDeltaHorizontal, scale;
var selectedDesignerItems = designer.SelectionService.CurrentSelection.OfType<DesignerItem>();
CalculateDragLimits(selectedDesignerItems,
out minLeft,
out minTop,
out minDeltaHorizontal,
out minDeltaVertical);
foreach (var item in selectedDesignerItems)
{
if (item != null && item.ParentID == Guid.Empty)
{
switch (VerticalAlignment)
{
case VerticalAlignment.Bottom:
dragDeltaVertical = Math.Min(-e.VerticalChange, minDeltaVertical);
scale = (item.ActualHeight - dragDeltaVertical)/item.ActualHeight;
DragBottom(scale, item, designer.SelectionService);
break;
case VerticalAlignment.Top:
var top = Canvas.GetTop(item);
dragDeltaVertical = Math.Min(Math.Max(-minTop, e.VerticalChange), minDeltaVertical);
scale = (item.ActualHeight - dragDeltaVertical)/item.ActualHeight;
DragTop(scale, item, designer.SelectionService);
break;
default:
break;
}
switch (HorizontalAlignment)
{
case HorizontalAlignment.Left:
var left = Canvas.GetLeft(item);
dragDeltaHorizontal = Math.Min(Math.Max(-minLeft, e.HorizontalChange), minDeltaHorizontal);
scale = (item.ActualWidth - dragDeltaHorizontal)/item.ActualWidth;
DragLeft(scale, item, designer.SelectionService);
break;
case HorizontalAlignment.Right:
dragDeltaHorizontal = Math.Min(-e.HorizontalChange, minDeltaHorizontal);
scale = (item.ActualWidth - dragDeltaHorizontal)/item.ActualWidth;
DragRight(scale, item, designer.SelectionService);
break;
default:
break;
}
}
}
e.Handled = true;
}
}
示例15: OnMoveThumbDragDelta
private void OnMoveThumbDragDelta(object sender, DragDeltaEventArgs e)
{
var window = VisualTreeExtension.FindMdiWindow(this);
if (window != null)
{
if (window.WindowState == WindowState.Maximized)
{
window.Normalize();
}
if (window.WindowState != WindowState.Minimized)
{
window.LastLeft = Canvas.GetLeft(window);
window.LastTop = Canvas.GetTop(window);
var candidateLeft = window.LastLeft + e.HorizontalChange;
var candidateTop = window.LastTop + e.VerticalChange;
Canvas.SetLeft(window, Math.Min(Math.Max(0,candidateLeft), window.Container.ActualWidth -25));
Canvas.SetTop(window, Math.Min(Math.Max(0, candidateTop), window.Container.ActualHeight - 25));
}
}
}