Ejemplo 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);
            }
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 3
0
		public void UpdateDisplay()
		{
			listView1.Items.Clear();
			listView1.Groups.Clear();
			foreach (KeyValuePair<string, string[]> commodityGroup in mainScreen.data.commodities)
			{
				ListViewGroup group = listView1.Groups.Add(commodityGroup.Key, commodityGroup.Key);

				foreach (string commodity in commodityGroup.Value)
				{
					CommodityPrice ourPrice = null;
					CommodityPrice theirPrice = null;
					if (stationData != null)
					{
						ourPrice = stationData.GetPrice(commodity);
						if (nextStationData != null)
						{
							theirPrice = nextStationData.GetPrice(commodity);
						}
					}
					int amount = selectedAmount == 0 ? mainScreen.pilotData.maxCargo : selectedAmount;
					ComparedCommodity compared = new ComparedCommodity(commodity, amount, ourPrice, theirPrice);

					ListViewItem li = new ListViewItem(new string[] {
						compared.Commodity,
						compared.Demand,
						compared.PriceSell,
						compared.PriceBuy,
						compared.ProfitPer,
						compared.Profit
					}, group);
					li.Tag = compared;
					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);
				}
			}
		}
Ejemplo n.º 4
0
        public void UpdateDisplay()
        {
            listView1.Items.Clear();
            listView1.Groups.Clear();
            foreach (KeyValuePair <string, string[]> commodityGroup in mainScreen.data.commodities)
            {
                ListViewGroup group = listView1.Groups.Add(commodityGroup.Key, commodityGroup.Key);

                foreach (string commodity in commodityGroup.Value)
                {
                    int    profitPer    = 0;
                    string priceBuy     = "";
                    string priceSell    = "";
                    string demand       = "";
                    string profitPerStr = "";
                    string profitStr    = "";

                    if (stationData != null)
                    {
                        CommodityPrice ourPrice = stationData.GetPrice(commodity);
                        if (ourPrice != null)
                        {
                            if (ourPrice.priceBuy > 0)
                            {
                                priceBuy = ourPrice.priceBuy.ToString("N0");
                            }
                            if (ourPrice.priceSell > 0)
                            {
                                priceSell = ourPrice.priceSell.ToString("N0");
                            }
                            demand = ourPrice.demandType.ToString();
                        }
                        if (nextStationData != null)
                        {
                            CommodityPrice theirPrice = nextStationData.GetPrice(commodity);
                            if (ourPrice != null && theirPrice != null && theirPrice.priceSell > 0 && ourPrice.priceBuy > 0)
                            {
                                profitPer = theirPrice.priceSell - ourPrice.priceBuy;
                            }
                        }
                    }
                    int profit = profitPer * (selectedAmount == 0 ? maxCargo : selectedAmount);

                    if (profitPer != 0)
                    {
                        profitPerStr = profitPer.ToString("N0");
                        profitStr    = profit.ToString("N0");
                    }

                    ListViewItem li = new ListViewItem(new string[] {
                        commodity,
                        demand,
                        priceSell,
                        priceBuy,
                        profitPerStr,
                        profitStr
                    }, group);
                    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);
                }
            }
        }
Ejemplo n.º 5
0
        public void UpdateDisplay()
        {
            evaluations.Clear();
            Destination     currentData    = mainScreen.currentRoute.destinations[index];
            StationData     currentStation = mainScreen.data.GetStation(currentData.system, currentData.station);
            CommoditySorter sorter         = new CommoditySorter();

            sorter.criteria  = CommoditySorterCriteria.Profit;
            sorter.sortOrder = SortOrder.Descending;
            foreach (StationData station in mainScreen.data.Stations)
            {
                if (station == currentStation)
                {
                    continue;
                }
                List <ComparedCommodity> compared = new List <ComparedCommodity>();
                int amount = mainScreen.pilotData.maxCargo;
                foreach (string commodity in mainScreen.data.allCommodities)
                {
                    compared.Add(new ComparedCommodity(commodity, amount, currentStation.GetPrice(commodity), station.GetPrice(commodity)));
                }
                compared.Sort(sorter);
                Destination destination = new Destination(currentData);
                int         profit      = 0;
                if (respectBalance)
                {
                    if (sliceTransactions)
                    {
                        //TODO: go from most to least profitable and add transactions with as much as we can afford
                    }
                    else
                    {
                        //TODO: go from most to least profitable and add a single transaction once we can afford a full load.
                    }
                    //TODO: What to do if we cannot afford anything? Fallback?
                }
                else
                {
                    ComparedCommodity comm = compared.First();
                    profit += comm.profitPer * amount;
                    destination.transactions.Add(new Transaction(comm.commodity, 0));
                }
                evaluations.Add(new Evaluation(destination, new Destination(station), profit));
            }
            evaluations.Sort(new EvaluationSorter());

            if (evaluations.Count > showResults)
            {
                evaluations.RemoveRange(evaluations.Count, evaluations.Count - showResults);
            }

            // Cut off controls we don't need anymore
            if (destinationControls.Count > evaluations.Count)
            {
                for (int i = destinationControls.Count - 1; i >= evaluations.Count; i--)
                {
                    destinationControls[i].Dispose();
                    destinationControls.RemoveAt(i);
                }
                destinationControls.TrimExcess();
            }
            // Add missing controls & update existing ones
            destinationControls.Capacity = evaluations.Count;
            for (int i = 0; i < evaluations.Count; i++)
            {
                EvaluateDestinationControl ctrl;
                if (i >= destinationControls.Count)
                {
                    ctrl = new EvaluateDestinationControl(this);
                    destinationControls.Add(ctrl);
                    ctrl.Parent = flowLayoutPanel1;
                }
                else
                {
                    ctrl = destinationControls[i];
                }
                ctrl.index           = i;
                ctrl.destination     = evaluations[i].destination;
                ctrl.nextDestination = evaluations[i].nextDestination;
                ctrl.updateDisplay();
            }
        }