Esempio n. 1
0
 /// <summary>
 /// Called when user stop dragging the <see cref="Thumb"/>.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnThumbDragCompleted(VectorEventArgs e)
 {
     _isDragging = false;
 }
Esempio n. 2
0
 private void HandleOnMasterMove(object sender, VectorEventArgs args)
 {
     Translate(args.VectorTo);
 }
Esempio n. 3
0
 /// <summary>
 /// Called when user start dragging the <see cref="Thumb"/>.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnThumbDragStarted(VectorEventArgs e)
 {
     _isDragging = true;
 }
Esempio n. 4
0
 /// <summary>
 /// set is dragging to true
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDragStarted(VectorEventArgs e)
 {
     IsDragging = true;
     base.OnDragStarted(e);
 }
Esempio n. 5
0
 /// <summary>
 /// set is dragging to false
 /// </summary>
 /// <param name="e"></param>
 protected override void OnDragCompleted(VectorEventArgs e)
 {
     IsDragging = false;
     base.OnDragCompleted(e);
 }
 private void WindowTitleThumbOnDragCompleted(object sender, VectorEventArgs e)
 {
     this.dragStartedMousePos = null;
 }
Esempio n. 7
0
 private static void OnThumbDragStarted(SliderEx sliderEx, VectorEventArgs args)
 {
     sliderEx.OnThumbDragStarted(args);
 }
Esempio n. 8
0
 private void WindowTitleThumbMoveOnDragDelta(object sender, VectorEventArgs e)
 {
     DoWindowTitleThumbMoveOnDragDelta(sender as IMetroThumb, this, e);
 }
Esempio n. 9
0
        internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, MetroWindow window, VectorEventArgs dragDeltaEventArgs)
        {
            if (thumb == null)
            {
                throw new ArgumentNullException(nameof(thumb));
            }
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            // drag only if IsWindowDraggable is set to true
            if (!window.IsWindowDraggable ||
                (!(Math.Abs(dragDeltaEventArgs.Vector.Y) > 2) && !(Math.Abs(dragDeltaEventArgs.Vector.X) > 2)))
            {
                return;
            }

            // tage from DragMove internal code
            window.VerifyAccess();

            //var cursorPos = WinApiHelper.GetPhysicalCursorPos();

            // if the window is maximized dragging is only allowed on title bar (also if not visible)
            var windowIsMaximized = window.WindowState == WindowState.Maximized;

            if (window._titleBar != null && window._titleBar.IsPointerOver /*&& _mouseDown*/)
            {
                window.WindowState = WindowState.Normal;

                //var pointerPress=new

                try
                {
                    window.BeginMoveDrag(null);
                }
                catch
                {
                    //little hack so I do not need create Pointerpressed event
                    //which has a huge constructor
                }
                window._mouseDown = false;
            }

            //var isMouseOnTitlebar = Mouse.GetPosition(thumb).Y <= window.TitleBarHeight && window.TitleBarHeight > 0;
            //if (!isMouseOnTitlebar && windowIsMaximized)
            //{
            //    return;
            //}

#pragma warning disable 618
            // for the touch usage
            //UnsafeNativeMethods.ReleaseCapture();
#pragma warning restore 618

            if (windowIsMaximized)
            {
                //var cursorXPos = cursorPos.x;
                EventHandler windowOnStateChanged = null;
                windowOnStateChanged = (sender, args) =>
                {
                    //window.Top = 2;
                    //window.Left = Math.Max(cursorXPos - window.RestoreBounds.Width / 2, 0);

                    //window.StateChanged -= windowOnStateChanged;
                    //if (window.WindowState == WindowState.Normal)
                    //{
                    //    Mouse.Capture(thumb, CaptureMode.Element);
                    //}
                };
                //window.StateChanged -= windowOnStateChanged;
                //window.StateChanged += windowOnStateChanged;
            }

            //            var criticalHandle = window.CriticalHandle;
            //#pragma warning disable 618
            //            // these lines are from DragMove
            //            // NativeMethods.SendMessage(criticalHandle, WM.SYSCOMMAND, (IntPtr)SC.MOUSEMOVE, IntPtr.Zero);
            //            // NativeMethods.SendMessage(criticalHandle, WM.LBUTTONUP, IntPtr.Zero, IntPtr.Zero);

            //            var wpfPoint = window.PointToScreen(Mouse.GetPosition(window));
            //            var x = (int)wpfPoint.X;
            //            var y = (int)wpfPoint.Y;
            //            NativeMethods.SendMessage(criticalHandle, WM.NCLBUTTONDOWN, (IntPtr)HT.CAPTION, new IntPtr(x | (y << 16)));
            //#pragma warning restore 618
        }
Esempio n. 10
0
        protected override void OnDragDelta(VectorEventArgs e)
        {
            base.OnDragDelta(e);

            Control item = this.DataContext as Control;

            if (item != null)
            {
                double delta_v, delta_h;

                Rect r1   = item.Bounds;
                Rect cvr2 = item.GetParentTOfLogical <Canvas>().Bounds;
                switch (VerticalAlignment)
                {
                case VerticalAlignment.Bottom:
                    delta_v = Math.Min(-e.Vector.Y, item.Bounds.Height + item.MinHeight);
                    Rect _r1 = r1.WithY(Canvas.GetBottom(item) + delta_v);
                    if (cvr2.Contains(_r1))
                    {
                        item.Height -= delta_v;
                    }
                    break;

                case VerticalAlignment.Top:
                    delta_v = Math.Min(e.Vector.Y, item.Bounds.Height + item.MinHeight);
                    Rect _r2 = r1.WithY(Canvas.GetTop(item) + delta_v);
                    if (cvr2.Contains(_r2))
                    {
                        Canvas.SetTop(item, Canvas.GetTop(item) + delta_v);
                        item.Height -= delta_v;
                    }
                    break;
                }

                switch (HorizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    delta_h = Math.Min(e.Vector.X, item.Bounds.Width - item.MinWidth);
                    Rect _r3 = r1.WithX(Canvas.GetLeft(item) + delta_h);
                    if (cvr2.Contains(_r3))
                    {
                        Canvas.SetLeft(item, Canvas.GetLeft(item) + delta_h);
                        item.Width -= delta_h;
                    }
                    break;

                case HorizontalAlignment.Right:
                    delta_h = Math.Min(e.Vector.X, item.Bounds.Width + item.MinWidth);
                    Rect _r4 = r1.WithX(Canvas.GetRight(item) + delta_h);
                    if (cvr2.Contains(_r4))
                    {
                        Canvas.SetRight(item, Canvas.GetRight(item) + delta_h);
                        item.Width += delta_h;
                    }
                    break;
                }
                #if DEBUG
                Debug.WriteLine($"canvas margin is Top : {Canvas.GetTop(item)}       Left : {Canvas.GetLeft(item)}");
                Debug.WriteLine($"                 Bottom : {Canvas.GetBottom(item)} Right : {Canvas.GetRight(item)}");
                #endif
            }
        }
 private void OnMove(object sender, VectorEventArgs args)
 {
     SetPermeable(args.VectorFrom);
     SetImpermeable(args.VectorTo);
 }
Esempio n. 12
0
 private void OnThumbDragComplete(VectorEventArgs e)
 {
     OnScroll(ScrollEventType.EndScroll);
 }
Esempio n. 13
0
 private void OnThumbDragDelta(VectorEventArgs e)
 {
     OnScroll(ScrollEventType.ThumbTrack);
 }
Esempio n. 14
0
 private void OnMove(object sender, VectorEventArgs args)
 {
     _light.Move(Owner.GetComponent <ITransformComponent>().Position + _lightOffset);
 }
Esempio n. 15
0
 /// <summary>
 /// Called when user start dragging the <see cref="Thumb"/>.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnThumbDragStarted(VectorEventArgs e)
 {
 }
Esempio n. 16
0
 private static void OnThumbDragDelta(SliderEx sliderEx, VectorEventArgs args)
 {
     sliderEx.OnThumbDragDelta(args);
 }
Esempio n. 17
0
 /// <summary>
 /// Called when user stop dragging the <see cref="Thumb"/>.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnThumbDragCompleted(VectorEventArgs e)
 {
 }
Esempio n. 18
0
 protected virtual void OnDragDelta(VectorEventArgs e)
 {
 }