public ClassDesign() { ComponentAmt = 1; MissileAmt = 1; TotalComponents = 0; CLBSet = false; CDGSet = false; CompLocation = new BindingList<int>(); ToolTip toolTip = new ToolTip(); toolTip.AutoPopDelay = 5000; toolTip.InitialDelay = 1000; toolTip.ReshowDelay = 500; toolTip.ShowAlways = true; // create panels: //m_oClassPropertiesPanel = new Panels.ClassDes_Properties(); //m_oDesignAndInformationPanel = new Panels.ClassDes_DesignAndInfo(); m_oOptionsPanel = new Panels.ClassDes_Options(); m_oRenameClassPanel = new Panels.ClassDes_RenameClass(); //m_oClassPropertiesPanel.ClassPropertyGrid.PropertySort = PropertySort.CategorizedAlphabetical; // creat ViewModel. VM = new ClassDesignViewModel(); /// <summary> /// setup bindings: /// </summary> m_oOptionsPanel.FactionComboBox.Bind(c => c.DataSource, VM, d => d.Factions); m_oOptionsPanel.FactionComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentFaction, DataSourceUpdateMode.OnPropertyChanged); m_oOptionsPanel.FactionComboBox.DisplayMember = "Name"; VM.FactionChanged += (s, args) => CurrentFaction = VM.CurrentFaction; CurrentFaction = VM.CurrentFaction; m_oOptionsPanel.FactionComboBox.SelectedIndexChanged += (s, args) => m_oOptionsPanel.FactionComboBox.DataBindings["SelectedItem"].WriteValue(); m_oOptionsPanel.FactionComboBox.SelectedIndexChanged += new EventHandler(FactionComboBox_SelectedIndexChanged); m_oOptionsPanel.ClassComboBox.Bind(c => c.DataSource, VM, d => d.ShipDesigns); m_oOptionsPanel.ClassComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentShipClass, DataSourceUpdateMode.OnPropertyChanged); m_oOptionsPanel.ClassComboBox.DisplayMember = "Name"; VM.ShipClassChanged += (s, args) => CurrentShipClass = VM.CurrentShipClass; CurrentShipClass = VM.CurrentShipClass; m_oOptionsPanel.ClassComboBox.SelectedIndexChanged += (s, args) => m_oOptionsPanel.ClassComboBox.DataBindings["SelectedItem"].WriteValue(); m_oOptionsPanel.ClassComboBox.SelectedIndexChanged += new EventHandler(ClassComboBox_SelectedIndexChanged); m_oOptionsPanel.Notes.Bind(c => c.Text, VM, d => d.CurrentShipClassNotes); //if (VM.CurrentShipClass != null) //{ // m_oClassPropertiesPanel.ClassPropertyGrid.SelectedObject = VM.CurrentShipClass; //} // Setup Events: m_oOptionsPanel.NewButton.Click += new EventHandler(NewButton_Click); m_oOptionsPanel.SizeInTonsCheckBox.CheckStateChanged += new EventHandler(SizeInTonsCheckBox_CheckedStateChanged); m_oOptionsPanel.GroupComponentsCheckBox.CheckStateChanged += new EventHandler(GroupComponentsCheckBox_CheckStateChanged); m_oOptionsPanel.OneRadioButton.CheckedChanged += new EventHandler(AMTRadioButton_CheckedChanged); m_oOptionsPanel.FiveRadioButton.CheckedChanged += new EventHandler(AMTRadioButton_CheckedChanged); m_oOptionsPanel.TenRadioButton.CheckedChanged += new EventHandler(AMTRadioButton_CheckedChanged); m_oOptionsPanel.HundredRadioButton.CheckedChanged += new EventHandler(AMTRadioButton_CheckedChanged); m_oOptionsPanel.ObsoleteCompButton.Click += new EventHandler(ObsoleteCompButton_Click); if (CurrentFaction != null) { if (CurrentFaction.ShipDesigns.Count != 0) CurrentShipClass = CurrentFaction.ShipDesigns[0]; } m_oOptionsPanel.ComponentDataGrid.SelectionMode = DataGridViewSelectionMode.CellSelect; m_oOptionsPanel.ComponentDataGrid.RowHeadersVisible = false; m_oOptionsPanel.ComponentDataGrid.AutoGenerateColumns = false; m_oOptionsPanel.ComponentDataGrid.SelectionChanged += new EventHandler(ComponentDataGrid_SelectionChanged); m_oOptionsPanel.ComponentDataGrid.DoubleClick += new EventHandler(ComponentDataGrid_DoubleClick); SetupComponentDataGrid(); m_oOptionsPanel.ComponentsListBox.SelectedIndexChanged += new EventHandler(ComponentsListBox_SelectedIndexChanged); m_oOptionsPanel.ComponentsListBox.DoubleClick += new EventHandler(ComponentsListBox_DoubleClick); /// <summary> /// options checkbox handlers: /// </summary> m_oOptionsPanel.TankerCheckBox.CheckedChanged += new System.EventHandler(this.TankerCheckbox_Changed); m_oOptionsPanel.CollierCheckBox.CheckedChanged += new System.EventHandler(this.CollierCheckbox_Changed); m_oOptionsPanel.SupplyShipCheckBox.CheckedChanged += new System.EventHandler(this.SupplyCheckbox_Changed); /// <summary> /// set checkbox tooltips: /// </summary> toolTip.SetToolTip(m_oOptionsPanel.TankerCheckBox, "Clicking this button will designate the ship as a fuel tanker. This allows the ship to carry out fuel delivery orders."); toolTip.SetToolTip(m_oOptionsPanel.CollierCheckBox, "Clicking this button will designate the ship as an ammunition collier. When a fleet reloads magazines during a turn, they will reload from the magazines of any colliers in the fleet."); toolTip.SetToolTip(m_oOptionsPanel.ConscriptCheckBox, "Checking this box means that all new ships of that class will use conscript-only crews."); toolTip.SetToolTip(m_oOptionsPanel.ObsoleteCheckBox, "Checking this box will stop this class appearing in lists for construction or refit."); toolTip.SetToolTip(m_oOptionsPanel.SupplyShipCheckBox, "Clicking this button will designate the ship as a maintenance supply ship."); toolTip.SetToolTip(m_oOptionsPanel.SizeInTonsCheckBox, "If this box is checked, sizes will be shown in tons rather than hull spaces (1 HS = 50 tons)."); toolTip.SetToolTip(m_oOptionsPanel.KeepExcessQuarters, "Do not automatically remove crew quarters beyond those needed for the normal crew. This is useful for carriers to leave Q available for the flight crews."); /// <summary> /// Button click handlers: /// </summary> m_oOptionsPanel.RefreshTechButton.Click += new EventHandler(RefreshTechButton_Click); m_oOptionsPanel.AddButton.Click += new EventHandler(AddButton_Click); m_oOptionsPanel.RemoveButton.Click += new EventHandler(RemoveButton_Click); m_oOptionsPanel.ArmourUpButton.Click += new EventHandler(ArmourUpButton_Click); m_oOptionsPanel.ArmourDownButton.Click += new EventHandler(ArmourDownButton_Click); m_oOptionsPanel.NewArmorButton.Click += new EventHandler(NewArmorButton_Click); m_oOptionsPanel.DesignTechButton.Click += new EventHandler(DesignTechButton_Click); m_oOptionsPanel.RenameButton.Click += new EventHandler(RenameButton_Click); m_oOptionsPanel.SaveNotes.Click += new EventHandler(SaveNotesButton_Click); /// <summary> /// Rename Class Button Handlers: /// </summary> m_oRenameClassPanel.OKButton.Click += new EventHandler(OKButton_Click); m_oRenameClassPanel.CancelRenameButton.Click += new EventHandler(CancelRenameButton_Click); m_oRenameClassPanel.RenameClassTextBox.KeyPress += new KeyPressEventHandler(RenameClassTextBox_KeyPress); m_oOptionsPanel.DeploymentTimeTextBox.TextChanged += new EventHandler(DeploymentTimeTextBox_TextChanged); /// <summary> /// Ordnance and fighter tab: /// </summary> m_oOptionsPanel.OF1xRadioButton.CheckedChanged += new EventHandler(MslAMTRadioButton_CheckedChanged); m_oOptionsPanel.OF10xRadioButton.CheckedChanged += new EventHandler(MslAMTRadioButton_CheckedChanged); m_oOptionsPanel.OF100xRadioButton.CheckedChanged += new EventHandler(MslAMTRadioButton_CheckedChanged); m_oOptionsPanel.OF1000xRadioButton.CheckedChanged += new EventHandler(MslAMTRadioButton_CheckedChanged); m_oOptionsPanel.MissileDataGrid.DoubleClick += new EventHandler(MissileDataGrid_DoubleClick); m_oOptionsPanel.PreferredOrdnanceListBox.DoubleClick += new EventHandler(PreferredOrdnanceListBox_DoubleClick); m_oOptionsPanel.MslObsButton.Click += new EventHandler(MslObsButton_Click); m_oOptionsPanel.ShowObsMslCheckBox.CheckedChanged += new EventHandler(ShowObsMslCheckBox_CheckedChanged); m_oOptionsPanel.IgnoreMslSizeCheckBox.CheckedChanged += new EventHandler(IgnoreMslSizeCheckBox_CheckedChanged); SetupMissileDataGrid(); UpdateDisplay(); }
public ClassDesign() { ComponentAmt = 1; MissileAmt = 1; TotalComponents = 0; CLBSet = false; CDGSet = false; CompLocation = new BindingList<int>(); // create panels: //m_oClassPropertiesPanel = new Panels.ClassDes_Properties(); //m_oDesignAndInformationPanel = new Panels.ClassDes_DesignAndInfo(); m_oOptionsPanel = new Panels.ClassDes_Options(); m_oRenameClassPanel = new Panels.ClassDes_RenameClass(); //m_oClassPropertiesPanel.ClassPropertyGrid.PropertySort = PropertySort.CategorizedAlphabetical; // creat ViewModel. VM = new ClassDesignViewModel(); /// <summary> /// setup bindings: /// </summary> m_oOptionsPanel.FactionComboBox.Bind(c => c.DataSource, VM, d => d.Factions); m_oOptionsPanel.FactionComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentFaction, DataSourceUpdateMode.OnPropertyChanged); m_oOptionsPanel.FactionComboBox.DisplayMember = "Name"; VM.FactionChanged += (s, args) => CurrentFaction = VM.CurrentFaction; CurrentFaction = VM.CurrentFaction; m_oOptionsPanel.FactionComboBox.SelectedIndexChanged += (s, args) => m_oOptionsPanel.FactionComboBox.DataBindings["SelectedItem"].WriteValue(); m_oOptionsPanel.FactionComboBox.SelectedIndexChanged += new EventHandler(FactionComboBox_SelectedIndexChanged); m_oOptionsPanel.ClassComboBox.Bind(c => c.DataSource, VM, d => d.ShipDesigns); m_oOptionsPanel.ClassComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentShipClass, DataSourceUpdateMode.OnPropertyChanged); m_oOptionsPanel.ClassComboBox.DisplayMember = "Name"; VM.ShipClassChanged += (s, args) => CurrentShipClass = VM.CurrentShipClass; CurrentShipClass = VM.CurrentShipClass; m_oOptionsPanel.ClassComboBox.SelectedIndexChanged += (s, args) => m_oOptionsPanel.ClassComboBox.DataBindings["SelectedItem"].WriteValue(); m_oOptionsPanel.ClassComboBox.SelectedIndexChanged += new EventHandler(ClassComboBox_SelectedIndexChanged); m_oOptionsPanel.Notes.Bind(c => c.Text, VM, d => d.CurrentShipClassNotes); //if (VM.CurrentShipClass != null) //{ // m_oClassPropertiesPanel.ClassPropertyGrid.SelectedObject = VM.CurrentShipClass; //} // Setup Events: m_oOptionsPanel.NewButton.Click += new EventHandler(NewButton_Click); m_oOptionsPanel.SizeInTonsCheckBox.CheckStateChanged += new EventHandler(SizeInTonsCheckBox_CheckedStateChanged); m_oOptionsPanel.GroupComponentsCheckBox.CheckStateChanged += new EventHandler(GroupComponentsCheckBox_CheckStateChanged); m_oOptionsPanel.OneRadioButton.CheckedChanged += new EventHandler(AMTRadioButton_CheckedChanged); m_oOptionsPanel.FiveRadioButton.CheckedChanged += new EventHandler(AMTRadioButton_CheckedChanged); m_oOptionsPanel.TenRadioButton.CheckedChanged += new EventHandler(AMTRadioButton_CheckedChanged); m_oOptionsPanel.HundredRadioButton.CheckedChanged += new EventHandler(AMTRadioButton_CheckedChanged); m_oOptionsPanel.ObsoleteCompButton.Click += new EventHandler(ObsoleteCompButton_Click); if (CurrentFaction != null) { if (CurrentFaction.ShipDesigns.Count != 0) CurrentShipClass = CurrentFaction.ShipDesigns[0]; } m_oOptionsPanel.ComponentDataGrid.SelectionMode = DataGridViewSelectionMode.CellSelect; m_oOptionsPanel.ComponentDataGrid.RowHeadersVisible = false; m_oOptionsPanel.ComponentDataGrid.AutoGenerateColumns = false; m_oOptionsPanel.ComponentDataGrid.SelectionChanged += new EventHandler(ComponentDataGrid_SelectionChanged); m_oOptionsPanel.ComponentDataGrid.DoubleClick += new EventHandler(ComponentDataGrid_DoubleClick); SetupComponentDataGrid(); m_oOptionsPanel.ComponentsListBox.SelectedIndexChanged += new EventHandler(ComponentsListBox_SelectedIndexChanged); m_oOptionsPanel.ComponentsListBox.DoubleClick += new EventHandler(ComponentsListBox_DoubleClick); /// <summary> /// options checkbox handlers: /// </summary> m_oOptionsPanel.TankerCheckBox.CheckedChanged += new System.EventHandler(this.TankerCheckbox_Changed); m_oOptionsPanel.CollierCheckBox.CheckedChanged += new System.EventHandler(this.CollierCheckbox_Changed); m_oOptionsPanel.SupplyShipCheckBox.CheckedChanged += new System.EventHandler(this.SupplyCheckbox_Changed); /// <summary> /// Button click handlers: /// </summary> m_oOptionsPanel.RefreshTechButton.Click += new EventHandler(RefreshTechButton_Click); m_oOptionsPanel.AddButton.Click += new EventHandler(AddButton_Click); m_oOptionsPanel.RemoveButton.Click += new EventHandler(RemoveButton_Click); m_oOptionsPanel.ArmourUpButton.Click += new EventHandler(ArmourUpButton_Click); m_oOptionsPanel.ArmourDownButton.Click += new EventHandler(ArmourDownButton_Click); m_oOptionsPanel.NewArmorButton.Click += new EventHandler(NewArmorButton_Click); m_oOptionsPanel.DesignTechButton.Click += new EventHandler(DesignTechButton_Click); m_oOptionsPanel.RenameButton.Click += new EventHandler(RenameButton_Click); m_oOptionsPanel.SaveNotes.Click += new EventHandler(SaveNotesButton_Click); /// <summary> /// Rename Class Button Handlers: /// </summary> m_oRenameClassPanel.OKButton.Click += new EventHandler(OKButton_Click); m_oRenameClassPanel.CancelRenameButton.Click += new EventHandler(CancelRenameButton_Click); m_oRenameClassPanel.RenameClassTextBox.KeyPress += new KeyPressEventHandler(RenameClassTextBox_KeyPress); m_oOptionsPanel.DeploymentTimeTextBox.TextChanged += new EventHandler(DeploymentTimeTextBox_TextChanged); /// <summary> /// Ordnance and fighter tab: /// </summary> m_oOptionsPanel.OF1xRadioButton.CheckedChanged += new EventHandler(MslAMTRadioButton_CheckedChanged); m_oOptionsPanel.OF10xRadioButton.CheckedChanged += new EventHandler(MslAMTRadioButton_CheckedChanged); m_oOptionsPanel.OF100xRadioButton.CheckedChanged += new EventHandler(MslAMTRadioButton_CheckedChanged); m_oOptionsPanel.OF1000xRadioButton.CheckedChanged += new EventHandler(MslAMTRadioButton_CheckedChanged); m_oOptionsPanel.MissileDataGrid.DoubleClick += new EventHandler(MissileDataGrid_DoubleClick); m_oOptionsPanel.PreferredOrdnanceListBox.DoubleClick += new EventHandler(PreferredOrdnanceListBox_DoubleClick); m_oOptionsPanel.MslObsButton.Click += new EventHandler(MslObsButton_Click); m_oOptionsPanel.ShowObsMslCheckBox.CheckedChanged += new EventHandler(ShowObsMslCheckBox_CheckedChanged); m_oOptionsPanel.IgnoreMslSizeCheckBox.CheckedChanged += new EventHandler(IgnoreMslSizeCheckBox_CheckedChanged); SetupMissileDataGrid(); UpdateDisplay(); }