Example #1
0
		public UI (IElementBuilder builder)
		{
			this._init ();
			if (builder != null) {
				foreach (UIEllement ellement in builder.Build()) {
					this.AddRule (ellement);
				}
			}
		}
        private LabelBuilder BuildToContentAndReturn <TElem>(IElementBuilder <TElem> builder)
            where TElem : LabelContent, new()
        {
            var element = builder.Build();

            Context.Content.Add(element);

            return(this);
        }
        public void BuildBy(IElementBuilder builder)
        {
            var conditionalBuilder = new ConditionalElementBuilder(_filter, builder)
            {
                ConditionDescription = _filterDescription
            };

            _set.Add(conditionalBuilder);
        }
        public VplServiceContext(IVplService vplService, IEnumerable <IVplPlugin> plugins = null)
        {
            if (vplService == null)
            {
                throw new ArgumentNullException(nameof(vplService));
            }
            _vplService = vplService;
            _plugins    = plugins?.ToArray() ?? new IVplPlugin[] {};

            _customResources = _plugins.SelectMany(p => p.Resources);

            var customFactories = _plugins.SelectMany(p => p.ElementFactories);

            _elementFactoryManager = new ElementFactoryManager(customFactories);

            //These are the "built-in" types
            var types = new List <IVplType>
            {
                new VplType(VplTypeId.Boolean, "Boolean", () => new BooleanValueCheckBoxView(), false, typeof(bool)),
                new VplType(VplTypeId.Float, "Float", () => new DoubleValueView(), 0.0, typeof(double)),
                new VplType(VplTypeId.Any, "Any", () => new TextValueView(), null, typeof(object)),
                new VplType(VplTypeId.String, "String", () => new TextValueView(), "", typeof(string)),
                new VplType(VplTypeId.Int, "Int", () => new Int32ValueView(), 0, typeof(int)),
                new VplType(VplTypeId.Byte, "Byte", () => new ByteValueView(), (byte)0, typeof(byte)),
                new VplType(VplTypeId.UInt16, "UInt16", () => new TextValueView(), (ushort)0, typeof(ushort)),
                new VplType(VplTypeId.UInt32, "UInt32", () => new TextValueView(), (uint)0, typeof(uint)),
                new VplType(VplTypeId.Single, "Single", () => new TextValueView(), (float)0, typeof(float)),
                new VplType(VplTypeId.SByte, "Int8", () => new TextValueView(), (sbyte)0, typeof(sbyte)),
                new VplType(VplTypeId.Int16, "Int16", () => new Int16ValueView(), (short)0, typeof(short)),
                new VplType(VplTypeId.DateTime, "DateTime", () => new DateTimeValueView(), DateTime.Now, typeof(DateTime)),
                new VplType(VplTypeId.UInt64, "UInt64", () => new TextValueView(), (ulong)0, typeof(ulong)),
                new VplType(VplTypeId.Int64, "Int64", () => new TextValueView(), (long)0, typeof(long)),
                new VplType(VplTypeId.Decimal, "Decimal", () => new TextValueView(), (decimal)0, typeof(decimal))
            };

            //Add the plugin types
            foreach (var plugin in _plugins)
            {
                types.AddRange(plugin.Types);
            }

            //Create the array of types
            _types = types
                     .OrderBy(t => t.Name)
                     .ToArray();

            //Create the services
            _services = _plugins
                        .SelectMany(p => p.Services)
                        .ToArray();

            //Create an element builder
            _elementBuilder = new ElementBuilder(_elementFactoryManager, this);
        }
Example #5
0
 public UI(IElementBuilder builder)
 {
     this._init();
     if (builder != null)
     {
         foreach (UIEllement ellement in builder.Build())
         {
             this.AddRule(ellement);
         }
     }
 }
Example #6
0
        public void ConfigureElement(IElementBuilder elementProcessing)
        {
            elementProcessing
            .AssignBindingContext()
            .AssignChildrenBindingContext();

            elementProcessing
            .AssignAttachedAsyncCommands()
            .AssignAttachedCommands()
            .AssignAsyncCommands()
            .AssignCommands();
        }
Example #7
0
        protected override void OnPostInitialize()
        {
            base.OnPostInitialize();

            for (int i = 0; i < Description.Elements.Count; i++)
            {
                IElementBuilder builder = Description.Elements[i];
                IElement        element = builder.Build(Context);

                m_parent.Children.Add(element);
            }

            m_parent.Initialize();
        }
Example #8
0
        public VplServiceContext(IEnumerable<IVplPlugin> plugins = null)
        {
            _plugins = plugins?.ToArray() ?? new IVplPlugin[] {};

            _customResources = _plugins.SelectMany(p => p.Resources);

            var customFactories = _plugins.SelectMany(p => p.ElementFactories);

            _elementFactoryManager = new ElementFactoryManager(customFactories);

            //These are the "built-in" types
            var types = new List<IVplType>
            {
                new VplType(VplTypeId.Boolean, "Boolean", () => new BooleanValueCheckBoxView(), false, typeof(bool)),
                new VplType(VplTypeId.Float, "Float", () => new DoubleValueView(), 0.0, typeof(double)),
                new VplType(VplTypeId.Any, "Any", () => new TextValueView(), null, typeof(object)),
                new VplType(VplTypeId.String, "String", () => new TextValueView(), "", typeof(string)),
                new VplType(VplTypeId.Int, "Int", () => new Int32ValueView(), 0, typeof(int)),
                new VplType(VplTypeId.Byte, "Byte", () => new ByteValueView(), (byte)0, typeof(byte)),
                new VplType(VplTypeId.UInt16, "UInt16", () => new TextValueView(), (ushort)0, typeof(ushort)),
                new VplType(VplTypeId.UInt32, "UInt32", () => new TextValueView(), (uint)0, typeof(uint)),
                new VplType(VplTypeId.Single, "Single", () => new TextValueView(), (float)0, typeof(float)),
                new VplType(VplTypeId.SByte, "Int8", () => new TextValueView(), (sbyte)0, typeof(sbyte)),
                new VplType(VplTypeId.Int16, "Int16", () => new Int16ValueView(), (short)0, typeof(short)),
                new VplType(VplTypeId.DateTime, "DateTime", () => new DateTimeValueView(), DateTime.Now, typeof(DateTime)),
                new VplType(VplTypeId.UInt64, "UInt64", () => new TextValueView(), (ulong)0, typeof(ulong)),
                new VplType(VplTypeId.Int64, "Int64", () => new TextValueView(), (long)0, typeof(long)),
                new VplType(VplTypeId.Decimal, "Decimal", () => new TextValueView(), (decimal)0, typeof(decimal))
            };

            //Add the plugin types
            foreach (var plugin in _plugins)
            {
                types.AddRange(plugin.Types);
            }

            //Create the array of types
            _types = types
                .OrderBy(t => t.Name)
                .ToArray();

            //Create the services
            _services = _plugins
                .SelectMany(p => p.Services)
                .ToArray();

            //Create an element builder
            _elementBuilder = new ElementBuilder(_elementFactoryManager, this);
        }
        /// <summary>Recursively traverse <paramref name="constituent"/> depth-first, creating a parallel tree of ElementBuilders</summary>
        /// <returns>The IElementTreeNode at the root of the created tree</returns>
        private static IElementTreeNode ElementBuilderTreeFrom(ParseResult parse, Tree constituent)
        {
            IElementBuilder theBuilder = ElementBuilderParsedFrom(constituent, parse);

            switch (theBuilder)
            {
            case PartOfSpeechBuilder posBuilder:
                return(posBuilder);

            case ParentElementBuilder parentElementBuilder:
                Tree[] childConstituents = constituent.children();
                for (int childConstituentIndex = 0; childConstituentIndex < childConstituents.Length; childConstituentIndex++)
                {
                    parentElementBuilder.AddChild(ElementBuilderTreeFrom(parse, constituent.getChild(childConstituentIndex)));
                }
                return(parentElementBuilder);

            default: throw new ArgumentException();
            }
        }
Example #10
0
 public ConditionalElementBuilder(Func <ElementRequest, bool> filter, IElementBuilder inner)
 {
     _filter = filter;
     _inner  = inner;
 }
Example #11
0
 public T Add(IElementBuilder child)
 {
     element.AppendChild(child.BuildElement());
     return(this as T);
 }
 public ConditionalElementBuilder(Func<ElementRequest, bool> filter, IElementBuilder inner)
 {
     _filter = filter;
     _inner = inner;
 }
Example #13
0
 public void Builder(IElementBuilder builder)
 {
     _factory.AddBuilder(builder);
 }
Example #14
0
        internal static ElementBuilderGraph Of(IElementBuilder model)
        {
            ElementBuilderGraph graph = new ElementBuilderGraph();

            AddSubtreeIncludingRoot(model);
            //AddSyntacticRelationEdges();
            return(graph);

            ElementBuilderVertex AddSubtreeIncludingRoot(IElementBuilder builder, ElementBuilderVertex parentVertex = null)
            {
                switch (builder)
                {
                case ParentElementBuilder peb:
                    return(AddSubtree(peb));

                case WordElementBuilder web:
                    return(AddLeafVertexFor(web));

                default: throw new InvalidOperationException("ElementGraphBuilder doesn't handle this ElementBuilder type");
                }

                ParentElementVertex AddSubtree(ParentElementBuilder parentElementBuilder)
                {
                    ParentElementVertex parentElementVertex = new ParentElementVertex(parentElementBuilder);

                    graph.AddVertex(parentElementVertex);

                    foreach (ElementBuilder eachChild in parentElementBuilder.Children)
                    {
                        ElementBuilderVertex eachChildVertex = AddSubtreeIncludingRoot(eachChild, parentElementVertex);
                        graph.AddEdge(new ParentElementToChildEdge(parentElementVertex, eachChildVertex, parentElementBuilder.RoleFor(eachChild)));
                    }

                    return(parentElementVertex);
                }

                WordPartOfSpeechVertex AddLeafVertexFor(WordElementBuilder wordElementBuilder)
                {
                    WordPartOfSpeechVertex partOfSpeechVertex = new WordPartOfSpeechVertex(wordElementBuilder);

                    graph.AddVertex(partOfSpeechVertex);
                    // The token node is the one actually containing the word
                    WordContentVertex contentVertex = new WordContentVertex(wordElementBuilder);

                    graph.AddVertex(contentVertex);
                    PartOfSpeechToContentEdge contentEdge = new PartOfSpeechToContentEdge(partOfSpeechVertex, contentVertex);

                    graph.AddEdge(contentEdge);
                    return(partOfSpeechVertex);
                }
            }

            //void AddSyntacticRelationEdges()
            //{
            //    foreach (PartOfSpeechVertex eachPartOfSpeechVertex in graph.PartsOfSpeech)
            //    {
            //        PartOfSpeechBuilder eachPartOfSpeechBuilder = eachPartOfSpeechVertex.Model;
            //        foreach (SyntacticRelation eachDependency in eachPartOfSpeechBuilder.IncomingSyntacticRelations)
            //        {
            //            graph.AddEdge(new DependencyEdge(graph.TokenVertexFor(eachDependency.Governor), graph.TokenVertexFor(eachDependency.Dependent), eachDependency.Relation));
            //        }
            //    }
            //}
        }
 public void Add(Func <ElementRequest, bool> filter, IElementBuilder builder) => _set.Add(filter, builder);
 public NestedDungeonElementBuilder AddSubElement <T>(IElementBuilder <T> element) where T : AbstractDungeonElement => this.Also(x => _element.SubElements.Add(element.Build()));
Example #17
0
 public void InsertFirstBuilder(IElementBuilder builder)
 {
     _sources.Insert(0, builder);
 }
Example #18
0
 public void AddBuilder(IElementBuilder builder)
 {
     _sources.Add(builder);
 }
Example #19
0
 public void AddBuilder(IElementBuilder builder)
 {
     _sources.Add(builder);
 }
Example #20
0
 public void InsertFirstBuilder(IElementBuilder builder)
 {
     _sources.Insert(0, builder);
 }
Example #21
0
 protected T Add(IElementBuilder elem)
 {
     this.Content.AppendChild(elem.BuildElement());
     return(this as T);
 }
Example #22
0
 public HomeController(ICoordinatesManager coordinatesManagerParam, IColorChooseHelper colorChooseHelperParam)
 {
     coordinatesManager = coordinatesManagerParam;
     colorChooseHelper  = colorChooseHelperParam;
     elementBuilder     = new SegmentBuilder(colorChooseHelper, coordinatesManager);
 }