Beispiel #1
0
        static AccountHistoryControl()
        {
            var blank = new MarketOrder();

            allColumns = new []
            {
                new FastColumn(blank.Property(p => p.ID), "#")
                {
                    SortOrder = FastColumnSort.Ascending
                },
                new FastColumn(blank.Property(p => p.Volume), Localizer.GetString("TitleSum"))
                {
                    formatter = v => ((int)v).ToStringUniformMoneyFormat()
                },
                new FastColumn(blank.Property(p => p.Symbol), Localizer.GetString("TitleSymbol")),
                new FastColumn(blank.Property(p => p.Side), Localizer.GetString("TitleType"))
                {
                    // отобразить BUY - SELL либо BalanceChangeType
                    formatter = s =>
                                (int)s == 1 ? "BUY" : (int)s == -1 ? "SELL"
                                : ((int)s / 10) == (int)BalanceChangeType.Deposit ? Localizer.GetString("TitleInvestment")
                                : ((int)s / 10) == (int)BalanceChangeType.Withdrawal ? Localizer.GetString("TitleWithdrawal")
                                : ((int)s / 10) == (int)BalanceChangeType.Profit ? Localizer.GetString("TitleDealProfit")
                                : ((int)s / 10) == (int)BalanceChangeType.Loss ? Localizer.GetString("TitleDealLoss") : "",
                    colorColumnFormatter = delegate(object cellValue, out Color? backColor, out Color? fontColor)
                    {
                        backColor = null;
                        fontColor = (int)cellValue == 1 ? Color.Green
                                : (int)cellValue == -1 ? Color.Red : Color.Black;
                    }
                },
                new FastColumn(blank.Property(p => p.PriceEnter), Localizer.GetString("TitleEnter"))
                {
                    formatter = (s => (float)s > 0 ?
                                 ((float)s).ToString("f4") : "")
                },
                new FastColumn(blank.Property(p => p.TimeEnter), Localizer.GetString("TitleTime"))
                {
                    formatter = (s => (DateTime)s == default(DateTime) ? "" : ((DateTime)s).ToStringUniform())
                },
                new FastColumn(blank.Property(p => p.PriceExit), Localizer.GetString("TitleExit"))
                {
                    FormatString = "f4"
                },
                new FastColumn(blank.Property(p => p.TimeExit), Localizer.GetString("TitleTime"))
                {
                    FormatString = "dd.MM.yyyy HH:mm:ss"
                },
                new FastColumn(blank.Property(p => p.ResultDepo), Localizer.GetString("TitleResult"))
                {
                    formatter            = c => Math.Abs((float)c) < 0.01f ? "" : ((float)c).ToStringUniformMoneyFormat(),
                    colorColumnFormatter = delegate(object cellValue, out Color? backColor, out Color? fontColor)
                    {
                        backColor = null;
                        fontColor = null;
                        if (cellValue == null)
                        {
                            return;
                        }
                        var resDepo = (float)cellValue;
                        fontColor = resDepo >= 0 ? Color.Green : Color.Red;
                    }
                },
                new FastColumn(blank.Property(p => p.ResultPoints), Localizer.GetString("TitlePLInPoints"))
                {
                    formatter            = c => Math.Abs((float)c) < 0.02f ? "" : ((float)c).ToStringUniformMoneyFormat(),
                    colorColumnFormatter = delegate(object cellValue,
                                                    out Color? backColor, out Color? fontColor)
                    {
                        backColor = null;
                        fontColor = null;
                        if (cellValue == null)
                        {
                            return;
                        }
                        var resPoints = (float)cellValue;
                        fontColor = resPoints >= 0 ? Color.Green : Color.Red;
                    }
                },
                new FastColumn(blank.Property(p => p.StopLoss), "S/L")
                {
                    FormatString = "f4"
                },
                new FastColumn(blank.Property(p => p.TakeProfit), "T/P")
                {
                    FormatString = "f4"
                },
                new FastColumn(blank.Property(p => p.Comment), Localizer.GetString("TitleCommentShort")),
                new FastColumn(blank.Property(p => p.ExpertComment), Localizer.GetString("TitleRobotCommentShort")),
                new FastColumn(blank.Property(p => p.ExitReason), Localizer.GetString("TitleClosing"))
                {
                    formatter = o => EnumFriendlyName <PositionExitReason> .GetString((PositionExitReason)o)
                }
            };
        }