當前位置: 首頁>>代碼示例>>C#>>正文


C# Primitives.DragDeltaEventArgs類代碼示例

本文整理匯總了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;
 }
開發者ID:redinkinc,項目名稱:Utilities,代碼行數:7,代碼來源:PCsettings.xaml.cs

示例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;
            }
        }
開發者ID:CrimsonChris,項目名稱:Half-Caked,代碼行數:60,代碼來源:ResizeThumb.cs

示例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;
            }
        }
開發者ID:jgkim999,項目名稱:WpfExample,代碼行數:26,代碼來源:MoveThumb.cs

示例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();
                }
            }
        }
開發者ID:AleksandarDev,項目名稱:Eve,代碼行數:28,代碼來源:DragThumb.cs

示例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;
            }
        }
開發者ID:AaronRevilla,項目名稱:TT_2012b-049_ComputerGraphics,代碼行數:26,代碼來源:MoveThumb.cs

示例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);
            }
        }
開發者ID:kjburns31,項目名稱:vixen-modules,代碼行數:26,代碼來源:MoveThumb.cs

示例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);

            }
        }
開發者ID:apazureck,項目名稱:bierstrichler,代碼行數:32,代碼來源:MoveThumb.cs

示例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);
            }
        }
開發者ID:palome06,項目名稱:psd48,代碼行數:25,代碼來源:MovePanelThumb.cs

示例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;
        }
開發者ID:modulexcite,項目名稱:Glass-Legacy,代碼行數:33,代碼來源:DesignableResizeChrome.cs

示例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;
            }
        }
開發者ID:worktycho,項目名稱:didactic-palm-tree,代碼行數:28,代碼來源:DragThumb.cs

示例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;
        }
開發者ID:hardborn,項目名稱:StadiumBrightnessTool,代碼行數:25,代碼來源:DragThumb.cs

示例12: DragablzDragDeltaEventArgs

        public DragablzDragDeltaEventArgs(DragablzItem dragablzItem, DragDeltaEventArgs dragDeltaEventArgs)
            : base(dragablzItem)
        {
            if (dragDeltaEventArgs == null) throw new ArgumentNullException("dragDeltaEventArgs");

            _dragDeltaEventArgs = dragDeltaEventArgs;
        }
開發者ID:CensoredHF,項目名稱:Snappie,代碼行數:7,代碼來源:DragablzDragDeltaEventArgs.cs

示例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;
                    }
                }
            }
        }
開發者ID:ArcadeRenegade,項目名稱:SidebarDiagnostics,代碼行數:26,代碼來源:FlatStyle.xaml.cs

示例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;
      }
    }
開發者ID:WinnieThePoooh,項目名稱:Lego,代碼行數:60,代碼來源:ResizeThumb.cs

示例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));
            }
         }
      }
開發者ID:epinoema,項目名稱:Hammer.MdiContainer,代碼行數:28,代碼來源:MoveThumb.cs


注:本文中的System.Windows.Controls.Primitives.DragDeltaEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。