Exemple #1
0
		static bool InsertBildFrame(DrawingContext BoardContext, BitmapSource finalPageBitmapSource, Rect partElementRect,
				MMElementLayout elementToDraw, bool DrawInEitherCase = false)
			{
			String Alignment = elementToDraw.Alignment;
			String PictureNameID = elementToDraw.LayoutChildConnector.MMElement.NameId;
			double DrawingAspectRatio = partElementRect.Width/partElementRect.Height;
			if (elementToDraw.LayoutChildConnector.MMElement.ValueAsBitmapSource == null)
				return false;
            double BitmapAspectRatio = (double)elementToDraw.LayoutChildConnector.MMElement.ValueAsBitmapSource.PixelWidth
				/(double)elementToDraw.LayoutChildConnector.MMElement.ValueAsBitmapSource.PixelHeight;
			if (DrawingAspectRatio > BitmapAspectRatio)
				{
				partElementRect.Width = partElementRect.Height*BitmapAspectRatio;
				}
			else
				{
				partElementRect.Height = partElementRect.Width/ BitmapAspectRatio;
				}
			Rect DrawingRect = new Rect(partElementRect.X, partElementRect.Y, partElementRect.Width, partElementRect.Height);
			if (elementToDraw.Alignment == "Left")
				{
				}
			if (elementToDraw.Alignment == "Center")
				{
				if (finalPageBitmapSource.PixelWidth < partElementRect.Width)
					DrawingRect.X = partElementRect.X + (partElementRect.Width - finalPageBitmapSource.PixelWidth) / 2;
				if (finalPageBitmapSource.PixelHeight < partElementRect.Height)
					DrawingRect.Y = partElementRect.Y + (partElementRect.Height - finalPageBitmapSource.PixelHeight) / 2;
				}
			if (elementToDraw.Alignment == "Right")
				{
				if (finalPageBitmapSource.PixelWidth < partElementRect.Width)
					DrawingRect.X = partElementRect.X + (partElementRect.Width - finalPageBitmapSource.PixelWidth);
				if (finalPageBitmapSource.PixelHeight < partElementRect.Height)
					DrawingRect.Y = partElementRect.Y + (partElementRect.Height - finalPageBitmapSource.PixelHeight);
				}

			if ((elementToDraw.Rotation == null)
				|| (elementToDraw.Rotation == 0))
				{
				BoardContext.DrawImage(elementToDraw.LayoutChildConnector.MMElement.ValueAsBitmapSource, DrawingRect);
				return true;
				}
			System.Windows.Media.RotateTransform TransformParameterRotate
				= new System.Windows.Media.RotateTransform((double)elementToDraw.Rotation);
			BoardContext.PushTransform(TransformParameterRotate);
			BoardContext.DrawImage(elementToDraw.LayoutChildConnector.MMElement.ValueAsBitmapSource, DrawingRect);
			BoardContext.Pop();
			return true;
			}
Exemple #2
0
		private static String GetMacroExpansion(MMElementLayout elementToDraw, String Macro)
			{
			if (Macro == "DisplayableTableName")
				{
				if (elementToDraw.LayoutChildConnector.MMElement == null)
					return elementToDraw.LayoutChildConnector.TextToProcess;
                Guid TableId = (Guid) elementToDraw.LayoutChildConnector
							.MMElement.ForeignElementTypId.Value;
                return elementToDraw.DataContext.WPMediaAddOnData
							.TableDefinitions.Find(TableId).DisplayableTableName;
				}
			return "Fehler in Macro Expansion";
			}
Exemple #3
0
		public static bool InsertTextFrame(DrawingContext BoardContext, BitmapSource finalPageBitmapSource,
				Rect partElementRect, MMElementLayout elementToDraw, bool DrawInEitherCase = false)
			{
			FormattedText TextToDisplay = FormatText(elementToDraw.LayoutChildConnector.TextToProcess,
				elementToDraw, partElementRect);
			if ((DrawInEitherCase == true)
				 && (TextToDisplay == null))
				TextToDisplay = FormatText("TestText", elementToDraw, partElementRect);
			if (TextToDisplay == null)
				return false;
			if (!String.IsNullOrEmpty(elementToDraw.BackGround))
					{
					BrushConverter m_BRConverter = new BrushConverter();
					Brush BackGroundBrush = (Brush)m_BRConverter.ConvertFromString(elementToDraw.BackGround);
					BoardContext.DrawRectangle(BackGroundBrush, null, partElementRect);
					}
			if ((elementToDraw.Rotation == null)
				|| (elementToDraw.Rotation == 0))
				{
				BoardContext.DrawText(TextToDisplay, partElementRect.Location);
				return true;
				}
			System.Windows.Media.RotateTransform TransformParameterRotate
				= new System.Windows.Media.RotateTransform((double)elementToDraw.Rotation);
			BoardContext.PushTransform(TransformParameterRotate);
			BoardContext.DrawText(TextToDisplay, partElementRect.Location);
			BoardContext.Pop();
			return true;
			}
Exemple #4
0
		private static FormattedText FormatText(String Input, MMElementLayout elementToDraw, Rect DrawingRect)
			{
			BrushConverter m_BRConverter = new BrushConverter();
			String ConvertContent = String.Empty;
			if (!Convert.IsDBNull(elementToDraw.ConvertContent))
				ConvertContent = elementToDraw.ConvertContent;
			String ConverterParameter = String.Empty;
			if (!Convert.IsDBNull(elementToDraw.ConverterParameter))
				ConverterParameter = elementToDraw.ConverterParameter;

			if (ConvertContent == "ToUpper")
				Input = Input.ToUpper();
			if (ConvertContent == "Macro")
				{
				Input = GetMacroExpansion(elementToDraw, ConverterParameter);
				}
			if (ConvertContent == "FormattedDate")
				{
				try
					{
					DateTime WorkingDate = DateTime.Parse(Input);
					if (String.IsNullOrEmpty(ConverterParameter))
						Input = WorkingDate.ToString();
					else
						Input = WorkingDate.ToString(ConverterParameter);
					}
				catch (Exception)
					{
					}
				}
			Size FinalTargetSize =
				new Size((double) elementToDraw.LayoutChildConnector.MMPart
							.MMUnit.MMUnitTyp.TargetPictureWidth,
					(double) elementToDraw.LayoutChildConnector.MMPart
							.MMUnit.MMUnitTyp.TargetPictureHeight);
			double emSize = (FinalTargetSize.Height * 10) / 100;
			if ((elementToDraw.FontSize != double.NaN)
				&& (elementToDraw.FontSize > 0))
				emSize = (FinalTargetSize.Height * (double) elementToDraw.FontSize) / 100;
			String FontFamily = "Verdana";
			if (!String.IsNullOrEmpty(elementToDraw.FontDescription))
				FontFamily = elementToDraw.FontDescription;

			String FontStyle = "Normal";
			if (!String.IsNullOrEmpty(elementToDraw.FontStyle))
				FontStyle = elementToDraw.FontStyle;
			Typeface DefaultTypeface = new Typeface(new FontFamily(FontFamily), FontStyles.Normal,
				 FontWeights.Normal, FontStretches.Normal, new FontFamily(("Arial")));
			if (FontStyle == "Bold")
				DefaultTypeface = new Typeface(new FontFamily(FontFamily), FontStyles.Normal,
				 FontWeights.Bold, FontStretches.Normal, new FontFamily(("Arial")));

			Brush TextBrush = (Brush)m_BRConverter.ConvertFromString("black");
			if (!String.IsNullOrEmpty(elementToDraw.FontColor))
				TextBrush = (Brush)m_BRConverter.ConvertFromString(elementToDraw.FontColor);
			FormattedText FinalTextBlock = null;
			String Alignment = "Left";
			if (!String.IsNullOrEmpty(elementToDraw.Alignment))
				Alignment = elementToDraw.Alignment;
			do
				{
				if (Alignment == "Left")
					{
					FinalTextBlock = new FormattedText(Input, CultureInfo.CurrentCulture,
														FlowDirection.LeftToRight, DefaultTypeface, emSize, TextBrush);
					}
				if (Alignment == "Right")
					{
					FinalTextBlock = new FormattedText(Input, CultureInfo.CurrentCulture,
														FlowDirection.RightToLeft, DefaultTypeface, emSize, TextBrush);
					}
				if (Alignment == "Center")
					{
					FinalTextBlock = new FormattedText(Input, CultureInfo.CurrentCulture,
						FlowDirection.LeftToRight, DefaultTypeface, emSize, TextBrush);
					FinalTextBlock.TextAlignment = TextAlignment.Center;
					}
				FinalTextBlock.MaxTextWidth = DrawingRect.Width;
				emSize /= 1.05;
				} while (FinalTextBlock.Height > DrawingRect.Height);

			return FinalTextBlock;
			}
Exemple #5
0
		private static Rect CreateDrawingRectFromElementLayout(Rect fullPageDrawingRect,
			MMElementLayout elementLayout)
			{
			Rect FramingRect = elementLayout.GetFramingRect(fullPageDrawingRect);
			if (FramingRect.Height < 2)
				{
				throw new Exception("GraphicsHandling.CreateDrawingRectFromFrame\r\n" +
					"Fehlerhafte Height - Frame Definition bei FrameID\r\n\"" + elementLayout["ID"].ToString() + "\"\r\n"
					+ "auf den Wert \"2\" korrigiert");
				FramingRect.Height = 2;
				}
			if (FramingRect.Width < 2)
				{
				throw new Exception("GraphicsHandling.CreateDrawingRectFromFrame\r\n" +
					"Fehlerhafte Width - Frame Definition bei FrameID\r\n\"" + elementLayout["ID"].ToString() + "\"\r\n"
					+ "auf den Wert \"2\" korrigiert");
				FramingRect.Width = 2;
				}
			return FramingRect;

			}