private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { this.canvas.MouseMove -= this.Canvas_MouseMove; e.Handled = true; RadFixedPage page = this.context.Page; FixedContentEditor editor = new FixedContentEditor(page); editor.GraphicProperties.IsFilled = false; editor.GraphicProperties.StrokeColor = new RgbColor(255, 0, 0); editor.DrawPath(this.pathGeometry); RadPdfViewer viewer = this.context.Presenter.Owner as RadPdfViewer; if (viewer != null) { viewer.InvalidatePageUI(page); } }
private static void ExportGeometry(FixedContentEditor editor, FixedContentEditor filledEditor, Geometry geometry, bool isConnection = false) { // We need two editors because there might be filled and not filled figures. #if WPF var pathGeometry = geometry as PathGeometry; #else var pathGeometry = GeometryParser.GetGeometry(geometry.ToString()) as PathGeometry; #endif if (pathGeometry != null) { var path = new G.PathGeometry(); var filledPath = new G.PathGeometry(); for (int i = 0; i < pathGeometry.Figures.Count; i++) { var figure = pathGeometry.Figures[i]; var newFigure = new G.PathFigure(); newFigure.StartPoint = figure.StartPoint; newFigure.IsClosed = figure.IsClosed; foreach (var segment in figure.Segments) { var arc = segment as ArcSegment; if (arc != null) { var newS = new G.ArcSegment(); newS.Point = arc.Point; newS.RadiusX = arc.Size.Width; newS.RadiusY = arc.Size.Height; newS.RotationAngle = arc.RotationAngle; // why new enum ? if (arc.SweepDirection == SweepDirection.Clockwise) { newS.SweepDirection = G.SweepDirection.Clockwise; } else { newS.SweepDirection = G.SweepDirection.Counterclockwise; } newS.IsLargeArc = arc.IsLargeArc; newFigure.Segments.Add(newS); continue; } var bezier = segment as BezierSegment; if (bezier != null) { var newS = new G.BezierSegment(); newS.Point1 = bezier.Point1; newS.Point2 = bezier.Point2; newS.Point3 = bezier.Point3; newFigure.StartPoint = newFigure.StartPoint; newFigure.Segments.Add(newS); continue; } var polyLine = segment as PolyLineSegment; if (polyLine != null) { foreach (var point in polyLine.Points) { var newS = new G.LineSegment(); newS.Point = point; newFigure.Segments.Add(newS); } continue; } var line = segment as LineSegment; if (line != null) { var newS = new G.LineSegment(); newS.Point = line.Point; newFigure.Segments.Add(newS); continue; } var quadraticBezier = segment as QuadraticBezierSegment; if (quadraticBezier != null) { var newS = new G.QuadraticBezierSegment(); newS.Point1 = quadraticBezier.Point1; newS.Point2 = quadraticBezier.Point2; newFigure.Segments.Add(newS); continue; } } #if SILVERLIGHT if (isConnection) { var realGeometry = geometry as PathGeometry; if (realGeometry != null && realGeometry.Figures.Count > i) { if (realGeometry.Figures[i].IsFilled) { filledPath.Figures.Add(newFigure); } else { path.Figures.Add(newFigure); } continue; } } #endif if (figure.IsFilled) { filledPath.Figures.Add(newFigure); } else { path.Figures.Add(newFigure); } } // why new enum ? if (pathGeometry.FillRule == FillRule.EvenOdd) { path.FillRule = G.FillRule.EvenOdd; filledPath.FillRule = G.FillRule.EvenOdd; } else { path.FillRule = G.FillRule.Nonzero; filledPath.FillRule = G.FillRule.Nonzero; } if (filledPath.Figures.Count > 0) { filledEditor.DrawPath(filledPath); } if (path.Figures.Count > 0) { editor.DrawPath(path); } } }
private void DrawFunnelFigure(FixedContentEditor editor) { editor.GraphicProperties.IsStroked = false; editor.GraphicProperties.FillColor = new RgbColor(231, 238, 247); editor.DrawEllipse(new Point(250, 70), 136, 48); editor.GraphicProperties.IsStroked = true; editor.GraphicProperties.StrokeColor = RgbColors.White; editor.GraphicProperties.StrokeThickness = 1; editor.GraphicProperties.FillColor = new RgbColor(91, 155, 223); editor.DrawEllipse(new Point(289, 77), 48, 48); editor.TextProperties.TrySetFont(new FontFamily("Calibri")); editor.TextProperties.HorizontalAlignment = HorizontalTextAlignment.Center; editor.TextProperties.VerticalAlignment = VerticalTextAlignment.Center; editor.TextProperties.TextBlockWidth = 96; editor.TextProperties.TextBlockHeight = 96; using (editor.SaveGraphicProperties()) { editor.Position.Translate(291, 204); editor.GraphicProperties.FillColor = RgbColors.White; editor.DrawText("Fonts"); } editor.Position.Translate(0, 0); editor.DrawEllipse(new Point(238, 274), 48, 48); using (editor.SaveGraphicProperties()) { editor.Position.Translate(190, 226); editor.GraphicProperties.FillColor = RgbColors.White; editor.DrawText("Images"); } editor.Position.Translate(0, 0); editor.DrawEllipse(new Point(307, 347), 48, 48); using (editor.SaveGraphicProperties()) { editor.Position.Translate(259, 299); editor.GraphicProperties.FillColor = RgbColors.White; editor.DrawText("Shapes"); } editor.Position.Translate(0, 0); PathGeometry arrow = new PathGeometry(); PathFigure figure = arrow.Figures.AddPathFigure(); figure.StartPoint = new Point(287, 422); figure.IsClosed = true; figure.Segments.AddLineSegment(new Point(287, 438)); figure.Segments.AddLineSegment(new Point(278, 438)); figure.Segments.AddLineSegment(new Point(300, 454)); figure.Segments.AddLineSegment(new Point(322, 438)); figure.Segments.AddLineSegment(new Point(313, 438)); figure.Segments.AddLineSegment(new Point(313, 422)); editor.DrawPath(arrow); editor.GraphicProperties.FillColor = new RgbColor(80, 255, 255, 255); editor.GraphicProperties.IsStroked = true; editor.GraphicProperties.StrokeThickness = 1; editor.GraphicProperties.StrokeColor = new RgbColor(91, 155, 223); PathGeometry funnel = new PathGeometry(); funnel.FillRule = FillRule.EvenOdd; figure = funnel.Figures.AddPathFigure(); figure.IsClosed = true; figure.StartPoint = new Point(164, 245); figure.Segments.AddArcSegment(new Point(436, 245), 136, 48); figure.Segments.AddArcSegment(new Point(164, 245), 136, 48); figure = funnel.Figures.AddPathFigure(); figure.IsClosed = true; figure.StartPoint = new Point(151, 245); figure.Segments.AddArcSegment(new Point(449, 245), 149, 61); figure.Segments.AddLineSegment(new Point(332, 415)); figure.Segments.AddArcSegment(new Point(268, 415), 16, 4); editor.DrawPath(funnel); using (editor.SaveGraphicProperties()) { using (editor.SaveTextProperties()) { editor.Position.Translate(164, 455); editor.GraphicProperties.FillColor = RgbColors.Black; editor.TextProperties.HorizontalAlignment = HorizontalTextAlignment.Center; editor.TextProperties.VerticalAlignment = VerticalTextAlignment.Top; editor.TextProperties.TextBlockWidth = 272; editor.TextProperties.FontSize = 18; editor.DrawText("PDF"); } } }
private void DrawFunnelFigure(FixedContentEditor editor) { editor.GraphicProperties.IsStroked = false; editor.GraphicProperties.FillColor = new RgbColor(231, 238, 247); editor.DrawEllipse(new Point(250, 70), 136, 48); editor.GraphicProperties.IsStroked = true; editor.GraphicProperties.StrokeColor = RgbColors.White; editor.GraphicProperties.StrokeThickness = 1; editor.GraphicProperties.FillColor = new RgbColor(91, 155, 223); editor.DrawEllipse(new Point(289, 77), 48, 48); editor.Position.Translate(291, 204); CenterText(editor, "Fonts"); editor.Position.Translate(0, 0); editor.DrawEllipse(new Point(238, 274), 48, 48); editor.Position.Translate(190, 226); CenterText(editor, "Images"); editor.Position.Translate(0, 0); editor.DrawEllipse(new Point(307, 347), 48, 48); editor.Position.Translate(259, 299); CenterText(editor, "Shapes"); editor.Position.Translate(0, 0); PathGeometry arrow = new PathGeometry(); PathFigure figure = arrow.Figures.AddPathFigure(); figure.StartPoint = new Point(287, 422); figure.IsClosed = true; figure.Segments.AddLineSegment(new Point(287, 438)); figure.Segments.AddLineSegment(new Point(278, 438)); figure.Segments.AddLineSegment(new Point(300, 454)); figure.Segments.AddLineSegment(new Point(322, 438)); figure.Segments.AddLineSegment(new Point(313, 438)); figure.Segments.AddLineSegment(new Point(313, 422)); editor.DrawPath(arrow); editor.GraphicProperties.FillColor = new RgbColor(80, 255, 255, 255); editor.GraphicProperties.IsStroked = true; editor.GraphicProperties.StrokeThickness = 1; editor.GraphicProperties.StrokeColor = new RgbColor(91, 155, 223); PathGeometry funnel = new PathGeometry(); funnel.FillRule = FillRule.EvenOdd; figure = funnel.Figures.AddPathFigure(); figure.IsClosed = true; figure.StartPoint = new Point(164, 245); figure.Segments.AddArcSegment(new Point(436, 245), 136, 48); figure.Segments.AddArcSegment(new Point(164, 245), 136, 48); figure = funnel.Figures.AddPathFigure(); figure.IsClosed = true; figure.StartPoint = new Point(151, 245); figure.Segments.AddArcSegment(new Point(449, 245), 149, 61); figure.Segments.AddLineSegment(new Point(332, 415)); figure.Segments.AddArcSegment(new Point(268, 415), 16, 4); editor.DrawPath(funnel); editor.Position.Translate(164, 455); Block block = new Block(); block.TextProperties.Font = editor.TextProperties.Font; block.GraphicProperties.FillColor = RgbColors.Black; block.HorizontalAlignment = HorizontalAlignment.Center; block.VerticalAlignment = VerticalAlignment.Top; block.TextProperties.FontSize = 18; block.InsertText("PDF"); editor.DrawBlock(block, new Size(272, double.PositiveInfinity)); }
private static void ExportGeometry(FixedContentEditor editor, FixedContentEditor filledEditor, Geometry geometry, bool isConnection = false) { // We need two editors because there might be filled and not filled figures. #if WPF var pathGeometry = geometry as PathGeometry; #else var pathGeometry = GeometryParser.GetGeometry(geometry.ToString()) as PathGeometry; #endif if (pathGeometry != null) { var path = new G.PathGeometry(); var filledPath = new G.PathGeometry(); for (int i = 0; i < pathGeometry.Figures.Count; i++) { var figure = pathGeometry.Figures[i]; var newFigure = new G.PathFigure(); newFigure.StartPoint = figure.StartPoint; newFigure.IsClosed = figure.IsClosed; foreach (var segment in figure.Segments) { var arc = segment as ArcSegment; if (arc != null) { var newS = new G.ArcSegment(); newS.Point = arc.Point; newS.RadiusX = arc.Size.Width; newS.RadiusY = arc.Size.Height; newS.RotationAngle = arc.RotationAngle; // why new enum ? if (arc.SweepDirection == SweepDirection.Clockwise) newS.SweepDirection = G.SweepDirection.Clockwise; else newS.SweepDirection = G.SweepDirection.Counterclockwise; newS.IsLargeArc = arc.IsLargeArc; newFigure.Segments.Add(newS); continue; } var bezier = segment as BezierSegment; if (bezier != null) { var newS = new G.BezierSegment(); newS.Point1 = bezier.Point1; newS.Point2 = bezier.Point2; newS.Point3 = bezier.Point3; newFigure.StartPoint = newFigure.StartPoint; newFigure.Segments.Add(newS); continue; } var polyLine = segment as PolyLineSegment; if (polyLine != null) { foreach (var point in polyLine.Points) { var newS = new G.LineSegment(); newS.Point = point; newFigure.Segments.Add(newS); } continue; } var line = segment as LineSegment; if (line != null) { var newS = new G.LineSegment(); newS.Point = line.Point; newFigure.Segments.Add(newS); continue; } var quadraticBezier = segment as QuadraticBezierSegment; if (quadraticBezier != null) { var newS = new G.QuadraticBezierSegment(); newS.Point1 = quadraticBezier.Point1; newS.Point2 = quadraticBezier.Point2; newFigure.Segments.Add(newS); continue; } } #if SILVERLIGHT if (isConnection) { var realGeometry = geometry as PathGeometry; if (realGeometry != null && realGeometry.Figures.Count > i) { if (realGeometry.Figures[i].IsFilled) filledPath.Figures.Add(newFigure); else path.Figures.Add(newFigure); continue; } } #endif if (figure.IsFilled) filledPath.Figures.Add(newFigure); else path.Figures.Add(newFigure); } // why new enum ? if (pathGeometry.FillRule == FillRule.EvenOdd) { path.FillRule = G.FillRule.EvenOdd; filledPath.FillRule = G.FillRule.EvenOdd; } else { path.FillRule = G.FillRule.Nonzero; filledPath.FillRule = G.FillRule.Nonzero; } if (filledPath.Figures.Count > 0) filledEditor.DrawPath(filledPath); if (path.Figures.Count > 0) editor.DrawPath(path); } }
private void DrawFunnelFigure(FixedContentEditor editor) { editor.GraphicProperties.IsStroked = false; editor.GraphicProperties.FillColor = new RgbColor(231, 238, 247); editor.DrawEllipse(new Point(250, 70), 136, 48); editor.GraphicProperties.IsStroked = true; editor.GraphicProperties.StrokeColor = RgbColors.White; editor.GraphicProperties.StrokeThickness = 1; editor.GraphicProperties.FillColor = new RgbColor(91, 155, 223); editor.DrawEllipse(new Point(289, 77), 48, 48); editor.TextProperties.Font = FontsRepository.Helvetica; editor.TextProperties.HorizontalAlignment = HorizontalTextAlignment.Center; editor.TextProperties.VerticalAlignment = VerticalTextAlignment.Center; editor.TextProperties.TextBlockWidth = 96; editor.TextProperties.TextBlockHeight = 96; using (editor.SaveGraphicProperties()) { editor.Position.Translate(291, 229); editor.GraphicProperties.FillColor = RgbColors.White; editor.DrawText("Fonts"); } editor.Position.Translate(0, 0); editor.DrawEllipse(new Point(238, 299), 48, 48); using (editor.SaveGraphicProperties()) { editor.Position.Translate(190, 251); editor.GraphicProperties.FillColor = RgbColors.White; editor.DrawText("Images"); } editor.Position.Translate(0, 0); editor.DrawEllipse(new Point(307, 372), 48, 48); using (editor.SaveGraphicProperties()) { editor.Position.Translate(259, 324); editor.GraphicProperties.FillColor = RgbColors.White; editor.DrawText("Shapes"); } editor.Position.Translate(0, 0); PathGeometry arrow = new PathGeometry(); PathFigure figure = arrow.Figures.AddPathFigure(); figure.StartPoint = new Point(287, 447); figure.IsClosed = true; figure.Segments.AddLineSegment(new Point(287, 463)); figure.Segments.AddLineSegment(new Point(278, 463)); figure.Segments.AddLineSegment(new Point(300, 479)); figure.Segments.AddLineSegment(new Point(322, 463)); figure.Segments.AddLineSegment(new Point(313, 463)); figure.Segments.AddLineSegment(new Point(313, 447)); editor.DrawPath(arrow); editor.GraphicProperties.FillColor = new RgbColor(80, 255, 255, 255); editor.GraphicProperties.IsStroked = true; editor.GraphicProperties.StrokeThickness = 1; editor.GraphicProperties.StrokeColor = new RgbColor(91, 155, 223); PathGeometry funnel = new PathGeometry(); funnel.FillRule = FillRule.EvenOdd; figure = funnel.Figures.AddPathFigure(); figure.IsClosed = true; figure.StartPoint = new Point(164, 270); figure.Segments.AddArcSegment(new Point(436, 270), 136, 48); figure.Segments.AddArcSegment(new Point(164, 270), 136, 48); figure = funnel.Figures.AddPathFigure(); figure.IsClosed = true; figure.StartPoint = new Point(151, 270); figure.Segments.AddArcSegment(new Point(449, 270), 149, 61); figure.Segments.AddLineSegment(new Point(332, 440)); figure.Segments.AddArcSegment(new Point(268, 440), 16, 4); editor.DrawPath(funnel); using (editor.SaveGraphicProperties()) { using (editor.SaveTextProperties()) { editor.Position.Translate(164, 484); editor.GraphicProperties.FillColor = RgbColors.Black; editor.TextProperties.HorizontalAlignment = HorizontalTextAlignment.Center; editor.TextProperties.VerticalAlignment = VerticalTextAlignment.Top; editor.TextProperties.TextBlockWidth = 272; editor.TextProperties.FontSize = 18; editor.DrawText("PDF"); } } }
private void DrawFunnelFigure(FixedContentEditor editor) { editor.GraphicProperties.IsStroked = false; editor.GraphicProperties.FillColor = new RgbColor(231, 238, 247); editor.DrawEllipse(new Point(250, 70), 136, 48); editor.GraphicProperties.IsStroked = true; editor.GraphicProperties.StrokeColor = RgbColors.White; editor.GraphicProperties.StrokeThickness = 1; editor.GraphicProperties.FillColor = new RgbColor(91, 155, 223); editor.DrawEllipse(new Point(289, 77), 48, 48); editor.Position.Translate(291, 204); CenterText(editor, "Fonts"); editor.Position.Translate(0, 0); editor.DrawEllipse(new Point(238, 274), 48, 48); editor.Position.Translate(190, 226); CenterText(editor, "Images"); editor.Position.Translate(0, 0); editor.DrawEllipse(new Point(307, 347), 48, 48); editor.Position.Translate(259, 299); CenterText(editor, "Shapes"); editor.Position.Translate(0, 0); PathGeometry arrow = new PathGeometry(); PathFigure figure = arrow.Figures.AddPathFigure(); figure.StartPoint = new Point(287, 422); figure.IsClosed = true; figure.Segments.AddLineSegment(new Point(287, 438)); figure.Segments.AddLineSegment(new Point(278, 438)); figure.Segments.AddLineSegment(new Point(300, 454)); figure.Segments.AddLineSegment(new Point(322, 438)); figure.Segments.AddLineSegment(new Point(313, 438)); figure.Segments.AddLineSegment(new Point(313, 422)); editor.DrawPath(arrow); editor.GraphicProperties.FillColor = new RgbColor(80, 255, 255, 255); editor.GraphicProperties.IsStroked = true; editor.GraphicProperties.StrokeThickness = 1; editor.GraphicProperties.StrokeColor = new RgbColor(91, 155, 223); PathGeometry funnel = new PathGeometry(); funnel.FillRule = FillRule.EvenOdd; figure = funnel.Figures.AddPathFigure(); figure.IsClosed = true; figure.StartPoint = new Point(164, 245); figure.Segments.AddArcSegment(new Point(436, 245), 136, 48); figure.Segments.AddArcSegment(new Point(164, 245), 136, 48); figure = funnel.Figures.AddPathFigure(); figure.IsClosed = true; figure.StartPoint = new Point(151, 245); figure.Segments.AddArcSegment(new Point(449, 245), 149, 61); figure.Segments.AddLineSegment(new Point(332, 415)); figure.Segments.AddArcSegment(new Point(268, 415), 16, 4); editor.DrawPath(funnel); editor.Position.Translate(164, 455); Block block = new Block(); block.TextProperties.Font = editor.TextProperties.Font; block.GraphicProperties.FillColor = RgbColors.Black; block.HorizontalAlignment = HorizontalAlignment.Center; block.VerticalAlignment = VerticalAlignment.Top; block.TextProperties.FontSize = 18; block.InsertText("PDF"); editor.DrawBlock(block, new Size(272, double.PositiveInfinity)); }