Beispiel #1
0
        public void NewFolder()
        {
            var categoryPaths = GetAllCategoryPaths(this);
            var dialog        = new NewCategoryViewModel(this.categoryPath, categoryPaths);

            if (dialog.ShowDialog() != 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;
        }
Beispiel #2
0
        public void Rename()
        {
            var categoryPaths = CategoryTreeViewItemViewModel.GetAllCategoryPaths(this);
            var dialog        = new RenameCategoryViewModel(this.categoryPath, categoryPaths);

            if (dialog.ShowDialog() != 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 void Move()
        {
            var dataSet       = this.dataTable.DataSet;
            var categoryPaths = CategoryTreeViewItemViewModel.GetAllCategoryPaths(this);
            var dialog        = new MoveViewModel(this.dataTable.CategoryPath + this.dataTable.Name, categoryPaths);

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            var targetViewModel = FindCategory(dialog.TargetPath);

            this.Parent = null;
            this.Parent = targetViewModel;

            if (this.selector != null)
            {
                this.ExpandAncestors();
            }
        }