private void ResetSimulationButton_Click(object sender, EventArgs e) { if (Simulation == null) { return; } if (int.TryParse(RandomSeedCombo.Text, out int seed)) { Simulation.ReseedRandoms(seed); } else { Simulation.ReseedRandoms(); } Simulation.ResetAgents(EditingProject.KB); ScenarioRenderingBox.Refresh(); LogsTreeView.Nodes.Clear(); LogDetailTextBox.Text = ""; AbsoluteTime = 0.0f; }
private void ResetSimulationButton_Click(object sender, EventArgs e) { if (Simulation == null) { return; } foreach (var agent in Simulation.Agents) { agent.Position = agent.StartPosition; agent.GenerateStartProperties(EditProject.KB); agent.Properties = new Dictionary <string, double>(); foreach (var kvp in agent.StartProperties) { agent.Properties.Add(kvp.Key, kvp.Value); } } ScenarioRenderingBox.Refresh(); LogsTreeView.Nodes.Clear(); LogDetailTextBox.Text = ""; AbsoluteTime = 0.0f; }
private void AutoAdvanceTimer_Tick(object sender, EventArgs e) { Simulation.Advance((float)AutoAdvanceTimer.Interval / 1000.0f); ScenarioRenderingBox.Refresh(); }
public EditWidgetScenario() { InitializeComponent(); AbsoluteTime = 0.0f; ScenarioRenderingBox.Paint += (obj, args) => { if (Simulation == null) { return; } Renderer.Render(Simulation, args.Graphics, ScenarioRenderingBox.ClientRectangle); }; ScenarioRenderingBox.LostFocus += (obj, args) => { SimulationInspectionTooltip.Hide(ScenarioRenderingBox); }; ScenarioRenderingBox.MouseClick += (obj, args) => { ScenarioRenderingBox.Focus(); if (args.Button != MouseButtons.Right) { SimulationInspectionTooltip.Hide(ScenarioRenderingBox); return; } if (Simulation == null) { SimulationInspectionTooltip.Hide(ScenarioRenderingBox); return; } var text = Renderer.GetInspectionText(Simulation, ScenarioRenderingBox.ClientRectangle, args.Location); if (text == null || string.IsNullOrEmpty(text.Caption)) { SimulationInspectionTooltip.Hide(ScenarioRenderingBox); return; } SimulationInspectionTooltip.ToolTipIcon = text.Icon; SimulationInspectionTooltip.ToolTipTitle = text.Caption; SimulationInspectionTooltip.Show(text.Description, ScenarioRenderingBox, args.X + 18, args.Y + 18); }; ScenarioRenderingBox.MouseDoubleClick += (obj, args) => { ScenarioRenderingBox.Focus(); if (Simulation == null) { return; } var agent = Renderer.GetAgentAtLocation(Simulation, ScenarioRenderingBox.ClientRectangle, args.Location); if (agent == null) { return; } for (int i = 0; i < AgentsListView.Items.Count; ++i) { if ((AgentsListView.Items[i].Tag as ScenarioAgent) == agent) { AgentsListView.SelectedItems.Clear(); AgentsListView.SelectedIndices.Add(i); ScenarioEditorTabs.SelectTab(AgentsTab); return; } } }; AgentsListView.AfterLabelEdit += (obj, args) => { if (string.IsNullOrEmpty(args.Label)) { return; } var agent = (AgentsListView.Items[args.Item].Tag as ScenarioAgent); agent.Name = args.Label; RefreshAgentTab(); EditingProject.MarkDirty(); }; LocationsListView.AfterLabelEdit += (obj, args) => { if (string.IsNullOrEmpty(args.Label)) { return; } var location = LocationsListView.Items[args.Item].Tag as ScenarioLocation; location.Name = args.Label; RefreshLocationTab(); EditingProject.MarkDirty(); }; LogsTreeView.NodeMouseClick += (obj, args) => { LogDetailTextBox.Text = ""; BuildLogText(args.Node); }; }
private void Advance100msButton_Click(object sender, EventArgs e) { Simulation.Advance(0.1f); ScenarioRenderingBox.Refresh(); }