Exemplo n.º 1
0
        private void CloseShipEditor()
        {
            if (_spaceDockPanel == null)
            {
                // Ship editor can only be shown from space dock.  So this should never be null at this point
                throw new InvalidOperationException("SpaceDock can't be null if ship editor was showing");
            }

            if (!_editShipTransfer.ShipEdited())
            {
                //TODO: Only show for a few seconds
                statusMessage.Content = "Invalid Ship - ignoring changes";
            }

            _editShipTransfer = null;

            // Just swap out the controls (panelContainer is currently showing the editor)
            panelContainer.Child = _spaceDockPanel;
        }
Exemplo n.º 2
0
        private void ShowShipEditor()
        {
            // Spacedock is currently showing.  Need to keep it alive, but change out panels

            SaveSession(false, false);      // the editor can be unstable, so this is a good spot to save

            if (_shipEditor == null)
            {
                #region instantiate _shipEditor

                StackPanel panel = new StackPanel()
                {
                    Orientation = Orientation.Horizontal,
                };

                //TODO: Make Ok, Cancel, Apply instead

                Button button = new Button()
                {
                    FontSize = 20,
                    FontWeight = FontWeights.Bold,
                    Padding = new Thickness(12, 4, 12, 4),
                    Content = "Close",
                };
                button.Click += CloseShipEditor_Click;
                panel.Children.Add(button);

                _shipEditorManagementControl = panel;

                _shipEditor = new Editor();

                var resouceDict = new ResourceDictionary()
                {
                    Source = new Uri("/Game.Newt.v2.AsteroidMiner;component/AstMin2D/Stylesheet.xaml", UriKind.RelativeOrAbsolute),
                };

                _shipEditorBorder = new Border()
                {
                    Style = resouceDict["dialogBorder"] as Style,
                    Child = _shipEditor,
                };

                #endregion
            }

            _editShipTransfer = new EditShipTransfer(_player, _spaceDockPanel, _shipEditor, _editorOptions, _world, _material_Ship, _map, _shipExtra);

            _editShipTransfer.EditShip(this.Title, _shipEditorManagementControl);


            //TODO: Uncomment to see contents of view model
            //TabDebugWindow debugWindow = new TabDebugWindow(_shipEditor.TabControl_DEBUG);
            //debugWindow.Owner = this;
            ////debugWindow.Top = this.Top + this.ActualHeight - 200;
            ////debugWindow.Left = this.Left + this.ActualWidth - 200;
            //debugWindow.Show();


            panelContainer.Child = _shipEditorBorder;
        }