Esempio n. 1
0
        public static Widget Explorer(ExplorerEntry explorer)
        {
            var widgets = new WidgetList(); // Gridformat is broken, cannot use

            foreach (var entry in explorer.GetDirectories())
            {
                var label  = Label(entry.Key);
                var spacer = new Widget();
                spacer.Width = 30;
                //spacer.IsFixedWidth = true;
                var widget = new Widget().WithAddedBehavior(new GridFormat(2, 1));
                widget[0, 0] = spacer;
                widget[1, 0] = label;
                widgets.Add(widget);
            }

            foreach (var entry in explorer.GetFiles())
            {
                var widget = Label(entry.Key);
                widgets.Add(widget);
            }

            var result = new Widget();

            result.AddRange(widgets);
            result.Behaviors.Add(new GridFormat(1, widgets.Count));
            return(result);
        }
Esempio n. 2
0
        public static Widget DropDown(
            IEnumerable <KeyValuePair <string, DropDownEntry> > entries,
            PopInOut pop_in_out_behavior = null
            )
        {
            var items = new WidgetList();

            foreach (var item in entries)
            {
                items.Add(DropDownEntry(item.Key, item.Value));
            }
            return(DropDown(items, pop_in_out_behavior));
        }
Esempio n. 3
0
        /// <summary> Get this <see cref="Widget"/>'s <see cref="Widget.Children"/> ordered by depth. </summary>
        public static WidgetList GetChildrenByDepth(
            this Widget widget
            )
        {
            var result       = new WidgetList();
            var ordered_list = widget.GetAllChildrenWithDepth().OrderBy(t => t.Item2).ToList();

            for (var i = 0; i < ordered_list.Count; i++)
            {
                result.Add(ordered_list[i].Item1);
            }
            return(result);
        }
Esempio n. 4
0
    private static void FillWidgetListWithChildren(Transform trans, ref WidgetList list, ref bool madeList)
    {
        UIWidget component = trans.GetComponent <UIWidget>();

        if (component != null)
        {
            if (!madeList)
            {
                list     = WidgetList.Generate();
                madeList = true;
            }
            list.Add(component);
        }
        int childCount = trans.childCount;

        while (childCount-- > 0)
        {
            FillWidgetListWithChildren(trans.GetChild(childCount), ref list, ref madeList);
        }
    }
Esempio n. 5
0
 public void AddWidget(IWidget widget)
 {
     _widgets.Add(widget);
     widget.Init();
 }
Esempio n. 6
0
        /// <summary>
        /// Populate the sub entities of fieldTestList
        /// </summary>
        /// <param name="fieldTests"></param>
        /// <param name="toPopulate"></param>
        public override void Populate(IEnumerable <FieldTest> fieldTests, Flags toPopulate)
        {
            Log("Populate", fieldTests.GetIdenties(), toPopulate);

            // Implement breadth first loading of related entities.
            // Any entity that has been requested to be loaded, should be loaded at this level where possible.
            // Remove all sub entity types that this entity relates to directly.
            Flags stillToPopulate = toPopulate;

            stillToPopulate = stillToPopulate.Remove(EntityType.Widget);
            stillToPopulate = stillToPopulate.Remove(EntityType.Widget);

            // Get parent entities: Widget
            if ((toPopulate & EntityType.Widget) == EntityType.Widget)
            {
                // Grab the ids for the ones that actually need populating
                IEnumerable <FieldTest> toBePopulated = fieldTests.Where(entity => entity.ForeignKeyFieldWidgetRequiresPopulation);
                int[] idsToLoad = toBePopulated.Select(entity => entity.ForeignKeyField).ToList().ToArray();

                // And load the sub entities for those ones.
                WidgetList parentWidgetList = toBePopulated.Count() > 0
                    ? WidgetRepo.Get(idsToLoad, stillToPopulate)
                    : new WidgetList();
                Dictionary <int, Widget> widgetListById = parentWidgetList.MapById;

                // Now go over all the entites. For ones that need popualting, populate entities
                // directly. For those already populated, make a check on sub entities to ensure
                // they are loaded to the required level
                WidgetList toBeChecked = new WidgetList();
                foreach (FieldTest fieldTest in fieldTests)
                {
                    if (fieldTest.ForeignKeyFieldWidgetRequiresPopulation)
                    {
                        fieldTest.ForeignKeyFieldWidget =
                            widgetListById.ContainsKey(fieldTest.ForeignKeyField)
                                                        ? widgetListById[fieldTest.ForeignKeyField]
                                                        : null;
                    }
                    else if (fieldTest.ForeignKeyFieldWidgetPopulated)
                    {
                        toBeChecked.Add(fieldTest.ForeignKeyFieldWidget);
                    }
                }

                // If there's any "to be checked" (because they were already loaded) let the entiies own
                // repo do whatever checks it needs to do
                if (toBeChecked.Count > 0)
                {
                    WidgetRepo.Populate(toBeChecked, stillToPopulate);
                }
            }

            // Get parent entities: Widget
            if ((toPopulate & EntityType.Widget) == EntityType.Widget)
            {
                // Grab the ids for the ones that actually need populating
                IEnumerable <FieldTest> toBePopulated = fieldTests.Where(entity => entity.ForeignKeyFieldNullableWidgetRequiresPopulation);
                int[] idsToLoad = toBePopulated.Select(entity => entity.ForeignKeyFieldNullable.Value).ToList().ToArray();

                // And load the sub entities for those ones.
                WidgetList parentWidgetList = toBePopulated.Count() > 0
                    ? WidgetRepo.Get(idsToLoad, stillToPopulate)
                    : new WidgetList();
                Dictionary <int, Widget> widgetListById = parentWidgetList.MapById;

                // Now go over all the entites. For ones that need popualting, populate entities
                // directly. For those already populated, make a check on sub entities to ensure
                // they are loaded to the required level
                WidgetList toBeChecked = new WidgetList();
                foreach (FieldTest fieldTest in fieldTests)
                {
                    if (fieldTest.ForeignKeyFieldNullableWidgetRequiresPopulation)
                    {
                        fieldTest.ForeignKeyFieldNullableWidget =
                            widgetListById.ContainsKey(fieldTest.ForeignKeyFieldNullable.Value)
                                                        ? widgetListById[fieldTest.ForeignKeyFieldNullable.Value]
                                                        : null;
                    }
                    else if (fieldTest.ForeignKeyFieldNullableWidgetPopulated)
                    {
                        toBeChecked.Add(fieldTest.ForeignKeyFieldNullableWidget);
                    }
                }

                // If there's any "to be checked" (because they were already loaded) let the entiies own
                // repo do whatever checks it needs to do
                if (toBeChecked.Count > 0)
                {
                    WidgetRepo.Populate(toBeChecked, stillToPopulate);
                }
            }
        }