コード例 #1
0
        public SystemGenAndDisplay()
        {
            // Create Panels:
            m_oDataPanel     = new Panels.SGaD_DataPanel();
            m_oControlsPanel = new Panels.SGaD_Controls();

            // setup view model:
            VM = new StarSystemViewModel();

            // bind System Selection combo box:
            m_oControlsPanel.SystemSelectionComboBox.DataSource = VM.StarSystems;
            m_oControlsPanel.SystemSelectionComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentStarSystem, DataSourceUpdateMode.OnPropertyChanged);
            m_oControlsPanel.SystemSelectionComboBox.DisplayMember = "Name";

            m_oControlsPanel.SystemSelectionComboBox.SelectedIndexChanged += (s, args) => m_oControlsPanel.SystemSelectionComboBox.DataBindings["SelectedItem"].WriteValue();

            // bind text boxes:
            m_oControlsPanel.AgeTextBox.Bind(c => c.Text, VM, d => d.CurrentStarSystemAge);
            m_oControlsPanel.SeedTextBox.Bind(c => c.Text, VM, d => d.Seed);

            // Setup the stars Grid
            m_oDataPanel.StarDataGrid.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            m_oDataPanel.StarDataGrid.RowHeadersVisible   = false;
            m_oDataPanel.StarDataGrid.AutoGenerateColumns = false;
            m_oDataPanel.StarDataGrid.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM);
            m_oDataPanel.StarDataGrid.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM);
            m_oDataPanel.StarDataGrid.Bind(c => c.ReadOnly, VM, d => d.isNotSM);

            AddColumnsToStarDataGrid();

            m_oDataPanel.StarDataGrid.DataSource        = VM.StarsSource;
            m_oDataPanel.StarDataGrid.SelectionChanged += new EventHandler(StarsDataGrid_SelectionChanged);

            // Setup the SystemBody Data Grid
            m_oDataPanel.PlanetsDataGrid.AutoGenerateColumns       = false;
            m_oDataPanel.PlanetsDataGrid.RowHeadersVisible         = false;
            m_oDataPanel.PlanetsDataGrid.SelectionMode             = DataGridViewSelectionMode.CellSelect;
            m_oDataPanel.PlanetsDataGrid.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            m_oDataPanel.PlanetsDataGrid.AutoSizeRowsMode          = DataGridViewAutoSizeRowsMode.DisplayedCells;
            m_oDataPanel.PlanetsDataGrid.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM);
            m_oDataPanel.PlanetsDataGrid.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM);
            m_oDataPanel.PlanetsDataGrid.Bind(c => c.ReadOnly, VM, d => d.isNotSM);
            AddColumnsToPlanetDataGrid();

            m_oDataPanel.PlanetsDataGrid.DataSource        = VM.PlanetSource;
            m_oDataPanel.PlanetsDataGrid.SelectionChanged += new EventHandler(PlanetsDataGrid_SelectionChanged);
            m_oDataPanel.PlanetsDataGrid.CellDoubleClick  += new DataGridViewCellEventHandler(PlanetDataGrid_CellDoubleClick);

            // Setup Event handlers for Controls panel buttons:
            m_oControlsPanel.GenSystemButton.Click    += new EventHandler(GenSystemButton_Click);
            m_oControlsPanel.GenGalaxyButton.Click    += new EventHandler(GenGalaxyButton_Click);
            m_oControlsPanel.DeleteSystemButton.Click += new EventHandler(DeleteSystemButton_Click);
            m_oControlsPanel.AutoRenameButton.Click   += new EventHandler(AutoRenameButton_Click);
            m_oControlsPanel.AddColonyButton.Click    += new EventHandler(AddColonyButton_Click);
            m_oControlsPanel.ExportButton.Click       += new EventHandler(ExportButton_Click);
        }
コード例 #2
0
        public SystemGenAndDisplay()
        {
            // Create Panels:
            m_oDataPanel = new Panels.SGaD_DataPanel();
            m_oControlsPanel = new Panels.SGaD_Controls();

            // setup view model:
            VM = new StarSystemViewModel();

            // bind System Selection combo box:
            m_oControlsPanel.SystemSelectionComboBox.DataSource = VM.StarSystems;
            m_oControlsPanel.SystemSelectionComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentStarSystem, DataSourceUpdateMode.OnPropertyChanged);
            m_oControlsPanel.SystemSelectionComboBox.DisplayMember = "Name";

            m_oControlsPanel.SystemSelectionComboBox.SelectedIndexChanged += (s, args) => m_oControlsPanel.SystemSelectionComboBox.DataBindings["SelectedItem"].WriteValue();

            // bind text boxes:
            m_oControlsPanel.AgeTextBox.Bind(c => c.Text, VM, d => d.CurrentStarSystemAge);
            m_oControlsPanel.SeedTextBox.Bind(c => c.Text, VM, d => d.Seed);

            // Setup the stars Grid
            m_oDataPanel.StarDataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            m_oDataPanel.StarDataGrid.RowHeadersVisible = false;
            m_oDataPanel.StarDataGrid.AutoGenerateColumns = false;
            m_oDataPanel.StarDataGrid.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM);
            m_oDataPanel.StarDataGrid.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM);
            m_oDataPanel.StarDataGrid.Bind(c => c.ReadOnly, VM, d => d.isNotSM);

            AddColumnsToStarDataGrid();

            m_oDataPanel.StarDataGrid.DataSource = VM.StarsSource;
            m_oDataPanel.StarDataGrid.SelectionChanged += new EventHandler(StarsDataGrid_SelectionChanged);

            // Setup the SystemBody Data Grid
            m_oDataPanel.PlanetsDataGrid.AutoGenerateColumns = false;
            m_oDataPanel.PlanetsDataGrid.RowHeadersVisible = false;
            m_oDataPanel.PlanetsDataGrid.SelectionMode = DataGridViewSelectionMode.CellSelect;
            m_oDataPanel.PlanetsDataGrid.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            m_oDataPanel.PlanetsDataGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells;
            m_oDataPanel.PlanetsDataGrid.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM);
            m_oDataPanel.PlanetsDataGrid.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM);
            m_oDataPanel.PlanetsDataGrid.Bind(c => c.ReadOnly, VM, d => d.isNotSM);
            AddColumnsToPlanetDataGrid();

            m_oDataPanel.PlanetsDataGrid.DataSource = VM.PlanetSource;
            m_oDataPanel.PlanetsDataGrid.SelectionChanged += new EventHandler(PlanetsDataGrid_SelectionChanged);
            m_oDataPanel.PlanetsDataGrid.CellDoubleClick += new DataGridViewCellEventHandler(PlanetDataGrid_CellDoubleClick);

            // Setup Event handlers for Controls panel buttons:
            m_oControlsPanel.GenSystemButton.Click += new EventHandler(GenSystemButton_Click);
            m_oControlsPanel.GenGalaxyButton.Click += new EventHandler(GenGalaxyButton_Click);
            m_oControlsPanel.DeleteSystemButton.Click += new EventHandler(DeleteSystemButton_Click);
            m_oControlsPanel.AutoRenameButton.Click += new EventHandler(AutoRenameButton_Click);
            m_oControlsPanel.AddColonyButton.Click += new EventHandler(AddColonyButton_Click);
            m_oControlsPanel.ExportButton.Click += new EventHandler(ExportButton_Click);
        }