Category CreateCategory(TemplateCategory templateCategory)
        {
            Category node = new NewFileDialog.Category(templateCategory.DisplayName);

            foreach (var subcategory in Sorted(templateCategory.Subcategories))
            {
                var subnode = CreateCategory(subcategory);
                if (!subnode.IsEmpty)
                {
                    node.Nodes.Add(subnode);
                }
            }
            foreach (var template in templateCategory.Templates.OfType <FileTemplate>())
            {
                if (!template.IsVisible(project))
                {
                    continue;
                }
                TemplateItem titem = new TemplateItem(template);
                if (titem.Template.Icon != null)
                {
                    icons[titem.Template.Icon] = 0;                     // "create template icon"
                }
                alltemplates.Add(titem);
                node.Templates.Add(titem);
            }
            return(node);
        }
        Category CreateCategory(TemplateCategory templateCategory)
        {
            Category node = new Category(templateCategory.DisplayName);

            foreach (var subcategory in Sorted(templateCategory.Subcategories))
            {
                var subnode = CreateCategory(subcategory);
                if (!subnode.IsEmpty)
                {
                    node.Nodes.Add(subnode);
                }
            }
            foreach (var template in templateCategory.Templates.OfType <ProjectTemplate>())
            {
                if (!template.IsVisible(SolutionFolder != null ? SolutionFolder.ParentSolution : null))
                {
                    // Do not show solution template when added a new project to existing solution
                    continue;
                }
                TemplateItem titem = new TemplateItem(template);
                if (titem.Template.Icon != null)
                {
                    icons[titem.Template.Icon] = 0;                     // "create template icon"
                }
                alltemplates.Add(titem);
                node.Templates.Add(titem);
            }
            return(node);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public JsonResult Update(TemplateCategory entity)
        {
            ModelState.Remove("CreatedTime");
            ModelState.Remove("UpdatedTime");
            ModelState.Remove("IsDelete");
            if (ModelState.IsValid)
            {
                var model = ITemplateCategoryService.Find(entity.ID);
                if (model == null || (model != null && model.IsDelete))
                {
                    return(DataErorrJResult());
                }

                if (ITemplateCategoryService.IsExits(x => x.Name == entity.Name && x.ID != entity.ID))
                {
                    return(JResult(Core.Code.ErrorCode.system_name_already_exist, ""));
                }

                if (ITemplateCategoryService.IsExits(x => x.RouteName == entity.RouteName && x.ID != entity.ID))
                {
                    return(JResult(Core.Code.ErrorCode.route_name_already_exist, ""));
                }
                model.Name      = entity.Name;
                model.Sort      = entity.Sort;
                model.RouteName = entity.RouteName;
                var result = ITemplateCategoryService.Update(model);
                return(JResult(result));
            }
            else
            {
                return(ParamsErrorJResult(ModelState));
            }
        }
        void ShowTemplatesForCategory(TemplateCategory category)
        {
            templateTextRenderer.RenderRecentTemplate = false;
            languageCellRenderer.RenderRecentTemplate = false;
            foreach (TemplateCategory subCategory in category.Categories)
            {
                var iter = templatesTreeStore.AppendValues(
                    MarkupTopLevelCategoryName(subCategory.Name),
                    null,
                    null);

                foreach (SolutionTemplate template in subCategory.Templates)
                {
                    if (template.HasProjects || controller.IsNewSolution)
                    {
                        templatesTreeStore.AppendValues(
                            iter,
                            template.Name,
                            GetIcon(template.IconId, IconSize.Dnd),
                            template);
                    }
                }
            }
            templatesTreeView.ExpandAll();
        }
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public JsonResult Add(TemplateCategory entity)
 {
     ModelState.Remove("ID");
     ModelState.Remove("CreatedTime");
     ModelState.Remove("UpdatedTime");
     ModelState.Remove("IsDelete");
     if (ModelState.IsValid)
     {
         if (ITemplateCategoryService.IsExits(x => x.Name == entity.Name))
         {
             return(JResult(Core.Code.ErrorCode.system_name_already_exist, ""));
         }
         if (ITemplateCategoryService.IsExits(x => x.RouteName == entity.RouteName))
         {
             return(JResult(Core.Code.ErrorCode.route_name_already_exist, ""));
         }
         entity.CreatedTime = entity.UpdatedTime = DateTime.Now;
         var result = ITemplateCategoryService.Add(entity);
         return(JResult(result));
     }
     else
     {
         return(ParamsErrorJResult(ModelState));
     }
 }
        public TemplateCategory ToTopLevelTemplateCategory()
        {
            TemplateCategory category = ToTemplateCategory();

            category.IsTopLevel = true;
            return(category);
        }
 void AddSubTemplateCategory(TemplateCategory category)
 {
     templateCategoriesListStore.AppendValues(
         GLib.Markup.EscapeText(category.Name),
         null,
         category);
 }
Exemple #8
0
        Category CreateCategory(TemplateCategory templateCategory)
        {
            Category item = new Category(templateCategory.DisplayName);

            foreach (var subcategory in Sorted(templateCategory.Subcategories))
            {
                var subItem = CreateCategory(subcategory);
                if (!subItem.IsEmpty)
                {
                    item.Items.Add(subItem);
                }
            }

            foreach (var template in templateCategory.Templates.OfType <ProjectTemplate>())
            {
                if (!template.IsVisible(SolutionFolder != null ? SolutionFolder.ParentSolution : null))
                {
                    // Do not show solution template when added a new project to existing solution
                    continue;
                }
                TemplateItem templateItem = new TemplateItem(template);
                AllTemplates.Add(templateItem);
                item.Templates.Add(templateItem);
            }

            return(item);
        }
        public async Task <ActionResult> PostTemplateCategory(TemplateCategory templateCategory)
        {
            database.TemplateCategories.Add(templateCategory);
            await database.SaveChangesAsync();

            return(Accepted());
        }
 void AddChildren(TemplateCategory category)
 {
     foreach (var childCodon in ChildNodes.OfType <TemplateCategoryCodon> ())
     {
         category.AddCategory(childCodon.ToTemplateCategory());
     }
 }
Exemple #11
0
        public async Task <IActionResult> GetDefaultTemplatesByCategory(TemplateCategory category)
        {
            GoNorthProject project = await _projectDbAccess.GetDefaultProject();

            List <ExportTemplate> templates = await _defaultTemplateProvider.GetDefaultTemplatesByCategory(project.Id, category);

            return(Ok(templates.Select(t => TranslateTemplateLabel(t)).ToList()));
        }
 void AddSubTemplateCategory(TreeIter iter, TemplateCategory category)
 {
     templateCategoriesTreeStore.AppendValues(
         iter,
         GLib.Markup.EscapeText(category.Name),
         null,
         category);
 }
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            TemplateCategory templateCategory = await db.TemplateCategories.FindAsync(id);

            db.TemplateCategories.Remove(templateCategory);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public void ImportTemplateViaUrl(string ImportUrl, string Language)
        {
            TemplateCategory ImportCategory = LoadTemplateCategoryFromUrl(ImportUrl);
            TemplateCategory RootCategory   = (from TemplateCategory Cat in CodeRush.Templates.GetCategories(Language)
                                               where Cat.Name == ImportCategory.Name
                                               select Cat).FirstOrDefault();

            DuplicateCategoryContent(ImportCategory, RootCategory);
        }
Exemple #15
0
        public async Task <InvokeResult> UpdateTemplateCategoryAsync(TemplateCategory templateCategory, EntityHeader org, EntityHeader user)
        {
            await AuthorizeAsync(templateCategory, AuthorizeResult.AuthorizeActions.Update, user, org);

            Validator.Validate(templateCategory, Actions.Update);

            await _repo.UpdateTemplateCateogryAsync(templateCategory);

            return(InvokeResult.Success);
        }
        public TemplateCategoryViewModel AddCategory(TemplateCategory category)
        {
            GetChildCategories();

            var viewModel = new TemplateCategoryViewModel(this, category);

            childCategories.Add(viewModel);

            return(viewModel);
        }
Exemple #17
0
        public async Task <InvokeResult> AddTemplateCategoryAsync(TemplateCategory templateCategory, EntityHeader org, EntityHeader user)
        {
            ValidationCheck(templateCategory, Actions.Create);

            await AuthorizeAsync(templateCategory, AuthorizeResult.AuthorizeActions.Create, user, org);

            await _repo.AddTemplateCateogrydAsync(templateCategory);

            return(InvokeResult.Success);
        }
                #pragma warning restore 649

        public TemplateCategory ToTemplateCategory()
        {
            var category = new TemplateCategory(Id, _name ?? name, icon);

            category.MappedCategories = mappedCategories;
            category.IsDefault        = IsDefaultCategory();

            AddChildren(category);
            return(category);
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,UserId,Name,Code,No,Type,Active,Description,CreatedBy,UpdatedBy,CreatedDate,UpdatedDate")] TemplateCategory templateCategory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(templateCategory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(templateCategory));
        }
Exemple #20
0
        public override TemplateCategory Get(Guid id)
        {
            if (HID.CacheClient.ContainsKey(id) == true)
            {
                return((TemplateCategory)HID.CacheClient[id]);
            }
            TemplateCategory result = base.Get(id);

            HID.Add(id, result);
            return(result);
        }
        public async Task <IActionResult> PutTemplateCategory(int id, TemplateCategory templateCategory)
        {
            if (id != templateCategory.Id)
            {
                return(BadRequest());
            }

            database.Entry(templateCategory).State = EntityState.Modified;
            await database.SaveChangesAsync();

            return(NoContent());
        }
        static IEnumerable <TemplateCategoryViewModel> ReadTemplateCategoriesInternal()
        {
            var doc = new XmlDocument();

            doc.Load(addinXmlFileName);

            foreach (XmlElement node in doc.SelectNodes("//Extension[@path='/MonoDevelop/Ide/ProjectTemplateCategories']/Category"))
            {
                TemplateCategory category = CreateTemplateCategory(node);
                yield return(new TemplateCategoryViewModel(null, category));
            }
        }
        void ShowTemplatesForSelectedCategory()
        {
            ClearSelectedCategoryInformation();

            TemplateCategory category = GetSelectedTemplateCategory();

            if ((category != null) && (category.IconId == null))
            {
                ShowTemplatesForCategory(category);
                SelectFirstTemplate();
            }
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,UserId,Name,Code,No,Type,Active,Description,CreatedBy,UpdatedBy,CreatedDate,UpdatedDate")] TemplateCategory templateCategory)
        {
            if (ModelState.IsValid)
            {
                templateCategory.Id = Guid.NewGuid();
                db.TemplateCategories.Add(templateCategory);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(templateCategory));
        }
        public TemplateCategoryViewModel(
            TemplateCategoryViewModel parentCategory,
            TemplateCategory category)
        {
            ParentCategory = parentCategory;
            Category       = category;

            IsBottomLevel = GetIsBottomLevel();
            IsTopLevel    = parentCategory == null;

            id   = category.Id;
            name = category.Name;
        }
Exemple #26
0
        private void templatesToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            TemplateCategory category = templatesToolStripComboBox.SelectedItem as TemplateCategory;

            if (category != null)
            {
                templateListBox.Items.Clear();

                foreach (Template template in category.Templates)
                {
                    templateListBox.Items.Add(template);
                }
            }
        }
 private void CopyTemplatesBetweenCategories(TemplateCategory SourceCategory, TemplateCategory DestCategory)
 {
     foreach (Template SourceTemplate in SourceCategory.Templates)
     {
         var DestTemplate = (from Template temp in DestCategory.Templates
                             where temp.Name == SourceTemplate.Name
                             select temp).FirstOrDefault();
         if (DestTemplate != null)
         {
             DestCategory.Templates.Remove(DestTemplate);
         }
         DestCategory.Templates.Add(SourceTemplate);
     }
 }
        static TemplateCategory CreateTemplateCategory(XmlElement node)
        {
            var category = new TemplateCategory(
                node.GetAttribute("id"),
                node.GetAttribute("name"),
                null);

            foreach (XmlElement childNode in node.SelectNodes("./Category"))
            {
                category.AddCategory(CreateTemplateCategory(childNode));
            }

            return(category);
        }
        // GET: TemplateCategories/Delete/5
        public async Task <ActionResult> Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TemplateCategory templateCategory = await db.TemplateCategories.FindAsync(id);

            if (templateCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(templateCategory));
        }
        private void CopyTemplatesBetweenCategories(TemplateCategory SourceCategory, TemplateCategory DestCategory)
        {
            foreach (Template SourceTemplate in SourceCategory.Templates)
            {
                var DestTemplate = (from Template temp in DestCategory.Templates
                                    where temp.Name == SourceTemplate.Name
                                    select temp).FirstOrDefault();
                if (DestTemplate != null)
                {
                    DestCategory.Templates.Remove(DestTemplate);
                }
                DestCategory.Templates.Add(SourceTemplate);

            }
        }
        void AddTopLevelTemplateCategory(TemplateCategory category)
        {
            Xwt.Drawing.Image icon = GetIcon(category.IconId, IconSize.Menu);
            categoryTextRenderer.CategoryIconWidth = (int)icon.Width;

            templateCategoriesListStore.AppendValues(
                MarkupTopLevelCategoryName(category.Name),
                icon,
                category);

            foreach (TemplateCategory subCategory in category.Categories)
            {
                AddSubTemplateCategory(subCategory);
            }
        }
 private void DuplicateCategoryContent(TemplateCategory SourceCategory, TemplateCategory DestCategory)
 {
     foreach (TemplateCategory SourceChildCategory in SourceCategory.Categories)
     {
         var DestChildCategory = (from TemplateCategory cat in DestCategory.Categories
                                  where cat.Name == SourceChildCategory.Name
                                  select cat).FirstOrDefault();
         if (DestChildCategory == null)
         {
             DestChildCategory = new TemplateCategory();
             DestChildCategory.Name = SourceChildCategory.Name;
             DestCategory.Categories.Add(DestChildCategory);
         }
         DuplicateCategoryContent(SourceChildCategory, DestChildCategory);
     }
     CopyTemplatesBetweenCategories(SourceCategory, DestCategory);
 }
Exemple #33
0
 private void LoadTemplates()
 {
     IDocumentTypeManager service = (IDocumentTypeManager) this.GetService(typeof(IDocumentTypeManager));
     TemplateCategory category = new TemplateCategory("(General)");
     this._templateCategories = new HybridDictionary(true);
     this._templateCategories.Add("General", category);
     ICollection creatableDocumentTypes = service.CreatableDocumentTypes;
     if ((creatableDocumentTypes != null) && (creatableDocumentTypes.Count != 0))
     {
         ImageList list = new ImageList();
         ImageList list2 = new ImageList();
         list.ImageSize = new Size(0x20, 0x20);
         list.ColorDepth = ColorDepth.Depth32Bit;
         this._templateListView.LargeImageList = list;
         list2.ImageSize = new Size(0x10, 0x10);
         list2.ColorDepth = ColorDepth.Depth32Bit;
         this._templateListView.SmallImageList = list2;
         ImageList.ImageCollection images = list.Images;
         ImageList.ImageCollection images2 = list2.Images;
         foreach (DocumentType type in creatableDocumentTypes)
         {
             images.Add(type.LargeIcon);
             images2.Add(type.SmallIcon);
             TemplateListViewItem item = new TemplateListViewItem(type, images.Count - 1);
             string templateCategory = type.TemplateCategory;
             if ((templateCategory == null) || (templateCategory.Length == 0))
             {
                 category.Items.Add(item);
                 continue;
             }
             TemplateCategory category2 = (TemplateCategory) this._templateCategories[templateCategory];
             if (category2 != null)
             {
                 category2.Items.Add(item);
             }
             else
             {
                 category2 = new TemplateCategory(templateCategory);
                 category2.Items.Add(item);
                 this._templateCategories.Add(templateCategory, category2);
             }
         }
     }
     foreach (TemplateCategory category3 in this._templateCategories.Values)
     {
         this._categoryListBox.Items.Add(category3);
     }
     this._categoryListBox.SelectedItem = category;
     if (this._fileNameText.Enabled)
     {
         this._fileNameText.Focus();
     }
 }