示例#1
0
 protected override IViewModelData BuildModelData(object value, IFieldData field, ITemplateData template)
 {
     return Dependencies.DataFactory.GetModelData(
                         (IFieldSet)value,
                         field.EmbeddedSchema.BaseData as ISchema, //Assuming it's DD4T implemented
                         template.BaseData as IComponentTemplate);
 }
示例#2
0
        public string Run(Template template, ITemplateData data)
        {
            var sw = new StringWriter();

            Run(template, data, sw);
            return(sw.ToString());
        }
示例#3
0
 public Dynamic.IComponentPresentation BuildComponentPresentation(IComponentData component, ITemplateData componentTemplate)
 {
     return new Dynamic.ComponentPresentation //Locking in to default DD4T implementation
     {
         Component = component.BaseData as Dynamic.Component, //Assuming default DD4T implementation
         ComponentTemplate = componentTemplate.BaseData as Dynamic.ComponentTemplate //Assuming default DD4T implementation
     };
 }
示例#4
0
 //public RichTextFieldAttribute(string fieldName) : base(fieldName) { }
 public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     return field.Values.Cast<string>()
         .Select(v => v.ResolveRichText()); //Hidden dependency on DD4T implementation
 }
示例#5
0
        private static string GetParentSuffix(ITemplateData currTemplate)
        {
            string suffix = currTemplate.GetSetting(CommonVariables.ParentSuffix);
            if (suffix == null)
                suffix = currTemplate.GetVariable(CommonVariables.ParentSuffix);

            if (suffix == null)
                suffix = "Parent";

            return suffix;
        }
示例#6
0
 public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     IEnumerable result = null;
     if (component != null && component.MultimediaData != null)
     {
         result = new string[] { component.MultimediaData.Url };
     }
     return result;
 }
示例#7
0
 public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     return component == null ? null : new string[] { component.Title };
 }
示例#8
0
 public HomeController(ITemplateData data) : base(data)
 {
 }
示例#9
0
 /// <summary>
 /// The Key of a Keyword field.
 /// </summary>
 /// <param name="fieldName">Tridion schema field name</param>
 //public KeywordKeyFieldAttribute(string fieldName) : base(fieldName) { }
 public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     IEnumerable value = null;
     var values = field.Values.Cast<Dynamic.IKeyword>();
     if (IsBooleanValue)
         value = values.Select(k => { bool b; return bool.TryParse(k.Key, out b) && b; });
     else value = values.Select(k => k.Key);
     return value;
 }
示例#10
0
 /// <summary>
 /// When overriden in a derived class, this gets the value of the Property for a given Component Template
 /// </summary>
 /// <param name="template">Component Template for the View Model</param>
 /// <param name="propertyType">Actual return type for the Property</param>
 /// <param name="factory">View Model factory</param>
 /// <returns>The Property value</returns>
 public abstract object GetPropertyValues(ITemplateData template, Type propertyType, IViewModelFactory factory);
示例#11
0
 protected override IViewModelData BuildModelData(object value, IFieldData field, ITemplateData template)
 {
     var keyword = (IKeyword)value;
     var categoryName = (field.BaseData as IField).CategoryName;
     return Dependencies.DataFactory.GetModelData(keyword, categoryName);
 }
示例#12
0
 public ComponentPresentation(IComponentData component, ITemplateData template)
 {
     this.component = component;
     this.template = template;
     this.cp = Helper.BuildComponentPresentation(component.BaseData as IComponent, template.BaseData as IComponentTemplate);
 }
示例#13
0
 public ContentPresentationData(IFieldsData content, ISchemaData schema, ITemplateData template)
 {
     this.content = content;
     this.schema = schema;
     this.template = template;
     publicationId = template.PublicationId;
 }
示例#14
0
 public ComponentPresentation(IComponent component, IComponentTemplate template)
 {
     this.cp = Helper.BuildComponentPresentation(component, template); //Helps get around naming conflicts
     this.component = new Component(component);
     this.template = new ComponentTemplate(template);
 }
示例#15
0
 public ComponentPresentation(IComponentPresentation cp)
 {
     this.cp = cp;
     component = new Component(cp.Component);
     template = new ComponentTemplate(cp.ComponentTemplate);
 }
示例#16
0
        internal static string GetClassPrefix(string tableName, ITemplateData currTemplate)
        {
            string className = ClassItemTemplate.GenerateClassName(tableName);
            if (currTemplate != null)
            {
                string suffixReplacementMap = currTemplate.GetVariable(SuffixReplacementMapVariableName);
                if (!string.IsNullOrEmpty(suffixReplacementMap))
                    className = TextUtil.ReplaceSuffixes(className, suffixReplacementMap);
            }

            return className;
        }
示例#17
0
 protected override IViewModelData BuildModelData(object value, IFieldData field, ITemplateData template)
 {
     var component = (IComponent)value;
     var componentData = Dependencies.DataFactory.GetModelData(component);
     return Dependencies.DataFactory.GetModelData(
         Dependencies.DD4TFactory.BuildComponentPresentation(componentData, template));
 }
示例#18
0
 /// <summary>
 /// When overriden in a derived class, this method should return the value of the View Model property from a Field object
 /// </summary>
 /// <param name="field">The Field</param>
 /// <param name="propertyType">The concrete type of the view model property for this attribute</param>
 /// <param name="template">The Component Template to use</param>
 /// <param name="factory">The View Model Builder</param>
 /// <returns></returns>
 public abstract IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template,IViewModelFactory factory = null);
        private DigitAndDigitRectangle SearchImageForDigit(Image <Bgr, byte> imageToSearch, Image <Bgr, byte> searchTemplate, ITemplateData templateData)
        {
            int numberToSearchFor = templateData.NumberValue;

            using (Image <Gray, float> result = imageToSearch.MatchTemplate(searchTemplate, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed))
            {
                double[] minValues, maxValues;
                Point[]  minLocations, maxLocations;

                result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations);

                // You can try different values of the threshold. I guess somewhere between 0.75 and 0.95 would be good.
                if (maxValues[0] > 0.92)
                {
                    // This is a match. Do something with it, for example draw a rectangle around it.
                    Rectangle match = new Rectangle(maxLocations[0], searchTemplate.Size);


                    for (int i = searchTemplate.Size.Width; i > 1; i--)
                    {
                        match = new Rectangle(maxLocations[0].X + 5, maxLocations[0].Y, searchTemplate.Size.Width - (10 + i), searchTemplate.Size.Height);
                        imageToSearch.Draw(match, new Bgr(Color.Gray), 3);
                    }

                    return(new DigitAndDigitRectangle()
                    {
                        FoundRectangle = match, ResultImage = imageToSearch, FoundInteger = numberToSearchFor, DigitImageName = templateData.TemplatePath
                    });
                }
            }
            return(null);
        }
示例#20
0
 public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template,IViewModelFactory factory = null)
 {
     IEnumerable fieldValue = null;
     var values = GetRawValues(field);
     if (values != null)
     {
         if (ComplexTypeMapping == null && ReturnRawData)
             fieldValue = values;
         else
             fieldValue = values.Cast<object>()
                 .Select(value => BuildModel(factory, BuildModelData(value, field, template)))
             .Where(value => value != null);
     }
     return fieldValue;
 }
示例#21
0
 protected BaseController(ITemplateData data)
 {
     this.Data = data;
 }
示例#22
0
 protected abstract IViewModelData BuildModelData(object value, IFieldData field, ITemplateData template);
示例#23
0
 public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     var result = new List<object>();
     foreach (var value in field.Values)
     {
         object parsed;
         if (EnumTryParse(property.ModelType, value, out parsed))
         {
             result.Add(parsed);
         }
     }
     return result;
 }
示例#24
0
 /// <summary>
 /// When overriden in a derived class, this gets the value of the Property for a given Component
 /// </summary>
 /// <param name="component">Component for the View Model</param>
 /// <param name="propertyType">Actual return type for the Property</param>
 /// <param name="template">Component Template</param>
 /// <param name="factory">View Model factory</param>
 /// <returns>The Property value</returns>
 public abstract IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory);
示例#25
0
 public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     IMultimediaData result = null;
     if (component != null && component.MultimediaData != null)
     {
         result = component.MultimediaData;
     }
     return new IMultimediaData[] { result };
 }
示例#26
0
 public string Run(string template, ITemplateData data)
 {
     return(Run(new Template(template), data));
 }
示例#27
0
 //public NumericKeywordKeyFieldAttribute(string fieldName) : base(fieldName) { }
 public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     return field.Values.Cast<Dynamic.IKeyword>()
         .Select(k => { double i; double.TryParse(k.Key, out i); return i; });
 }
示例#28
0
 //public DateFieldAttribute(string fieldName) : base(fieldName) { }
 public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     return field.Values.Cast<DateTime>();
 }
示例#29
0
 //public ResolvedUrlFieldAttribute(string fieldName) : base(fieldName) { }
 public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     return field.Values.Cast<Dynamic.IComponent>()
         .Select(x => x.GetResolvedUrl());
 }
        private IEnumerable <DigitAndDigitRectangle> FindDigit(Image <Bgr, byte> source, ITemplateData digitTemplateInfo)
        {
            if (!File.Exists(digitTemplateInfo.TemplatePath))
            {
                return(null);
            }

            Image <Bgr, byte> template = new Image <Bgr, byte>(digitTemplateInfo.TemplatePath);


            var foundRectanglesList = new List <Rectangle>();
            var foundResultsList    = new List <DigitAndDigitRectangle>();

            DigitAndDigitRectangle findResult = new DigitAndDigitRectangle()
            {
                ResultImage = source
            };

            do
            {
                findResult = SearchImageForDigit(findResult.ResultImage, template, digitTemplateInfo);
                if (findResult != null)
                {
                    foundRectanglesList.Add(findResult.FoundRectangle);
                    foundResultsList.Add(findResult);
                }
            } while (findResult != null);

            return(foundResultsList);
        }
示例#31
0
        public override IEnumerable GetFieldValues(IFieldData field, IModelProperty property, ITemplateData template, IViewModelFactory factory)
        {
            IEnumerable fieldValue = null;
            var values = field.Values.Cast<string>();
            if (IsBooleanValue)
                fieldValue = values.Select(v => { bool b; return bool.TryParse(v, out b) && b; });
            else fieldValue = values;

            return fieldValue;
        }
示例#32
0
        private static string GetRecursiveParentSuffix(ITemplateData currTemplate)
        {
            string suffix = currTemplate.GetSetting(CommonVariables.RecursiveParentSuffix);
            if (suffix == null)
                suffix = currTemplate.GetVariable(CommonVariables.RecursiveParentSuffix);

            if (suffix == null)
                suffix = "Superior";

            return suffix;
        }
示例#33
0
 //Example of using the BaseData object
 public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     Dynamic.IMultimedia[] result = null;
     if (component != null && component.MultimediaData != null)
     {
         result = new Dynamic.IMultimedia[] { component.MultimediaData.BaseData as Dynamic.IMultimedia };
     }
     return result;
 }
示例#34
0
 public void Run(Template template, ITemplateData data, TextWriter writer)
 {
     Run(template, (object)data, writer);
 }