private void InitReporter(DataBase data)
		{
			var reporter = new ReporterCreator(data, _reportKind);
			_document = reporter.Document;
			FlowDocument.Document = _document;
			GC.Collect();
		}
Ejemplo n.º 2
0
		public ReporterCreator(DataBase data, ReportKind reportKind)
		{
			_reportKind = reportKind;
			Document = new FlowDocument { ColumnWidth = 15000 };
			var mainTable = new Table
			{
				FontFamily = new FontFamily("Arial")
			};
			BaseRows(data, ref mainTable);
			Document.Blocks.Add(mainTable);
		}
Ejemplo n.º 3
0
		//Warning - shit!
		private void BaseRows(DataBase data, ref Table table)
		{
			table.CellSpacing = 0;
			var rowGroup = new TableRowGroup();
			table.RowGroups.Add(rowGroup);
			//draw header
			//input or output
			var kindOfData = new TableRow { Foreground = Brushes.Gray, FontWeight = FontWeights.Bold, Background = Brushes.LightBlue };
			if (data is OutputData)
				kindOfData.Cells.Add(new TableCell(new Paragraph(new Run("Вихідні дані")) { Margin = new Thickness(10), TextAlignment = TextAlignment.Center }) { ColumnSpan = 6 });
			else
				kindOfData.Cells.Add(new TableCell(new Paragraph(new Run("Вхідні дані")) { Margin = new Thickness(10), TextAlignment = TextAlignment.Center }) { ColumnSpan = 4 });
			var titleRow = new TableRow { Background = Brushes.LightBlue };
			titleRow.Cells.Add(new TableCell(new Paragraph(new Run("Дані") { FontWeight = FontWeights.Bold, Foreground = Brushes.Gray }) { Margin = new Thickness(10) }) { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1, 0, 1, 0), ColumnSpan = 2 });
			titleRow.Cells.Add(new TableCell(new Paragraph(new Run("Умовне позначення") { FontWeight = FontWeights.Bold, Foreground = Brushes.Gray }) { Margin = new Thickness(10) }) { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(0, 0, 1, 0) });
			titleRow.Cells.Add(new TableCell(new Paragraph(new Run("Значення") { FontWeight = FontWeights.Bold, Foreground = Brushes.Gray }) { Margin = new Thickness(10) }) { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(0, 0, 1, 0) });
			rowGroup.Rows.Add(kindOfData);
			rowGroup.Rows.Add(titleRow);
			if (data is OutputData)
			{
				titleRow.Cells.Add(new TableCell(new Paragraph(new Run("Діапазон значення") { FontWeight = FontWeights.Bold, Foreground = Brushes.Gray }) { Margin = new Thickness(10) }) { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(0, 0, 1, 0) });
				titleRow.Cells.Add(new TableCell(new Paragraph(new Run("Формула") { FontWeight = FontWeights.Bold, Foreground = Brushes.Gray }) { Margin = new Thickness(10) }) { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(0, 0, 1, 0) });
			}

			var i = 0;
			var previousIndex = -1;
			var metaData = data.Data.ToArray();
			//is input data table for dynamic report shown?
			var isSubTableShown = false;
			//draw data
			while (i < data.Data.Count)
			{
				if (metaData[i].Value.Report == _reportKind)
				{
					//draw groups, previousIndex == -1 - for first group
					if (data is OutputData && (previousIndex == -1 || metaData[previousIndex].Value.Group < metaData[i].Value.Group))
					{
						var dataGroupRow = new TableRow();
						rowGroup.Rows.Add(dataGroupRow);
						dataGroupRow.Cells.Add(
							new TableCell(new Paragraph(new Run(OutputDataGroups.Groups[metaData[i].Value.Group]) { Foreground = Brushes.White, FontWeight = FontWeights.Bold }) { Margin = new Thickness(10), TextAlignment = TextAlignment.Center })
							{
								Background = new LinearGradientBrush(Colors.DarkGray, Colors.Gray, new Point(0, 0), new Point(0, 1)),
								ColumnSpan = 6
							});
						//draw input data table for dynamic report
						if (!isSubTableShown && _reportKind == ReportKind.Dynamic)
						{
							DynamicInputDataRows(ref table, data as OutputData);
							isSubTableShown = true;
						}
						//draw dynamic specific ordinates inertial forces
						if (_reportKind == ReportKind.Dynamic &&
							metaData[i].Value.Group == 11 && metaData[previousIndex].Value.Group == 9)
						{
							DynamicSpecificOrdinatesInertialForces(ref table, data as OutputData);
							DynamicOrdinatesSpecificSummaryForces(ref table, data as OutputData);
							DynamicResultTable(ref table, data as OutputData);
						}
					}
					//if metaData[i] is table data (as like for dynamic specific ordinates inertial forces)
					if (data is InputData || metaData[i].Value.Group != -1)
					{
						var dataRow = new TableRow();
						rowGroup.Rows.Add(dataRow);
						//change every second row bg 
						if (i % 2 == 0)
							dataRow.Background = Brushes.AliceBlue;
						//draw title
						dataRow.Cells.Add(
							new TableCell(new Paragraph(new Run(metaData[i].Value.Title))
							{
								Margin = new Thickness(10, 5, 0, 5),
								TextAlignment = TextAlignment.Left
							}) { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(1, 0, 1, 0), ColumnSpan = 2 });
						//draw symbol
						var symbolParagraph = new Paragraph { Margin = new Thickness(10, 5, 0, 5), TextAlignment = TextAlignment.Center };
						if (metaData[i].Value.Symbol != null)
						{

							symbolParagraph.Inlines.Add(new Run(metaData[i].Value.Symbol.MainSymbol));
							symbolParagraph.Inlines.Add(new Run(metaData[i].Value.Symbol.SubSymbol) { FontSize = 10 });

						}
						dataRow.Cells.Add(new TableCell(symbolParagraph)
						{
							BorderBrush = Brushes.Gray,
							BorderThickness = new Thickness(0, 0, 1, 0)
						});
						if (data is OutputData)
						{
							//brush for value, can be black as default, 
							//red - if value out of range
							//green - if value in range
							var brush = Brushes.Black;
							if (metaData[i].Value.ValRange.HasValue)
							{
								if (metaData[i].Value.Val >= metaData[i].Value.ValRange.Value.From &&
									metaData[i].Value.Val <= metaData[i].Value.ValRange.Value.To)
									brush = Brushes.Green;
								else
									brush = Brushes.Red;
							}
							//draw value
							dataRow.Cells.Add(
								new TableCell(
									new Paragraph(new Run(Math.Round(metaData[i].Value.Val, 3).ToString(CultureInfo.InstalledUICulture)))
									{
										Margin = new Thickness(10, 5, 0, 5),
										Foreground = brush,
										TextAlignment = TextAlignment.Center
									})
								{
									BorderBrush = Brushes.Gray,
									BorderThickness = new Thickness(0, 0, 1, 0)
								});
							//draw value range
							dataRow.Cells.Add(
								new TableCell(new Paragraph(new Run(metaData[i].Value.ValRange.ToString()))
								{
									Margin = new Thickness(10, 5, 0, 5)
								})
								{
									BorderBrush = Brushes.Gray,
									BorderThickness = new Thickness(0, 0, 1, 0),
									TextAlignment = TextAlignment.Center
								});
							//draw furmula image
							dataRow.Cells.Add(
								new TableCell(new BlockUIContainer(new Image { Source = metaData[i].Value.Formula, MaxWidth = 100 }))
								{
									BorderBrush = Brushes.Gray,
									BorderThickness = new Thickness(0, 0, 1, 0),
									TextAlignment = TextAlignment.Center
								});
						}
						else
						{
							//draw value for input data
							dataRow.Cells.Add(
								new TableCell(
									new Paragraph(new Run(Math.Round(metaData[i].Value.Val, 3).ToString(CultureInfo.InstalledUICulture)))
									{
										Margin = new Thickness(10, 5, 0, 5)
									}) { BorderBrush = Brushes.Gray, BorderThickness = new Thickness(0, 0, 1, 0) });
						}
					}
				}
				previousIndex++;
				i++;
			}
		}