mirror of
				https://github.com/2dust/v2rayN.git
				synced 2025-11-04 14:32:53 +00:00 
			
		
		
		
	Merge pull request #2962 from FrzMtrsprt/Fix_Window_Size
Fix window size on first launch
This commit is contained in:
		
						commit
						97a369df0a
					
				
					 1 changed files with 16 additions and 11 deletions
				
			
		| 
						 | 
					@ -1,11 +1,13 @@
 | 
				
			||||||
using ReactiveUI;
 | 
					using ReactiveUI;
 | 
				
			||||||
using Splat;
 | 
					using Splat;
 | 
				
			||||||
using System.ComponentModel;
 | 
					using System.ComponentModel;
 | 
				
			||||||
 | 
					using System.Drawing;
 | 
				
			||||||
using System.Reactive.Disposables;
 | 
					using System.Reactive.Disposables;
 | 
				
			||||||
using System.Windows;
 | 
					using System.Windows;
 | 
				
			||||||
using System.Windows.Controls;
 | 
					using System.Windows.Controls;
 | 
				
			||||||
using System.Windows.Controls.Primitives;
 | 
					using System.Windows.Controls.Primitives;
 | 
				
			||||||
using System.Windows.Input;
 | 
					using System.Windows.Input;
 | 
				
			||||||
 | 
					using System.Windows.Interop;
 | 
				
			||||||
using v2rayN.Handler;
 | 
					using v2rayN.Handler;
 | 
				
			||||||
using v2rayN.Mode;
 | 
					using v2rayN.Mode;
 | 
				
			||||||
using v2rayN.Resx;
 | 
					using v2rayN.Resx;
 | 
				
			||||||
| 
						 | 
					@ -372,18 +374,21 @@ namespace v2rayN.Views
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (_config.uiItem.mainWidth > 0 && _config.uiItem.mainHeight > 0)
 | 
					            if (_config.uiItem.mainWidth > 0 && _config.uiItem.mainHeight > 0)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (_config.uiItem.mainWidth > SystemInformation.WorkingArea.Width)
 | 
					                Width = _config.uiItem.mainWidth;
 | 
				
			||||||
                {
 | 
					                Height = _config.uiItem.mainHeight;
 | 
				
			||||||
                    _config.uiItem.mainWidth = SystemInformation.WorkingArea.Width * 2 / 3;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (_config.uiItem.mainHeight > SystemInformation.WorkingArea.Height)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    _config.uiItem.mainHeight = SystemInformation.WorkingArea.Height * 2 / 3;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                this.Width = _config.uiItem.mainWidth;
 | 
					 | 
				
			||||||
                this.Height = _config.uiItem.mainHeight;
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            IntPtr hWnd = new WindowInteropHelper(this).EnsureHandle();
 | 
				
			||||||
 | 
					            Graphics g = Graphics.FromHwnd(hWnd);
 | 
				
			||||||
 | 
					            if (Width > SystemInformation.WorkingArea.Width * 96 / g.DpiX)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Width = SystemInformation.WorkingArea.Width * 96 / g.DpiX;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (Height > SystemInformation.WorkingArea.Height * 96 / g.DpiY)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Height = SystemInformation.WorkingArea.Height * 96 / g.DpiY;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (int k = 0; k < lstProfiles.Columns.Count; k++)
 | 
					            for (int k = 0; k < lstProfiles.Columns.Count; k++)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var width = ConfigHandler.GetformMainLvColWidth(ref _config, ((EServerColName)k).ToString(), Convert.ToInt32(lstProfiles.Columns[k].Width.Value));
 | 
					                var width = ConfigHandler.GetformMainLvColWidth(ref _config, ((EServerColName)k).ToString(), Convert.ToInt32(lstProfiles.Columns[k].Width.Value));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue