Beispiel #1
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            Focus();

            if (!AllowManipulate)
            {
                return;
            }

            CaptureMouse();
            currentHeight             = ActualHeight;
            currentWidth              = ActualWidth;
            currentCompositeTransform = RenderTransform as CompositeTransform ?? new CompositeTransform();
            startPoint      = e.GetPosition(null);
            startLocalPoint = e.GetPosition(this);
            var ri = ControlHelper.GetParent <Primitives.ManipulatorHandle>(e.OriginalSource as FrameworkElement);

            if (ri != null)
            {
                manipulatorHandleType = ri.Type;

                if (manipulatorHandleType == Primitives.ManipulatorHandleType.W || manipulatorHandleType == Primitives.ManipulatorHandleType.E)
                {
                    ManipulationMode = ManipulationMode.HorizontalResize;
                }
                else if (manipulatorHandleType == Primitives.ManipulatorHandleType.N || manipulatorHandleType == Primitives.ManipulatorHandleType.S)
                {
                    ManipulationMode = ManipulationMode.VerticalResize;
                }
                else if (manipulatorHandleType == Primitives.ManipulatorHandleType.ES || manipulatorHandleType == Primitives.ManipulatorHandleType.NE ||
                         manipulatorHandleType == Primitives.ManipulatorHandleType.SW || manipulatorHandleType == Primitives.ManipulatorHandleType.WN)
                {
                    ManipulationMode = ManipulationMode.BothResize;
                }
                else if (manipulatorHandleType == Primitives.ManipulatorHandleType.Rotate)
                {
                    ManipulationMode = ManipulationMode.Rotate;
                }
                else
                {
                    ManipulationMode = ManipulationMode.Translate;
                }
            }
            else if (DragHandlerMode == DragHandlerMode.UseWholeControl)
            {
                ManipulationMode = ManipulationMode.Translate;
            }

            base.OnMouseLeftButtonDown(e);
        }
		protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
		{
			Focus();

			if (!AllowManipulate)
				return;

			CaptureMouse();
			currentHeight = ActualHeight;
			currentWidth = ActualWidth;
			currentCompositeTransform = RenderTransform as CompositeTransform ?? new CompositeTransform();
			startPoint = e.GetPosition(null);
			startLocalPoint = e.GetPosition(this);
			var ri = ControlHelper.GetParent<Primitives.ManipulatorHandle>(e.OriginalSource as FrameworkElement);
			if (ri != null)
			{
				manipulatorHandleType = ri.Type;

				if (manipulatorHandleType == Primitives.ManipulatorHandleType.W || manipulatorHandleType == Primitives.ManipulatorHandleType.E)
				{
					ManipulationMode = ManipulationMode.HorizontalResize;
				}
				else if (manipulatorHandleType == Primitives.ManipulatorHandleType.N || manipulatorHandleType == Primitives.ManipulatorHandleType.S)
				{
					ManipulationMode = ManipulationMode.VerticalResize;
				}
				else if (manipulatorHandleType == Primitives.ManipulatorHandleType.ES || manipulatorHandleType == Primitives.ManipulatorHandleType.NE
					|| manipulatorHandleType == Primitives.ManipulatorHandleType.SW || manipulatorHandleType == Primitives.ManipulatorHandleType.WN)
				{
					ManipulationMode = ManipulationMode.BothResize;
				}
				else if (manipulatorHandleType == Primitives.ManipulatorHandleType.Rotate)
				{
					ManipulationMode = ManipulationMode.Rotate;
				}
				else
				{
					ManipulationMode = ManipulationMode.Translate;
				}
			}
			else if (DragHandlerMode == DragHandlerMode.UseWholeControl)
			{
				ManipulationMode = ManipulationMode.Translate;
			}

			base.OnMouseLeftButtonDown(e);
		}