public void Equals_Same_Name_Return_True() { var x = ShapeStyle.Create("Style1"); var y = ShapeStyle.Create("Style1"); Assert.Equal(x, y, new ShapeStyleByNameComparer()); }
public void Equals_Different_Name_Return_False() { var x = ShapeStyle.Create("Style1"); var y = ShapeStyle.Create("Style2"); Assert.NotEqual(x, y, new ShapeStyleByNameComparer()); }
public void Equals_Second_Object_Null_Return_False() { var y = ShapeStyle.Create(); var c = new ShapeStyleByNameComparer(); Assert.False(c.Equals(y, null)); }
public void Equals_First_Object_Null_Return_False() { var x = ShapeStyle.Create(); var c = new ShapeStyleByNameComparer(); Assert.False(c.Equals(null, x)); }
/// <summary> /// Creates a new instance of the <see cref="XLibrary{ShapeStyle}"/> class. /// </summary> /// <returns>The new instance of the <see cref="XLibrary{ShapeStyle}"/>.</returns> public static XLibrary <ShapeStyle> TemplateStyleLibrary() { var sgt = XLibrary <ShapeStyle> .Create("Template"); var gs = ShapeStyle.Create("Grid", 255, 222, 222, 222, 255, 222, 222, 222, 1.0); var builder = sgt.Items.ToBuilder(); builder.Add(gs); sgt.Items = builder.ToImmutable(); sgt.Selected = sgt.Items.FirstOrDefault(); return(sgt); }
/// <summary> /// Creates a new instance of the <see cref="XLibrary{ShapeStyle}"/> class. /// </summary> /// <returns>The new instance of the <see cref="XLibrary{ShapeStyle}"/>.</returns> public static XLibrary <ShapeStyle> DefaultStyleLibrary() { var sgd = XLibrary <ShapeStyle> .Create("Default"); var builder = sgd.Items.ToBuilder(); builder.Add(ShapeStyle.Create("Black", 255, 0, 0, 0, 80, 0, 0, 0, 2.0)); builder.Add(ShapeStyle.Create("Red", 255, 255, 0, 0, 80, 255, 0, 0, 2.0)); builder.Add(ShapeStyle.Create("Green", 255, 0, 255, 0, 80, 0, 255, 0, 2.0)); builder.Add(ShapeStyle.Create("Blue", 255, 0, 0, 255, 80, 0, 0, 255, 2.0)); builder.Add(ShapeStyle.Create("Cyan", 255, 0, 255, 255, 80, 0, 255, 255, 2.0)); builder.Add(ShapeStyle.Create("Magenta", 255, 255, 0, 255, 80, 255, 0, 255, 2.0)); builder.Add(ShapeStyle.Create("Yellow", 255, 255, 255, 0, 80, 255, 255, 0, 2.0)); sgd.Items = builder.ToImmutable(); sgd.Selected = sgd.Items.FirstOrDefault(); return(sgd); }
/// <summary> /// Creates a new <see cref="XOptions"/> instance. /// </summary> /// <returns>The new instance of the <see cref="XOptions"/> class.</returns> public static XOptions Create() { var options = new XOptions() { SnapToGrid = true, SnapX = 15.0, SnapY = 15.0, HitThreshold = 7.0, MoveMode = XMoveMode.Point, DefaultIsStroked = true, DefaultIsFilled = false, DefaultIsClosed = true, DefaultIsSmoothJoin = true, DefaultFillRule = XFillRule.EvenOdd, TryToConnect = false, CloneStyle = false }; options.SelectionStyle = ShapeStyle.Create( "Selection", 0x7F, 0x33, 0x33, 0xFF, 0x4F, 0x33, 0x33, 0xFF, 1.0); options.HelperStyle = ShapeStyle.Create( "Helper", 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 1.0); options.PointStyle = ShapeStyle.Create( "Point", 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 1.0); options.PointShape = RectanglePointShape(options.PointStyle); return(options); }
/// <summary> /// Creates a new instance of the <see cref="XLibrary{ShapeStyle}"/> class. /// </summary> /// <returns>The new instance of the <see cref="XLibrary{ShapeStyle}"/>.</returns> public static XLibrary <ShapeStyle> LinesStyleLibrary() { var sgdl = XLibrary <ShapeStyle> .Create("Lines"); var solid = ShapeStyle.Create("Solid", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); solid.Dashes = default(string); solid.DashOffset = 0.0; var dash = ShapeStyle.Create("Dash", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); dash.Dashes = "2 2"; dash.DashOffset = 1.0; var dot = ShapeStyle.Create("Dot", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); dot.Dashes = "0 2"; dot.DashOffset = 0.0; var dashDot = ShapeStyle.Create("DashDot", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); dashDot.Dashes = "2 2 0 2"; dashDot.DashOffset = 1.0; var dashDotDot = ShapeStyle.Create("DashDotDot", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); dashDotDot.Dashes = "2 2 0 2 0 2"; dashDotDot.DashOffset = 1.0; var builder = sgdl.Items.ToBuilder(); builder.Add(solid); builder.Add(dash); builder.Add(dot); builder.Add(dashDot); builder.Add(dashDotDot); sgdl.Items = builder.ToImmutable(); sgdl.Selected = sgdl.Items.FirstOrDefault(); return(sgdl); }
public void Equals_Second_Object_Null_Return_False() { var y = ShapeStyle.Create(); Assert.NotEqual(y, null, new ShapeStyleByNameComparer()); }
public void Equals_First_Object_Null_Return_False() { var x = ShapeStyle.Create(); Assert.NotEqual(null, x, new ShapeStyleByNameComparer()); }
public void Equals_Same_Object_Return_True() { var x = ShapeStyle.Create(); Assert.Equal(x, x, new ShapeStyleByNameComparer()); }
/// <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); }
/// <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); }