123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- using System;
- using System.IO;
- using System.Xml;
- using System.Drawing;
- using System.Windows.Forms;
- using FastReport.MSChart;
- using FastReport.Table;
- namespace FastReport.Import.RDL
- {
- /// <summary>
- /// Represents the RDL import plugin.
- /// </summary>
- public partial class RDLImport : ImportBase
- {
- #region Private Methods
- private void LoadBorderColorExt(XmlNode borderColorNode)
- {
- XmlNodeList nodeList = borderColorNode.ChildNodes;
- foreach (XmlNode node in nodeList)
- {
- if (node.Name == "Default")
- {
- if (component is MSChartObject)
- {
- (component as MSChartObject).Chart.BorderlineColor = UnitsConverter.ConvertColor(node.InnerText);
- }
- else if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.Color = UnitsConverter.ConvertColor(node.InnerText);
- }
- }
- else if (node.Name == "Top")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.TopLine.Color = UnitsConverter.ConvertColor(node.InnerText);
- }
- }
- else if (node.Name == "Left")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.LeftLine.Color = UnitsConverter.ConvertColor(node.InnerText);
- }
- }
- else if (node.Name == "Right")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.RightLine.Color = UnitsConverter.ConvertColor(node.InnerText);
- }
- }
- else if (node.Name == "Bottom")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.BottomLine.Color = UnitsConverter.ConvertColor(node.InnerText);
- }
- }
- }
- }
- private void LoadBorderStyleExt(XmlNode borderStyleNode)
- {
- XmlNodeList nodeList = borderStyleNode.ChildNodes;
- foreach (XmlNode node in nodeList)
- {
- if (node.Name == "Default")
- {
- if (component is MSChartObject)
- {
- (component as MSChartObject).Chart.BorderlineDashStyle = UnitsConverter.ConvertBorderStyleToChartDashStyle(node.InnerText);
- }
- else if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.Lines = BorderLines.All;
- (component as ReportComponentBase).Border.Style = UnitsConverter.ConvertBorderStyle(node.InnerText);
- }
- }
- else if (node.Name == "Top")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.Lines |= BorderLines.Top;
- (component as ReportComponentBase).Border.TopLine.Style = UnitsConverter.ConvertBorderStyle(node.InnerText);
- }
- }
- else if (node.Name == "Left")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.Lines |= BorderLines.Left;
- (component as ReportComponentBase).Border.LeftLine.Style = UnitsConverter.ConvertBorderStyle(node.InnerText);
- }
- }
- else if (node.Name == "Right")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.Lines |= BorderLines.Right;
- (component as ReportComponentBase).Border.RightLine.Style = UnitsConverter.ConvertBorderStyle(node.InnerText);
- }
- }
- else if (node.Name == "Bottom")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.Lines |= BorderLines.Bottom;
- (component as ReportComponentBase).Border.BottomLine.Style = UnitsConverter.ConvertBorderStyle(node.InnerText);
- }
- }
- }
- }
- private void LoadBorderWidthExt(XmlNode borderWidthNode)
- {
- XmlNodeList nodeList = borderWidthNode.ChildNodes;
- foreach (XmlNode node in nodeList)
- {
- if (node.Name == "Default")
- {
- if (component is MSChartObject)
- {
- (component as MSChartObject).Chart.BorderlineWidth = (int)UnitsConverter.SizeToPixels(node.InnerText);
- }
- else if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.Width = UnitsConverter.SizeToPixels(node.InnerText);
- }
- }
- else if (node.Name == "Top")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.TopLine.Width = UnitsConverter.SizeToPixels(node.InnerText);
- }
- }
- else if (node.Name == "Left")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.LeftLine.Width = UnitsConverter.SizeToPixels(node.InnerText);
- }
- }
- else if (node.Name == "Right")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.RightLine.Width = UnitsConverter.SizeToPixels(node.InnerText);
- }
- }
- else if (node.Name == "Bottom")
- {
- if (component is ReportComponentBase)
- {
- (component as ReportComponentBase).Border.BottomLine.Width = UnitsConverter.SizeToPixels(node.InnerText);
- }
- }
- }
- }
- private void LoadStyleExt(XmlNode styleNode)
- {
- FontStyle fontStyle = FontStyle.Regular;
- string fontFamily = "Arial";
- float fontSize = 10.0f;
- int paddingTop = 0;
- int paddingLeft = 2;
- int paddingRight = 2;
- int paddingBottom = 0;
- XmlNodeList nodeList = styleNode.ChildNodes;
- foreach (XmlNode node in nodeList)
- {
- if (node.Name == "BorderColor")
- {
- LoadBorderColorExt(node);
- }
- else if (node.Name == "BorderStyle")
- {
- LoadBorderStyleExt(node);
- }
- else if (node.Name == "BorderWidth")
- {
- LoadBorderWidthExt(node);
- }
- else if (node.Name == "BackgroundColor")
- {
- if (component is ShapeObject)
- {
- (component as ShapeObject).FillColor = UnitsConverter.ConvertColor(node.InnerText);
- }
- else if (component is MSChartObject)
- {
- (component as MSChartObject).Chart.BackColor = UnitsConverter.ConvertColor(node.InnerText);
- }
- else if (component is TableObject)
- {
- (component as TableObject).FillColor = UnitsConverter.ConvertColor(node.InnerText);
- }
- //else if (component is SubreportObject)
- //{
- // (component as SubreportObject).FillColor = UnitsConverter.ConvertColor(node.InnerText);
- //}
- }
- else if (node.Name == "BackgroundGradientType")
- {
- if (component is MSChartObject)
- {
- (component as MSChartObject).Chart.BackGradientStyle = UnitsConverter.ConvertGradientType(node.InnerText);
- }
- }
- else if (node.Name == "BackgroundGradientEndColor")
- {
- if (component is MSChartObject)
- {
- (component as MSChartObject).Chart.BackSecondaryColor = UnitsConverter.ConvertColor(node.InnerText);
- }
- }
- else if (node.Name == "FontStyle")
- {
- fontStyle = UnitsConverter.ConvertFontStyle(node.InnerText);
- }
- else if (node.Name == "FontFamily")
- {
- fontFamily = node.InnerText;
- }
- else if (node.Name == "FontSize")
- {
- fontSize = Convert.ToSingle(UnitsConverter.ConvertFontSize(node.InnerText));
- }
- else if (node.Name == "TextAlign")
- {
- if (component is TextObject)
- {
- (component as TextObject).HorzAlign = UnitsConverter.ConvertTextAlign(node.InnerText);
- }
- }
- else if (node.Name == "VerticalAlign")
- {
- if (component is TextObject)
- {
- (component as TextObject).VertAlign = UnitsConverter.ConvertVerticalAlign(node.InnerText);
- }
- }
- else if (node.Name == "WritingMode")
- {
- if (component is TextObject)
- {
- (component as TextObject).Angle = UnitsConverter.ConvertWritingMode(node.InnerText);
- }
- }
- else if (node.Name == "Color")
- {
- if (component is TextObject)
- {
- (component as TextObject).TextColor = UnitsConverter.ConvertColor(node.InnerText);
- }
- }
- else if (node.Name == "PaddingLeft")
- {
- paddingLeft = UnitsConverter.SizeToInt(node.InnerText, SizeUnits.Point);
- }
- else if (node.Name == "PaddingRight")
- {
- paddingRight = UnitsConverter.SizeToInt(node.InnerText, SizeUnits.Point);
- }
- else if (node.Name == "PaddingTop")
- {
- paddingTop = UnitsConverter.SizeToInt(node.InnerText, SizeUnits.Point);
- }
- else if (node.Name == "PaddingBottom")
- {
- paddingBottom = UnitsConverter.SizeToInt(node.InnerText, SizeUnits.Point);
- }
- }
- if (component is TextObject)
- {
- (component as TextObject).Font = new Font(fontFamily, fontSize, fontStyle);
- (component as TextObject).Padding = new Padding(paddingLeft, paddingTop, paddingRight, paddingBottom);
- }
- else if (component is PictureObject)
- {
- (component as PictureObject).Padding = new Padding(paddingLeft, paddingTop, paddingRight, paddingBottom);
- }
- #if !FRCORE
- else if (component is MSChartObject)
- {
- (component as MSChartObject).Chart.Padding = new Padding(paddingLeft, paddingTop, paddingRight, paddingBottom);
- }
- #endif
- }
- private void LoadThreeDProperties(XmlNode threeDPropertiesNode)
- {
- XmlNodeList nodeList = threeDPropertiesNode.ChildNodes;
- foreach (XmlNode node in nodeList)
- {
- if (node.Name == "Enabled")
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.Enable3D = UnitsConverter.BooleanToBool(node.InnerText);
- }
- else if (node.Name == "Rotation")
- {
- int rotation = Convert.ToInt32(node.InnerText);
- if (rotation >= -180 && rotation <= 180)
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.Rotation = rotation;
- }
- else
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.Rotation = 30;
- }
- }
- else if (node.Name == "Inclination")
- {
- int inclination = Convert.ToInt32(node.InnerText);
- if (inclination >= -90 && inclination <= 90)
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.Inclination = inclination;
- }
- else
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.Inclination = 30;
- }
- }
- else if (node.Name == "Perspective")
- {
- int perspective = Convert.ToInt32(node.InnerText);
- if (perspective >= 0 && perspective <= 60)
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.Perspective = perspective;
- }
- else
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.Perspective = 0;
- }
- }
- else if (node.Name == "DepthRatio")
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.PointDepth = Convert.ToInt32(node.InnerText);
- }
- else if (node.Name == "Shading")
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.LightStyle = UnitsConverter.ConvertShading(node.InnerText);
- }
- else if (node.Name == "GapDepth")
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.PointGapDepth = Convert.ToInt32(node.InnerText);
- }
- else if (node.Name == "WallThickness")
- {
- int width = Convert.ToInt32(node.InnerText);
- if (width < 0)
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.WallWidth = 0;
- }
- else if (width > 30)
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.WallWidth = 30;
- }
- else
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.WallWidth = width;
- }
- }
- else if (node.Name == "Clustered")
- {
- (component as MSChartObject).Chart.ChartAreas[0].Area3DStyle.IsClustered = UnitsConverter.BooleanToBool(node.InnerText);
- }
- }
- }
- #endregion // Private Methods
- }
- }
|