public ProjectDashboardTicketsListLayout(IShapeFactory shapeFactory, IContentManager contentManager)
 {
     this.contentManager = contentManager;
     Shape            = shapeFactory;
     this.shapeLayout = new ShapeLayout(shapeFactory, contentManager);
     T = NullLocalizer.Instance;
 }
示例#2
0
        public static Action <Context> Render(IShape shape, Size size, UiState uiState, IStyleSheet styleSheet)
        {
            if (styleSheet == null)
            {
                styleSheet = Registry.Pooled <StyleSheets> ().DefaultStyleSheet;
            }

            shape.Size = size;
            var layout  = new ShapeLayout(styleSheet);
            var painter = layout.GetPainter(shape.GetType());

            painter.Style = layout.GetStyle(shape, uiState);
            painter.Shape = shape;
            return(ctx => painter.Render(new ContextSurface {
                Context = ctx
            }));
        }
示例#3
0
        private void TestSimpleAll2(SdbSchemaDatas sdbSchemaDatas)
        {
            ValidationContext validationContext = new ValidationContext();
            OpenXmlElement    errorChild;

            ShapeLayout shapeLayout        = new ShapeLayout();
            var         particleConstraint = sdbSchemaDatas.GetSchemaTypeData(shapeLayout).ParticleConstraint;
            var         target             = particleConstraint.ParticleValidator as AllParticleValidator;

            validationContext.Element = shapeLayout;
            var expected = shapeLayout;

            //<xsd:complexType name="CT_ShapeLayout">
            //  <xsd:all>
            //    <xsd:element name="idmap" type="CT_IdMap" minOccurs="0">
            //    <xsd:element name="regrouptable" type="CT_RegroupTable" minOccurs="0">
            //    <xsd:element name="rules" type="CT_Rules" minOccurs="0">
            //  </xsd:all>
            //  <xsd:attributeGroup ref="v:AG_Ext" />
            //</xsd:complexType>

            // ***** good case ******

            // empty is ok
            target.Validate(validationContext);
            Assert.True(validationContext.Valid);

            // any one is ok
            shapeLayout.AppendChild(new RegroupTable());
            target.Validate(validationContext);
            Assert.True(validationContext.Valid);

            // any order is ok
            shapeLayout.AppendChild(new ShapeIdMap());
            target.Validate(validationContext);
            Assert.True(validationContext.Valid);

            // any order is ok
            shapeLayout.AppendChild(new Rules());
            target.Validate(validationContext);
            Assert.True(validationContext.Valid);

            // ***** error case ******

            // first is invlaid
            errorChild = shapeLayout.PrependChild(new Paragraphs());
            target.Validate(validationContext);
            Assert.False(validationContext.Valid);
            Assert.Single(validationContext.Errors);
            Assert.Same(expected, validationContext.Errors[0].Node);
            Assert.Same(errorChild, validationContext.Errors[0].RelatedNode);
            Assert.Equal(ValidationErrorType.Schema, validationContext.Errors[0].ErrorType);
            Assert.Equal("Sch_InvalidElementContentExpectingComplex", validationContext.Errors[0].Id);
            Assert.Contains(":idmap", validationContext.Errors[0].Description);
            Assert.Contains(":rules", validationContext.Errors[0].Description);
            shapeLayout.RemoveChild(errorChild);

            validationContext.Clear();
            //invalid child in middle
            errorChild = shapeLayout.InsertBefore(new Paragraphs(), shapeLayout.LastChild);
            target.Validate(validationContext);
            Assert.False(validationContext.Valid);
            Assert.Single(validationContext.Errors);
            Assert.Same(expected, validationContext.Errors[0].Node);
            Assert.Same(errorChild, validationContext.Errors[0].RelatedNode);
            Assert.Equal(ValidationErrorType.Schema, validationContext.Errors[0].ErrorType);
            Assert.Equal("Sch_InvalidElementContentExpectingComplex", validationContext.Errors[0].Id);
            Assert.Contains(":rules", validationContext.Errors[0].Description);
            shapeLayout.RemoveChild(errorChild);

            validationContext.Clear();
            // dup
            errorChild = shapeLayout.FirstChild;
            shapeLayout.PrependChild(new RegroupTable());
            target.Validate(validationContext);
            Assert.False(validationContext.Valid);
            Assert.Single(validationContext.Errors);
            Assert.Same(expected, validationContext.Errors[0].Node);
            Assert.Equal(ValidationErrorType.Schema, validationContext.Errors[0].ErrorType);
            Assert.Equal("Sch_AllElement", validationContext.Errors[0].Id);
            Assert.Same(errorChild, validationContext.Errors[0].RelatedNode);
            shapeLayout.RemoveChild(errorChild);
        }
示例#4
0
 public ShapeLayoutWrapper(ShapeLayout model) : base(model)
 {
 }