コード例 #1
0
        public EditWidgetScenario()
        {
            InitializeComponent();

            AbsoluteTime = 0.0f;

            ScenarioRenderingBox.Paint += (obj, args) =>
            {
                if (Simulation == null)
                {
                    return;
                }

                Simulation.Render(args.Graphics, ScenarioRenderingBox.ClientRectangle);
            };

            ScenarioRenderingBox.MouseClick += (obj, args) =>
            {
                if (Simulation == null)
                {
                    SimulationInspectionTooltip.Hide(ScenarioRenderingBox);
                    return;
                }

                var text = Simulation.GetInspectionText(ScenarioRenderingBox.ClientRectangle, args.Location);
                if (string.IsNullOrEmpty(text))
                {
                    SimulationInspectionTooltip.Hide(ScenarioRenderingBox);
                    return;
                }

                SimulationInspectionTooltip.Show(text, ScenarioRenderingBox, args.X + 18, args.Y + 18);
            };

            AgentsListView.AfterLabelEdit += (obj, args) =>
            {
                if (string.IsNullOrEmpty(args.Label))
                {
                    return;
                }

                var agent = (AgentsListView.Items[args.Item].Tag as ScenarioAgent);
                agent.Name = args.Label;

                RefreshAgentTab();
            };

            LogsTreeView.NodeMouseClick += (obj, args) =>
            {
                LogDetailTextBox.Text = "";
                BuildLogText(args.Node);
            };
        }
コード例 #2
0
        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);
            };
        }