public MainWindow() { InitializeComponent(); //ContentBackground.Background.Opacity = 1.0; new WindowResizer(this, new WindowBorder(BorderPosition.TopLeft, topLeft), new WindowBorder(BorderPosition.Top, top), new WindowBorder(BorderPosition.TopRight, topRight), new WindowBorder(BorderPosition.Right, right), new WindowBorder(BorderPosition.BottomRight, bottomRight), new WindowBorder(BorderPosition.Bottom, bottom), new WindowBorder(BorderPosition.BottomLeft, bottomLeft), new WindowBorder(BorderPosition.Left, left)); TitleBar.MouseLeftButtonDown += ((o, e) => DragMove()); MinimizeButton.MouseLeftButtonDown += ((o, e) => WindowState = WindowState.Minimized); CloseButton.MouseLeftButtonDown += ((o, e) => Close()); _errorPage = new ErrorPage(); _errorPage.ErrorClose += _errorPage_ErrorClose; transitionControl.AddPage(_errorPage); _loadingPage = new LoadingPage(); transitionControl.AddPage(_loadingPage); _update = new UpdateCheck(); transitionControl.ShowPage(_loadingPage); _config = new Config(_configLocation ?? ""); if (!_config.LoadConfig()) { _configError = true; } else { if (_config.Fields.Proxy_Address != string.Empty) PRequest.SetProxy(_config.Fields.Proxy_Address, _config.Fields.Proxy_Port, _config.Fields.Proxy_User, _config.Fields.Proxy_Password); var loc = _config.Fields.Elpis_StartupLocation; var size = _config.Fields.Elpis_StartupSize; if (loc.X != -1 && loc.Y != -1) { this.Left = loc.X; this.Top = loc.Y; } if (size.Width != 0 && size.Height != 0) { this.Width = size.Width; this.Height = size.Height; } } _mainWindow = this; }
public MainWindow() { InitializeComponent(); //ContentBackground.Background.Opacity = 1.0; new WindowResizer(this, new WindowBorder(BorderPosition.TopLeft, topLeft), new WindowBorder(BorderPosition.Top, top), new WindowBorder(BorderPosition.TopRight, topRight), new WindowBorder(BorderPosition.Right, right), new WindowBorder(BorderPosition.BottomRight, bottomRight), new WindowBorder(BorderPosition.Bottom, bottom), new WindowBorder(BorderPosition.BottomLeft, bottomLeft), new WindowBorder(BorderPosition.Left, left)); TitleBar.MouseLeftButtonDown += ((o, e) => DragMove()); MinimizeButton.MouseLeftButtonDown += ((o, e) => WindowState = WindowState.Minimized); CloseButton.MouseLeftButtonDown += ((o, e) => Close()); _errorPage = new ErrorPage(); _errorPage.ErrorClose += _errorPage_ErrorClose; transitionControl.AddPage(_errorPage); _loadingPage = new LoadingPage(); transitionControl.AddPage(_loadingPage); _update = new UpdateCheck(); transitionControl.ShowPage(_loadingPage); _config = new Config(_configLocation ?? ""); if (!_config.LoadConfig()) { _configError = true; } else { if (_config.Fields.Proxy_Address != string.Empty) PRequest.SetProxy(_config.Fields.Proxy_Address, _config.Fields.Proxy_Port, _config.Fields.Proxy_User, _config.Fields.Proxy_Password); var loc = _config.Fields.Elpis_StartupLocation; var size = _config.Fields.Elpis_StartupSize; if (loc.X != -1 && loc.Y != -1) { // Bug Fix: Issue #54, make sure that the initial window location is // always fully within the virtual screen bounds. // Unfortunately may not preserve window location when primary display is not left most // but it eliminates the missing window problem in most situations. this.Left = Math.Max(0, Math.Min(loc.X, SystemParameters.VirtualScreenWidth - this.ActualWidth)); this.Top = Math.Max(0, Math.Min(loc.Y, SystemParameters.VirtualScreenHeight - this.ActualHeight)); } if (size.Width != 0 && size.Height != 0) { this.Width = size.Width; this.Height = size.Height; } } _mainWindow = this; }