public static bool SelectTestSet(out TestProgramSet testSet) { testSet = null; string testSetPath = GetTestSetPath(); //FileManager.OpenFolder(out testSetPath); var form = new DirectorySelectionForm(testSetPath); form.Text = @"Select Test Program Set Project"; if (DialogResult.OK == form.ShowDialog()) { using (new HourGlass()) { string testSetName = form.SelectedFolder; testSet = OpenTestSet(testSetName); } } return(testSet != null); }
static void Main() { // Check security try { SecurityPermission permissions = new SecurityPermission(PermissionState.Unrestricted); permissions.Demand(); } catch (SecurityException) { MessageBox.Show( "Vha.Chat was unable to obtain the required execution permissions.\n" + "This might be because you're attempting to run this application from a network drive or due to specific restrictions setup on your machine.\n\n" + "This application will now close.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Initialize Windows.Forms application Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); #if !DEBUG AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException); #endif // Fix working directory string path = Assembly.GetExecutingAssembly().Location; if (path.LastIndexOf(Path.DirectorySeparatorChar) > 0) { path = Path.GetDirectoryName(path); Environment.CurrentDirectory = path; } // Load initial configuration Data.Base data = Data.Base.Load("Configuration.xml"); if (data == null) { data = new Data.ConfigurationV1(); } while (data.CanUpgrade) { data = data.Upgrade(); } if (data.Type != typeof(ConfigurationV1)) { throw new ArgumentException("Unexpected data type in Configuration.xml: " + data.Type.ToString()); } ConfigurationV1 configData = (ConfigurationV1)data; // Detect folders string defaultPath = Path.GetFullPath(configData.OptionsPath); bool defaultOptionsExists = File.Exists(defaultPath + Path.DirectorySeparatorChar + configData.OptionsFile); string appDataPath = string.Format("{1}{0}{2}", Path.DirectorySeparatorChar, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Vha.Chat"); bool appDataOptionsExists = File.Exists(appDataPath + Path.DirectorySeparatorChar + configData.OptionsFile); // Determine default folder if (defaultOptionsExists) { configData.OptionsPath = defaultPath; } else if (appDataOptionsExists) { configData.OptionsPath = appDataPath; } else { // Show directory selection form DirectorySelectionForm form = new DirectorySelectionForm( configData, defaultPath, appDataPath); Application.Run(form); // Guess the user didn't like Vha.Chat :( if (form.DialogResult != DialogResult.OK) { return; } } // Create context Configuration configuration = new Configuration(configData); Context context = new Context(configuration); context.Options.Save(); #if !DEBUG context.ExceptionEvent += new Handler <Exception>(UnhandledException); #endif // Store config directory ApplicationConfigDirectory = configData.OptionsPath; // Start application ApplicationContext = new ApplicationContext(); ApplicationContext.MainForm = new AuthenticationForm(context); Application.Run(ApplicationContext); }