void ConfigureWorldGUI() { bool firstRound = GlobalManager.MStorage.FirstRound; int selectedLevel = GlobalManager.MStorage.SelectedLevel; // configure world GUI GUIConfiguration worldConfiguration = worldGenericGUIConfiguration; if (firstRound) { switch (selectedLevel) { case 0: worldConfiguration = worldLevel0GUIConfiguration; break; case 1: worldConfiguration = worldLevel1GUIConfiguration; break; default: worldConfiguration = worldRun1GUIConfiguration; worldConfiguration.magicButon = showMagicButton; break; } } else { worldConfiguration.magicButon = showMagicButton; } GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.GUIConfigureAppearance, this, worldConfiguration); }
bool puzzleCompletionProcessed; // set to false on puzzle start; set to true on entry into OnPuzzleComplete void OnPuzzleStarted(object sender, InstantMessageArgs args) { sceneType = SceneType.Puzzle; bool firstRound = GlobalManager.MStorage.FirstRound; int selectedLevel = GlobalManager.MStorage.SelectedLevel; puzzleHintsShown = true; puzzleCompletionProcessed = false; // configure puzzle GUI GUIConfiguration puzzleConfiguration = puzzleGenericGUIConfiguration; if (firstRound) { switch (selectedLevel) { case 0: puzzleHintsShown = false; puzzleCompletionProcessed = false; puzzleConfiguration = puzzleLevel0GUIConfiguration; break; case 1: puzzleHintsShown = false; puzzleCompletionProcessed = false; puzzleConfiguration = puzzleLevel1GUIConfiguration; break; } } GlobalManager.MInstantMessage.DeliverMessage(InstantMessageType.GUIConfigureAppearance, this, puzzleConfiguration); }
public void LoadOrCreateConfiguration_MalformedXMLFile_ThrowsKraken() { string tempFile = Path.Combine(tempDir, "invalid.xml"); using (var stream = new StreamWriter(tempFile)) { stream.Write("This is not a valid XML file."); } Assert.Throws <Kraken>(() => GUIConfiguration.LoadOrCreateConfiguration(tempFile)); }
public void LoadOrCreateConfiguration_CorrectConfigurationFile_Loaded() { string tempFile = Path.Combine(tempDir, "valid.xml"); using (var stream = new StreamWriter(tempFile)) { stream.Write(TestData.ConfigurationFile()); } var result = GUIConfiguration.LoadOrCreateConfiguration(tempFile); Assert.IsNotNull(result); }
// This function is registered to handle data events from the acquisitor. // Whenever the acquisitor has new data it will call this function. // Note well that this will be called on the acquisitor thread (meaning // no direct GUI manipulation in this function). private void DataHandler(object sender, DataEventArgs e) { lock (this) { // grab the settings GUIConfiguration guiConfig = profileManager.CurrentProfile.GUIConfig; // store the datapoint dataStore.AddScanPoint(e.point); // tell the viewers to handle the data point viewerManager.HandleDataPoint(e); } }
public static void Loader() { ProgressChain chain = new ProgressChain(); chain.OnChange += delegate() { SplashScreen.Progress = chain.Progress * 0.7f; }; chain.AddTask(delegate(ProgressHandler handler) { if (Configuration.Load(handler) == Configuration.ResultCode.ERROR) { } }, 30f); chain.AddTask(delegate(ProgressHandler handler) { if (DynamicTypes.Load(handler) == DynamicTypes.ResultCode.ERROR) { } }, 10f); chain.AddTask(delegate(ProgressHandler handler) { if (GUIConfiguration.Load(handler) == GUIConfiguration.ResultCode.ERROR) { handler.Progress = 100f; } }, 30f); chain.Start(); /*if (DynamicTypes.Load() == DynamicTypes.ResultCode.OK) * { * SplashScreen.Progress = 100; * }*/ }
public void Run() { manager.Window.WriteLine("ScanMaster command shell."); for (;;) { String command = manager.Window.GetNextLine(); if (manager.CurrentProfile == null) { manager.Window.WriteLine("No profile selected !"); continue; } if (Controller.GetController().appState != Controller.AppState.stopped) { if (command.StartsWith("tweak")) { manager.Window.WriteLine("Entering tweak mode ..."); TweakMode(command); continue; } manager.Window.WriteLine("Only tweak is available when acquiring."); continue; } // info on the current profile if (command == "i") { manager.Window.WriteLine(manager.CurrentProfile.ToString()); continue; } // update profile set to incorporate any newly introduced settings if (command == "refresh") { manager.UpdateProfiles(); manager.Window.WriteLine("Updated profiles."); continue; } if (command == "g") { if (groupEditMode) { groupEditMode = false; manager.Window.WriteLine("Group edit mode is off"); manager.Window.Prompt = ":> "; manager.Window.OutputColor = System.Drawing.Color.Lime; continue; } else { groupEditMode = true; manager.Window.WriteLine("Group edit mode is on. Current group " + manager.CurrentProfile.Group); manager.Window.Prompt = manager.CurrentProfile.Group + ":> "; manager.Window.OutputColor = System.Drawing.Color.White; continue; } } // anything after here (apart from a syntax error) will change the profiles // so this is an appropriate point to manager.ProfilesChanged = true; if (command.StartsWith("set") && groupEditMode) { manager.Window.WriteLine("You can't set things in group mode."); continue; } // changing plugins if (command == "set out") { String[] plugins = PluginRegistry.GetRegistry().GetOutputPlugins(); int r = ChoosePluginDialog(plugins); if (r != -1) { manager.CurrentProfile.AcquisitorConfig.SetOutputPlugin(plugins[r]); } continue; } if (command == "set shot") { String[] plugins = PluginRegistry.GetRegistry().GetShotGathererPlugins(); int r = ChoosePluginDialog(plugins); if (r != -1) { manager.CurrentProfile.AcquisitorConfig.SetShotGathererPlugin(plugins[r]); } continue; } if (command == "set pg") { String[] plugins = PluginRegistry.GetRegistry().GetPatternPlugins(); int r = ChoosePluginDialog(plugins); if (r != -1) { manager.CurrentProfile.AcquisitorConfig.SetPatternPlugin(plugins[r]); } continue; } if (command == "set yag") { String[] plugins = PluginRegistry.GetRegistry().GetYAGPlugins(); int r = ChoosePluginDialog(plugins); if (r != -1) { manager.CurrentProfile.AcquisitorConfig.SetYAGPlugin(plugins[r]); } continue; } if (command == "set analog") { String[] plugins = PluginRegistry.GetRegistry().GetAnalogPlugins(); int r = ChoosePluginDialog(plugins); if (r != -1) { manager.CurrentProfile.AcquisitorConfig.SetAnalogPlugin(plugins[r]); } continue; } if (command == "set switch") { String[] plugins = PluginRegistry.GetRegistry().GetSwitchPlugins(); int r = ChoosePluginDialog(plugins); if (r != -1) { manager.CurrentProfile.AcquisitorConfig.SetSwitchPlugin(plugins[r]); } continue; } // changing group if (command.StartsWith("set group")) { String[] bits = command.Split(new char[] { ' ' }); if (bits.Length != 3) { manager.Window.WriteLine("Syntax error."); continue; } manager.CurrentProfile.Group = bits[2]; manager.Window.WriteLine("Group changed"); continue; } // listing plugin settings if (command == "out") { String settings = sr.ListSettings(manager.CurrentProfile.AcquisitorConfig.outputPlugin); manager.Window.WriteLine(settings); continue; } if (command == "analog") { String settings = sr.ListSettings(manager.CurrentProfile.AcquisitorConfig.analogPlugin); manager.Window.WriteLine(settings); continue; } if (command == "switch") { String settings = sr.ListSettings(manager.CurrentProfile.AcquisitorConfig.switchPlugin); manager.Window.WriteLine(settings); continue; } if (command == "pg") { String settings = sr.ListSettings(manager.CurrentProfile.AcquisitorConfig.pgPlugin); manager.Window.WriteLine(settings); continue; } if (command == "yag") { String settings = sr.ListSettings(manager.CurrentProfile.AcquisitorConfig.yagPlugin); manager.Window.WriteLine(settings); continue; } if (command == "shot") { String settings = sr.ListSettings(manager.CurrentProfile.AcquisitorConfig.shotGathererPlugin); manager.Window.WriteLine(settings); continue; } if (command == "gui") { manager.Window.WriteLine("tofUpdate " + manager.CurrentProfile.GUIConfig.updateTOFsEvery); manager.Window.WriteLine("spectraUpdate " + manager.CurrentProfile.GUIConfig.updateSpectraEvery); manager.Window.WriteLine("switch " + manager.CurrentProfile.GUIConfig.displaySwitch); manager.Window.WriteLine("average " + manager.CurrentProfile.GUIConfig.average); continue; } // changing plugin settings if (command.StartsWith("out:") | command.StartsWith("analog:") | command.StartsWith("pg:") | command.StartsWith("yag:") | command.StartsWith("switch:") | command.StartsWith("shot:") | command.StartsWith("gui:")) { String[] bits = command.Split(new char[] { ':', ' ' }); if (bits.Length != 3) { manager.Window.WriteLine("Syntax error."); continue; } // special case for GUI settings (it's not a plugin) if (bits[0] == "gui") { if (groupEditMode) { manager.Window.WriteLine("Sorry, but, hilariously, there is no " + "group edit mode for GUI settings."); continue; } GUIConfiguration guiConfig = manager.CurrentProfile.GUIConfig; try { if (bits[1] == "tofUpdate") { guiConfig.updateTOFsEvery = Convert.ToInt32(bits[2]); manager.Window.WriteLine("GUI:tofUpdate updated."); continue; } if (bits[1] == "spectraUpdate") { guiConfig.updateSpectraEvery = Convert.ToInt32(bits[2]); manager.Window.WriteLine("GUI:spectraUpdate updated."); continue; } if (bits[1] == "switch") { guiConfig.displaySwitch = Convert.ToBoolean(bits[2]); manager.Window.WriteLine("GUI:switch updated."); continue; } if (bits[1] == "average") { guiConfig.average = Convert.ToBoolean(bits[2]); manager.Window.WriteLine("GUI:average updated."); continue; } manager.Window.WriteLine("Unrecognised parameter"); } catch (Exception) { manager.Window.WriteLine("Error."); } } else { if (groupEditMode) { // first, check to make sure that every profile in the group has such // a setting. ArrayList groupProfiles = manager.ProfilesInGroup(manager.CurrentProfile.Group); bool fieldFlag = true; foreach (Profile p in groupProfiles) { AcquisitorPlugin pl = PluginForString(p, bits[0]); if (!sr.HasField(pl, bits[1])) { fieldFlag = false; } } if (!fieldFlag) { manager.Window.WriteLine("You can only change the value of a setting in group " + "edit mode if all profiles in the group have that setting."); continue; } // if so, then set them all foreach (Profile p in groupProfiles) { AcquisitorPlugin plugin = PluginForString(p, bits[0]); if (sr.SetField(plugin, bits[1], bits[2])) { manager.Window.WriteLine(p.Name + ":" + bits[0] + ":" + bits[1] + " modified."); } else { manager.Window.WriteLine("Error setting field"); } } } else { AcquisitorPlugin plugin = PluginForString(manager.CurrentProfile, bits[0]); if (sr.SetField(plugin, bits[1], bits[2])) { manager.Window.WriteLine(bits[0] + ":" + bits[1] + " modified."); } else { manager.Window.WriteLine("Error setting field"); } } } continue; } // tweaking a setting // if we reach here there must be a syntax error manager.Window.WriteLine("Syntax error"); } }