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


C# Window.CaptureMouse方法代码示例

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


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

示例1: OpenPopup

        public void OpenPopup(bool UseMouse)
        {
            root = FindWindow(this);
            isMouseMode = UseMouse;
            if (root == null)
                return;
            this.Visibility = Visibility.Collapsed;
            overlay = new Canvas();
            RenderTargetBitmap content = new RenderTargetBitmap((int)root.ActualWidth, (int)root.ActualHeight, 96, 96, PixelFormats.Pbgra32);
            content.Render(root);
            _contentLayer = new Image() { Source = content, Width = root.ActualWidth, Height = root.ActualHeight };
            overlay.Children.Add(_contentLayer);
            overlay.Width = root.ActualWidth;
            overlay.Height = root.ActualHeight;

            mask.Opacity = 0;
            mask.Width = root.ActualWidth;
            mask.Height = root.ActualHeight;
            overlay.Children.Add(mask);

            myContent = this.Content as FrameworkElement;
            myContentSize = new Size(myContent.ActualWidth, myContent.ActualHeight);
            this.Content = null;
            selfLayer = new ContentControl() { Content = myContent };
            selfLayer.Width = myContentSize.Width; selfLayer.Height = myContentSize.Height;
            myContent.Width = myContent.Width; myContent.Height = myContent.Height;
            overlay.Children.Add(selfLayer);
            Point location = this.TranslatePoint(new Point(0, 0), root);
            selfLayer.SetValue(Canvas.LeftProperty, location.X);
            selfLayer.SetValue(Canvas.TopProperty, location.Y);
            myContent.Visibility = Visibility.Visible;
            oldContent = root.Content;
            oy = Mouse.GetPosition(root).Y;
            root.Content = overlay;
            overlay.IsEnabled = false;
            orginValue = Value;

            AnimateContent(1, 1.08, new EventHandler((sender, e) => { overlay.IsEnabled = true; }));
            //mask.MouseDown += new MouseButtonEventHandler(_contentLayer_MouseDown);
            root.SizeChanged += new SizeChangedEventHandler(root_SizeChanged);
            myContent.Effect = new DropShadowEffect() { ShadowDepth = 0 };
            lastTick = Environment.TickCount;
            if (UseMouse)
            {
                root.MouseMove += new MouseEventHandler(root_MouseMove);
                root.MouseLeftButtonUp += new MouseButtonEventHandler(root_MouseLeftButtonUp);
                root.CaptureMouse();
            }
            else
            {
                root.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(root_ManipulationDelta);
                root.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(root_ManipulationCompleted);
            }
        }
开发者ID:Kendry06,项目名称:Gymnastika,代码行数:54,代码来源:NumericUpDownControl.xaml.cs


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