当前位置: 首页>>代码示例>>C#>>正文


C# InputEventArgs.ToString方法代码示例

本文整理汇总了C#中System.Windows.Input.InputEventArgs.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# InputEventArgs.ToString方法的具体用法?C# InputEventArgs.ToString怎么用?C# InputEventArgs.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Input.InputEventArgs的用法示例。


在下文中一共展示了InputEventArgs.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DragSourcePreviewInputDeviceDown

        //Drag and Drop
        /// <summary>
        /// Creates Cursor and starts drag of image
        /// get help at msdn: Dragging and Dropping Items from ScatterView Controls to SurfaceListBox Controls
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DragSourcePreviewInputDeviceDown(object sender, InputEventArgs e)
        {
            log.Debug("DragSourcePreviewInputDeviceDown(object " + sender.ToString() + ", InputEventArgs " + e.ToString() + ") - Begin");
            FrameworkElement findSource = e.OriginalSource as FrameworkElement;
            ScatterViewItem draggedElement = null;
            ScatterViewItem sci = sender as ScatterViewItem;
            Image img = sci.Content as Image;

            // Find the ScatterViewItem object that is being touched.
            while (draggedElement == null && findSource != null)
            {
                if ((draggedElement = findSource as ScatterViewItem) == null)
                {
                    findSource = VisualTreeHelper.GetParent(findSource) as FrameworkElement;
                }
            }

            if (draggedElement == null)
            {
                return;
            }

            object data = draggedElement.Content;
            
            // If the data has not been specified as draggable, 
            // or the ScatterViewItem cannot move, return.
            if (data == null)
            {
                return;
            }

            // Set the dragged element. This is needed in case the drag operation is canceled.
            //data.DraggedElement = draggedElement;

            // Create the cursor visual.
            ContentControl cursorVisual = new ContentControl()
            {
                Content = img,
                //Style = FindResource("CursorStyle") as Style
            };

            // Create a list of input devices, 
            // and add the device passed to this event handler.
            List<InputDevice> devices = new List<InputDevice>();
            devices.Add(e.Device);

            // If there are touch devices captured within the element,
            // add them to the list of input devices.
            foreach (InputDevice device in draggedElement.TouchesCapturedWithin)
            {
                if (device != e.Device)
                {
                    devices.Add(device);
                }
            }

            // Get the drag source object.
            ItemsControl dragSource = ItemsControl.ItemsControlFromItemContainer(draggedElement);

            // Start the drag-and-drop operation.
            SurfaceDragCursor cursor =
                SurfaceDragDrop.BeginDragDrop(
                // The ScatterView object that the cursor is dragged out from.
                  dragSource,
                // The ScatterViewItem object that is dragged from the drag source.
                  draggedElement,
                // The visual element of the cursor.
                  cursorVisual,
                // The data attached with the cursor.
                  img,
                // The input devices that start dragging the cursor.
                  devices,
                // The allowed drag-and-drop effects of the operation.
                  DragDropEffects.Move);

            // If the cursor was created, the drag-and-drop operation was successfully started.
            if (cursor != null)
            {
                // Hide the ScatterViewItem.
                //draggedElement.Visibility = Visibility.Hidden;
                //Console.WriteLine("Begin Drag");
                // This event has been handled.
                log.Debug("DragSourcePreviewInputDeviceDown() handled - End");
                e.Handled = true;
            }
            log.Debug("DragSourcePreviewInputDeviceDown() check if handled - End");
        }
开发者ID:B3J4y,项目名称:Poker,代码行数:94,代码来源:MainWindow.xaml.cs


注:本文中的System.Windows.Input.InputEventArgs.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。