Exemple #1
0
		public override void Visit(ExportText exportColumn){
			/*			
			var textBlock = FixedDocumentCreator.CreateTextBlock((ExportText)exportColumn,ShouldSetBackcolor(exportColumn));
			CanvasHelper.SetPosition(textBlock,new Point(exportColumn.Location.X,exportColumn.Location.Y));
			UIElement = textBlock;
			*/
			
			var ft = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn);
			var visual = new DrawingVisual();
			var location = new Point(exportColumn.Location.X,exportColumn.Location.Y);
			using (var dc = visual.RenderOpen()){
				if (ShouldSetBackcolor(exportColumn)) {
					dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor),
						null,
						new Rect(location,new Size(exportColumn.Size.Width,exportColumn.Size.Height)));
				}
				dc.DrawText(ft,location);
			}
			var dragingElement = new DrawingElement(visual);
			UIElement = dragingElement;
			
		}
Exemple #2
0
		public override void Visit(ExportRectangle exportRectangle)
		{
			var pen = FixedDocumentCreator.CreateWpfPen(exportRectangle);
			
			var visual = new DrawingVisual();
			using (var dc = visual.RenderOpen()){
				dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportRectangle.BackColor),
				                 pen,
				                 new Rect(exportRectangle.Location.X,exportRectangle.Location.Y,
				                          exportRectangle.Size.Width,exportRectangle.Size.Height));
			}
			var dragingElement = new DrawingElement(visual);
			UIElement = dragingElement;
		}
Exemple #3
0
		public override void Visit(ExportCircle exportCircle)
		{
			var pen = FixedDocumentCreator.CreateWpfPen(exportCircle);
			var rad = CalcRad(exportCircle.Size);
			
			var visual = new DrawingVisual();
			using (var dc = visual.RenderOpen()){
				
				dc.DrawEllipse(FixedDocumentCreator.ConvertBrush(exportCircle.BackColor),
				                 pen,
				                 new Point(exportCircle.Location.X + rad.X,
				                           exportCircle.Location.Y + rad.Y),
				                 rad.X,
				                 rad.Y);
				                           
				                 
			}
			var dragingElement = new DrawingElement(visual);
			UIElement = dragingElement;
		}
Exemple #4
0
		public override void Visit(ExportLine exportGraphics)
		{
			var pen = FixedDocumentCreator.CreateWpfPen(exportGraphics);
			var visual = new DrawingVisual();
			using (var dc = visual.RenderOpen()){
				dc.DrawLine(pen,
				            new Point(exportGraphics.Location.X, exportGraphics.Location.Y),
				            new Point(exportGraphics.Location.X + exportGraphics.Size.Width,exportGraphics.Location.Y));
			}
			var dragingElement = new DrawingElement(visual);
			UIElement = dragingElement;
		}
Exemple #5
0
		public override void Visit(ExportImage exportImage)
		{
			var visual = new DrawingVisual();
			using (var dc = visual.RenderOpen()){
				var iss = ToBitmapSource(exportImage.Image);
				dc.DrawImage(iss,new Rect(exportImage.Location.ToWpf(),
				                          new Size(exportImage.Size.Width,exportImage.Size.Height)));
			}
			var drawingElement = new DrawingElement(visual);
			UIElement = drawingElement;
		}
Exemple #6
0
//	http://stackoverflow.com/questions/25308612/vertical-alignment-with-drawingcontext-drawtext	
		
		public override void Visit(ExportText exportColumn){
			
			var formattedText = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn);

			var location = new Point(exportColumn.Location.X,exportColumn.Location.Y);
			
			var visual = new DrawingVisual();
			using (var drawingContext = visual.RenderOpen()){
				var bachgroundRect = new Rect(location,new Size(exportColumn.DesiredSize.Width,formattedText.MaxTextHeight));
				if (ShouldSetBackcolor(exportColumn)) {
					drawingContext.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor),  null,bachgroundRect);	                             
				}
				
				drawingContext.DrawText(formattedText,location);
				
				if (HasFrame(exportColumn)) {
					var frameRect = new Rect(location,new Size(exportColumn.DesiredSize.Width,formattedText.Height));
					var pen = FixedDocumentCreator.CreateWpfPen(exportColumn);
					pen.Thickness = 1;
					drawingContext.DrawRectangle(null, pen,
					                             frameRect);
				}
			}
			
			var drawingElement = new DrawingElement(visual);
			UIElement = drawingElement;
		}
Exemple #7
0
		public override void Visit(ExportText exportColumn){
		
			var formattedText = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn);
			var visual = new DrawingVisual();
			
			var location = new Point(exportColumn.Location.X,exportColumn.Location.Y);
			
			using (var dc = visual.RenderOpen()){
				if (ShouldSetBackcolor(exportColumn)) {
					dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor),
						null,
						new Rect(location,new Size(exportColumn.Size.Width,exportColumn.Size.Height)));
				}
				
//			http://stackoverflow.com/questions/9264398/how-to-calculate-wpf-textblock-width-for-its-known-font-size-and-characters	
				
//				if (exportColumn.ContentAlignment == System.Drawing.ContentAlignment.MiddleCenter) {
//					location = new Point(location.X + (exportColumn.Size.Width - formattedText.Width) /2,location.Y + (exportColumn.Size.Height - formattedText.Height) / 2);
//				}
				var offset = FixedDocumentCreator.CalculateAlignmentOffset(formattedText,exportColumn);
				var newLoc = new Point(location.X + offset.X,location.Y + offset.Y);
//				dc.DrawText(formattedText,location);
				dc.DrawText(formattedText,newLoc);
			}
			var dragingElement = new DrawingElement(visual);
			UIElement = dragingElement;
		}
Exemple #8
0
		public override void Visit(ExportText exportColumn){
		
			var formattedText = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn);

			var location = new Point(exportColumn.Location.X,exportColumn.Location.Y);
			
			var visual = new DrawingVisual();
			using (var drawingContext = visual.RenderOpen()){
				if (ShouldSetBackcolor(exportColumn)) {
					var r = new Rect(location,new Size(exportColumn.Size.Width,exportColumn.Size.Height));
					drawingContext.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor),
						null,
						new Rect(location,new Size(exportColumn.Size.Width,exportColumn.Size.Height)));
				}
				drawingContext.DrawText(formattedText,location);
			}
			var dragingElement = new DrawingElement(visual);
			UIElement = dragingElement;
		}