本文整理汇总了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);
}
}