private void ModuleUsageVisualizerForm_Paint(object sender, PaintEventArgs e) { if (selectedRobot != null && selectedRobot.brainHistory != null && selectedRobot.brainHistory.Count > 1) { double widthPerStep = this.Width / (1.0 * selectedRobot.brainHistory.Count); g = e.Graphics; int currentMode = selectedRobot.brainHistory[0]; int modeStartTime = 0; Rectangle r; for (int i = 0; i < selectedRobot.brainHistory.Count; i++) { // Schrum: Draw each contiguous period of the same mode as a single // rectangle. This is needed because individual time slices eventually // drop in width below one pixel, and can't be drawn individuallly. if (currentMode != selectedRobot.brainHistory[i]) { r = new Rectangle((int)(modeStartTime * widthPerStep), 0, (int)((i - modeStartTime) * widthPerStep), this.Height); g.FillRectangle(EngineUtilities.modePen(currentMode), r); // Schrum: Adjust to track new mode modeStartTime = i; currentMode = selectedRobot.brainHistory[i]; } } // Schrum: Draw final rectangle for module used up until the current time step r = new Rectangle((int)(modeStartTime * widthPerStep), 0, (int)((selectedRobot.brainHistory.Count - modeStartTime) * widthPerStep), this.Height); g.FillRectangle(EngineUtilities.modePen(currentMode), r); } }
public OneDasProjectSettings Load(string filePath) { JObject jObject; OneDasProjectSettings projectSettings; jObject = JObject.Parse(File.ReadAllText(filePath)); this.Upgrade(jObject); try { projectSettings = _oneDasSerializer.Deserialize <OneDasProjectSettings>(jObject.ToString()); projectSettings.Validate(); return(projectSettings); } catch (Exception ex) { throw EngineUtilities.UnwrapException(ex); } }