private string GetOrdersHint(Point ptClient)
        {
            var asterixes = seriesAsteriks.GetObjectsUnderCursor(ptClient.X, ptClient.Y, SeriesComment.DefaultMouseTolerance);

            if (asterixes.Count == 0)
            {
                return(string.Empty);
            }

            var selectedOrders = new List <Cortege2 <string, string> >();

            foreach (var aster in asterixes)
            {
                var posId = aster.Magic;
                if (aster.Name == "p")
                {
                    var orderPend = pendingOrders.FirstOrDefault(p => p.ID == posId);
                    if (orderPend != null)
                    {
                        selectedOrders.Add(new Cortege2 <string, string>("",
                                                                         DisplayedOrder.MakeOrderTitle(orderPend)));
                    }
                    continue;
                }

                var list     = aster.Name == "o" ? openPositions : closedPositions;
                var pos      = list.FirstOrDefault(p => p.ID == posId);
                var eventStr = aster.Name == "q" ? "выход: " : "";
                if (pos != null)
                {
                    selectedOrders.Add(
                        new Cortege2 <string, string>(eventStr, DisplayedOrder.MakeOrderTitle(pos)));
                }
            }

            if (selectedOrders.Count > OrdersInHintMax)
            {
                var lastIndex = selectedOrders.Count - OrdersInHintMax;
                currentHintIndex++;
                if (currentHintIndex > lastIndex)
                {
                    currentHintIndex = 0;
                }
                lastIndex = currentHintIndex + OrdersInHintMax;
                var trimmedList = new List <Cortege2 <string, string> >();
                for (var i = currentHintIndex; i < lastIndex; i++)
                {
                    trimmedList.Add(selectedOrders[i]);
                }
                selectedOrders = trimmedList;
            }
            var sb = new StringBuilder();

            foreach (var order in selectedOrders)
            {
                sb.AppendLine(order.a + order.b);
            }

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        private void UpdateDisplayedOrders(List <MarketOrder> newOrders, List <MarketOrder> targetList)
        {
            if (newOrders.Count == 0)
            {
                targetList.Clear();
                return;
            }
            if (newOrders.Count != targetList.Count)
            {
                targetList.Clear();
                targetList.AddRange(newOrders);
                return;
            }

            // сравнить новые ордера с обработанными
            newOrders = newOrders.OrderBy(o => o.ID).ToList();
            var same = true;

            for (var i = 0; i < newOrders.Count; i++)
            {
                if (DisplayedOrder.AreSame(newOrders[i], targetList[i]))
                {
                    continue;
                }
                same = false;
                break;
            }
            if (same)
            {
                return;
            }

            // таки обновить
            targetList.Clear();
            targetList.AddRange(newOrders);
            BuildSeries(owner);
        }