コード例 #1
0
ファイル: ShipDesignDialog.cs プロジェクト: ekolis/stars-nova
        /// <Summary>
        /// Save the the design when the OK button is pressed
        /// </Summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param>
        private void OK_Click(object sender, System.EventArgs e)
        {
            ShipDesign newDesign      = new ShipDesign(clientState.EmpireState.GetNextDesignKey());
            Hull       hullProperties = selectedHull.Properties["Hull"] as Hull;

            hullProperties.Modules = HullGrid.ActiveModules;
            newDesign.Name         = DesignName.Text;
            newDesign.Owner        = clientState.EmpireState.Id;
            newDesign.Blueprint    = selectedHull;
            newDesign.Icon         = shipIcon;
            newDesign.Update();

            if (hullProperties.IsStarbase)
            {
                newDesign.Type = ItemType.Starbase;
            }
            else
            {
                newDesign.Type = ItemType.Ship;
                if (newDesign.Engine == null)
                {
                    Report.Error("A ship design must have an engine");
                    return;
                }
            }
            DesignCommand command = new DesignCommand(CommandMode.Add, newDesign);

            if (command.IsValid(clientState.EmpireState))
            {
                clientState.Commands.Push(command);
                command.ApplyToState(clientState.EmpireState);
            }
            Close();
        }
コード例 #2
0
        protected override void OnInitialized()
        {
            base.OnInitialized();
            _menu         = new QuickOperationMenu();
            _menu.Loaded += OnMenuLoaded;
            var placement = new RelativePlacement(HorizontalAlignment.Right, VerticalAlignment.Top)
            {
                XOffset = 7, YOffset = 3.5
            };

            this.AddAdorners(placement, _menu);

            var kbs     = this.ExtendedItem.Services.GetService(typeof(IKeyBindingService)) as IKeyBindingService;
            var command = new DesignCommand(delegate
            {
                _menu.MainHeader.IsSubmenuOpen = true;
                _menu.MainHeader.Focus();
            }, delegate
            {
                return(true);
            });

            _keyBinding = new KeyBinding(command, Key.Enter, ModifierKeys.Alt);
            if (kbs != null)
            {
                kbs.RegisterBinding(_keyBinding);
            }
        }
コード例 #3
0
		protected override void OnInitialized()
		{
			base.OnInitialized();
			_menu = new QuickOperationMenu();
			_menu.Loaded += OnMenuLoaded;
			var placement = new RelativePlacement(HorizontalAlignment.Right, VerticalAlignment.Top) {XOffset = 7, YOffset = 3.5};
			this.AddAdorners(placement, _menu);
			
			var kbs = this.ExtendedItem.Services.GetService(typeof (IKeyBindingService)) as IKeyBindingService;
			var command = new DesignCommand(delegate
			                                {
			                                	_menu.MainHeader.IsSubmenuOpen = true;
			                                	_menu.MainHeader.Focus();
			                                }, delegate
			                                {
			                                	return true;
			                                });
			_keyBinding=new KeyBinding(command, Key.Enter, ModifierKeys.Alt);
			if (kbs != null)
				kbs.RegisterBinding(_keyBinding);
		}
コード例 #4
0
ファイル: DesignManager.cs プロジェクト: ekolis/stars-nova
        /// <Summary>
        /// The delete button has been pressed. Confirm he really means it and, if he
        /// does, delete all ships based on that design, if that leaves the fleet
        /// containing the ship empty delete that too. Then delete the actual design.
        /// </Summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param>
        private void Delete_Click(object sender, EventArgs e)
        {
            string text =
                @"You are about to delete the selected design.
If you do this you will destroy all ships of that design.
           
Are you sure you want to do this?";

            DialogResult result = MessageBox.Show(
                text,
                "Nova - Warning",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning,
                MessageBoxDefaultButton.Button2,
                MessageBoxOptions.DefaultDesktopOnly);

            if (result != DialogResult.Yes)
            {
                return;
            }

            ShipDesign design = designList.SelectedItems[0].Tag as ShipDesign;

            DesignCommand command = new DesignCommand(CommandMode.Delete, design.Key);

            if (command.IsValid(clientState.EmpireState))
            {
                clientState.Commands.Push(command);
                command.ApplyToState(clientState.EmpireState);
            }

            DesignOwner_SelectedIndexChanged(null, null);

            // Ensure the Star map is updated in case we've completely removed any
            // fleets that are being displayed.

            OnStarmapChanged(EventArgs.Empty);
        }