Example #1
0
        public void Flags_On_Set_Notify_Events_Are_Raised()
        {
            var state  = new LineFixedLength();
            var target = new PropertyChangedObserver(state);

            state.Flags =
                LineFixedLengthFlags.Start
                | LineFixedLengthFlags.Vertical
                | LineFixedLengthFlags.Horizontal;

            Assert.Equal(
                LineFixedLengthFlags.Start
                | LineFixedLengthFlags.Vertical
                | LineFixedLengthFlags.Horizontal, state.Flags);
            Assert.Equal(7, target.PropertyNames.Count);

            var propertyNames = new string[]
            {
                nameof(LineFixedLength.Flags),
                nameof(LineFixedLength.Disabled),
                nameof(LineFixedLength.Start),
                nameof(LineFixedLength.End),
                nameof(LineFixedLength.Vertical),
                nameof(LineFixedLength.Horizontal),
                nameof(LineFixedLength.All)
            };

            Assert.Equal(propertyNames, target.PropertyNames);
        }
Example #2
0
        public void ToString_Should_Return_Flags_String()
        {
            var target = LineFixedLength.Create(
                LineFixedLengthFlags.Start
                | LineFixedLengthFlags.Vertical
                | LineFixedLengthFlags.Horizontal);

            Assert.Equal("Start, Vertical, Horizontal", target.ToString());
        }
Example #3
0
        public void Parse_LineFixedLengthFlags_String()
        {
            var target = LineFixedLength.Parse("Start, Vertical, Horizontal");

            Assert.Equal(
                LineFixedLengthFlags.Start
                | LineFixedLengthFlags.Vertical
                | LineFixedLengthFlags.Horizontal, target.Flags);
        }
Example #4
0
        public void Vertical_Property()
        {
            var target = new LineFixedLength();

            target.Vertical = true;
            Assert.Equal(LineFixedLengthFlags.Vertical, target.Flags);

            target.Vertical = false;
            Assert.Equal(LineFixedLengthFlags.Disabled, target.Flags);
        }
Example #5
0
        public void End_Property()
        {
            var target = new LineFixedLength();

            target.End = true;
            Assert.Equal(LineFixedLengthFlags.End, target.Flags);

            target.End = false;
            Assert.Equal(LineFixedLengthFlags.Disabled, target.Flags);
        }
Example #6
0
        /// <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);
        }
Example #7
0
        public void Inherits_From_ObservableObject()
        {
            var target = new LineFixedLength();

            Assert.True(target is ObservableObject);
        }
Example #8
0
        /// <summary>
        /// Initializes static designer context.
        /// </summary>
        /// <param name="renderer">The design time renderer instance.</param>
        /// <param name="clipboard">The design time clipboard instance.</param>
        /// <param name="jsonSerializer">The design time Json serializer instance.</param>
        /// <param name="xamlSerializer">The design time Xaml serializer instance.</param>
        /// <returns>The new instance of the <see cref="DesignerContext"/> class.</returns>
        public static void InitializeContext(ShapeRenderer renderer, ITextClipboard clipboard, ITextSerializer jsonSerializer, ITextSerializer xamlSerializer)
        {
            // Editor

            Editor = new ProjectEditor()
            {
                CurrentTool     = Tool.Selection,
                CurrentPathTool = PathTool.Line,
                CommandManager  = new DesignerCommandManager(),
                Renderers       = new ShapeRenderer[] { renderer },
                ProjectFactory  = new ProjectFactory(),
                TextClipboard   = clipboard,
                JsonSerializer  = jsonSerializer,
                XamlSerializer  = xamlSerializer
            }.Defaults();

            // Recent Projects
            Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project"));
            Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project"));

            // Commands

            Editor.InitializeCommands();
            InitializeCommands(Editor);
            Editor.CommandManager.RegisterCommands();

            // New Project

            Editor.OnNew(null);

            // Data

            var db      = XDatabase.Create("Db");
            var fields  = new string[] { "Column0", "Column1" };
            var columns = ImmutableArray.CreateRange(fields.Select(c => XColumn.Create(db, c)));

            db.Columns = columns;
            var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => XValue.Create(c));
            var record = XRecord.Create(
                db,
                db.Columns,
                ImmutableArray.CreateRange(values));

            db.Records       = db.Records.Add(record);
            db.CurrentRecord = record;

            Database = db;
            Data     = XContext.Create(record);
            Record   = record;

            // Project

            IProjectFactory factory = new ProjectFactory();

            Project = factory.GetProject();

            Template = XContainer.CreateTemplate();

            Page = XContainer.CreatePage();
            var layer = Page.Layers.FirstOrDefault();

            layer.Shapes      = layer.Shapes.Add(XLine.Create(0, 0, null, null));
            Page.CurrentLayer = layer;
            Page.CurrentShape = layer.Shapes.FirstOrDefault();
            Page.Template     = Template;

            Document = XDocument.Create();
            Layer    = XLayer.Create();
            Options  = XOptions.Create();

            // State

            State = ShapeState.Create();

            // Style

            ArgbColor       = ArgbColor.Create();
            ArrowStyle      = ArrowStyle.Create();
            FontStyle       = FontStyle.Create();
            LineFixedLength = LineFixedLength.Create();
            LineStyle       = LineStyle.Create();
            Style           = ShapeStyle.Create("Default");
            TextStyle       = TextStyle.Create();

            // Shapes

            Arc             = XArc.Create(0, 0, Style, null);
            CubicBezier     = XCubicBezier.Create(0, 0, Style, null);
            Ellipse         = XEllipse.Create(0, 0, Style, null);
            Group           = XGroup.Create(Constants.DefaulGroupName);
            Image           = XImage.Create(0, 0, Style, null, "key");
            Line            = XLine.Create(0, 0, Style, null);
            Path            = XPath.Create("Path", Style, null);
            Point           = XPoint.Create();
            QuadraticBezier = XQuadraticBezier.Create(0, 0, Style, null);
            Rectangle       = XRectangle.Create(0, 0, Style, null);
            Text            = XText.Create(0, 0, Style, null, "Text");

            // Path

            ArcSegment                 = XArcSegment.Create(XPoint.Create(), XPathSize.Create(), 180, true, XSweepDirection.Clockwise, true, true);
            CubicBezierSegment         = XCubicBezierSegment.Create(XPoint.Create(), XPoint.Create(), XPoint.Create(), true, true);
            LineSegment                = XLineSegment.Create(XPoint.Create(), true, true);
            PathFigure                 = XPathFigure.Create(XPoint.Create(), false, true);
            PathGeometry               = XPathGeometry.Create(ImmutableArray.Create <XPathFigure>(), XFillRule.EvenOdd);
            PathSize                   = XPathSize.Create();
            PolyCubicBezierSegment     = XPolyCubicBezierSegment.Create(ImmutableArray.Create <XPoint>(), true, true);
            PolyLineSegment            = XPolyLineSegment.Create(ImmutableArray.Create <XPoint>(), true, true);
            PolyQuadraticBezierSegment = XPolyQuadraticBezierSegment.Create(ImmutableArray.Create <XPoint>(), true, true);
            QuadraticBezierSegment     = XQuadraticBezierSegment.Create(XPoint.Create(), XPoint.Create(), true, true);
        }