/// <summary> /// Creates a new instance of the <see cref="PageContainer"/> class. /// </summary> /// <param name="factory">The project factory.</param> /// <param name="project">The new container owner project.</param> /// <param name="name">The new container name.</param> /// <returns>The new instance of the <see cref="PageContainer"/>.</returns> private PageContainer CreateGridTemplate(IProjectFactory factory, ProjectContainer project, string name) { var template = factory.GetTemplate(project, name); var style = project .StyleLibraries.FirstOrDefault(g => g.Name == "Template") .Items.FirstOrDefault(s => s.Name == "Grid"); var layer = template.Layers.FirstOrDefault(); var builder = layer.Shapes.ToBuilder(); var grid = RectangleShape.Create( 0, 0, template.Width, template.Height, style, project.Options.PointShape); grid.IsStroked = true; grid.IsFilled = false; grid.IsGrid = true; grid.OffsetX = 30.0; grid.OffsetY = 30.0; grid.CellWidth = 30.0; grid.CellHeight = 30.0; grid.State.Flags &= ~ShapeStateFlags.Printable; builder.Add(grid); layer.Shapes = builder.ToImmutable(); return(template); }
/// <summary> /// Transfer selection state to BottomRight. /// </summary> public void ToStateBottomRight() { _helperRectangle = RectangleShape.Create(0, 0, _style, null); _topLeftHelperPoint = PointShape.Create(0, 0, _point); _bottomRightHelperPoint = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperRectangle); _layer.Shapes = _layer.Shapes.Add(_topLeftHelperPoint); _layer.Shapes = _layer.Shapes.Add(_bottomRightHelperPoint); }
/// <inheritdoc/> RectangleShape IShapeFactory.Rectangle(PointShape topLeft, PointShape bottomRight, bool isStroked, bool isFilled, string text) { var style = _editor.Project.CurrentStyleLibrary.Selected; var rectangle = RectangleShape.Create( topLeft, bottomRight, _editor.Project.Options.CloneStyle ? style.Clone() : style, _editor.Project.Options.PointShape, isStroked, isFilled, text); _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, rectangle); return(rectangle); }
/// <inheritdoc/> RectangleShape IShapeFactory.Rectangle(double x1, double y1, double x2, double y2, bool isStroked, bool isFilled, string text) { var style = _editor.Project.CurrentStyleLibrary.Selected; var rectangle = RectangleShape.Create( x1, y1, x2, y2, _editor.Project.Options.CloneStyle ? style.Clone() : style, _editor.Project.Options.PointShape, isStroked, isFilled, text); _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, rectangle); return(rectangle); }
/// <summary> /// Initializes static designer context. /// </summary> /// <param name="serviceProvider">The service provider.</param> public static void InitializeContext(IServiceProvider serviceProvider) { // Editor Editor = serviceProvider.GetService <ProjectEditor>(); // Recent Projects Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project")); Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project")); // New Project Editor.OnNewProject(); // Transform Transform = MatrixObject.Identity; // Data var db = Database.Create("Db"); var fields = new string[] { "Column0", "Column1" }; var columns = ImmutableArray.CreateRange(fields.Select(c => Column.Create(db, c))); db.Columns = columns; var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => Value.Create(c)); var record = Record.Create( db, ImmutableArray.CreateRange(values)); db.Records = db.Records.Add(record); db.CurrentRecord = record; Database = db; Data = Context.Create(record); Record = record; // Project IProjectFactory factory = new ProjectFactory(); Project = factory.GetProject(); Template = PageContainer.CreateTemplate(); Page = PageContainer.CreatePage(); var layer = Page.Layers.FirstOrDefault(); layer.Shapes = layer.Shapes.Add(LineShape.Create(0, 0, null, null)); Page.CurrentLayer = layer; Page.CurrentShape = layer.Shapes.FirstOrDefault(); Page.Template = Template; Document = DocumentContainer.Create(); Layer = LayerContainer.Create(); Options = Options.Create(); // State State = ShapeState.Create(); // Style ArgbColor = ArgbColor.Create(128, 255, 0, 0); ArrowStyle = ArrowStyle.Create(); FontStyle = FontStyle.Create(); LineFixedLength = LineFixedLength.Create(); LineStyle = LineStyle.Create(); Style = ShapeStyle.Create("Default"); TextStyle = TextStyle.Create(); // Shapes Arc = ArcShape.Create(0, 0, Style, null); CubicBezier = CubicBezierShape.Create(0, 0, Style, null); Ellipse = EllipseShape.Create(0, 0, Style, null); Group = GroupShape.Create(Constants.DefaulGroupName); Image = ImageShape.Create(0, 0, Style, null, "key"); Line = LineShape.Create(0, 0, Style, null); Path = PathShape.Create(Style, null); Point = PointShape.Create(); QuadraticBezier = QuadraticBezierShape.Create(0, 0, Style, null); Rectangle = RectangleShape.Create(0, 0, Style, null); Text = TextShape.Create(0, 0, Style, null, "Text"); // Path ArcSegment = ArcSegment.Create(PointShape.Create(), PathSize.Create(), 180, true, SweepDirection.Clockwise, true, true); CubicBezierSegment = CubicBezierSegment.Create(PointShape.Create(), PointShape.Create(), PointShape.Create(), true, true); LineSegment = LineSegment.Create(PointShape.Create(), true, true); PathFigure = PathFigure.Create(PointShape.Create(), false, true); PathGeometry = PathGeometry.Create(ImmutableArray.Create <PathFigure>(), FillRule.EvenOdd); PathSize = PathSize.Create(); PolyCubicBezierSegment = PolyCubicBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyLineSegment = PolyLineSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyQuadraticBezierSegment = PolyQuadraticBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); QuadraticBezierSegment = QuadraticBezierSegment.Create(PointShape.Create(), PointShape.Create(), true, true); }