本文整理汇总了C#中System.Windows.Window.UpdateLayout方法的典型用法代码示例。如果您正苦于以下问题:C# Window.UpdateLayout方法的具体用法?C# Window.UpdateLayout怎么用?C# Window.UpdateLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.UpdateLayout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetAtCenter
public static void SetAtCenter(Window v, Window w)
{
v.UpdateLayout();
w.UpdateLayout();
w.Left = v.Left + (v.ActualWidth - w.ActualWidth) / 2;
w.Top = v.Top + (v.ActualHeight - w.ActualHeight) / 2;
}
示例2: CheckWindowPos
public static void CheckWindowPos(Window wnd, ref IntPtr hwnd, bool limit_size)
{
try
{
if (!Settings.CheckWindowsPos || !wnd.IsVisible)
return;
if (hwnd == IntPtr.Zero)
hwnd = new WindowInteropHelper(wnd).Handle;
if (hwnd == IntPtr.Zero)
return;
//Монитор, на котором окно занимает бОльшую площадь (или ближайший к окну).
//SystemParameters.WorkArea - только для основного монитора, но уже с dpi.
Rectangle _WorkingArea = System.Windows.Forms.Screen.FromHandle(hwnd).WorkingArea;
//Масштабируем под dpi
double dpi = SysInfo.dpi;
Rect WorkingArea = (_WorkingArea.Width <= 0 || _WorkingArea.Height <= 0) ? SystemParameters.WorkArea :
new Rect(_WorkingArea.X / dpi, _WorkingArea.Y / dpi, _WorkingArea.Width / dpi, _WorkingArea.Height / dpi);
//Ограничение размеров окна
if (limit_size)
{
wnd.MaxWidth = WorkingArea.Width;
wnd.MaxHeight = WorkingArea.Height;
wnd.UpdateLayout();
}
//Вписывание в границы
if (wnd.ActualWidth > 0 && wnd.ActualHeight > 0 && !double.IsNaN(wnd.Left) && !double.IsNaN(wnd.Top))
{
if (wnd.Left < WorkingArea.Left)
{
//Слева
wnd.Left = WorkingArea.Left;
}
else if (wnd.Left - WorkingArea.Left + wnd.ActualWidth > WorkingArea.Width)
{
//Справа
wnd.Left = WorkingArea.Width - wnd.ActualWidth + WorkingArea.Left;
}
if (wnd.Top < WorkingArea.Top)
{
//Сверху
wnd.Top = WorkingArea.Top;
}
else if (wnd.Top - WorkingArea.Top + wnd.ActualHeight > WorkingArea.Height)
{
//Снизу
wnd.Top = WorkingArea.Height - wnd.ActualHeight + WorkingArea.Top;
}
}
}
catch (Exception) { }
}
示例3: CreateLogoWindow
private void CreateLogoWindow ()
{
String LogoFileName = Path.Combine (m_CVM.GetProgrammDirectory (), "WPMediaLogo.png");
if (!File.Exists (LogoFileName))
return;
BrushConverter BRConverter = new BrushConverter ();
m_LogoWindow = new System.Windows.Window ();
m_LogoWindow.AllowsTransparency = true;
Brush TransparentBrush = (Brush) BRConverter.ConvertFromString ("Transparent");
m_LogoWindow.Background = TransparentBrush;
m_LogoWindow.BorderBrush = TransparentBrush;
m_LogoWindow.WindowStyle = System.Windows.WindowStyle.None;
m_LogoWindow.SizeToContent = SizeToContent.WidthAndHeight;
m_LogoWindow.Topmost = true;
m_LogoWindow.Top = (double) m_CVM.VideoRectangle.Top + ((double) m_CVM.VideoRectangle.Height) * 0.085;
m_LogoWindow.Left = (double) m_CVM.VideoRectangle.Left + ((double) m_CVM.VideoRectangle.Width) * 0.88;
double Sizing = ((double) m_CVM.VideoRectangle.Width) * 0.055;
Image LogoImage = new Image ();
LogoImage.Opacity = 0.7;
BitmapImage LogoBitmap = new BitmapImage ();
LogoBitmap.BeginInit ();
LogoBitmap.UriSource = new Uri (LogoFileName);
LogoBitmap.CacheOption = BitmapCacheOption.OnLoad;
LogoBitmap.DecodePixelWidth = (int) Sizing;
LogoBitmap.DecodePixelHeight = (int) Sizing;
LogoBitmap.EndInit ();
LogoImage.Source = LogoBitmap;
m_LogoWindow.Content = LogoImage;
m_LogoWindow.UpdateLayout ();
m_LogoWindow.MaxWidth = Sizing;
m_LogoWindow.MaxHeight = Sizing;
m_LogoWindow.Cursor = Cursors.None;
m_LogoWindow.Show ();
}
示例4: NextWindow
static void NextWindow()
{
if (currentWindow == null)
{
if (windowQueue.Count > 0)
{
positionWindow = true;
currentWindow = windowQueue[0];
currentWindow.Opacity = 0.0;
if (currentWindow.IsEnabled)
currentWindow.Show();
currentWindow.UpdateLayout();
windowQueue.RemoveAt(0);
MainWindow.Instance.Focusable = false;
}
else
{
MainWindow.Instance.Focusable = true;
}
}
}