Beispiel #1
0
        public void Rename()
        {
            var categoryPaths = this.dataSet.ExtendedProperties[CremaSchema.TypeDirectory] as string[];
            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.Types)
            {
                var categoryPath = item.CategoryPath;
                if (categoryPath.StartsWith(this.categoryPath) == true)
                {
                    item.CategoryPath = categoryName.Path + categoryPath.Substring(this.categoryPath.Length);
                }
            }

            this.dataSet.ExtendedProperties[CremaSchema.TypeDirectory] = categoryPaths;
            this.categoryPath = categoryName.Path;
            this.categoryName = categoryName.Name;
            this.Refresh();
            if (this.selector != null)
            {
                this.selector.SelectedItem = this;
            }
        }
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;
            }
        }