private bool ConnectWithForm() { ConnectForm form = new ConnectForm(); if (_connectionProfile == null) { form.ServerSettings = new ServerSettings(); } else { form.ProfileName = _connectionProfile.Name; form.ServerSettings = new ServerSettings() { ServerName = _connectionProfile.ServerSettings.ServerName, Port = ServerSettings.DefaultHttpPort, Transport = ServiceTransport.Http }; } if (form.ShowDialog(this) == DialogResult.OK) { _connectionProfile = new ConnectionProfile() { ServerSettings = form.ServerSettings, SavePassword = form.SavePassword }; if (!String.IsNullOrEmpty(form.ProfileName)) { _connectionProfile.Name = form.ProfileName; ConnectionProfiles.Add(_connectionProfile); } RefreshFormTitle(); return(true); } return(false); }
private void GenerateDesignMode() { var random = new Random(); for (var x = 0; x < 10; x++) { var connectionInfo = new ConnectionInfo { AuthenticationType = RandomItem(AuthenticationTypes, random), EncryptionType = RandomItem(EncryptionTypes, random), ConnectivityLevel = RandomItem(ConnectivityLevels, random), DomainConnectivityLevel = RandomItem(DomainLevels, random), IncomingBitsPerSecond = random.Next(0, int.MaxValue), OutgoingBitsPerSecond = random.Next(0, int.MaxValue), IsWlan = random.Next(0, 1) == 0, IsWwan = random.Next(0, 1) == 0, Name = Guid.NewGuid().ToString().Replace('-', ' '), NetworkAdapterId = Guid.NewGuid(), NetworkType = RandomItem(NetworkTypeList, random), CostType = RandomItem(CostTypes, random), SignalBars = (short)random.Next(0, 5), Flags = string.Format( "{0} {1}", random.Next(0, 1) == 0 ? (random.Next(0, 1) == 0 ? "Approaching Data Limit" : "Over Data Limit") : string.Empty, random.Next(0, 1) == 0 ? "Roaming" : string.Empty) .Trim() }; if (random.Next(0, 1) == 0) { var dataPlan = new DataPlanInfo { DataLimitMegabytes = random.Next(0, int.MaxValue), InboundBitsPerSecond = (ulong)random.Next(0, int.MaxValue), OutboundBitsPerSecond = (ulong)random.Next(0, int.MaxValue) }; if (random.Next(0, 1) == 0) { dataPlan.NextBillingCycle = DateTime.Now.AddDays(random.Next(1, 30)); } if (random.Next(0, 1) == 0) { dataPlan.MegabytesUsed = random.Next(0, int.MaxValue); dataPlan.LastSyncTime = DateTime.Now.AddHours(-1 * random.Next(2, 12)); } connectionInfo.DataPlan = dataPlan; } connectionInfo.BytesReceivedLastDay = (ulong)random.Next(0, int.MaxValue); connectionInfo.BytesSentLastDay = (ulong)random.Next(0, int.MaxValue); ConnectionProfiles.Add(connectionInfo); } CurrentConnectionInfo = ConnectionProfiles[random.Next(0, ConnectionProfiles.Count)]; }
private void AddServer(object cp) { if (!(cp is ConnectionProfile)) { throw new ArgumentException("connProfile is not of type ConnectionProfile.", "connProfile"); } var connProfile = (ConnectionProfile)cp; ConnectionProfiles.Add(connProfile); }
public void Initialize() { var profiles = MtRegistryManager.LoadConnectionProfiles(); if (profiles != null) { foreach (var prof in profiles) { ConnectionProfiles.Add(prof); } } }
private void ExecuteAddProfile(object o) { var dlg = new AddProfileDialog(App.Current.MainWindow); var result = dlg.ShowDialog(); if (result == true) { var profile = new MtConnectionProfile(dlg.ProfileName); profile.Host = dlg.Host; profile.Port = int.Parse(dlg.Port); MtRegistryManager.AddConnectionProfile(profile); ConnectionProfiles.Add(profile); } }