public ExitEditor(Exit exit) { InitializeComponent(); Exit = exit.ShallowCopy(); propertyGrid.SelectedObject = Exit; SelectedArea = Exit.Area; if (Common.Settings.World.Areas.Any()) { areaComboBox.Items.AddRange(Common.Settings.World.Areas.Select(x => x.Name).ToArray()); areaComboBox.SelectedIndex = areaComboBox.Items.IndexOf(SelectedArea.Name); } }
private void exitListBox_SelectedIndexChanged(object sender, EventArgs e) { SelectedExit = roomEdits.Exits.Find((room => room.Name == (string)exitListBox.SelectedItem)); }
private void exitListBox_MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; var index = exitListBox.IndexFromPoint(e.Location); if (index != ListBox.NoMatches) { exitListBox.SelectedIndex = index; SelectedExit = roomEdits.Exits.Find((room => room.Name == (string)exitListBox.SelectedItem)); for (int i = 0; i <= exitContextMenu.Items.Count - 1; i++) { exitContextMenu.Items[i].Enabled = true; } exitContextMenu.Show(Cursor.Position); } else { exitListBox.SelectedIndex = -1; for (int i = 0; i <= exitContextMenu.Items.Count - 1; i++) { if (i == 0) continue; exitContextMenu.Items[i].Enabled = false; } exitContextMenu.Show(Cursor.Position); } }
public void LoadXml(XmlNode node, Area area) { Name = node["Name"].InnerText; Description = node["Description"].InnerText; shortDescription = node["ShortDescription"].InnerText; Tag = node["Tag"].InnerText; Area = area; var exitsNode = node.SelectSingleNode("Exits"); if (exitsNode != null) { XmlNodeList exits = node["Exits"].SelectNodes("Exit"); foreach (XmlNode exit in exits) { Exit newExit = new Exit(); newExit.LoadXml(exit, this); Exits.Add(newExit); } } }
public void CreateExit() { Exit exit = new Exit() { Name = this.Name + " Exit", Description = Name + " exit is not yet linked to another room", DoorLabel = Name + " Exit (unassigned)", DoorType = doorType.none }; AddExit(exit); }
public void AddExit(Exit exit) { exit.Owner = this; if (exit.Name == null) exit.Name = exit.DoorLabel; Exits.Add(exit); }
private void Button_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { ExitEditor exitEditor; DialogResult dialogResult; switch (e.ClickedItem.Text) { case "Add": // call exit.add dialog with selected room Exit exit; exit = new Exit() { Area = SelectedRoom.Area, Owner = SelectedRoom }; exitEditor = new ExitEditor(exit); dialogResult = exitEditor.ShowDialog(); if (dialogResult == DialogResult.OK) { exit = exitEditor.Exit.ShallowCopy(); SelectedRoom.Exits.Add(exit); RefreshEditor(); SyncControls(); } exitEditor.Dispose(); break; case "Remove All": SelectedRoom.Exits.Clear(); RefreshEditor(); SyncControls(); break; case "Remove": SelectedRoom.Exits.RemoveAt(SelectedRoom.Exits.FindIndex(item => item.DoorLabel == ((ToolStripSplitButton)sender).Text)); RefreshEditor(); SyncControls(); break; case "Edit": exitEditor = new ExitEditor((Exit)e.ClickedItem.OwnerItem.Tag); dialogResult = exitEditor.ShowDialog(); if (dialogResult == DialogResult.OK) { e.ClickedItem.OwnerItem.Tag = exitEditor.Exit.ShallowCopy(); RefreshEditor(); SyncControls(); } exitEditor.Dispose(); break; } }