12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Reflection;
- using FastReport.Data;
- using FastReport.Utils;
- using FastReport.Editor.Syntax.Parsers;
- namespace FastReport.Controls
- {
- internal class DescriptionControl : Panel
- {
- private Panel pnDescription;
- private Report txReport;
- private TextObject txDescription;
- private void RecalcDescriptionSize()
- {
- txDescription.Width = (Width - this.LogicalToDevice(20)) * 96f / this.Dpi();
- var height = txDescription.CalcHeight();
- pnDescription.Size = new Size(Width - this.LogicalToDevice(20), (int)this.LogicalToDevice(height));
- pnDescription.Refresh();
- }
- protected override void OnSizeChanged(EventArgs e)
- {
- base.OnSizeChanged(e);
- RecalcDescriptionSize();
- }
- public void ShowDescription(Report report, object info)
- {
- string descr = "";
- if (info is SystemVariable)
- {
- descr = "<b>" + (info as SystemVariable).Name + "</b>";
- descr += "<br/><br/>" + ReflectionRepository.DescriptionHelper.GetDescription(info.GetType());
- }
- else if (info is MethodInfo)
- {
- descr = report.CodeHelper.GetMethodSignature(info as MethodInfo, true);
- descr += "<br/><br/>" + ReflectionRepository.DescriptionHelper.GetDescription(info as MethodInfo);
- foreach (ParameterInfo parInfo in (info as MethodInfo).GetParameters())
- {
- // special case - skip "thisReport" parameter
- if (parInfo.Name == "thisReport")
- continue;
- string s = ReflectionRepository.DescriptionHelper.GetDescription(parInfo);
- s = s.Replace("<b>", "{i}").Replace("</b>:", "{/i}").Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("{i}", "<i>").Replace("{/i}", "</i>");
- descr += "<br/><br/>" + s;
- }
- }
- descr = descr.Replace("\t", "<br/>");
- txDescription.Text = descr;
- RecalcDescriptionSize();
- pnDescription.Refresh();
- }
- private void pnDescription_Paint(object sender, PaintEventArgs e)
- {
- #if AVALONIA
- e.Graphics.FontScale = 1;
- #endif
- e.Graphics.FillRectangle(SystemBrushes.Window, new Rectangle(0, 0, pnDescription.Width, pnDescription.Height));
- txDescription.Width = pnDescription.Width * 96f / this.Dpi();
- txDescription.Height = pnDescription.Height * 96f / this.Dpi();
- txDescription.DrawText(new FRPaintEventArgs(e.Graphics, this.DpiMultiplier(), this.DpiMultiplier(), txDescription.Report.GraphicCache));
- }
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- txDescription.Dispose();
- txReport.Dispose();
- }
- public DescriptionControl()
- {
- pnDescription = new Panel();
- pnDescription.Padding = new Padding(2, 2, 2, 0);
- pnDescription.Paint += pnDescription_Paint;
- txReport = new Report();
- txDescription = new TextObject();
- txDescription.SetReport(txReport);
- txDescription.TextRenderType = TextRenderType.HtmlTags;
- txDescription.Font = DrawUtils.DefaultFont;
- Controls.Add(pnDescription);
-
- AutoScroll = true;
- BackColor = SystemColors.Window;
- }
- }
- }
|