示例#1
0
 void CreateBody() // in my image
 {
     body = new Body.Body();
     body.AddBodyPart(new Body.Torso(0, Vector2.Zero)
     {
         lerpSpeed = .2f,
         turnAngle = 25,
         scale     = 1
     });
     body.AddBodyPart(new Body.Head(1, new Vector2(-22, 0))
     {
         lerpSpeed = 1,
         turnAngle = 5,
         scale     = 1f
     });
     body.AddBodyPart(new Body.Hand(2, new Vector2(30, -44))
     {
         scale = 1.3f,
         // try 25 for lols
         lerpSpeed = .1f,
         turnAngle = 10
     });
     body.AddBodyPart(new Body.Hand(2, new Vector2(30, 11))
     {
         scale     = 1.3f,
         lerpSpeed = .1f,
         turnAngle = 10
     });
 }
        public RenderBody(HtmlHelper <T> html, Body.Body <T> body)
        {
            if (body.ValidationSummary)
            {
                _innerHtml.AppendLine(new RenderValidationSummary(html, body.ItemTemplates).ToString());
            }
            if (body.AntiForgeryToken)
            {
                _innerHtml.AppendLine(html.AntiForgeryToken().ToString());
            }

            _innerHtml.Append(new RenderHiddenProperties <T>(html, body.ItemTemplates));

            var anyRequired = false;

            foreach (var propertyInfo in typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => p.CanWrite && p.CanRead))
            {
                if (propertyInfo.IsHidden() || propertyInfo.IgnoreInForm())
                {
                    continue;
                }
                // when HideNullProperties == true, check for null values...
                if (html.ViewData.Model != null && body.Model.HideNullProperties && propertyInfo.GetValue(html.ViewData.Model, null) == null)
                {
                    continue;
                }

                if (propertyInfo.IsRequired())
                {
                    anyRequired = true;
                }

                _innerHtml.AppendLine(new RenderProperty <T>(html, body.PropertyInfos, body.ItemTemplates, propertyInfo).ToString());
            }

            if (!anyRequired)
            {
                return;
            }

            _innerHtml.AppendLine(TemplateConfig.Instance.MandatoryText);
        }