Exemplo n.º 1
0
        public static ListScreenTemplate LoadListScreenTemplate(ListScreenOrigin origin)
        {
            if (null == origin)
            {
                throw new ArgumentNullException(nameof(origin));
            }

            var template = TemplateLoader.LoadTemplate <ListScreenTemplate>(origin.ExtensionManager, origin.ExtensionId);

            if (null == template.TunableList)
            {
                throw new BadTemplateException("null == template.TunableList");
            }

            // Меню
            if (null != origin.MenuItemsTagName)
            {
                template.TunableList.CommandMenu =
                    MenuDisplayHelper.BuildCommandMenu(origin.ExtensionManager, origin.MenuItemsTagName, template.BaseDirectory);
            }

            // Кнопки
            if (null != origin.CommandBarTagName)
            {
                template.CommandButtons.Clear();
                template.CommandButtons.AddRange(
                    CommandBarDisplayHelper.BuildCommandButtons(origin.ExtensionManager, origin.CommandBarTagName));
            }

            template.SetTemplateInternals(template.TemplateName, template.BaseDirectory);

            return(template);
        }
Exemplo n.º 2
0
        public static FilterFormTemplate <WMColumnTemplate> LoadFilterFormTemplate(FilterOrigin origin)
        {
            if (null == origin)
            {
                throw new ArgumentNullException(nameof(origin));
            }

            var template =
                TemplateLoader.LoadTemplate <FilterFormTemplate <WMColumnTemplate> >(origin.ExtensionManager,
                                                                                     origin.ExtensionId);

            if (null == template.FilterScreen)
            {
                throw new BadTemplateException("null == template.FilterScreen");
            }

            if (null == template.FilterScreen.Grid)
            {
                throw new BadTemplateException("null == template.FilterScreen.Grid");
            }

            if (null != origin.ColumnsSettings)
            {
                SetupColumns(template.FilterScreen.Grid.Columns, origin.ColumnsSettings);
            }

            // Меню
            if (null != origin.MenuItemsTagName)
            {
                template.FilterScreen.Grid.CommandMenu =
                    MenuDisplayHelper.BuildCommandMenu(origin.ExtensionManager, origin.MenuItemsTagName,
                                                       template.BaseDirectory);
            }

            // Кнопки
            if (null != origin.CommandBarTagName)
            {
                template.FilterScreen.CommandButtons.Clear();
                template.FilterScreen.CommandButtons.AddRange(
                    CommandBarDisplayHelper.BuildCommandButtons(origin.ExtensionManager, origin.CommandBarTagName));
            }

            template.SetTemplateInternals(template.TemplateName, template.BaseDirectory);

            return(template);
        }