Ejemplo n.º 1
0
 internal void RaiseOnKeyDown(BrowserKeyEventArgs args)
 {
     if (null != this.m_onKeyDown)
     {
         this.m_onKeyDown(this, args);
     }
 }
Ejemplo n.º 2
0
        private static void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (BrowserEventsHandler == null)
            {
                return;
            }

            ItemsControl itemsControl = sender as ItemsControl;

            // get selected objects
            IEnumerable SourceItems = itemsControl.GetSelectedItems();

            // click only apply to one object
            object dataObject = SourceItems.Cast <object>().FirstOrDefault();

            if (dataObject == null)
            {
                return;
            }

            // dynamic cast to view model
            BrowserNodeViewModel viewModel = dataObject as BrowserNodeViewModel;

            // collect event arguments
            BrowserKeyEventArgs args = new BrowserKeyEventArgs()
            {
                Sender = sender
            };

            args.BrowserNodeViewModel = viewModel;
            args.DataObject           = viewModel == null ? null : viewModel.DataObject;
            args.Key = e.Key;

            // Raise event
            bool hookBrowserEvents = GetHookBrowserEvents((UIElement)sender);

            if (hookBrowserEvents && BrowserEventsHandler != null)
            {
                BrowserEventsHandler.RaiseOnKeyDown(args);
            }
        }