コード例 #1
0
        /// <summary>
        /// Used for showing agent edit form
        /// </summary>
        private void mapPanel_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var currentAgentsInTheCell = GraphicalUIShell.Model.GetAgentsAt(GetModelCoord(e.Location));                     //Agents that are in the cell with mouse coords

            if (currentAgentsInTheCell.Count == 1)
            {
                var newEditForm = new FormAgentEdit(currentAgentsInTheCell[0]);
                newEditForm.Show(this);

                newEditForm.FormClosed += new FormClosedEventHandler((obj, args) =>
                {
                    this.Refresh();
                });
            }
            if (currentAgentsInTheCell.Count > 1)
            {
                contextMenuChooseEditAgents.Items.Clear();

                //Adding new context menu elements to choose between several agents
                foreach (var ag in currentAgentsInTheCell)
                {
                    var newMenuItemToAdd = new ToolStripMenuItem(ag.Name, null, new EventHandler(contextMenuEditAgentElement_Click));
                    newMenuItemToAdd.Tag = ag;
                    contextMenuChooseEditAgents.Items.Add(newMenuItemToAdd);
                }
                contextMenuChooseEditAgents.Show(Cursor.Position);
            }
        }
コード例 #2
0
        private void contextMenuEditAgentElement_Click(object sender, EventArgs e)
        {
            var newEditForm = new FormAgentEdit((sender as ToolStripMenuItem).Tag as Agent);

            newEditForm.Show(this);

            newEditForm.FormClosed += new FormClosedEventHandler((obj, args) =>
            {
                this.Refresh();
            });
        }