Exemplo n.º 1
0
        private void LoadTemplates(Maestro.Base.Services.NewItemTemplateService.TemplateSet templSet)
        {
            lstTemplates.Clear();
            tplImgList.Images.Clear();
            lstTemplates.Groups.Clear();

            lstTemplates.SmallImageList = tplImgList;
            lstTemplates.LargeImageList = tplImgList;

            Dictionary<string, ListViewGroup> groups = new Dictionary<string, ListViewGroup>();
            foreach (var cat in templSet.GetCategories())
            {
                var grp = new ListViewGroup();
                grp.Name = cat;
                grp.Header = cat;

                lstTemplates.Groups.Add(grp);

                groups.Add(cat, grp);
            }
            foreach (var cat in templSet.GetCategories())
            {
                tplImgList.Images.Add(Properties.Resources.document);
                foreach (var tpl in templSet.GetTemplatesForCategory(cat))
                {
                    //This is to weed out resource types not supported by the current connection
                    //we're working with
                    if (!_conn.Capabilities.IsSupportedResourceType(tpl.ResourceType))
                        continue;

                    var li = new ListViewItem();
                    li.Name = tpl.Name;
                    li.Text = tpl.Name;
                    li.ToolTipText = tpl.Description;

                    if (tpl.Icon == null)
                    {
                        li.ImageIndex = 0;
                    }
                    else
                    {
                        tplImgList.Images.Add(tpl.Icon);
                        li.ImageIndex = tplImgList.Images.Count - 1;
                    }

                    li.Tag = tpl;

                    li.Group = groups[cat];

                    lstTemplates.Items.Add(li);
                }

            }
        }