public override string ToString() { var sb = new StringBuilder(); sb.Append(LeftBorder.ToString()); sb.Append("-"); sb.Append(LeftBorderColor); sb.Append("-"); sb.Append(RightBorder.ToString()); sb.Append("-"); sb.Append(RightBorderColor); sb.Append("-"); sb.Append(TopBorder.ToString()); sb.Append("-"); sb.Append(TopBorderColor); sb.Append("-"); sb.Append(BottomBorder.ToString()); sb.Append("-"); sb.Append(BottomBorderColor); sb.Append("-"); sb.Append(DiagonalBorder.ToString()); sb.Append("-"); sb.Append(DiagonalBorderColor); sb.Append("-"); sb.Append(DiagonalUp.ToString()); sb.Append("-"); sb.Append(DiagonalDown.ToString()); return(sb.ToString()); }
public override string ToString() { #region Одно мгновение if (LeftBorder == RightBorder) { return(LeftBorder.ToString(CultureInfo.CurrentCulture)); } #endregion #region Факт if (LeftBorder == new DateTime(1, 1, 2) && RightBorder == LeftBorder.AddTicks(1)) { return("Факт"); } #endregion #region Факт2 if (LeftBorder == new DateTime(1, 1, 2).AddTicks(1) && RightBorder == LeftBorder.AddTicks(2)) { return("Факт2"); } #endregion #region День if (LeftBorder.AddDays(1) == RightBorder && LeftBorder.AddTicks(-1).Day != LeftBorder.Day) { return(string.Format("{0}", LeftBorder.ToString("d.MM.yy"))); } #endregion #region Месяц if (LeftBorder.AddMonths(1) == RightBorder && LeftBorder.AddTicks(-1).Month != LeftBorder.Month) { return(string.Format("{0} '{1}", LeftBorder.ToString("MMM"), LeftBorder.ToString("yy"))); } #endregion #region Полугодие if (LeftBorder.AddMonths(6) == RightBorder) { if (LeftBorder.Month == 1 && LeftBorder.AddTicks(-1).Month != LeftBorder.Month) { return(string.Format("1 п. '{0}", LeftBorder.ToString("yy"))); } if (LeftBorder.Month == 7 && LeftBorder.AddTicks(-1).Month != LeftBorder.Month) { return(string.Format("2 п. '{0}", LeftBorder.ToString("yy"))); } } #endregion #region Год if (LeftBorder.AddYears(1) == RightBorder && LeftBorder.AddTicks(-1).Year != LeftBorder.Year) { return(string.Format("'{0}", LeftBorder.ToString("yy"))); } #endregion #region Все периоды if (LeftBorder == new DateTime(1, 1, 2).AddTicks(2) && RightBorder == new DateTime(1, 1, 2).AddTicks(3)) { return("Все периоды"); } #endregion #region Произвольный период return(string.Format("{0} - {1}", LeftBorder.ToShortDateString(), RightBorder.ToShortDateString())); #endregion }