public async Task NewFolderAsync() { var categoryPaths = GetAllCategoryPaths(this); var dialog = new NewCategoryViewModel(this.categoryPath, categoryPaths); if (await dialog.ShowDialogAsync() != true) { return; } var categoryName = new CategoryName(this.categoryPath, dialog.CategoryName); var viewModel = new CategoryTreeViewItemViewModel(this.dataSet, categoryName.Path, this.selector) { Parent = this, }; this.IsExpanded = true; viewModel.IsSelected = true; }
public async Task RenameAsync() { var categoryPaths = CategoryTreeViewItemViewModel.GetAllCategoryPaths(this); var dialog = new RenameCategoryViewModel(this.categoryPath, categoryPaths); if (await dialog.ShowDialogAsync() != true) { return; } var categoryName = new CategoryName(this.categoryPath) { Name = dialog.NewName, }; //for (var i = 0; i < categoryPaths.Length; i++) //{ // var categoryPath = categoryPaths[i]; // if (categoryPath.StartsWith(this.categoryPath) == true) // { // categoryPaths[i] = categoryName.Path + categoryPath.Substring(this.categoryPath.Length); // } //} //foreach (var item in this.dataSet.Tables) //{ // var categoryPath = item.CategoryPath; // if (categoryPath.StartsWith(this.categoryPath) == true) // { // item.CategoryPath = categoryName.Path + categoryPath.Substring(this.categoryPath.Length); // } //} this.categoryPath = categoryName.Path; this.categoryName = categoryName.Name; this.Refresh(); if (this.selector != null) { this.selector.SelectedItem = this; } }
public async Task MoveAsync() { var dataSet = this.dataTable.DataSet; var categoryPaths = CategoryTreeViewItemViewModel.GetAllCategoryPaths(this); var dialog = new MoveViewModel(this.dataTable.CategoryPath + this.dataTable.Name, categoryPaths); if (await dialog.ShowDialogAsync() != true) { return; } var targetViewModel = FindCategory(dialog.TargetPath); this.Parent = null; this.Parent = targetViewModel; if (this.selector != null) { this.ExpandAncestors(); } }