void profileItem_Click(object sender, EventArgs e) { if (driver == null) { try { driver = new NetworkEmulationDriver(); if (!driver.Initialize()) { ExitWithError("Failed to Initialize Driver", "NetworkEmulationDriver.Initialize returned false."); return; } } catch (NetworkEmulationException exception) { ExitWithError("Failed to Initialize Driver", exception.Message); return; } } MenuItem menuItem = (MenuItem)sender; string profileLocation = string.Format("{0}{1}Profiles{1}{2}.network", Application.StartupPath, Path.DirectorySeparatorChar, menuItem.Text); try { if (!driver.LoadProfile(profileLocation)) { ExitWithError("Failed to Load Profile", "NetworkEmulationDriver.LoadProfile returned false."); return; } } catch (NetworkEmulationException exception) { ExitWithError("Failed to Load Profile", exception.Message); return; } try { if (!driver.StartEmulation()) { ExitWithError("Failed to Start Emulation", "NetworkEmulationDriver.StartEmulation returned false."); return; } } catch (NetworkEmulationException exception) { ExitWithError("Failed to Start Emulation", exception.Message); return; } tray.Text = string.Format("XLag - On ({0})", menuItem.Text); tray.Icon = onIcon; start.Enabled = false; stop.Enabled = true; running = true; }
public static void Initialize() { if (nDriver == null) { try { nDriver = new NetworkEmulationDriver(); if (nDriver.Initialize()) { Framework.Logger.LogDebug("Network Emulator initialized"); } else { Framework.Logger.LogDebug("Network Emulator failed to initialize"); } } catch (NetworkEmulationDriverNotInstalledException eInstalled) { Framework.Logger.LogDebug(eInstalled.Message); throw new Exception("Emulator Driver not installed", eInstalled); } } }