/// <summary> /// 在将要展开节点时 加载子节点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void treeSourcePath_BeforeExpand(object sender, TreeViewCancelEventArgs e) { //01 加载子节点 TreeViewItems.Add(e.Node); //curFilePath = e.Node.Name; dt.Rows.Clear(); //02 加载文件到DataGridView if (e.Node.Tag.ToString() != "This PC") { // e.Node.Nodes.Clear(); TreeNode tNode = e.Node; string path = tNode.Name; if (e.Node.Tag.ToString() == "Documents") { path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } curFilePath = path; //MessageBox.Show(curFilePath); foreach (var file in Directory.GetFiles(path, "*.*", e.Node.Level > 1 ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)) { FileInfo fileInfo = new FileInfo(file); addToDtRow(dt, fileInfo); } dgvResult.DataSource = dt; } }
internal void RefreshValues() { if (!DispatcherHelper.UIDispatcher.CheckAccess()) { DispatcherHelper.RunAsync(RefreshValues); return; } if (!ViewModelLocator.GameLoader.ValidGame) { TreeViewItems.Clear(); return; } var path = ViewModelLocator.GameLoader.GamePath; var di = new DirectoryInfo(path); foreach (var d in di.GetDirectories().OrderBy(x => x.Name)) { if (!object.Equals((d.Attributes & FileAttributes.System), FileAttributes.System) && !object.Equals((d.Attributes & FileAttributes.Hidden), FileAttributes.Hidden)) { TreeViewItems.Add(new AssetTreeViewItemViewModel(d)); } } foreach (var f in di.GetFiles().OrderBy(x => x.Name)) { TreeViewItems.Add(new AssetTreeViewItemViewModel(f)); } }
void Display(NodeVm rootNodeVm) { var tvis = rootNodeVm.ToTreeViewItem(); TreeViewItems.Clear(); TreeViewItems.Add(tvis); }
public Window1ViewModel() { var drives = Directory.GetLogicalDrives(); foreach (var drive in drives) { var treeItem = new TreeViewItemViewModel ( type: ItemModel.Types.Drive, fullpath: drive, isRoot: true ); treeItem.Expanded += TreeViewItem_Expanded; treeItem.Selected += TreeViewItem_Selected; TreeViewItems.Add(treeItem); var listItem = new ListViewItemViewModel ( type: ItemModel.Types.Drive, fullpath: drive, isRoot: true ); listItem.Selected += ListViewItem_Selected; ListViewItems.Add(listItem); } }
public void LoadTreeView() { TreeViewItems.Add(new PUTreeViewItemModel() { Header = "第一章", Value = "1", Items = new List <PUTreeViewItemModel>() { new PUTreeViewItemModel() { Header = "第一节", Value = "1.1", }, new PUTreeViewItemModel() { Header = "第二节", Value = "1.2", }, }, }); TreeViewItems.Add(new PUTreeViewItemModel() { Header = "第二章", Value = "2", Items = new List <PUTreeViewItemModel>() { new PUTreeViewItemModel() { Header = "第一节", Value = "2.1", }, new PUTreeViewItemModel() { Header = "第二节", Value = "2.2", }, }, }); TreeViewItems.Add(new PUTreeViewItemModel() { Header = "第三章", Value = "3", Items = new List <PUTreeViewItemModel>() { new PUTreeViewItemModel() { Header = "第一节", Value = "3.1", }, new PUTreeViewItemModel() { Header = "第二节", Value = "3.2", }, }, }); NotifyOfPropertyChange(() => TreeViewItems); }
/// <summary> /// Loads the content. /// </summary> /// <remarks>Documented by Dev08, 2009-07-18</remarks> private void LoadContent() { textBlockProgressBar.Text = string.Empty; progressBarLoad.IsIndeterminate = false; TreeViewItems.Add(new LearningModuleTreeViewItem(SettingsManagerLogic.LearningModule)); LearningModuleTreeViewItem item = TreeViewItems[0]; item.ContentLoaded += new EventHandler(ContentLoaded); item.ContentLoading += new LearningModuleTreeViewItem.ContentLoadingEventHandler(ContentLoading); item.LoadLearningModuleContent(); }
private void AddDatabaseToTree(string databasePath) { if (TreeViewItems.Any(x => x.DatabasePath.Equals(databasePath))) { return; } var schemaMapper = new SchemaToViewModelMapper(); var databaseItem = schemaMapper.MapSchemaToViewModel(databasePath); TreeViewItems.Add(databaseItem); log.Info("Opened database '" + databaseItem.DatabasePath + "'."); }
public void RefreshTree() { log.Info("Refreshing the database tree."); var databasePaths = TreeViewItems.Select(x => x.DatabasePath).ToList(); TreeViewItems.Clear(); var schemaMapper = new SchemaToViewModelMapper(); foreach (var path in databasePaths) { TreeViewItems.Add(schemaMapper.MapSchemaToViewModel(path)); } }
protected void OnIsExpandedChanged(bool oldValue) { if (IsExpanded) { try { TreeViewItems.Clear(); DirectoryInfo.EnumerateDirectories().ToList().ForEach(f => TreeViewItems.Add(Create(f))); } catch (UnauthorizedAccessException) { //无权限 } } }
private void SetVariant(int index) { TreeViewItems.Clear(); var variantName = AvailableLods.Skip(index).FirstOrDefault(); objectModel.SetVariant(variantName); foreach (var child in objectModel.Children.OfType <IMeshNode>()) { TreeViewItems.Add(new TreeItemModel { Header = child.Name, IsChecked = true, Tag = child }); } }
//================================================================================================================================================ // Delegate Command Methods //================================================================================================================================================ #region OnAddProject(object parameter) protected void OnAddProject(object parameter) { Project p = new Project(); Projects.Add(p); //Items.Add(p); NewProjectDialog npd = new NewProjectDialog(p); npd.ShowDialog(); TreeViewItem tvi = new TreeViewItem(); tvi.Header = p.Name; tvi.DataContext = p; TreeViewItems.Add(tvi); CurrentItem = tvi; }
public void AddItem() { TreeViewItems.Add(new PUTreeViewItemModel() { Header = "第" + (TreeViewItems.Count + 1) + "部分", Value = (TreeViewItems.Count + 1).ToString(), Items = new List <PUTreeViewItemModel>() { new PUTreeViewItemModel() { Header = "Value : " + (TreeViewItems.Count + 1) + "-1", Value = (TreeViewItems.Count + 1) + "-1", }, new PUTreeViewItemModel() { Header = "Value : " + (TreeViewItems.Count + 1) + "-2", Value = (TreeViewItems.Count + 1) + "-2", }, } }); }
private void AddRenderModelNodes <TParent, TChild>(IEnumerable <TParent> collection, Func <TParent, IEnumerable <TChild> > getChildren) where TParent : IMeshNode where TChild : IMeshNode { foreach (var parent in collection) { var parentNode = new TreeItemModel { Header = parent.Name, IsChecked = true, Tag = parent }; foreach (var child in getChildren(parent)) { var childNode = new TreeItemModel { Header = child.Name, IsChecked = true, Tag = child }; parentNode.Items.Add(childNode); } if (parentNode.HasItems) { TreeViewItems.Add(parentNode); } } }
private void directoryTree_BeforeExpand(object sender, TreeViewCancelEventArgs e) { TreeViewItems.Add(e.Node); }
protected void OnAddTool(object parameter) { if (CurrentItem != null) { if (CurrentItem.GetType() == typeof(TreeViewItem)) { TreeViewItem tvItem = (TreeViewItem)CurrentItem; Tool tool; Project tempProject = null; if (tvItem.DataContext.GetType() == typeof(Project)) { tempProject = (Project)tvItem.DataContext; tool = new Tool(tempProject); tempProject.Tools.Add(tool); } else { tool = new Tool(null); } NewToolDialog ntd = new NewToolDialog(tool); ntd.ShowDialog(); UpdateCurrentItem(); OnPropertyChanged("CurrentItem"); TreeViewItem tvi = new TreeViewItem(); tvi.Header = tool.Name; tvi.DataContext = tool; TreeViewItem tvi_ = null; if (tempProject != null) { tvi_ = TreeViewItems.Where(x => x.Header.ToString() == tempProject.Name).FirstOrDefault(); } if (tvi_ != null) { tvi_.Items.Add(tvi); } else { TreeViewItems.Add(tvi); } Tools.Add(tool); CurrentItem = tvi; } } else { Tool tool = new Tool(); //object tool = new object(); NewToolDialog ntd = new NewToolDialog(tool); ntd.ShowDialog(); UpdateCurrentItem(); OnPropertyChanged("CurrentItem"); TreeViewItem tvi = new TreeViewItem(); tvi.Header = tool.Name; tvi.DataContext = tool; //Items.Add(tool); TreeViewItems.Add(tvi); Tools.Add(tool); CurrentItem = tvi; } }
private void SetLod(int index) { model = geometry.ReadGeometry(index); var meshes = GetMeshes(model).ToList(); TreeViewItems.Clear(); modelGroup.Children.Clear(); foreach (var region in model.Regions) { var regNode = new TreeItemModel { Header = region.Name, IsChecked = true }; foreach (var perm in region.Permutations) { var mesh = meshes.ElementAtOrDefault(perm.MeshIndex); if (mesh == null || perm.MeshCount <= 0) { continue; } var permNode = new TreeItemModel { Header = perm.Name, IsChecked = true }; regNode.Items.Add(permNode); var tGroup = new Transform3DGroup(); if (perm.TransformScale != 1) { var tform = new ScaleTransform3D(perm.TransformScale, perm.TransformScale, perm.TransformScale); tform.Freeze(); tGroup.Children.Add(tform); } if (!perm.Transform.IsIdentity) { var tform = new MatrixTransform3D(new Matrix3D { M11 = perm.Transform.M11, M12 = perm.Transform.M12, M13 = perm.Transform.M13, M21 = perm.Transform.M21, M22 = perm.Transform.M22, M23 = perm.Transform.M23, M31 = perm.Transform.M31, M32 = perm.Transform.M32, M33 = perm.Transform.M33, OffsetX = perm.Transform.M41, OffsetY = perm.Transform.M42, OffsetZ = perm.Transform.M43 }); tform.Freeze(); tGroup.Children.Add(tform); } Model3DGroup permGroup; if (tGroup.Children.Count == 0 && perm.MeshCount == 1) { permGroup = meshes[perm.MeshIndex]; } else { permGroup = new Model3DGroup(); for (int i = 0; i < perm.MeshCount; i++) { if (tGroup.Children.Count > 0) { (permGroup.Transform = tGroup).Freeze(); permGroup.Children.Add(meshes[perm.MeshIndex + i]); permGroup.Freeze(); } else { permGroup.Children.Add(meshes[perm.MeshIndex + i]); } } } permNode.Tag = new MeshTag(permGroup, perm); modelGroup.Children.Add(permGroup); } if (regNode.HasItems) { TreeViewItems.Add(regNode); } } renderer.ScaleToContent(new[] { modelGroup }); }