public bool ConnectToServer(List <ServerListEntry> publicServers, string hash) { if (String.IsNullOrEmpty(hash)) { return(false); } ClientStartData data = null; for (int i = 0; i < publicServers.Count; i++) { ServerListEntry entry = publicServers[i]; if (entry.Hash != hash) { continue; } data = new ClientStartData(Session.Username, entry.Mppass, entry.IPAddress, entry.Port); Client.Start(data, true, ref ShouldExit); return(true); } // Fallback to private server handling try { data = Session.GetConnectInfo(hash); } catch (WebException ex) { ErrorHandler2.LogError("retrieving server information", ex); return(false); } catch (ArgumentOutOfRangeException) { return(false); } Client.Start(data, true, ref ShouldExit); return(true); }
public void Init() { Window.Resize += Resize; Window.FocusedChanged += FocusedChanged; Window.WindowStateChanged += Resize; Window.Keyboard.KeyDown += KeyDown; LoadFont(); logoFont = new Font(FontName, 32, FontStyle.Regular); string path = Assembly.GetExecutingAssembly().Location; try { Window.Icon = Icon.ExtractAssociatedIcon(path); } catch (Exception ex) { ErrorHandler2.LogError("LauncherWindow.Init() - Icon", ex); } //Minimised = Window.WindowState == WindowState.Minimized; PlatformID platform = Environment.OSVersion.Platform; if (platform == PlatformID.Win32Windows) { platformDrawer = new WinOldPlatformDrawer(); } else if (Configuration.RunningOnWindows) { platformDrawer = new WinPlatformDrawer(); } else if (Configuration.RunningOnX11) { platformDrawer = new X11PlatformDrawer(); } else if (Configuration.RunningOnMacOS) { platformDrawer = new OSXPlatformDrawer(); } Drawer.Colours['g'] = new FastColour(125, 125, 125); }