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; } } } }
/// <summary> /// Handler for resizing from the bottom-right. /// </summary> private void HandleBottomRight(object sender, DragDeltaEventArgs args) { FrameworkElement adornedElement = this.AdornedElement as FrameworkElement; Thumb hitThumb = sender as Thumb; if (adornedElement == null || hitThumb == null) return; FrameworkElement parentElement = adornedElement.Parent as FrameworkElement; // Ensure that the Width and Height are properly initialized after the resize. EnforceSize(adornedElement); // Change the size by the amount the user drags the mouse, as long as it's larger // than the width or height of an adorner, respectively. adornedElement.Width = Math.Max(adornedElement.Width + args.HorizontalChange, hitThumb.DesiredSize.Width); adornedElement.Height = Math.Max(args.VerticalChange + adornedElement.Height, hitThumb.DesiredSize.Height); if (adornedElement.Width > parentElement.Width) { parentElement.Width = adornedElement.Width; } if (adornedElement.Height > parentElement.Height) { parentElement.Height = adornedElement.Height; } }
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Canvas.SetLeft(thumb1, Canvas.GetLeft(thumb1) + e.HorizontalChange); Canvas.SetTop(thumb1, Canvas.GetTop(thumb1) + e.VerticalChange); //lineH.Y1 = Canvas.GetTop(thumb1) + e.VerticalChange; //lineH.Y2 = Canvas.GetTop(thumb1) + e.VerticalChange; }
private void thumb2_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { var pos = CalcPos(Thumb2, e); Marker2 = (int)pos; this.RaiseMoveMarker2(); }
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); } }
void ThumbRight_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if (this.Width + e.HorizontalChange > 10) { this.Width += e.HorizontalChange; } }
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); } }
/// <summary> /// Raised while dragging the <see cref="Thumb">Thumb</see>. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event arguments.</param> /// <exception cref="System.ArgumentNullException">e</exception> protected override void OnDragDelta(object sender, DragDeltaEventArgs e) { if (e == null) throw new ArgumentNullException("e"); this.DragOffset += e.HorizontalChange * this.ZoomFactor; this.Offset = Math.Max(this.UncheckedOffset, Math.Min(this.CheckedOffset, this.DragOffset)); }
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)); } } }
/*拖动Thumb*/ private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Thumb myThumb = (Thumb)sender; double nTop = Canvas.GetTop(myThumb) + e.VerticalChange; double nLeft = Canvas.GetLeft(myThumb) + e.HorizontalChange; //防止Thumb控件被拖出容器。 if (nTop <= 0) { nTop = 0; } if (nTop >= (g.Height - myThumb.Height)) { nTop = g.Height - myThumb.Height; } if (nLeft <= 0) { nLeft = 0; } if (nLeft >= (g.Width - myThumb.Width)) { nLeft = g.Width - myThumb.Width; } Canvas.SetTop(myThumb, nTop); Canvas.SetLeft(myThumb, nLeft); tt.Text = "Top:" + nTop.ToString() + "\nLeft:" + nLeft.ToString(); }
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { var node = (sender as FrameworkElement).DataContext as Node; if (node == null) { return; } Diagram diagram = this.DataContext as Diagram; if (diagram.SelectedItems != null && node.IsSelected == true) { if (diagram.SelectedItems.Count == 0) { MoveNode(e.HorizontalChange, e.VerticalChange, node, diagram); } else { MoveNodes(e.HorizontalChange, e.VerticalChange, diagram); } } else { MoveNode(e.HorizontalChange, e.VerticalChange, node, diagram); } e.Handled = true; }
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if (this._left_thumb.IsMouseOver || this._right_thumb.IsMouseOver) { return; } Debug.WriteLine(Canvas.GetLeft(this)); if ((Canvas.GetLeft(this) + e.HorizontalChange) < 0) { Canvas.SetLeft(this, 0); this.OnDragDeltaChanged(); this.OnDragCompletedChanged(); return; } Canvas parent = this.Parent as Canvas; if (parent.ActualWidth - Canvas.GetLeft(this) - this.Width - e.HorizontalChange < 0) { Canvas.SetLeft(this, parent.ActualWidth - this.Width); this.OnDragDeltaChanged(); this.OnDragCompletedChanged(); return; } Canvas.SetLeft(this, Canvas.GetLeft(this) + e.HorizontalChange); this.OnDragDeltaChanged(); this.OnDragCompletedChanged(); }
private void Thumb_Left_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if (this.Width < minValue && e.HorizontalChange > 0) { return; } if ((Canvas.GetLeft(this) + e.HorizontalChange) < 0) { Canvas.SetLeft(this, 0); return; } if (this.Width - e.HorizontalChange < 0) { return; } this.Width -= e.HorizontalChange; Canvas.SetLeft(this, Canvas.GetLeft(this) + e.HorizontalChange); e.Handled = true; this.OnDragDeltaChanged(ThumbType.Left); }
private void Part_toggle_slider_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if ((e.OriginalSource as Thumb).IsDragging) { ToggleSliderThumbMoving();// ToggleSliderThumbDownMove?.Invoke(this, e); } }
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; }
private void ResizeThumb_DragDelta(Object sender, DragDeltaEventArgs e) { var designerItem = DataContext as Control; if (designerItem != null) { Double deltaVertical, deltaHorizontal; switch (VerticalAlignment) { case VerticalAlignment.Bottom: deltaVertical = Math.Min(-e.VerticalChange, designerItem.ActualHeight - designerItem.MinHeight); designerItem.Height -= deltaVertical; break; case VerticalAlignment.Top: deltaVertical = Math.Min(e.VerticalChange, designerItem.ActualHeight - designerItem.MinHeight); Canvas.SetTop(designerItem, Canvas.GetTop(designerItem) + deltaVertical); designerItem.Height -= deltaVertical; break; } switch (HorizontalAlignment) { case HorizontalAlignment.Left: deltaHorizontal = Math.Min(e.HorizontalChange, designerItem.ActualWidth - designerItem.MinWidth); Canvas.SetLeft(designerItem, Canvas.GetLeft(designerItem) + deltaHorizontal); designerItem.Width -= deltaHorizontal; break; case HorizontalAlignment.Right: deltaHorizontal = Math.Min(-e.HorizontalChange, designerItem.ActualWidth - designerItem.MinWidth); designerItem.Width -= deltaHorizontal; break; } } e.Handled = true; }
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; } }
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; } }
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, Math.Min(Canvas.GetLeft(item) + deltaHorizontal, designerCanvas.ActualWidth - item.Width)); Canvas.SetTop(item, Math.Min(Canvas.GetTop(item) + deltaVertical, designerCanvas.ActualHeight - item.Height)); if (item.PropertyWindow != null) item.PropertyWindow.Moved(); else if (item.Model != null) item.Model.Moved(); } this.designerCanvas.InvalidateMeasure(); e.Handled = true; } }
private void DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Thumb thumb = sender as Thumb; Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.HorizontalChange); Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.VerticalChange); }
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(); } } }
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Grid grid = (sender as Thumb).Tag as Grid; Canvas.SetLeft(grid, Canvas.GetLeft(grid) + e.HorizontalChange); Canvas.SetTop(grid, Canvas.GetTop(grid) + e.VerticalChange); }
private void PART_GradientDetailsLinearBottomThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Canvas.SetLeft(PART_GradientDetailsLinearBottomThumb, Canvas.GetLeft(PART_GradientDetailsLinearBottomThumb) + e.HorizontalChange); Canvas.SetTop(PART_GradientDetailsLinearBottomThumb, Canvas.GetTop(PART_GradientDetailsLinearBottomThumb) + e.VerticalChange); if (Canvas.GetLeft(PART_GradientDetailsLinearBottomThumb) < 0) { Canvas.SetLeft(PART_GradientDetailsLinearBottomThumb, 0); } if (Canvas.GetTop(PART_GradientDetailsLinearBottomThumb) < 0) { Canvas.SetTop(PART_GradientDetailsLinearBottomThumb, 0); } if (Canvas.GetLeft(PART_GradientDetailsLinearBottomThumb) > PART_GradientDetailsLinearGrid.RenderSize.Width - PART_GradientDetailsLinearBottomThumb.Width / 2) { Canvas.SetLeft(PART_GradientDetailsLinearBottomThumb, PART_GradientDetailsLinearGrid.RenderSize.Width - PART_GradientDetailsLinearBottomThumb.Width / 2); } if (Canvas.GetTop(PART_GradientDetailsLinearBottomThumb) > PART_GradientDetailsLinearGrid.RenderSize.Height - PART_GradientDetailsLinearBottomThumb.Height / 2) { Canvas.SetTop(PART_GradientDetailsLinearBottomThumb, PART_GradientDetailsLinearGrid.RenderSize.Height - PART_GradientDetailsLinearBottomThumb.Height / 2); } EndPoint = new Point( Canvas.GetLeft(PART_GradientDetailsLinearBottomThumb) + PART_GradientDetailsLinearBottomThumb.Width / 2, Canvas.GetTop(PART_GradientDetailsLinearBottomThumb) + PART_GradientDetailsLinearBottomThumb.Height / 2 ); PART_GradientDetailsLinearLine.X2 = EndPoint.X; PART_GradientDetailsLinearLine.Y2 = EndPoint.Y; double XX; double YY; if (EndPoint.X >= PART_GradientDetailsLinearGrid.RenderSize.Width) { XX = Math.Round(EndPoint.X / PART_GradientDetailsLinearGrid.RenderSize.Width, 2); } else { XX = Math.Round(EndPoint.X / PART_GradientDetailsLinearGrid.RenderSize.Width - 0.03, 2); } if (EndPoint.Y >= PART_GradientDetailsLinearGrid.RenderSize.Height) { YY = Math.Round(EndPoint.Y / PART_GradientDetailsLinearGrid.RenderSize.Height, 2); } else { YY = Math.Round(EndPoint.Y / PART_GradientDetailsLinearGrid.RenderSize.Height - 0.03, 2); } EndPoint = new Point(XX, YY); SetLinearGradientBrush(); test1.Content = "X: " + EndPoint.X + "- Y: " + EndPoint.Y; }
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; }
private void Thumb_Right_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if (this.Width < minValue && e.HorizontalChange < 0) { return; } Canvas parent = this.Parent as Canvas; if (parent.ActualWidth - Canvas.GetLeft(this) - this.Width - e.HorizontalChange < 0) { Canvas.SetLeft(this, parent.ActualWidth - this.Width); return; } if (this.Width + e.HorizontalChange < 0) { return; } this.Width += e.HorizontalChange; e.Handled = true; this.OnDragDeltaChanged(ThumbType.Right); }
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; } }
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; }
private void Thumb_DragDelta( object sender, DragDeltaEventArgs e ) { switch( ResizerPosition ) { case ResizerPositions.Top: if( window.Height - e.VerticalChange > ActualHeight ) { window.Top += e.VerticalChange; window.Height -= e.VerticalChange; } break; case ResizerPositions.Left: if( window.Width - e.HorizontalChange > ActualWidth ) { window.Left += e.HorizontalChange; window.Width -= e.HorizontalChange; } break; case ResizerPositions.Bottom: if( window.Height + e.VerticalChange > ActualHeight ) { window.Height += e.VerticalChange; } break; case ResizerPositions.Right: if( window.Width + e.HorizontalChange > ActualWidth ) { window.Width += e.HorizontalChange; } break; } }
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if (ActualWidth > MinWidth) { MaxWidth += (e.HorizontalChange - drag_diff_x); Width = MaxWidth; } else { MaxWidth = MinWidth + 4; Width = MaxWidth; (sender as Thumb).ReleaseMouseCapture(); } if (ActualHeight > MinHeight) { MaxHeight += (e.VerticalChange - drag_diff_y); Height = MaxHeight; } else { MaxHeight = MinHeight + 4; Height = MaxHeight; (sender as Thumb).ReleaseMouseCapture(); } }
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; } }
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); } }
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; } }
private void TimeBlock_Resize_Left(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { TimeBlock tb = ((TimeBlock)((Thumb)sender).TemplatedParent); if (tb.Width - e.HorizontalChange > 5) { tb.Width -= e.HorizontalChange; Canvas.SetLeft(tb, VisualTreeHelper.GetOffset(tb).X + e.HorizontalChange); tb.StartTime = Canvas.GetLeft(tb) * tb.TimelineParent.TimePerPixel; } //snapping if (Keyboard.IsKeyDown(Key.LeftCtrl)) { TimeBlock snap_tb = null; foreach (Timeline tline in timelines) { if ((snap_tb = GetSnapStatus(tline, tb)) != null) { break; } } if (snap_tb != null) { SetSnap(snap_tb, tb, false); } } tb.StartTime = Canvas.GetLeft(tb) * tb.TimelineParent.TimePerPixel; SelectedControl = tb; }
private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e) { if (DesignerItem.IsSelected) { _wasMoved = true; Vector shift = new Vector(e.HorizontalChange, e.VerticalChange); foreach (DesignerItem designerItem in DesignerCanvas.SelectedItems) { Rect rect = new Rect(Canvas.GetLeft(designerItem), Canvas.GetTop(designerItem), designerItem.ActualWidth, designerItem.ActualHeight); if (rect.Right + shift.X > DesignerCanvas.Width) shift.X = DesignerCanvas.Width - rect.Right; if (rect.Left + shift.X < 0) shift.X = -rect.Left; if (rect.Bottom + shift.Y > DesignerCanvas.Height) shift.Y = DesignerCanvas.Height - rect.Bottom; if (rect.Top + shift.Y < 0) shift.Y = -rect.Top; } foreach (DesignerItem designerItem in DesignerCanvas.SelectedItems) { designerItem.Element.Position += shift; designerItem.SetLocation(); } DesignerCanvas.InvalidateMeasure(); e.Handled = true; ServiceFactory.SaveService.PlansChanged = true; } }
void ThumbBottom_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if (this.Height + e.VerticalChange > 10) { this.Height += e.VerticalChange; } }
/// <summary> /// This delegate is called when the item is dragged. /// </summary> /// <param name="pEventSender">The event sender.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnDragDelta(Object pEventSender, DragDeltaEventArgs pEventArgs) { NodeViewModel lItem = this.DataContext as NodeViewModel; if (lItem == null) { return; } Double lLeft = lItem.X; Double lTop = lItem.Y; if (Double.IsNaN(lLeft)) { lItem.X = 0; } else { lItem.X = lLeft + pEventArgs.HorizontalChange; } if (Double.IsNaN(lTop)) { lItem.Y = 0; } else { lItem.Y = lTop + pEventArgs.VerticalChange; } }
/// <summary> /// This event listener is called when a thumb was dragged and is now being dropped. /// It updates the Left and Top values and also checks if the canvas has to be enlarged for the Thumb to fit. /// It also stores the new values in the Nodes for future drawing. /// </summary> /// <autor>Krystian Zielonka, Jannik Arndt</autor> protected void DragAndDropThumb(object sender, DragDeltaEventArgs e) { Canvas parent = ((Thumb) sender).Parent as Canvas; if (parent == null) return; ExtendedThumb thumb = (ExtendedThumb) sender; // If the element is dragged beyond the bottom border if (Canvas.GetTop(thumb) > parent.Height) parent.Height = parent.Height + thumb.Height + 20; // If the element is dragged beyond the right border if (Canvas.GetLeft(thumb) > parent.Width) parent.Width = parent.Width + thumb.Width + 20; // If the element is dragged beyond the left border if (Canvas.GetLeft(thumb) < 0) parent.Width = parent.Width + (Canvas.GetLeft(thumb)*-1) + thumb.Width + 20; // Calculate the point in the grid, where the Thumb snaps to. int newX = NearestMultiple(Canvas.GetLeft(thumb) + e.HorizontalChange, Settings.Default.ColumnWidth/2); int newY = NearestMultiple(Canvas.GetTop(thumb) + e.VerticalChange, Settings.Default.RowHeight/2); // Place Thumb in Canvas Canvas.SetLeft(thumb, newX); Canvas.SetTop(thumb, newY); // Update values in the original Node thumb.BaseNode.PositionX = newX; thumb.BaseNode.PositionY = newY; }
void Thumb_Drag(object sender, DragDeltaEventArgs e) { Canvas.SetRight(MyThumb, Canvas.GetRight(MyThumb) - e.HorizontalChange); //Canvas.SetTop(MyThumb, Canvas.GetTop(MyThumb) + e.VerticalChange); Canvas.SetRight(MyCanvas, Canvas.GetLeft(MyThumb) - e.HorizontalChange); //Canvas.SetTop(MyCanvas, Canvas.GetTop(MyThumb) + e.VerticalChange); }
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { var thumb = sender as Thumb; if (thumb == null) { return; } //親コントロールを探す UIElement parent = (UIElement)thumb.Parent; if (parent == null) { return; } double x = Canvas.GetLeft(parent); if (double.IsNaN(x)) { x = 0; } double y = Canvas.GetTop(parent); if (double.IsNaN(y)) { y = 0; } //ドラッグ量に応じてThumbコントロールを移動する Canvas.SetLeft(parent, x + e.HorizontalChange); Canvas.SetTop(parent, y + e.VerticalChange); }
public DragablzDragDeltaEventArgs(DragablzItem dragablzItem, DragDeltaEventArgs dragDeltaEventArgs) : base(dragablzItem) { if (dragDeltaEventArgs == null) throw new ArgumentNullException("dragDeltaEventArgs"); _dragDeltaEventArgs = dragDeltaEventArgs; }
private void Target(object sender, DragDeltaEventArgs e) { Thumb thumb = e.OriginalSource as Thumb; if (thumb != null) { GridViewColumnHeader column = thumb.TemplatedParent as GridViewColumnHeader; if (column != null) { switch (column.Content.ToString()) { case @"Tipo": column.Column.Width = ColunaTipo; break; case @"Modulo": column.Column.Width = ColunaModulo; break; case @"Descricao": column.Column.Width = ColunaDescricao; break; case @"Privilegio": column.Column.Width = ColunaPrivilegio; break; } } } }
public DragablzDragDeltaEventArgs(RoutedEvent routedEvent, object source, DragablzItem dragablzItem, DragDeltaEventArgs dragDeltaEventArgs) : base(routedEvent, source, dragablzItem) { if (dragDeltaEventArgs == null) throw new ArgumentNullException("dragDeltaEventArgs"); _dragDeltaEventArgs = dragDeltaEventArgs; }
private void SelectionThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { FWControl.Left = (double)GetValue(Canvas.LeftProperty) + e.HorizontalChange; FWControl.Top = (double)GetValue(Canvas.TopProperty) + e.VerticalChange; SetComponentPosition(FWControl); }
/// <summary> /// Resizes the info pane. /// </summary> /// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param> /// <param name="iospecExpander">The iospec expander.</param> /// <param name="iospecRow">The iospec row.</param> /// <param name="outputsListView">The outputs list view.</param> /// <param name="inputsListView">The inputs list view.</param> protected static void resizeInfoPane(System.Windows.Controls.Primitives.DragDeltaEventArgs e, Expander iospecExpander, RowDefinition iospecRow, ListView outputsListView, ListView inputsListView) { if (iospecExpander != null && outputsListView != null && inputsListView != null) { if (iospecExpander.IsExpanded == true && outputsListView.Items.Count + inputsListView.Items.Count > 1) { double deltaVertical = Math.Min(-e.VerticalChange, iospecRow.ActualHeight - c_minResizeHeight); double newHeight; //if iospecExpander has been just expanded iospecRow has height set to auto if (iospecRow.Height == GridLength.Auto) { iospecRow.MaxHeight = iospecRow.ActualHeight; //record current actual height as max height for iospec row newHeight = iospecRow.ActualHeight - deltaVertical; } else { newHeight = iospecRow.Height.Value - deltaVertical; } if (newHeight > iospecRow.MaxHeight) { newHeight = iospecRow.MaxHeight; } iospecRow.Height = new GridLength(newHeight); } } e.Handled = true; }
private void thmRight_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Thumb thmRight = sender as Thumb; Window window = thmRight.TemplatedParent as Window; DragRight(window, e.HorizontalChange); }
private void thmBottom_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Thumb thmBottom = sender as Thumb; Window window = thmBottom.TemplatedParent as Window; DragDown(window, e.VerticalChange); }
void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e) { //DesignerItem designerItem = this.DataContext as DesignerItem; //DesignerCanvas designer = VisualTreeHelper.GetParent(designerItem) as DesignerCanvas; //if (designerItem != null && designer != null && designerItem.IsSelected) //{ // double minLeft, minTop, minDeltaHorizontal, minDeltaVertical; // double dragDeltaVertical, dragDeltaHorizontal; // // only resize DesignerItems // IEnumerable<DesignerItem> selectedDesignerItems = designer.SelectionService.CurrentSelection.OfType<DesignerItem>(); // //var selectedDesignerItems = from item in designer.SelectedItems // // where item is DesignerItem // // select item; // CalculateDragLimits(selectedDesignerItems, out minLeft, out minTop, // out minDeltaHorizontal, out minDeltaVertical); // foreach (DesignerItem item in selectedDesignerItems) // { // if (item != null) // { // switch (base.VerticalAlignment) // { // case VerticalAlignment.Bottom: // dragDeltaVertical = Math.Min(-e.VerticalChange, minDeltaVertical); // item.Height = item.ActualHeight - dragDeltaVertical; // break; // case VerticalAlignment.Top: // double top = Canvas.GetTop(item); // dragDeltaVertical = Math.Min(Math.Max(-minTop, e.VerticalChange), minDeltaVertical); // Canvas.SetTop(item, top + dragDeltaVertical); // item.Height = item.ActualHeight - dragDeltaVertical; // break; // default: // break; // } // switch (base.HorizontalAlignment) // { // case HorizontalAlignment.Left: // double left = Canvas.GetLeft(item); // dragDeltaHorizontal = Math.Min(Math.Max(-minLeft, e.HorizontalChange), minDeltaHorizontal); // Canvas.SetLeft(item, left + dragDeltaHorizontal); // item.Width = item.ActualWidth - dragDeltaHorizontal; // break; // case HorizontalAlignment.Right: // dragDeltaHorizontal = Math.Min(-e.HorizontalChange, minDeltaHorizontal); // item.Width = item.ActualWidth - dragDeltaHorizontal; // break; // default: // break; // } // } // } // e.Handled = true; //} }
public void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e) { Thumb myThumb = (Thumb)sender; double nTop = Canvas.GetTop(myThumb) + e.VerticalChange; double nLeft = Canvas.GetLeft(myThumb) + e.HorizontalChange; Canvas.SetTop(myThumb, nTop); Canvas.SetLeft(myThumb, nLeft); }
private void Thumb_DragDelta(object sender, DragDeltaEventArgs e) { Left = _startLeft +(e.HorizontalChange); Top = _startTop +(e.VerticalChange); _startLeft = Left; _startTop = Top; }
private void DragDeltaHandler(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { var delta = new Vector(e.HorizontalChange, 0); _MoveHandler.Update(delta); UpdateConnections(); }
void ThumbTop_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if (this.Top + e.VerticalChange > 10 && this.Height - e.VerticalChange >= this.MinHeight) { this.Top += e.VerticalChange; this.Height -= e.VerticalChange; } }
protected override void OnDragDelta(object sender, DragDeltaEventArgs e) { if (Target != null) { var delta = new Point(e.HorizontalChange, e.VerticalChange); Target.Move(delta); } }
void ThumbLeft_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if (this.Left + e.HorizontalChange > 10 && this.Width - e.HorizontalChange >= this.MinWidth) { this.Left += e.HorizontalChange; this.Width -= e.HorizontalChange; } }
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Thumb t = e.Source as Thumb; SketchThumbnail s = t.DataContext as SketchThumbnail; s.x = s.x + e.HorizontalChange; s.y = s.y + e.VerticalChange; }
private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { if (!IsReadOnly) { IsDragging = true; UIElement thumb = e.Source as UIElement; Thumb th = ((Thumb)thumb); bool go = false; Point point; if (th.Tag.ToString() == quadrants[0].Name) { point = Mouse.GetPosition(assumptionsPolygon); if (assumptionsPolygon.RenderedGeometry.FillContains(point)) { go = true; } } else if (th.Tag.ToString() == quadrants[1].Name) { point = Mouse.GetPosition(benefitsPolygon); if (benefitsPolygon.RenderedGeometry.FillContains(point)) { go = true; } } else if (th.Tag.ToString() == quadrants[2].Name) { point = Mouse.GetPosition(questionsPolygon); if (questionsPolygon.RenderedGeometry.FillContains(point)) { go = true; } } else if (th.Tag.ToString() == quadrants[3].Name) { point = Mouse.GetPosition(risksPolygon); if (risksPolygon.RenderedGeometry.FillContains(point)) { go = true; } } if (go && nextUpdate <= DateTime.Now) { Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.HorizontalChange); Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.VerticalChange); // update data Data[Thumbs.IndexOf(th)].Position = new Point(Canvas.GetLeft(thumb) + (th.Width / 2), Canvas.GetTop(thumb) + (th.Height / 2)); UpdateScore(Data[Thumbs.IndexOf(th)]); nextUpdate = DateTime.Now.AddMilliseconds(20); } } }
//二维移动 private void Corner_thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { var thumb = sender as System.Windows.Controls.Primitives.Thumb; myright_c = Canvas.GetRight(thumb) - e.HorizontalChange; mybottom_c = Canvas.GetBottom(thumb) - e.VerticalChange; Canvas.SetRight(thumb, myright_c); Canvas.SetBottom(thumb, mybottom_c); }
private void PART_RightHeaderGripper_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { SfDataGrid sfDataGrid = (sender as Thumb).Tag as SfDataGrid; var width = sfDataGrid.RowHeaderWidth + e.HorizontalChange; if (width >= 24) { sfDataGrid.RowHeaderWidth = width; } }
private void HPThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Thumb thumb = (Thumb)sender; int newHP = initialVal - (int)(e.VerticalChange / 5.0); //int change = newHP - Value.Value; //DataContext }
private void DropDownThumb_OnDragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { double newHeight = DropDownHeight + e.VerticalChange; double newWidth = DropDownWidth + e.HorizontalChange; if ((newHeight >= 0) && (newWidth >= 0)) { DropDownHeight = newHeight; DropDownWidth = newWidth; } }
/// <summary> /// Handle the user dragging the rectangle. /// </summary> private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Thumb thumb = (Thumb)sender; RectangleViewModel myRectangle = (RectangleViewModel)thumb.DataContext; // // Update the the position of the rectangle in the view-model. // myRectangle.X += e.HorizontalChange; myRectangle.Y += e.VerticalChange; }