public MainForm(IServiceProvider bootstrappingServiceProvider, IServiceProvider serviceProvider) { this.serviceProvider = serviceProvider; this.applicationSettings = bootstrappingServiceProvider.GetService <ApplicationSettingsRepository>(); // // Restore window settings. // var windowSettings = this.applicationSettings.GetSettings(); if (windowSettings.IsMainWindowMaximized.BoolValue) { this.WindowState = FormWindowState.Maximized; InitializeComponent(); } else if (windowSettings.MainWindowHeight.IntValue != 0 && windowSettings.MainWindowWidth.IntValue != 0) { InitializeComponent(); this.Size = new Size( windowSettings.MainWindowWidth.IntValue, windowSettings.MainWindowHeight.IntValue); } else { InitializeComponent(); } // Set fixed size for the left/right panels (in pixels). this.dockPanel.DockLeftPortion = this.dockPanel.DockRightPortion = 300.0f; // // Bind controls. // this.Text = GeneralOptionsViewModel.FriendlyName; this.ViewMenu = new CommandContainer <IMainForm>( this, this.viewToolStripMenuItem.DropDownItems, ToolStripItemDisplayStyle.ImageAndText, this.serviceProvider) { Context = this // There is no real context for this. }; this.viewModel = new MainFormViewModel( this, this.vs2015LightTheme.ColorPalette, bootstrappingServiceProvider.GetService <ApplicationSettingsRepository>(), bootstrappingServiceProvider.GetService <AuthSettingsRepository>()); this.reportInternalIssueToolStripMenuItem.BindProperty( c => c.Visible, this.viewModel, m => m.IsReportInternalIssueVisible, this.components); // Status bar. this.statusStrip.BindProperty( c => c.BackColor, this.viewModel, m => m.StatusBarBackColor, this.components); this.toolStripStatus.BindProperty( c => c.Text, this.viewModel, m => m.StatusText, this.components); this.backgroundJobLabel.BindProperty( c => c.Visible, this.viewModel, m => m.IsBackgroundJobStatusVisible, this.components); this.cancelBackgroundJobsButton.BindProperty( c => c.Visible, this.viewModel, m => m.IsBackgroundJobStatusVisible, this.components); this.backgroundJobLabel.BindProperty( c => c.Text, this.viewModel, m => m.BackgroundJobStatus, this.components); this.toolStripSignInStateButton.BindProperty( c => c.Text, this.viewModel, m => m.SignInStateCaption, this.components); this.toolStripDeviceStateButton.BindProperty( c => c.Text, this.viewModel, m => m.DeviceStateCaption, this.components); this.toolStripDeviceStateButton.BindProperty( c => c.Visible, this.viewModel, m => m.IsDeviceStateVisible, this.components); // Logging. this.enableloggingToolStripMenuItem.BindProperty( c => c.Checked, this.viewModel, m => m.IsLoggingEnabled, this.components); }
public MainForm(IServiceProvider bootstrappingServiceProvider, IServiceProvider serviceProvider) { this.serviceProvider = serviceProvider; this.applicationSettings = bootstrappingServiceProvider.GetService <ApplicationSettingsRepository>(); // // Restore window settings. // var windowSettings = this.applicationSettings.GetSettings(); if (windowSettings.IsMainWindowMaximized) { this.WindowState = FormWindowState.Maximized; InitializeComponent(); } else if (windowSettings.MainWindowHeight != 0 && windowSettings.MainWindowWidth != 0) { InitializeComponent(); this.Size = new Size( windowSettings.MainWindowWidth, windowSettings.MainWindowHeight); } else { InitializeComponent(); } // Set fixed size for the left/right panels (in pixels). this.dockPanel.DockLeftPortion = this.dockPanel.DockRightPortion = 300.0f; // // Bind controls. // this.Text = MainFormViewModel.FriendlyName; this.ViewCommands = new CommandContainer <IMainForm>( this, this.viewToolStripMenuItem.DropDownItems, ToolStripItemDisplayStyle.ImageAndText, this.serviceProvider); this.ViewCommands.Context = this; // There is no real context for this. this.viewModel = new MainFormViewModel( this, this.applicationSettings, bootstrappingServiceProvider.GetService <AuthSettingsRepository>(), bootstrappingServiceProvider.GetService <AppProtocolRegistry>()); // Status bar. this.backgroundJobLabel.BindProperty( c => c.Visible, this.viewModel, m => m.IsBackgroundJobStatusVisible, this.components); this.cancelBackgroundJobsButton.BindProperty( c => c.Visible, this.viewModel, m => m.IsBackgroundJobStatusVisible, this.components); this.backgroundJobLabel.BindProperty( c => c.Text, this.viewModel, m => m.BackgroundJobStatus, this.components); this.toolStripEmail.BindProperty( c => c.Text, this.viewModel, m => m.UserEmail, this.components); // Menus. this.checkForUpdatesOnExitToolStripMenuItem.BindProperty( c => c.Checked, this.viewModel, m => m.IsUpdateCheckEnabled, this.components); this.enableAppProtocolToolStripMenuItem.BindProperty( c => c.Checked, this.viewModel, m => m.IsProtocolRegistred, this.components); }