This project is read-only.

ItemDoubleClick RoutedEvent

Nov 4, 2009 at 2:16 PM

Hi,

If it helps anyone I made a local mod to support a double click and a begin drag event. I added the following to ElementFlow.cs:

This in the PrepareModel method:

      ModelUIElement3D model = CreateMeshModel(elt);
#if LOCAL_MODS
      model.MouseLeftButtonDown += MouseLButtonDown;
      model.MouseMove += ModelMouseMove;
#endif
      _modelContainer.Children.Insert(index, model);

And this after the PrepareModel method:

#if LOCAL_MODS

    private int moveCount_;

    void ModelMouseMove(object sender, MouseEventArgs e)
    {
      if (e.LeftButton == MouseButtonState.Pressed)
      {
        moveCount_++;
        if (moveCount_ > 5)
          RaiseEvent(new RoutedEventArgs(ItemBeginDragEvent, this));
      }
      else
      {
        moveCount_ = 0;
      }
    }

    public static readonly RoutedEvent ItemDoubleClickEvent =
      EventManager.RegisterRoutedEvent("ItemDoubleClickEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ElementFlow));

    public event RoutedEventHandler ItemDoubleClick
    {
      add { AddHandler(ItemDoubleClickEvent, value); }
      remove { RemoveHandler(ItemDoubleClickEvent, value); }
    }

    public static readonly RoutedEvent ItemBeginDragEvent =
      EventManager.RegisterRoutedEvent("ItemBeginDragEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ElementFlow));

    public event RoutedEventHandler ItemBeginDrag
    {
      add { AddHandler(ItemBeginDragEvent, value); }
      remove { RemoveHandler(ItemBeginDragEvent, value); }
    }

    private DateTime lastTimeDown_ = DateTime.MinValue;

    void MouseLButtonDown(object sender, MouseButtonEventArgs e)
    {
      TimeSpan ts = DateTime.Now - lastTimeDown_;

      if (ts.TotalMilliseconds < 250)
        RaiseEvent(new RoutedEventArgs(ItemDoubleClickEvent, this));

      lastTimeDown_ = DateTime.Now;
    }

#endif

 

Dec 19, 2011 at 9:48 PM

very helpful, thanks!