Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
0
        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();
            }
        }