public NetworkQuickConnectViewModel() { this.NetworkName = string.Empty; this.NetworkAddress = string.Empty; this.IdentityName = string.Empty; this.IdentityAlternative = string.Empty; this.IdentityRealName = string.Empty; this.UseCustomIdentity = this.forceCustomIdentity = Identity.GlobalIdentity() == null; }
/// <summary> /// Initializes a new instance of the IrcNetworkViewModel class /// </summary> public IrcNetworkViewModel(Network network, Settings settings) { this.Closable = true; this.DisplayName = network.Name; this.Settings = settings; IrcRegistrationInfo info; if (network.UseCustomIdentity) { info = new IrcUserRegistrationInfo() { NickName = network.Identity.Name ?? Environment.UserName, UserName = Environment.UserName, RealName = network.Identity.RealName ?? "Rumpelstilzchen", }; } else { Identity id = Identity.GlobalIdentity(); info = new IrcUserRegistrationInfo() { NickName = id.Name ?? Environment.UserName, UserName = Environment.UserName, RealName = id.RealName ?? "Rumpelstilzchen", }; } this.ProgressService = IoC.Get <IProgressService>(); this.Client = new IrcClient(); this.Client.Registered += this.clientRegistered; this.Client.ProtocolError += this.clientProtocolError; // TODO Display Popup this.Client.ConnectFailed += delegate(object sender, IrcErrorEventArgs e) { this.ProgressService.Hide(); Console.WriteLine("Couldn't connect to server"); }; using (var connectedEvent = new ManualResetEventSlim(false)) { this.Client.Connected += (sender, e) => connectedEvent.Set(); this.ProgressService.Show(); client.Connect(network.Address, false, info); if (!connectedEvent.Wait(1000)) { this.Client.Dispose(); return; } } }
/// <summary> /// Initializes a new instance of the NetworkSelectionViewModel class. /// </summary> public NetworkSelectionViewModel() { this.loadNetworks(); this.DisplayName = "Networks"; try { this.windowManager = IoC.Get <IWindowManager>(); } catch { this.windowManager = new WindowManager(); } this.GlobalIdentity = Identity.GlobalIdentity(); }
public void Connect() { if (this.UseCustomIdentity) { this.ConnectButtonPressed(new Network(this.NetworkName, this.NetworkAddress, false, string.Empty, new Identity(this.IdentityName, string.Empty, this.IdentityAlternative, this.IdentityRealName), true)); } else { this.ConnectButtonPressed(new Network(this.NetworkName, this.NetworkAddress, false, string.Empty, Identity.GlobalIdentity(), false)); } }