Exemple #1
0
        public TemplateTreeItemViewModel(TemplateTreeItemViewModel parent = null)
        {
            Parent = parent;

            Text     = String.Empty;
            Children = new ObservableCollection <TemplateTreeItemViewModel>();

            isSelected = false;
            IsExpanded = false;
        }
Exemple #2
0
        private List <TemplateTreeItemViewModel> LoadAsync()
        {
            var returnList       = new List <TemplateTreeItemViewModel>();
            var folderDictionary = new Dictionary <string, TemplateTreeItemViewModel>();

            foreach (Template template in  templateSource.Load())
            {
                string folderName = "";
                TemplateTreeItemViewModel folder = null;
                if (!String.IsNullOrEmpty(template.Path))
                {
                    foreach (string pathSection in  template.Path.Split('.'))
                    {
                        folderName += pathSection;

                        if (!folderDictionary.ContainsKey(folderName))
                        {
                            folderDictionary[folderName] = new TemplateTreeItemViewModel(pathSection, folder);
                            if (folder == null)
                            {
                                returnList.Add(folderDictionary[folderName]);
                            }
                            else
                            {
                                folder.Children.Add(folderDictionary[folderName]);
                            }
                        }


                        folder = folderDictionary[folderName];

                        folderName += ".";
                    }
                }
                folderName += template.Name;
                if (folderDictionary.ContainsKey(folderName))
                {
                    folderDictionary[folderName].Template = template;
                }
                else
                {
                    var viewModel = new TemplateTreeItemViewModel(template, folder);
                    if (folder != null)
                    {
                        folder.Children.Add(viewModel);
                    }
                    else
                    {
                        folderDictionary.Add(folderName, viewModel);
                        returnList.Add(viewModel);
                    }
                }
            }
            return(returnList);
        }
Exemple #3
0
 public TemplateTreeItemViewModel(Template template, TemplateTreeItemViewModel parent) : this(parent)
 {
     Template    = template;
     Text        = template.Name;
     ToolTipText = template.Description;
 }
Exemple #4
0
 public TemplateTreeItemViewModel(string name, TemplateTreeItemViewModel parent = null) : this(parent)
 {
     Text       = name;
     IsExpanded = Text.Contains("Samples");
 }