Exemple #1
0
 internal void RaiseOnBeforeStartDrag(BrowserValidateEventArgs args)
 {
     if (null != this.m_onBeforeStartDrag)
     {
         this.m_onBeforeStartDrag(this, args);
     }
 }
Exemple #2
0
 internal void RaiseOnBeforeDoubleClick(BrowserValidateEventArgs args)
 {
     if (null != this.m_onBeforeDoubleClick)
     {
         this.m_onBeforeDoubleClick(this, args);
     }
 }
Exemple #3
0
        private static void StartDrag(DragInfo dragInfo, BrowserEvents browserEvents)
        {
            var sourceItems = dragInfo.SourceItems.Cast <object>();

            // only support single selection
            int itemCount = sourceItems.Count();

            if (itemCount != 1)
            {
                return;
            }

            dragInfo.Data = sourceItems.Single();

            // browser node
            BrowserNodeViewModel viewModel = dragInfo.Data as BrowserNodeViewModel;

            if (viewModel == null)
            {
                return;
            }

            // If view model doesn't support dragging, then bail
            if (!viewModel.SupportsDrag)
            {
                dragInfo.Effects = DragDropEffects.None;
                return;
            }

            // collect event arguments
            BrowserValidateEventArgs args = new BrowserValidateEventArgs
            {
                BrowserNodeViewModel = viewModel,
                DataObject           = dragInfo,
            };

            // Validate the drag operation.
            if (browserEvents != null)
            {
                browserEvents.RaiseOnBeforeStartDrag(args);
                if (!args.StopEvent)
                {
                    // Raise start drag event
                    browserEvents.RaiseOnStartDrag(args);
                }
            }

            dragInfo.Effects = (dragInfo.Data != null) ? DragDropEffects.Copy : DragDropEffects.None;
        }
Exemple #4
0
        private static void OnPreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (BrowserEventsHandler == null)
            {
                return;
            }

            // Handle drag&drop, click and double click
            if (s_isDragging)
            {
                return;
            }

            // Ignore the click if the user has clicked on a scrollbar.
            if (HitTestScrollBar(sender, e))
            {
                s_dragInfo = null;
                return;
            }

            // If the mouse doesn't click on any item.
            // Return if the mouse is not click on the element
            var dataContext = HitTestValidItem(sender, e);

            if (dataContext == null)
            {
                return;
            }

            // Handle double click
            if (e.ClickCount == 2)
            {
                // Make sure the first clicked item is equal to the second clicked item.
                BrowserNodeViewModel viewModel = GetSelectedBrowserNodeViewModel(sender);
                if (viewModel == null || dataContext != viewModel)
                {
                    return;
                }

                // collect event arguments
                BrowserValidateEventArgs args = new BrowserValidateEventArgs()
                {
                    Sender = sender
                };
                args.BrowserNodeViewModel = viewModel;
                args.DataObject           = viewModel.DataObject;
                args.StopEvent            = false;

                // If hook to browser events, raise double click event.
                bool hookBrowserEvents = GetHookBrowserEvents((UIElement)sender);
                if (hookBrowserEvents && BrowserEventsHandler != null)
                {
                    // Validate the drag operation.
                    BrowserEventsHandler.RaiseOnBeforeDoubleClick(args);
                    if (!args.StopEvent)
                    {
                        // Raise event
                        BrowserEventsHandler.RaiseOnDoubleClick(args);
                    }
                }
            }
            else
            {
                // Create a drag info which will be used in next events.
                s_dragInfo = new DragInfo(sender, e);
            }
        }