public void Show(Point pt) { int num = base.Parent.Width - 20; Graphics graphics = base.CreateGraphics(); int num2 = 6; int width = 8; SizeF ef = Utility.MeasureString(graphics, this.Text, this.Font); width = (int) Math.Min((float) num, Math.Max(ef.Width + 8f, (float) width)); this.m_wrapper = Utility.WrapText(graphics, this.Text, this.Font, width); width = this.m_wrapper.Width; num2 += this.m_wrapper.Height; pt.Y -= num2; if (pt.Y < 0) { pt.Y = 0; } pt.X -= width / 2; if ((pt.X + width) > num) { pt.X -= (pt.X + width) - num; } if (pt.X <= 0) { pt.X = 10; } graphics.Dispose(); base.Height = num2; base.Width = width; base.Location = pt; base.Visible = true; base.BringToFront(); }
public void Show(Point pt) { int num = base.Parent.Width - 20; Graphics graphics = base.CreateGraphics(); int num2 = 6; int width = 8; SizeF ef = Utility.MeasureString(graphics, this.Text, this.Font); width = (int)Math.Min((float)num, Math.Max(ef.Width + 8f, (float)width)); this.m_wrapper = Utility.WrapText(graphics, this.Text, this.Font, width); width = this.m_wrapper.Width; num2 += this.m_wrapper.Height; pt.Y -= num2; if (pt.Y < 0) { pt.Y = 0; } pt.X -= width / 2; if ((pt.X + width) > num) { pt.X -= (pt.X + width) - num; } if (pt.X <= 0) { pt.X = 10; } graphics.Dispose(); base.Height = num2; base.Width = width; base.Location = pt; base.Visible = true; base.BringToFront(); }
public override int GetAutoHeight(Row r, int index, RowSpecificCellProperties preRscp) { int num = 0; if (!base.AutoHeight) { return(base.Bounds.Height); } RowSpecificCellProperties properties = (preRscp == null) ? base.GetRowSpecificProperties(r) : preRscp; if (properties.CachedAutoHeight >= 0) { return(properties.CachedAutoHeight); } string text = this.GetText(base[r, index]); if (((text == null) || (text.Length == 0)) || !properties.Visible.Value) { return(0); } int gridWidth = 0; Resco.Controls.AdvancedList.AdvancedList parent = base.Parent; if (parent != null) { gridWidth = parent.CalculateClientRect().Width - (parent.ScrollbarVisible ? parent.ScrollbarWidth : 0); } if (gridWidth != 0) { Rectangle rectangle = base.CalculateCellWidth(gridWidth); rectangle.Width -= 3; if (rectangle.Width > base.Parent.ScrollbarWidth) { Graphics gr = base.Graphics; bool flag = false; if ((gr == null) && (base.Parent != null)) { gr = base.Parent.CreateGraphics(); flag = true; } WrapTextData data = Utility.WrapText(gr, text, this.m_Font, rectangle.Width); if ((gr != null) && flag) { gr.Dispose(); } num = (data != null) ? (data.Height + 2) : 0; } } properties.CachedAutoHeight = num; return(num); }
protected bool DrawAlignedText(Graphics gr, string text, Brush foreBrush, Rectangle layoutRectangle) { int num; int num2; HorizontalAlignment center; VerticalAlignment middle; if (((text == null) || (text.Length == 0)) || (((num = layoutRectangle.Width) < 1) || ((num2 = layoutRectangle.Height) < 1))) { return(true); } Font font = this.m_Font; switch (this.m_TextAlignment) { case Resco.Controls.AdvancedList.Alignment.MiddleCenter: center = HorizontalAlignment.Center; middle = VerticalAlignment.Middle; break; case Resco.Controls.AdvancedList.Alignment.MiddleRight: center = HorizontalAlignment.Right; middle = VerticalAlignment.Middle; break; case Resco.Controls.AdvancedList.Alignment.MiddleLeft: center = HorizontalAlignment.Left; middle = VerticalAlignment.Middle; break; case Resco.Controls.AdvancedList.Alignment.BottomCenter: center = HorizontalAlignment.Center; middle = VerticalAlignment.Bottom; break; case Resco.Controls.AdvancedList.Alignment.BottomRight: center = HorizontalAlignment.Right; middle = VerticalAlignment.Bottom; break; case Resco.Controls.AdvancedList.Alignment.BottomLeft: center = HorizontalAlignment.Left; middle = VerticalAlignment.Bottom; break; case Resco.Controls.AdvancedList.Alignment.TopCenter: center = HorizontalAlignment.Center; middle = VerticalAlignment.Top; break; case Resco.Controls.AdvancedList.Alignment.TopRight: center = HorizontalAlignment.Right; middle = VerticalAlignment.Top; break; default: center = HorizontalAlignment.Left; middle = VerticalAlignment.Top; break; } int num3 = -1; if (this.m_selectedText != "") { num3 = text.ToLower().IndexOf(this.m_selectedText.ToLower()); } Brush brush = Resco.Controls.AdvancedList.AdvancedList.GetBrush(this.SelectedForeColor); Brush brush2 = Resco.Controls.AdvancedList.AdvancedList.GetBrush(this.SelectedBackColor); bool flag = true; WrapTextData data = Utility.WrapText(gr, text, this.m_Font, layoutRectangle.Width); if (data == null) { return(true); } int length = data.Lines.Length; int lineHeight = data.LineHeight; int height = data.Height; if (num2 < data.Height) { length = num2 / lineHeight; if (length < 1) { if (num2 <= (lineHeight / 2)) { return(false); } length = 1; } height = length * lineHeight; flag = data.Lines.Length <= length; } int y = layoutRectangle.Y; if (middle != VerticalAlignment.Top) { int num8 = num2 - height; if (middle == VerticalAlignment.Middle) { num8 /= 2; } y += num8; } int x = layoutRectangle.X; int num10 = 0; int index = 0; if (y < 0) { int num12 = -y / lineHeight; y += num12 * lineHeight; index += num12; } int num13 = base.Parent.CalculateClientRect().Height; int num14 = -1; int num15 = 0; int num17 = this.m_selectedText.Length; while (index < length) { string str2; int num18; DrawLineData data2 = data.Lines[index]; if (!flag && (index == (length - 1))) { int cutLength = data2.CutLength; if ((data2.Index + cutLength) > text.Length) { cutLength = data2.Length; } str2 = text.Substring(data2.Index, cutLength); num18 = (cutLength == data2.Length) ? data2.Width : num; if ((base.Parent != null) && (base.Parent.ToolTipType == ToolTipType.Dots)) { int width = (int)Math.Ceiling((double)Utility.MeasureString(gr, "...", font).Width); int num21 = num - width; num18 = (int)Math.Ceiling((double)Utility.MeasureString(gr, str2, font).Width); while ((str2.Length > 0) && (num18 >= num21)) { str2 = str2.Remove(str2.Length - 1, 1); num18 = (int)Math.Ceiling((double)Utility.MeasureString(gr, str2, font).Width); } int num22 = 0; if (center != HorizontalAlignment.Left) { num22 = num - (num18 + width); if (center == HorizontalAlignment.Center) { num22 /= 2; } } int num23 = (x + num22) + num18; this.DrawTextLine(gr, "...", font, foreBrush, num23, y, width, lineHeight, 0); base.Parent.AddTooltipArea(new Rectangle(num23, y, (num - num23) + 2, lineHeight + 2), text); } } else { str2 = text.Substring(data2.Index, data2.Length); num18 = data2.Width; } if (center != HorizontalAlignment.Left) { num10 = num - num18; if (center == HorizontalAlignment.Center) { num10 /= 2; } } if ((((num3 > 0) && !this.m_restrictSelectedTextToStart) || (num3 == 0)) && (((num3 + (num15 = num17)) > (num14 = data2.Index)) && (num3 < (num14 + str2.Length)))) { string str; int num16; int num24 = num3 - num14; if (num24 > 0) { str = str2.Substring(0, num24); this.DrawTextLine(gr, str, font, foreBrush, x + num10, y, num18, lineHeight, data2.Index); num16 = (int)Utility.MeasureString(gr, str, font).Width; if ((num24 + num15) < str2.Length) { str = str2.Substring(num24, num15); int num25 = (int)Utility.MeasureString(gr, str, font).Width; gr.FillRectangle(brush2, (x + num10) + num16, y, num25, lineHeight); this.DrawTextLine(gr, str, font, brush, (x + num10) + num16, y, num18 - num16, lineHeight, data2.Index); num16 += num25; str = str2.Substring(num24 + num15, str2.Length - (num24 + num15)); this.DrawTextLine(gr, str, font, foreBrush, (x + num10) + num16, y, num18 - num16, lineHeight, data2.Index); } else { str = str2.Substring(num24, (num14 + str2.Length) - num3); gr.FillRectangle(brush2, (x + num10) + num16, y, num18 - num16, lineHeight); this.DrawTextLine(gr, str, font, brush, (x + num10) + num16, y, num18 - num16, lineHeight, data2.Index); } } else { if ((num24 + num15) < str2.Length) { str = str2.Substring(0, num24 + num15); } else { str = str2; } num16 = (int)Utility.MeasureString(gr, str, font).Width; gr.FillRectangle(brush2, x + num10, y, num16, lineHeight); this.DrawTextLine(gr, str, font, brush, x + num10, y, num18, lineHeight, data2.Index); if ((num24 + num15) < str2.Length) { str = str2.Substring(num15 + num24, str2.Length - (num15 + num24)); this.DrawTextLine(gr, str, font, foreBrush, (x + num10) + num16, y, num18 - num16, lineHeight, data2.Index); } } } else { this.DrawTextLine(gr, str2, font, foreBrush, x + num10, y, num18, lineHeight, data2.Index); } y += lineHeight; data2 = null; if (y > num13) { break; } index++; } data = null; return(flag); }
public static WrapTextData WrapText(Graphics gr, string text, Font font, int width) { int num12; ArrayList list2; if (gr == null) { return null; } object hashKey = GetHashKey(text); WrapTextData[] dataArray = (WrapTextData[]) WrapTextCache[hashKey]; if (dataArray != null) { for (int j = dataArray.Length - 1; j >= 0; j--) { if (((dataArray[j].TextLength == text.Length) && (dataArray[j].Width == width)) && dataArray[j].Font.Equals(font)) { return dataArray[j]; } } } WrapTextData data = new WrapTextData(text.Length, font, width); SizeF ef = MeasureString(gr, text, font); float num2 = ef.Width; if (num2 > width) { int length = text.Length; int index = 0; int startIndex = 0; int num11 = length; Math.Ceiling((double) ef.Height); num12 = 0; list2 = new ArrayList(); index = text.IndexOf('\n', startIndex); if (index != -1) { while (index > -1) { num11 = index - startIndex; if ((num11 > 0) && (text[(startIndex + num11) - 1] == '\r')) { num11--; } string str2 = text.Substring(startIndex, num11); ef = MeasureString(gr, str2, font); num12 = Math.Max(num12, (int) Math.Ceiling((double) ef.Height)); list2.Add(new DrawLineData(startIndex, num11, (int) Math.Ceiling((double) ef.Width))); startIndex = index + 1; if (startIndex >= length) { break; } if (text[startIndex] == '\r') { startIndex++; if (startIndex >= length) { break; } } index = text.IndexOf('\n', startIndex); } if (startIndex < length) { num11 = length - startIndex; string str3 = text.Substring(startIndex, num11); ef = MeasureString(gr, str3, font); num12 = Math.Max(num12, (int) Math.Ceiling((double) ef.Height)); list2.Add(new DrawLineData(startIndex, num11, (int) Math.Ceiling((double) ef.Width))); } } else { num12 = (int) Math.Ceiling((double) ef.Height); list2.Add(new DrawLineData(0, length, (int) Math.Ceiling((double) ef.Width))); } } else { if (text.IndexOf('\n') == -1) { data.LineHeight = (int) Math.Ceiling((double) ef.Height); data.Height = data.LineHeight; data.Lines = new DrawLineData[] { new DrawLineData(0, text.Length, (int) Math.Ceiling((double) num2)) }; } else { int num3 = text.Length; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = (int) Math.Ceiling((double) ef.Height); ArrayList list = new ArrayList(); do { num4 = text.IndexOf('\n', num5); num6 = (num4 == -1) ? (num3 - num5) : (num4 - num5); if ((num6 > 0) && (text[(num5 + num6) - 1] == '\r')) { num6--; } string str = text.Substring(num5, num6); ef = MeasureString(gr, str, font); list.Add(new DrawLineData(num5, num6, (int) Math.Ceiling((double) ef.Width))); num5 = num4 + 1; if (num5 >= num3) { break; } if (text[num5] == '\r') { num5++; if (num5 >= num3) { break; } } } while (num4 > -1); data.Lines = (DrawLineData[]) list.ToArray(typeof(DrawLineData)); data.Height = num7; data.LineHeight = num7 / data.Lines.Length; } goto Label_0614; } ArrayList list3 = new ArrayList(2 * list2.Count); int count = list2.Count; for (int i = 0; i < count; i++) { float num19; int num20; DrawLineData data2 = (DrawLineData) list2[i]; int num15 = data2.Width; if (num15 <= width) { list3.Add(data2); continue; } int num16 = data2.Length; int num17 = (int) Math.Ceiling((double) ((num16 * width) / num15)); if (num17 < 1) { list3.Add(new DrawLineData(data2.Index, 1, width)); if (num16 > 1) { data2.Index++; data2.Length--; ef = MeasureString(gr, text.Substring(data2.Index, data2.Length), font); data2.Width = (int) Math.Ceiling((double) ef.Width); i--; } continue; } int num18 = data2.Index; if (MeasureString(gr, text.Substring(num18, num17), font).Width > width) { do { if (num17 <= 1) { break; } num17--; } while (MeasureString(gr, text.Substring(num18, num17), font).Width > width); goto Label_04CB; } Label_0492: if (num17 < (num16 - 1)) { ef = MeasureString(gr, text.Substring(num18, num17 + 1), font); if (ef.Width <= width) { num17++; num19 = ef.Width; goto Label_0492; } } Label_04CB: num20 = num18 + num17; if (char.IsWhiteSpace(text[num20])) { num20++; } else { int num21 = text.LastIndexOfAny(new char[] { ' ', '\t' }, num20 - 1, num17 - 1); if (num21 > 0) { num20 = num21 + 1; } } if (num20 < (num18 + num16)) { int num22 = num20 - num18; if (num22 > num17) { num22 = num17; } num19 = MeasureString(gr, text.Substring(num18, num22), font).Width; DrawLineData data3 = new DrawLineData(num18, num22, (int) Math.Ceiling((double) num19)); data3.CutLength = num17; list3.Add(data3); data2.Index = num20; num16 += num18 - num20; data2.Length = num16; ef = MeasureString(gr, text.Substring(num20, num16), font); data2.Width = (int) Math.Ceiling((double) ef.Width); i--; } else { list3.Add(data2); } } data.Lines = (DrawLineData[]) list3.ToArray(typeof(DrawLineData)); data.Height = num12 * data.Lines.Length; data.LineHeight = num12; Label_0614: if (dataArray == null) { dataArray = new WrapTextData[] { data }; } else { WrapTextData[] array = new WrapTextData[dataArray.Length + 1]; array[0] = data; dataArray.CopyTo(array, 1); dataArray = array; } if (WrapTextCache.Count >= CacheCapacity) { WrapTextCache.Clear(); } WrapTextCache[hashKey] = dataArray; return data; }
protected override void Dispose(bool disposing) { this.m_wrapper = null; base.Dispose(disposing); }
public static WrapTextData WrapText(Graphics gr, string text, Font font, int width) { int num12; ArrayList list2; if (gr == null) { return(null); } object hashKey = GetHashKey(text); WrapTextData[] dataArray = (WrapTextData[])WrapTextCache[hashKey]; if (dataArray != null) { for (int j = dataArray.Length - 1; j >= 0; j--) { if (((dataArray[j].TextLength == text.Length) && (dataArray[j].Width == width)) && dataArray[j].Font.Equals(font)) { return(dataArray[j]); } } } WrapTextData data = new WrapTextData(text.Length, font, width); SizeF ef = MeasureString(gr, text, font); float num2 = ef.Width; if (num2 > width) { int length = text.Length; int index = 0; int startIndex = 0; int num11 = length; Math.Ceiling((double)ef.Height); num12 = 0; list2 = new ArrayList(); index = text.IndexOf('\n', startIndex); if (index != -1) { while (index > -1) { num11 = index - startIndex; if ((num11 > 0) && (text[(startIndex + num11) - 1] == '\r')) { num11--; } string str2 = text.Substring(startIndex, num11); ef = MeasureString(gr, str2, font); num12 = Math.Max(num12, (int)Math.Ceiling((double)ef.Height)); list2.Add(new DrawLineData(startIndex, num11, (int)Math.Ceiling((double)ef.Width))); startIndex = index + 1; if (startIndex >= length) { break; } if (text[startIndex] == '\r') { startIndex++; if (startIndex >= length) { break; } } index = text.IndexOf('\n', startIndex); } if (startIndex < length) { num11 = length - startIndex; string str3 = text.Substring(startIndex, num11); ef = MeasureString(gr, str3, font); num12 = Math.Max(num12, (int)Math.Ceiling((double)ef.Height)); list2.Add(new DrawLineData(startIndex, num11, (int)Math.Ceiling((double)ef.Width))); } } else { num12 = (int)Math.Ceiling((double)ef.Height); list2.Add(new DrawLineData(0, length, (int)Math.Ceiling((double)ef.Width))); } } else { if (text.IndexOf('\n') == -1) { data.LineHeight = (int)Math.Ceiling((double)ef.Height); data.Height = data.LineHeight; data.Lines = new DrawLineData[] { new DrawLineData(0, text.Length, (int)Math.Ceiling((double)num2)) }; } else { int num3 = text.Length; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = (int)Math.Ceiling((double)ef.Height); ArrayList list = new ArrayList(); do { num4 = text.IndexOf('\n', num5); num6 = (num4 == -1) ? (num3 - num5) : (num4 - num5); if ((num6 > 0) && (text[(num5 + num6) - 1] == '\r')) { num6--; } string str = text.Substring(num5, num6); ef = MeasureString(gr, str, font); list.Add(new DrawLineData(num5, num6, (int)Math.Ceiling((double)ef.Width))); num5 = num4 + 1; if (num5 >= num3) { break; } if (text[num5] == '\r') { num5++; if (num5 >= num3) { break; } } }while (num4 > -1); data.Lines = (DrawLineData[])list.ToArray(typeof(DrawLineData)); data.Height = num7; data.LineHeight = num7 / data.Lines.Length; } goto Label_0614; } ArrayList list3 = new ArrayList(2 * list2.Count); int count = list2.Count; for (int i = 0; i < count; i++) { float num19; int num20; DrawLineData data2 = (DrawLineData)list2[i]; int num15 = data2.Width; if (num15 <= width) { list3.Add(data2); continue; } int num16 = data2.Length; int num17 = (int)Math.Ceiling((double)((num16 * width) / num15)); if (num17 < 1) { list3.Add(new DrawLineData(data2.Index, 1, width)); if (num16 > 1) { data2.Index++; data2.Length--; ef = MeasureString(gr, text.Substring(data2.Index, data2.Length), font); data2.Width = (int)Math.Ceiling((double)ef.Width); i--; } continue; } int num18 = data2.Index; if (MeasureString(gr, text.Substring(num18, num17), font).Width > width) { do { if (num17 <= 1) { break; } num17--; }while (MeasureString(gr, text.Substring(num18, num17), font).Width > width); goto Label_04CB; } Label_0492: if (num17 < (num16 - 1)) { ef = MeasureString(gr, text.Substring(num18, num17 + 1), font); if (ef.Width <= width) { num17++; num19 = ef.Width; goto Label_0492; } } Label_04CB: num20 = num18 + num17; if (char.IsWhiteSpace(text[num20])) { num20++; } else { int num21 = text.LastIndexOfAny(new char[] { ' ', '\t' }, num20 - 1, num17 - 1); if (num21 > 0) { num20 = num21 + 1; } } if (num20 < (num18 + num16)) { int num22 = num20 - num18; if (num22 > num17) { num22 = num17; } num19 = MeasureString(gr, text.Substring(num18, num22), font).Width; DrawLineData data3 = new DrawLineData(num18, num22, (int)Math.Ceiling((double)num19)); data3.CutLength = num17; list3.Add(data3); data2.Index = num20; num16 += num18 - num20; data2.Length = num16; ef = MeasureString(gr, text.Substring(num20, num16), font); data2.Width = (int)Math.Ceiling((double)ef.Width); i--; } else { list3.Add(data2); } } data.Lines = (DrawLineData[])list3.ToArray(typeof(DrawLineData)); data.Height = num12 * data.Lines.Length; data.LineHeight = num12; Label_0614: if (dataArray == null) { dataArray = new WrapTextData[] { data }; } else { WrapTextData[] array = new WrapTextData[dataArray.Length + 1]; array[0] = data; dataArray.CopyTo(array, 1); dataArray = array; } if (WrapTextCache.Count >= CacheCapacity) { WrapTextCache.Clear(); } WrapTextCache[hashKey] = dataArray; return(data); }