本文整理汇总了C#中System.Windows.Window.PointToScreen方法的典型用法代码示例。如果您正苦于以下问题:C# Window.PointToScreen方法的具体用法?C# Window.PointToScreen怎么用?C# Window.PointToScreen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.PointToScreen方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NotificationWindow
/// <summary>
///
/// </summary>
/// <param name="mainWindow">Window on which the notification will be opened</param>
/// <param name="timeOpened">time(ms) before the notification is closed (0 means no automatic close)</param>
/// <param name="contentTemplate">Template to display</param>
/// <param name="notificationWindows"></param>
/// <param name="text"></param>
public NotificationWindow(Window mainWindow, int timeOpened, DataTemplate contentTemplate, IEnumerable<NotificationWindow> notificationWindows, string text = null)
{
InitializeComponent();
if (null != contentTemplate)
{
Control.ContentTemplate = contentTemplate;
}
if (null != text)
{
Control.Content = text;
}
_timer = new Timer(timeOpened);
_timer.Elapsed += timer_Elapsed;
Loaded += NotificationWindow_Loaded;
if (mainWindow != null)
{
var point = mainWindow.PointToScreen(new Point(0, 0));
point.Offset(mainWindow.ActualWidth - 23, mainWindow.ActualHeight - 50);
this.Left = point.X;
this.Top = point.Y;
}
Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
{
Visibility = Visibility.Visible;
if (mainWindow != null)
{
var point = mainWindow.PointToScreen(new Point(0, 0));
point.Offset(mainWindow.ActualWidth - 23, mainWindow.ActualHeight - 50);
this.Left = point.X - this.ActualWidth;
this.Top = point.Y - this.ActualHeight;
}
foreach (var notificationWindow in notificationWindows)
{
if (notificationWindow != this)
{
notificationWindow.Top -= this.ActualHeight + 5;
}
}
}));
}
示例2: calculateStartup
private static Point calculateStartup(FrameworkElement content, Window owner)
{
int top = Math.Floor(owner.Height/4).Zeroed();
double left = Math.Floor(owner.Width/2) - content.Width.Zeroed();
var relative = new Point(top, left);
return owner.PointToScreen(relative);
}
示例3: AnimatedImageControl
/// <summary>
/// AnimatedImageControl constructor
/// </summary>
/// <param name="pWindow">Window</param>
/// <param name="pBitmap">Bitmap</param>
/// <param name="pBrush">Brush</param>
public AnimatedImageControl(Window pWindow, Bitmap pBitmap, Brush pBrush)
{
mAnimatedImage = pBitmap;
mHwnd = PresentationSource.FromVisual(pWindow) as HwndSource;
mBrush = pBrush;
Width = pBitmap.Width;
Height = pBitmap.Height;
mPoint = pWindow.PointToScreen(new Point(0, 0));
ImageAnimator.Animate(mAnimatedImage, OnFrameChanged);
Loaded += AnimatedImageControl_Loaded;
}
示例4: Lookup
public Lookup(TextBox parent, Window owner)
: this()
{
_parent = parent;
Owner = owner;
var relative = new Point(0, parent.ActualHeight);
Point desiredLocation = owner.TranslatePoint(relative, parent);
Point point = Owner.PointToScreen(desiredLocation);
Top = point.Y;
Left = point.X;
Show();
}
示例5: ConfigureNewHostSizeAndGetDragStartWindowOffset
private Point ConfigureNewHostSizeAndGetDragStartWindowOffset(Window currentWindow, INewTabHost<Window> newTabHost, DragablzItem dragablzItem)
{
var layout = this.VisualTreeAncestory().OfType<Layout>().FirstOrDefault();
Point dragStartWindowOffset;
if (layout != null)
{
newTabHost.Container.Width = ActualWidth + Math.Max(0, currentWindow.RestoreBounds.Width - layout.ActualWidth);
newTabHost.Container.Height = ActualHeight + Math.Max(0, currentWindow.RestoreBounds.Height - layout.ActualHeight);
dragStartWindowOffset = dragablzItem.TranslatePoint(new Point(), this);
//dragStartWindowOffset.Offset(currentWindow.RestoreBounds.Width - layout.ActualWidth, currentWindow.RestoreBounds.Height - layout.ActualHeight);
}
else
{
if (newTabHost.Container.GetType() == currentWindow.GetType())
{
newTabHost.Container.Width = currentWindow.RestoreBounds.Width;
newTabHost.Container.Height = currentWindow.RestoreBounds.Height;
dragStartWindowOffset = dragablzItem.TranslatePoint(new Point(), currentWindow);
}
else
{
newTabHost.Container.Width = ActualWidth;
newTabHost.Container.Height = ActualHeight;
dragStartWindowOffset = dragablzItem.TranslatePoint(new Point(), this);
dragStartWindowOffset.Offset(dragablzItem.MouseAtDragStart.X, dragablzItem.MouseAtDragStart.Y);
return dragStartWindowOffset;
}
}
dragStartWindowOffset.Offset(dragablzItem.MouseAtDragStart.X, dragablzItem.MouseAtDragStart.Y);
var borderVector = currentWindow.WindowState == WindowState.Maximized
? currentWindow.PointToScreen(new Point()).ToWpf() - new Point()
: currentWindow.PointToScreen(new Point()).ToWpf() - new Point(currentWindow.Left, currentWindow.Top);
dragStartWindowOffset.Offset(borderVector.X, borderVector.Y);
return dragStartWindowOffset;
}
示例6: ShowSystemMenuPhysicalCoordinates
/// <summary>
/// Shows the system menu at the current mouse position.
/// </summary>
/// <param name="window">The window for which the system menu should be shown.</param>
/// <param name="e">The mouse event args.</param>
public static void ShowSystemMenuPhysicalCoordinates(Window window, MouseButtonEventArgs e)
{
var mousePosition = e.GetPosition(window);
var physicalScreenLocation = window.PointToScreen(mousePosition);
ShowSystemMenuPhysicalCoordinates(window, e, physicalScreenLocation);
}