Esempio n. 1
0
        public void updateDisplay()
        {
            lblStationName.Text = destination.station;
            lblSystemName.Text  = destination.system;

            listView1.Items.Clear();
            overallProfit = 0;

            Destination nextDestination = mainScreen.getNextDestination(index);
            StationData stationData     = mainScreen.data.GetStation(destination.system, destination.station);
            StationData nextStationData = null;

            if (nextDestination != null)
            {
                nextStationData = mainScreen.data.GetStation(nextDestination.system, nextDestination.station);
            }

            foreach (Transaction transaction in destination.transactions)
            {
                int profitPer = 0;

                if (stationData != null && nextStationData != null)
                {
                    CommodityPrice ourPrice   = stationData.GetPrice(transaction.commodity);
                    CommodityPrice theirPrice = nextStationData.GetPrice(transaction.commodity);
                    if (ourPrice != null && theirPrice != null && theirPrice.priceSell > 0 && ourPrice.priceBuy > 0)
                    {
                        profitPer = theirPrice.priceSell - ourPrice.priceBuy;
                    }
                }

                int profit = profitPer * transaction.amount;
                overallProfit += profit;
                ListViewItem li = new ListViewItem(new string[] {
                    transaction.commodity,
                    transaction.amount.ToString("N0"),
                    profitPer.ToString("N0"),
                    profit.ToString("N0")
                });

                if (profit == 0)
                {
                    li.BackColor = Color.Yellow;
                    li.ForeColor = Color.OrangeRed;
                }
                else if (profit < 0)
                {
                    li.BackColor = Color.Red;
                    li.ForeColor = Color.Yellow;
                }
                else
                {
                    li.BackColor = Color.Green;
                    li.ForeColor = Color.LightGreen;
                }
                listView1.Items.Add(li);
            }
        }
Esempio n. 2
0
        public void updateDisplay()
        {
            lblStationName.Text = destination.station;
            lblSystemName.Text  = destination.system;

            listView1.Items.Clear();
            overallProfit = 0;

            Destination nextDestination = mainScreen.getNextDestination(index);
            StationData stationData     = mainScreen.data.GetStation(destination.system, destination.station);
            StationData nextStationData = null;

            if (nextDestination != null)
            {
                nextStationData = mainScreen.data.GetStation(nextDestination.system, nextDestination.station);
            }

            foreach (Transaction transaction in destination.transactions)
            {
                CommodityPrice ourPrice   = null;
                CommodityPrice theirPrice = null;
                if (stationData != null)
                {
                    ourPrice = stationData.GetPrice(transaction.commodity);
                    if (nextStationData != null)
                    {
                        theirPrice = nextStationData.GetPrice(transaction.commodity);
                    }
                }
                ComparedCommodity compared = new ComparedCommodity(transaction.commodity, transaction.GetAmount(mainScreen.pilotData.maxCargo), ourPrice, theirPrice);

                overallProfit += compared.profit;
                ListViewItem li = new ListViewItem(new string[] {
                    transaction.commodity,
                    transaction.amount == 0 ? String.Format("MAX ({0:0})", mainScreen.pilotData.maxCargo) : transaction.amount.ToString("N0"),
                    compared.ProfitPer,
                    compared.Profit
                });

                if (compared.profitPer == 0)
                {
                    li.BackColor = Color.Yellow;
                    li.ForeColor = Color.OrangeRed;
                }
                else if (compared.profitPer < 0)
                {
                    li.BackColor = Color.Red;
                    li.ForeColor = Color.Yellow;
                }
                else
                {
                    li.BackColor = Color.Green;
                    li.ForeColor = Color.LightGreen;
                }
                listView1.Items.Add(li);
            }
        }