Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 public static bool StartEmulation(string fileName)
 {
     if (!string.IsNullOrEmpty(fileName))
     {
         nDriver.LoadProfile(fileName);
         return(nDriver.StartEmulation());
     }
     else
     {
         return(false);
     }
 }