/// <summary> /// This form displays the profits one can make between two stations. /// </summary> /// <param name="localStation">The local station.</param> /// <param name="entityHandler">The entity handler to use.</param> /// <param name="hideSwitchButton">True if the switch button shall be hidden. This can be useful when this dialog is part of a /// longer planning process.</param> /// <param name="maximumCommodityPrice">The maximum price a commodity may cost. Set to 0 to disable (default).</param> public SpaceStationCommodityDialog( Entity.SpaceStation localStation, Core.IEntityHandler entityHandler, bool hideSwitchButton = false, UInt64 maximumCommodityPrice = 0 ) { _localStation = localStation; _entityHandler = entityHandler; _maximumCommodityPrice = maximumCommodityPrice; InitializeComponent(); if (hideSwitchButton) { this.SwitchButton.Hide(); this.ProfitView.Height += this.SwitchButton.Height; } _remoteSpaceStationComboBox.Initialize(entityHandler); // Fill the space station manually - OnInitialObjectsLoaded won't be called since the application is fully initialized already _remoteSpaceStationComboBox.OnInitialObjectsLoaded(entityHandler.GetEntityManager <Entity.SpaceStation>().GetAll()); // Remove the local station from the list. _remoteSpaceStationComboBox.OnDataSetRemoved(localStation); _remoteSpaceStationComboBox.SelectedIndexChanged += RemoteSpaceStationComboBox_SelectedIndexChanged; ComboBoxPanel.Controls.Add(_remoteSpaceStationComboBox); MostRecentlySelectedEntry = null; this.ProfitView.ProfitListView.DoubleClick += ProfitListView_DoubleClick; // Simulate a selection RemoteSpaceStationComboBox_SelectedIndexChanged(_remoteSpaceStationComboBox, null); }
void ProfitListView_DoubleClick(object sender, EventArgs e) { MostRecentlySelectedEntry = this.ProfitView.ProfitListView.SelectedItem.RowObject as Calculation.ProfitEntry; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }