private void SelectProfileMenu_Click(object sender, RoutedEventArgs e) { SelectProfileForm selectProfileForm = new SelectProfileForm(); selectProfileForm.FillUI(); if (selectProfileForm.ShowDialog() != true) { return; } CurrentProfile = selectProfileForm.SelectedProfile; IsProfileSelected = true; }
public bool ConnectToArgusTVService(string currentProfileName, bool reconnect) { bool result = false; bool abortConnection = false; bool tryConnectionWithoutUI = !reconnect; bool skipSelectionForm = false; IList <ConnectionProfile> profiles = ConnectionProfiles.GetList(); if (!reconnect && !String.IsNullOrEmpty(currentProfileName)) { _connectionProfile = FindConnectionProfileByName(profiles, currentProfileName); skipSelectionForm = (_connectionProfile != null); } if (_connectionProfile != null) { currentProfileName = _connectionProfile.Name; } else { currentProfileName = Properties.Settings.Default.LastUsedConnectionProfile; } if (profiles.Count == 1) { _connectionProfile = profiles[0]; } else if (profiles.Count > 1 && !skipSelectionForm) { if (!reconnect) { Program.App.HideSplash(); } SelectProfileForm selectProfileForm = new SelectProfileForm(); selectProfileForm.SetSelectedProfileName(currentProfileName); if (selectProfileForm.ShowDialog(this) == DialogResult.OK) { _connectionProfile = selectProfileForm.SelectedProfile; if (_connectionProfile != null) { tryConnectionWithoutUI = !selectProfileForm.EditSelectedProfile; if (tryConnectionWithoutUI && !reconnect) { Program.App.ShowSplash(); } } } else { result = false; abortConnection = true; } } if (!abortConnection) { if (tryConnectionWithoutUI && _connectionProfile != null) { bool saveProfiles = false; if (_connectionProfile.ServerSettings.Transport == ServiceProxy.ServiceTransport.Https && String.IsNullOrEmpty(_connectionProfile.ServerSettings.Password)) { using (LogonForm logonForm = new LogonForm()) { logonForm.UserName = _connectionProfile.ServerSettings.UserName; Program.App.HideSplash(); if (DialogResult.OK == logonForm.ShowDialog(this)) { _connectionProfile.ServerSettings.UserName = logonForm.UserName; _connectionProfile.ServerSettings.Password = logonForm.Password; _connectionProfile.SavePassword = logonForm.SavePassword; saveProfiles = _connectionProfile.SavePassword; } } } try { Cursor.Current = Cursors.WaitCursor; string macAddresses = _connectionProfile.ServerSettings.WakeOnLan.MacAddresses; string ipAddress = _connectionProfile.ServerSettings.WakeOnLan.IPAddress; if (!Proxies.Initialize(_connectionProfile.ServerSettings, false)) { Program.App.HideSplash(); result = ConnectWithForm(); } else { if (saveProfiles || !String.Equals(macAddresses, _connectionProfile.ServerSettings.WakeOnLan.MacAddresses) || !String.Equals(ipAddress, _connectionProfile.ServerSettings.WakeOnLan.IPAddress)) { ConnectionProfiles.Save(); } RefreshFormTitle(); result = true; } } finally { Cursor.Current = Cursors.Default; } } else { if (!reconnect) { Program.App.HideSplash(); } result = ConnectWithForm(); } } if (result && Properties.Settings.Default.LastUsedConnectionProfile != _connectionProfile.Name) { Properties.Settings.Default.LastUsedConnectionProfile = _connectionProfile.Name; Properties.Settings.Default.Save(); } return(result); }