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


C# Window.UpdateLayout方法代码示例

本文整理汇总了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;
 }
开发者ID:hinst,项目名称:MyCSharp,代码行数:7,代码来源:WindowPositionManager.cs

示例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) { }
        }
开发者ID:BrunoReX,项目名称:xvid4psp,代码行数:58,代码来源:Calculate.cs

示例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 ();
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:34,代码来源:RootWindow.xaml.cs

示例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;
         }
     }
 }
开发者ID:hamada147,项目名称:ModAPI,代码行数:21,代码来源:MainWindow.xaml.cs


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