예제 #1
0
        void tb_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SelItem = sender as TopicDragItem;
            if (SelItem == null)
            {
                return;
            }
            SelItem.ReleaseMouseCapture();
            // int index = LeftText.FindIndex(new Predicate<TopicDragItem>(FindItem));
            object        o   = InputHitTest(e.GetPosition(this));
            TopicDragItem tb2 = GetMouseSelItem((DependencyObject)InputHitTest(e.GetPosition(this))) as TopicDragItem;

            if (tb2 != null)
            {
                SelItem.UserAnswer = tb2.Id;
                tb2.LinePoint      = currentPoint;
            }
            else
            {
                SelItem.LinePoint  = new Point(0, 0);
                currentPoint       = new Point(0, 0);
                SelItem.UserAnswer = -1;
            }
            DrawLine();
        }
예제 #2
0
 void tb_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     SelItem = sender as TopicDragItem;
     if (SelItem == null)
     {
         return;
     }
     SelItem.UserAnswer = -1;
     SelItem.LinePoint  = new Point(e.GetPosition(null).X - e.GetPosition(SelItem).X + SelItem.ActualWidth, e.GetPosition(null).Y - e.GetPosition(SelItem).Y + SelItem.ActualHeight / 2);
 }
예제 #3
0
 bool FindItem(TopicDragItem p)// 比较器(这里的p为Plans中的元素,即p.PlanID与给定的PlanID比较)
 {
     if (SelItem.Id == p.Id)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #4
0
        void tb_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                return;
            }

            SelItem = sender as TopicDragItem;
            if (SelItem == null)
            {
                return;
            }

            // int index = LeftText.FindIndex(new Predicate<TopicDragItem>(FindItem));

            if (e.GetPosition(null).X > currentPoint.X)
            {
                currentPoint.X = e.GetPosition(null).X - 1;
            }
            else
            {
                currentPoint.X = e.GetPosition(null).X + 1;
            }

            if (e.GetPosition(null).Y > currentPoint.Y)
            {
                currentPoint.Y = e.GetPosition(null).Y - 1;
            }
            else
            {
                currentPoint.Y = e.GetPosition(null).Y + 1;
            }

            if (SelItem.CaptureMouse())
            {
                DrawLine();
            }
        }