Exemplo n.º 1
0
        private void InitializeTemplates()
        {
            if (!Directory.Exists(ProjectTemplatesPath))
            {
                return;
            }

            var templates = new List <TemplateInfo>();

            foreach (var path in Directory.GetFiles(ProjectTemplatesPath, "*.xml"))
            {
                try
                {
                    var templateInfo = new TemplateInfo();
                    templateInfo.Load(path);
                    templates.Add(templateInfo);
                }
                catch (Exception ex)
                {
                    Messenger.Default.Send(new ShowMessageBoxMessage(this, String.Format("Error in Loading {0}", path)));
                    Messenger.Default.Send(new ShowMessageBoxMessage(this, ex.Message));
                }
            }

            foreach (var template in templates)
            {
                var nodes = Root.Children;
                TreeNodeViewModel <TemplateInfo> lastNode = null;
                foreach (var split in template.Type.Split('\\'))
                {
                    var foundNode = nodes.FirstOrDefault(n => n.Text == split);
                    if (foundNode == null)
                    {
                        foundNode = new TreeNodeViewModel <TemplateInfo>
                        {
                            Text = split
                        };
                        nodes.Add(foundNode);
                    }
                    lastNode = foundNode;
                    nodes    = foundNode.Children;
                }
                if (lastNode != null)
                {
                    var node = new TreeNodeViewModel <TemplateInfo>
                    {
                        Text  = template.Name,
                        Value = template
                    };
                    lastNode.Children.Add(node);
                }
            }
            if (Root.Children.Count > 0)
            {
                Root.Children[0].IsExpanded = true;
                Root.Children[0].IsSelected = true;
                UpdateListView(Root.Children[0]);
            }
        }
Exemplo n.º 2
0
 private void UpdateListView(TreeNodeViewModel <TemplateInfo> selectedTreeNode)
 {
     Templates.Clear();
     foreach (var value in selectedTreeNode.Values)
     {
         Templates.Add(new ListViewModel <TemplateInfo>
         {
             Value = value
         });
     }
     if (Templates.Count > 0)
     {
         Templates[0].IsSelected = true;
     }
 }
Exemplo n.º 3
0
 public NewProjectWindowViewModel(LanguageReader languageReader)
 {
     TranslateExtension.Language = languageReader;
     Templates = new ObservableCollection <ListViewModel <TemplateInfo> >();
     Root      = new TreeNodeViewModel <TemplateInfo>();
 }