/// <summary> /// Select File Node /// </summary> /// <param name="pni"></param> void lucSolutionExplorer_SelectFileNode(PropertyNodeItem pni) { if (this.DocumentHost.Items.Count > 0) { foreach (Control c in this.DocumentHost.Items) { if (((ucBaseDocument)c).DocPath != null && ((ucBaseDocument)c).DocPath.ToLower() == pni.Value.ToLower()) { ((ucBaseDocument)c).Activate(); return; } } } if (File.Exists(pni.Value)) { FileInfo finfo = new FileInfo(pni.Value); ucBaseDocument doc = new ucBaseDocument(); doc.DocExt = finfo.Extension; doc.DocPath = pni.Value; doc.DocType = DocumentType.CodeDocument; doc.DocChanged = false; doc.Title = finfo.Name; TextEditor tb = new TextEditor(); tb.IsReadOnly = true; tb.SyntaxHighlighting = tb.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(finfo.Extension); tb.Load(pni.Value); doc.Content = tb; doc.LoadProperties(this.lucDocumentProperties); this.DocumentHost.Items.Add(doc); doc.Activate(); } }
/// <summary> /// /// </summary> /// <param name="projectPath"></param> public void LoadFiles(string projectPath) { TreeViewTools.SelectObject(this.tvObjects, this.RootNode); objectTree = new List <PropertyNodeItem>(); if (File.Exists(projectPath)) { FileInfo info = new FileInfo(projectPath); if (info.Extension.ToLower() == ".sln") { LoadSolution(projectPath, info); } if (info.Extension.Contains("proj")) { FileInfo pinfo = new FileInfo(projectPath); PropertyNodeItem prj = new PropertyNodeItem(); prj.DisplayName = pinfo.Name.Replace(pinfo.Extension, string.Empty); prj.Value = projectPath; prj.Icon = @"images/Proj.png"; objectTree.Add(prj); RootNode = prj; LoadProjs(projectPath, prj); } this.tvObjects.ItemsSource = objectTree; } }
/// <summary> /// /// </summary> /// <param name="projNode"></param> /// <param name="selectedNode"></param> /// <returns></returns> public string GetFloderPathToProj(PropertyNodeItem projNode, PropertyNodeItem selectedNode) { if (File.Exists(selectedNode.Value)) { FileInfo finfo = new FileInfo(selectedNode.Value); if (finfo.Directory.Name == projNode.DisplayName) { return(@"\" + finfo.Directory.Name); } else { return(GetFloderPathToProj(projNode, selectedNode.Parent) + @"\" + finfo.Directory.Name); } } if (Directory.Exists(selectedNode.Value)) { DirectoryInfo finfo = new DirectoryInfo(selectedNode.Value); if (finfo.Name == projNode.DisplayName) { return(@"\" + finfo.Name); } else { return(GetFloderPathToProj(projNode, selectedNode.Parent) + @"\" + finfo.Name); } } return(string.Empty); }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="i"></param> private void GetFiles(string path, PropertyNodeItem i) { DirectoryInfo di = new DirectoryInfo(path); FileInfo[] fis = di.GetFiles(); int count = 0; foreach (FileInfo info in fis) { if (info.Extension.ToLower() == ".tt") { PropertyNodeItem subn = new PropertyNodeItem(); subn.Icon = @"images\file-manager.png"; subn.DisplayName = info.Name; subn.Value = info.FullName; i.Children.Add(subn); count++; } } if (count == 0 && i.Icon == null) { i.Icon = @"Images\FolderClosed.png"; } else { i.Icon = @"Images\FolderOpen.png"; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoadTemplate_Click(object sender, RoutedEventArgs e) { //OpenFileDialog dlg = new OpenFileDialog(); if (folderBrowserDialog == null) { folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); folderBrowserDialog.SelectedPath = AppDomain.CurrentDomain.BaseDirectory; } folderBrowserDialog.Description = "Select an folder, and load all templates below it."; System.Windows.Forms.DialogResult dr = folderBrowserDialog.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { List <PropertyNodeItem> itemList = new List <PropertyNodeItem>(); if (Directory.Exists(folderBrowserDialog.SelectedPath)) { DirectoryInfo di = new DirectoryInfo(folderBrowserDialog.SelectedPath); PropertyNodeItem rootn = new PropertyNodeItem(); rootn.DisplayName = di.Name; rootn.Value = folderBrowserDialog.SelectedPath; // this.tvTemplates.GetItemFromObject(rootn).IsExpanded = true; GetFolders(folderBrowserDialog.SelectedPath, rootn); itemList.Add(rootn); } this.tvTemplates.ItemsSource = itemList; } //MessageBox.Show(dialog.SelectedPath); }
/// <summary> /// /// </summary> /// <param name="folderPath"></param> /// <param name="Last"></param> private void LoadFolder(string folderPath, PropertyNodeItem Last) { DirectoryInfo dinfo = new DirectoryInfo(folderPath); DirectoryInfo[] dList = dinfo.GetDirectories(); if (dList != null) { foreach (DirectoryInfo di in dList) { PropertyNodeItem d = new PropertyNodeItem(); d.DisplayName = di.Name; d.Value = di.FullName; d.Icon = @"images/Folder.png"; d.Parent = Last; Last.Children.Add(d); LoadFolder(di.FullName, d); } } FileInfo[] fList = dinfo.GetFiles(); if (fList != null) { foreach (FileInfo fi in fList) { PropertyNodeItem f = new PropertyNodeItem(); f.DisplayName = fi.Name; f.Value = fi.FullName; f.Icon = @"images/code.png"; f.Parent = Last; Last.Children.Add(f); } } }
private void btnGenerate_Click(object sender, RoutedEventArgs e) { if (this.listRightTables.Items.Count == 0) { MessageBox.Show("Please select object(s)"); return; } if (this.txtNameSpaceRoot.Text.Trim().Length == 0) { MessageBox.Show("Please input root Namespace"); this.txtNameSpaceRoot.Focus(); return; } if (this.tvTemplates.SelectedItem == null) { MessageBox.Show("Please select template package or template."); return; } if (!Directory.Exists(this.txtExportPath.Text + @"\" + this.cboxDatabases.Text)) { Directory.CreateDirectory(this.txtExportPath.Text + @"\" + this.cboxDatabases.Text); } PropertyNodeItem sn = (PropertyNodeItem)this.tvTemplates.SelectedItem; this.proCount = 0; this.pbarBatchGenerate.Maximum = totalCount; this.pbarBatchGenerate.Minimum = 0; this.pbarBatchGenerate.Value = 0; updatePbDelegate = new UpdateProgressBarDelegate(pbarBatchGenerate.SetValue); //Start to Generate Codes GenerateByTreeNode(sn); Process.Start("explorer.exe", this.txtExportPath.Text); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvObjects_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { CurSelectedNode = (PropertyNodeItem)tvObjects.SelectedItem; if (CurSelectedNode.DisplayName != "Tables" && CurSelectedNode.DisplayName != "Views" && CurSelectedNode.DisplayName != this.cboxDatabases.Text) { List <CustomProperty> pniList = new List <CustomProperty>(); CustomProperty conn = new CustomProperty(); conn.Name = "ConnectionStr"; conn.Value = this.connector.dbHelper.SqlConnectionString; pniList.Add(conn); CustomProperty nspace = new CustomProperty(); nspace.Name = "NameSpace"; nspace.Value = this.cboxDatabases.Text; pniList.Add(nspace); CustomProperty tName = new CustomProperty(); tName.Name = "TableName"; tName.Value = CurSelectedNode.DisplayName; pniList.Add(tName); if (SelectServerObject != null && pniList.Count > 0) { SelectServerObject(pniList); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvTemplates_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { CurSelectedNode = (PropertyNodeItem)tvTemplates.SelectedItem; if (SelectTemplateNode != null && File.Exists(CurSelectedNode.Value)) { SelectTemplateNode(CurSelectedNode.Value, CurSelectedNode.DisplayName); } }
/// <summary> /// / /// </summary> /// <param name="n"></param> /// <returns></returns> private string GetPath(PropertyNodeItem n) { if (n.Value == CurSelectedNode.Value) { return(n.DisplayName); } else { return(GetPath(n.Parent) + @"\" + n.DisplayName); } }
/// <summary> /// ss /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvObjects_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (tvObjects.SelectedItem != null) { CurSelectedNode = (PropertyNodeItem)tvObjects.SelectedItem; this.CurProject = GetProjectNode(this.CurSelectedNode); if (SelectFileNode != null && File.Exists(CurSelectedNode.Value) && this.CurProject != null && this.CurProject.Value != CurSelectedNode.Value && CurSelectedNode.Parent != null) { SelectFileNode(CurSelectedNode); } } }
/// <summary> /// /// </summary> /// <param name="tn"></param> private void CreateTopDirectory(PropertyNodeItem sn) { if (sn.Parent != null && sn.Parent.DisplayName != "Templates") { if (!Directory.Exists(this.txtExportPath.Text + @"\" + this.cboxDatabases.Text + @"\" + GetFolder(sn.Parent).Replace("Templates", string.Empty))) { CreateTopDirectory(sn.Parent); } else { Directory.CreateDirectory(this.txtExportPath.Text + @"\" + this.cboxDatabases.Text + @"\" + GetFolder(sn).Replace("Templates", string.Empty)); } } }
/// <summary> /// /// </summary> /// <param name="tn"></param> /// <returns></returns> private string GetNamespace(PropertyNodeItem sn) { if (sn.Parent == null) { return(string.Empty); } else if (sn.Children.Count == 0) { return(GetPath(sn.Parent)); } else { return(GetPath(sn.Parent) + @"." + sn.DisplayName); } }
/// <summary> /// / /// </summary> /// <param name="n"></param> /// <returns></returns> private string GetFolder(PropertyNodeItem n) { if (n.Parent.Value == CurSelectedNode.Value) { return(string.Empty); } else if (n.Children.Count == 0) { return(this.GetPath(n.Parent)); } else { return(GetPath(n.Parent) + @"\" + n.DisplayName); } }
private void LoadTemplates() { if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Templates\")) { List <PropertyNodeItem> itemList = new List <PropertyNodeItem>(); if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Templates\")) { DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Templates\"); PropertyNodeItem rootn = new PropertyNodeItem(); rootn.DisplayName = di.Name; rootn.Value = AppDomain.CurrentDomain.BaseDirectory + @"\Templates\"; GetFolders(AppDomain.CurrentDomain.BaseDirectory + @"\Templates\", rootn); itemList.Add(rootn); } this.tvTemplates.ItemsSource = itemList; } }
/// <summary> /// /// </summary> /// <param name="filePath"></param> private void LoadProjs(string filePath, PropertyNodeItem proj) { FileInfo finfo = new FileInfo(filePath); System.Text.RegularExpressions.MatchCollection ma = System.Text.RegularExpressions.Regex.Matches(File.ReadAllText(filePath), @"(\<Compile Include="").*("" /\>)", RegexOptions.Multiline); foreach (Match item in ma) { if (item.Success) { int length = item.Value.Length; string tmp = item.Value.Substring(18, length - 22); string fPath = finfo.Directory.FullName + @"\" + tmp; int fIndex = tmp.IndexOf(@"\"); if (fIndex > 0) { string fp = finfo.Directory.FullName + @"\" + tmp.Substring(0, fIndex); if (Directory.Exists(fp)) { DirectoryInfo dinfo = new DirectoryInfo(fp); PropertyNodeItem d = new PropertyNodeItem(); d.DisplayName = tmp.Substring(0, fIndex); d.Value = fp; d.Icon = @"images/Folder.png"; d.Parent = proj; proj.Children.Add(d); LoadFolder(fp, d); } } else { if (File.Exists(fPath)) { FileInfo pinfo = new FileInfo(fPath); PropertyNodeItem f = new PropertyNodeItem(); f.DisplayName = tmp; f.Value = fPath; f.Icon = @"images/code.png"; f.Parent = proj; proj.Children.Add(f); } } } } }
/// <summary> /// /// </summary> /// <param name="pni"></param> /// <returns></returns> private PropertyNodeItem GetProjectNode(PropertyNodeItem pni) { if (pni.Parent == null && pni.Value.IndexOf("proj") > 0) { return(pni); } if (pni.Parent == null && pni.Value.IndexOf("proj") < 0) { return(null); } if (pni.Parent.Parent == null && pni.Value.IndexOf("proj") > 0) { return(pni); } else { return(GetProjectNode(pni.Parent)); } }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="i"></param> private void GetFolders(string path, PropertyNodeItem i) { string[] folders = Directory.GetDirectories(path); GetFiles(path, i); if (folders.Length > 0) { i.Icon = @"Images\FolderOpen.png"; foreach (string folder in folders) { DirectoryInfo di = new DirectoryInfo(folder); PropertyNodeItem subn = new PropertyNodeItem(); subn.DisplayName = di.Name; subn.Value = path + @"\" + di.Name; i.Children.Add(subn); GetFolders(folder, subn); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { if (this.tvTemplates.SelectedItem != null) { PropertyNodeItem sn = (PropertyNodeItem)this.tvTemplates.SelectedItem; ZipHelper zip = new ZipHelper(); zip.FileNameZipped = sn.Value; folderBrowserDialog.ShowDialog(); if (!string.IsNullOrEmpty(folderBrowserDialog.SelectedPath)) { zip.UnZipFile(sn.Value, folderBrowserDialog.SelectedPath, string.Empty); Process.Start("explorer.exe", folderBrowserDialog.SelectedPath); this.Close(); } } else { MessageBox.Show("Please select a template."); return; } }
/// <summary> /// /// </summary> private void LoadTemplates() { if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\SolutionTemplates\")) { List <PropertyNodeItem> itemList = new List <PropertyNodeItem>(); string[] files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + @"\SolutionTemplates\"); foreach (string f in files) { FileInfo fi = new FileInfo(f); if (fi.Extension.ToLower() == ".zip") { PropertyNodeItem pn = new PropertyNodeItem(); pn.DisplayName = fi.Name; pn.Value = fi.FullName; pn.Icon = @"Images\SolutionTemplate.png"; itemList.Add(pn); } } this.tvTemplates.ItemsSource = itemList; } }
/// <summary> /// /// </summary> /// <param name="tn"></param> private void GenerateByTreeNode(PropertyNodeItem sn) { foreach (PropertyNodeItem n in sn.Children) { if (n.Children.Count == 0) { //UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(this.pbarBatchGenerate.SetValue); BatchGenerate(n); //Dispatcher.Invoke(updatePbDelegate, //System.Windows.Threading.DispatcherPriority.Background, //new object[] { ProgressBar.ValueProperty, proCount }); } else { string tmpDir = this.txtExportPath.Text + @"\" + this.cboxDatabases.Text + @"\" + this.GetFolder(n); if (!System.IO.Directory.Exists(tmpDir)) { Directory.CreateDirectory(tmpDir); } GenerateByTreeNode(n); } } }
/// <summary> /// /// </summary> /// <param name="filePath"></param> /// <param name="info"></param> private void LoadSolution(string filePath, FileInfo info) { PropertyNodeItem sln = new PropertyNodeItem(); sln.DisplayName = info.Name.Replace(info.Extension, string.Empty); sln.Value = info.FullName; sln.Icon = @"images/Solution.png"; objectTree.Add(sln); RootNode = sln; System.Text.RegularExpressions.MatchCollection ma = System.Text.RegularExpressions.Regex.Matches(File.ReadAllText(filePath), @"(\}""\) = "").*("", ""\{)", RegexOptions.Multiline); List <string> pnList = new List <string>(); foreach (Match item in ma) { if (item.Success) { string tmp = item.Value.Substring(7).Replace(@"""", ""); string[] strList = tmp.Split(','); if (strList != null && strList.Length == 3) { string projPath = GetRealPath(info.Directory.FullName, strList[1].Trim()); //info.Directory + @"\" + strList[1]; if (File.Exists(projPath)) { FileInfo pinfo = new FileInfo(projPath); PropertyNodeItem prj = new PropertyNodeItem(); prj.DisplayName = strList[0].Trim(); prj.Value = projPath; prj.Icon = @"images/Proj.png"; prj.Parent = sln; sln.Children.Add(prj); LoadProjs(projPath, prj); } } } } }
/// <summary> /// /// </summary> /// <param name="tn"></param> /// <returns></returns> private int GetTemplatesCount(PropertyNodeItem sn) { int count = 0; foreach (PropertyNodeItem n in sn.Children) { if (n.Children.Count == 0 && n.DisplayName.LastIndexOf(".tt") == n.DisplayName.Length - 3) { if (n.Parent.DisplayName == "Base" || n.DisplayName.ToLower().IndexOf("proj") == 0) { count++; } else { count += this.listRightTables.Items.Count; } } else { count += GetTemplatesCount(n); } } return(count); }
/// <summary> /// /// </summary> /// <param name="tempTreeNode"></param> private void BatchGenerate(PropertyNodeItem sn) { CreateTopDirectory(sn); string strTmp = GetNamespace(sn); for (int i = 0; i < this.listRightTables.Items.Count; i++) { try { TextTemplatingEngineHost host = new TextTemplatingEngineHost(); host.TemplateFileValue = AppDomain.CurrentDomain.BaseDirectory + @"\Templates\" + GetPath(sn); Engine engine = new Engine(); host.Session = new TextTemplatingSession(); string inputTemplate = File.ReadAllText(host.TemplateFileValue); string oName = this.listRightTables.Items[i].ToString(); Parameter connStrparameter = new Parameter() { Text = "ConnectionStr", Value = dbHelper.SqlConnectionString }; host.Session.Add("ConnectionStr", connStrparameter); Parameter nameSpaceParameter = new Parameter() { Text = "NameSpace", Value = this.txtNameSpaceRoot.Text }; //+ strTmp.Replace("Templates." + this.CurSelectedNode.DisplayName, string.Empty) host.Session.Add("NameSpace", nameSpaceParameter); Parameter tableNameParameter = new Parameter() { Text = "TableName", Value = oName.Substring(2) }; host.Session.Add("TableName", tableNameParameter); if ((oName.Substring(0, 1) == "T" && sn.DisplayName.Substring(2, 1) != "T" && sn.DisplayName.Substring(2, 1) != "A" && sn.DisplayName.Substring(2, 1) != "N") || (oName.Substring(0, 1) == "V" && sn.DisplayName.Substring(2, 1) != "V" && sn.DisplayName.Substring(2, 1) != "A" && sn.DisplayName.Substring(2, 1) != "N") ) { continue; } string strCodes = engine.ProcessTemplate(inputTemplate, host); string filefullname = string.Empty;// this.txtExportPath.Text + @"\" + this.cboxDatabases.Text + @"\" + GetFolder(sn).Replace("Templates", string.Empty) + @"\" + this.listRightTables.Items[i].ToString() + "." + this.GetOutputExtension(inputTemplate); if (sn.DisplayName.Substring(2, 1) == "N") { filefullname = this.txtExportPath.Text + @"\" + this.cboxDatabases.Text + @"\" + GetFolder(sn).Replace("Templates", string.Empty) + @"\" + sn.DisplayName.Substring(4, sn.DisplayName.Length - 7) + "." + this.GetOutputExtension(inputTemplate); } else { filefullname = this.txtExportPath.Text + @"\" + this.cboxDatabases.Text + @"\" + GetFolder(sn).Replace("Templates", string.Empty) + @"\" + this.listRightTables.Items[i].ToString().Substring(2) + sn.DisplayName.Substring(4, sn.DisplayName.Length - 7) + "." + this.GetOutputExtension(inputTemplate); } if (string.IsNullOrEmpty(filefullname)) { return; } FileStream fs; if (!File.Exists(filefullname)) { fs = new FileStream(filefullname, FileMode.Create); } else { fs = new FileStream(filefullname, FileMode.Open); } StreamWriter sw = new StreamWriter(fs); sw.WriteLine(strCodes); sw.Close(); fs.Close(); if (sn.DisplayName.Substring(0, 1) == "1") { break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } proCount += 1; if (this.pbarBatchGenerate.Value != pbarBatchGenerate.Maximum) { Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, proCount }); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvTemplates_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { this.CurSelectedNode = (PropertyNodeItem)this.tvTemplates.SelectedItem; }
/// <summary> /// /// </summary> /// <param name="tempTreeNode"></param> private void BaseGenerate(PropertyNodeItem sn) { try { CreateTopDirectory(sn); string strTmp = GetNamespace(sn); TextTemplatingEngineHost host = new TextTemplatingEngineHost(); host.TemplateFileValue = AppDomain.CurrentDomain.BaseDirectory + @"\Templates\" + GetPath(sn); Engine engine = new Engine(); host.Session = new TextTemplatingSession(); string inputTemplate = File.ReadAllText(host.TemplateFileValue); Parameter connStrparameter = new Parameter() { Text = "ConnectionStr", Value = dbHelper.SqlConnectionString }; host.Session.Add("ConnectionStr", connStrparameter); Parameter nameSpaceParameter = new Parameter() { Text = "NameSpace", Value = this.txtNameSpaceRoot.Text + strTmp.Replace("Templates." + this.CurSelectedNode.DisplayName, string.Empty) }; host.Session.Add("NameSpace", nameSpaceParameter); Parameter tableNameParameter = new Parameter() { Text = "TableName", Value = string.Empty }; host.Session.Add("TableName", tableNameParameter); string strCodes = engine.ProcessTemplate(inputTemplate, host); string filefullname = this.txtExportPath.Text + @"\" + this.cboxDatabases.Text + @"\" + GetFolder(sn).Replace("Templates", string.Empty) + @"\" + sn.DisplayName.Trim().Replace(".tt", string.Empty) + "." + this.GetOutputExtension(inputTemplate); if (string.IsNullOrEmpty(filefullname)) { return; } FileStream fs; if (!File.Exists(filefullname)) { fs = new FileStream(filefullname, FileMode.Create); } else { fs = new FileStream(filefullname, FileMode.Open); } StreamWriter sw = new StreamWriter(fs); sw.WriteLine(strCodes); sw.Close(); fs.Close(); ++proCount; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// /// </summary> private void LoadTables() { System.Text.RegularExpressions.MatchCollection ma = System.Text.RegularExpressions.Regex.Matches(connector.dbHelper.SqlConnectionString, @"Database=.*?;"); string databaseName = string.Empty; foreach (Match item in ma) { if (item.Success) { databaseName = item.Value.Replace("Database=", string.Empty).Replace(";", string.Empty); break; } } if (databaseName == string.Empty) { connector.dbHelper.SqlConnectionString = connector.dbHelper.SqlConnectionString.Replace("Database=;", "Database=" + this.cboxDatabases.SelectedItem.ToString() + ";"); } else { connector.dbHelper.SqlConnectionString = connector.dbHelper.SqlConnectionString.Replace(databaseName, cboxDatabases.SelectedItem.ToString()); } List <PropertyNodeItem> niList = new List <PropertyNodeItem>(); PropertyNodeItem sRoot = new PropertyNodeItem(); sRoot.Icon = @"images/display.png"; sRoot.DisplayName = this.cboxDatabases.SelectedItem.ToString(); sRoot.Value = "@ServerRootNode"; niList.Add(sRoot); DataTable tList = connector.dbHelper.GetTables(); PropertyNodeItem tRoot = new PropertyNodeItem(); tRoot.Icon = @"images/Table.png"; tRoot.DisplayName = "Tables"; tRoot.Value = "@TableRootNode"; sRoot.Children.Add(tRoot); foreach (DataRow r in tList.Rows) { PropertyNodeItem i = new PropertyNodeItem(); i.Icon = @"images/Table.png"; i.DisplayName = r["Name"].ToString(); i.Value = "@TableNode"; tRoot.Children.Add(i); } DataTable vList = connector.dbHelper.GetViews(); PropertyNodeItem vRoot = new PropertyNodeItem(); vRoot.Icon = @"images/View.png"; vRoot.DisplayName = "Views"; vRoot.Value = "@ViewRootNode"; sRoot.Children.Add(vRoot); foreach (DataRow r in vList.Rows) { PropertyNodeItem i = new PropertyNodeItem(); i.Icon = @"images/View.png"; i.DisplayName = r["Name"].ToString(); i.Value = "@ViewNode"; vRoot.Children.Add(i); } this.tvObjects.ItemsSource = niList; this.tvObjects.GetItemFromObject(sRoot).IsExpanded = true; }