/// <summary>
        /// 修改或新添标签标注
        /// </summary>
        /// <param name="path">标注路径</param>
        /// <param name="isNew">是否是新建</param>
        public static void AllOrEditTag(string path, bool isNew)
        {
            SelectTagWindow window       = new SelectTagWindow();
            bool?           dialogResult = window.ShowDialog();

            if (dialogResult == true)
            {
                TagBean tagBean = window.tagBean;
                if (tagBean.Id == 0)
                {
                    DirTagMapper.DeleteOneByPath(path);
                }
                if (isNew)
                {
                    DirTagMapper.AddOne(new DirTagBean()
                    {
                        Path  = path,
                        TagId = tagBean.Id,
                    });
                }
                else
                {
                    DirTagMapper.EditOneByPath(path, tagBean.Id);
                }
                //刷新标签缓存
                TagSupport.SetTagSort();
            }
        }
Example #2
0
        //添加或修改标签的地址
        public void EditedItem_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (isInIt)
            {
                return;
            }
            //取消注册事件
            MouseLeftButtonDown          -= EditedItem_MouseDown;
            pathList.MouseLeftButtonDown -= EditedItem_MouseDown;
            tagName.MouseLeftButtonDown  -= EditedItem_MouseDown;
            pathGrid.MouseLeftButtonDown -= EditedItem_MouseDown;
            //获取相关信息
            string editedGridUid = editedGrid.Uid;
            string editedPath    = null;

            foreach (UIElement element in editedGrid.Children)
            {
                if (element is TextBox)
                {
                    editedPath = (element as TextBox).Text;
                }
            }
            if (editedPath != string.Empty)
            {
                //添加
                if (editedGridUid == "newPath")
                {
                    DirTagMapper.AddOne(new DirTagBean()
                    {
                        TagId = selectedTagId,
                        Path  = editedPath,
                    });
                }
                //修改
                else
                {
                    DirTagMapper.EditOneById(uint.Parse(editedGridUid), editedPath);
                }
            }
            TagSupport.SetTagSort();
            int index = pathList.SelectedIndex;

            pathList.ItemsSource   = TagService.GetPathItemSource(selectedTagId);
            pathList.SelectedIndex = index;
            isInIt = true; //设置为true,关闭该方法的相应
        }