Exemple #1
0
        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;
            }
        }
Exemple #2
0
 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;
     }
 }