Example #1
0
        void LoadPrevOrNextCommentItem(bool bPrev)
        {
            string strError = "";

            CommentItem new_commentitem = GetPrevOrNextCommentItem(bPrev,
                                                                   out strError);

            if (new_commentitem == null)
            {
                goto ERROR1;
            }

            // 保存当前事项
            int nRet = FinishOneCommentItem(out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }

            LoadCommentItem(new_commentitem);

            // 在listview中滚动到可见范围
            new_commentitem.HilightListViewItem(true);
            this.Text = "册信息";
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Example #2
0
        // 填充编辑界面数据
        int FillEditing(CommentItem commentitem,
                        out string strError)
        {
            strError = "";

            if (commentitem == null)
            {
                strError = "commentitem参数值为空";
                return(-1);
            }

            string strXml = "";
            int    nRet   = commentitem.BuildRecord(out strXml,
                                                    out strError);

            if (nRet == -1)
            {
                return(-1);
            }

            nRet = this.commentEditControl_editing.SetData(strXml,
                                                           commentitem.RecPath,
                                                           commentitem.Timestamp,
                                                           out strError);
            if (nRet == -1)
            {
                return(-1);
            }


            return(0);
        }
Example #3
0
 // 把事项重新全部加入listview
 /// <summary>
 /// 把当前集合中的事项全部加入 ListView
 /// </summary>
 /// <param name="list"></param>
 public void AddToListView(ListView list)
 {
     for (int i = 0; i < this.Count; i++)
     {
         CommentItem item = this[i];
         item.AddToListView(list);
     }
 }
Example #4
0
        // 从集合中和视觉上同时删除
        /// <summary>
        /// 从集合中和 ListView 中同时清除指定的事项。
        /// 注意,不是指从数据库删除记录
        /// </summary>
        /// <param name="commentitem"></param>
        public void PhysicalDeleteItem(
            CommentItem commentitem)
        {
            // 从listview中消失
            commentitem.DeleteFromListView();

            this.Remove(commentitem);
        }
Example #5
0
        /// <summary>
        /// 清除集合内元素
        /// 从集合中和 ListView 中同时清除全部事项
        /// 注意,不是指从数据库删除记录
        /// </summary>
        public new void Clear()
        {
            for (int i = 0; i < this.Count; i++)
            {
                CommentItem item = this[i];
                item.DeleteFromListView();
            }

            base.Clear();
        }
Example #6
0
 // 设置全部commentitem事项的Parent域
 /// <summary>
 /// 为全部事项设置一致的 Parent ID 值
 /// </summary>
 /// <param name="strParentID">要设置的 Parent ID 值</param>
 public void SetParentID(string strParentID)
 {
     for (int i = 0; i < this.Count; i++)
     {
         CommentItem item = this[i];
         if (item.Parent != strParentID) // 避免连带无谓地修改item.Changed
         {
             item.Parent = strParentID;
         }
     }
 }
Example #7
0
        /// <summary>
        /// 以记录路径定位一个事项
        /// </summary>
        /// <param name="strRecPath">评注记录路径</param>
        /// <returns>找到的事项。null 表示没有找到</returns>
        public CommentItem GetItemByRecPath(string strRecPath)
        {
            for (int i = 0; i < this.Count; i++)
            {
                CommentItem item = this[i];
                if (item.RecPath == strRecPath)
                {
                    return(item);
                }
            }

            return(null);
        }
Example #8
0
        // Undo标记删除
        // return:
        //      false   没有必要Undo
        //      true    成功Undo
        /// <summary>
        /// 撤销对一个事项的标记删除
        /// </summary>
        /// <param name="commentitem">要撤销标记删除的事项</param>
        /// <returns>false: 没有必要撤销(因为指定的事项不在标记删除状态); true: 成功撤销标记删除</returns>
        public bool UndoMaskDeleteItem(CommentItem commentitem)
        {
            if (commentitem.ItemDisplayState != ItemDisplayState.Deleted)
            {
                return(false);   // 要Undo的事项根本就不是Deleted状态,所以谈不上Undo
            }
            // 因为不知道上次标记删除前数据是否改过,因此全当改过
            commentitem.ItemDisplayState = ItemDisplayState.Changed;
            commentitem.Changed          = true;

            // 刷新
            commentitem.RefreshListView();
            return(true);
        }
Example #9
0
        // 为编辑目的的初始化
        // parameters:
        //      commentitems   容器。用于UndoMaskDelete
        public int InitialForEdit(
            CommentItem commentitem,
            CommentItemCollection commentitems,
            out string strError)
        {
            strError = "";

            this.CommentItem  = commentitem;
            this.CommentItems = commentitems;

            this.StartCommentItem = commentitem;

            return(0);
        }
Example #10
0
        /// <summary>
        /// 获得 Panrent ID 列表
        /// </summary>
        /// <returns>Parent ID 列表</returns>
        public List <string> GetParentIDs()
        {
            List <string> results = new List <string>();

            for (int i = 0; i < this.Count; i++)
            {
                CommentItem item        = this[i];
                string      strParentID = item.Parent;
                if (results.IndexOf(strParentID) == -1)
                {
                    results.Add(strParentID);
                }
            }

            return(results);
        }
Example #11
0
        /// <summary>
        /// 根据一个 XML 字符串内容,构建出集合内的若干事项
        /// </summary>
        /// <param name="nodeCommentCollection">XmlNode对象,本方法将使用其下属的 dprms:comment 元素来构造事项</param>
        /// <param name="list">ListView 对象。构造好的事项会显示到其中</param>
        /// <param name="bRefreshRefID">构造事项的过程中,是否要刷新每个事项的 RefID 成员值</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错。错误信息在 strError 中; 0: 成功</returns>
        public int ImportFromXml(XmlNode nodeCommentCollection,
                                 ListView list,
                                 bool bRefreshRefID,
                                 out string strError)
        {
            strError = "";
            int nRet = 0;

            if (nodeCommentCollection == null)
            {
                return(0);
            }

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());

            nsmgr.AddNamespace("dprms", DpNs.dprms);

            XmlNodeList nodes = nodeCommentCollection.SelectNodes("dprms:comment", nsmgr);

            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                CommentItem comment_item = new CommentItem();
                nRet = comment_item.SetData("",
                                            node.OuterXml,
                                            null,
                                            out strError);
                if (nRet == -1)
                {
                    return(-1);
                }

                if (bRefreshRefID == true)
                {
                    comment_item.RefID = Guid.NewGuid().ToString();
                }

                this.Add(comment_item);
                comment_item.ItemDisplayState = ItemDisplayState.New;
                comment_item.AddToListView(list);

                comment_item.Changed = true;
            }

            return(0);
        }
Example #12
0
        void LoadCommentItem(CommentItem commentitem)
        {
            if (commentitem != null)
            {
                string strError = "";
                int    nRet     = FillEditing(commentitem, out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, "LoadCommentItem() 发生错误: " + strError);
                    return;
                }
            }
            if (commentitem != null &&
                commentitem.ItemDisplayState == ItemDisplayState.Deleted)
            {
                // 已经标记删除的事项, 不能进行修改。但是可以观察
                this.commentEditControl_editing.SetReadOnly(ReadOnlyStyle.All);
                this.checkBox_autoSearchDup.Enabled = false;

                this.button_editing_undoMaskDelete.Enabled = true;
                this.button_editing_undoMaskDelete.Visible = true;
            }
            else
            {
                this.commentEditControl_editing.SetReadOnly(ReadOnlyStyle.Librarian);

                this.button_editing_undoMaskDelete.Enabled = false;
                this.button_editing_undoMaskDelete.Visible = false;
            }

            this.commentEditControl_editing.GetValueTable -= new GetValueTableEventHandler(commentEditControl_editing_GetValueTable);
            this.commentEditControl_editing.GetValueTable += new GetValueTableEventHandler(commentEditControl_editing_GetValueTable);

            this.CommentItem = commentitem;

            SetOkButtonState();
        }
Example #13
0
        /// <summary>
        /// 以参考 ID 定位一个事项
        /// </summary>
        /// <param name="strRefID">参考 ID</param>
        /// <param name="excludeItems">要加以排除的事项列表</param>
        /// <returns>找到的事项。null 表示没有找到</returns>
        public CommentItem GetItemByRefID(string strRefID,
                                          List <CommentItem> excludeItems)
        {
            for (int i = 0; i < this.Count; i++)
            {
                CommentItem item = this[i];

                // 需要排除的事项
                if (excludeItems != null)
                {
                    if (excludeItems.IndexOf(item) != -1)
                    {
                        continue;
                    }
                }

                if (item.RefID == strRefID)
                {
                    return(item);
                }
            }

            return(null);
        }
Example #14
0
        /// <summary>
        /// 复制出一个新的 CommentItem 对象
        /// </summary>
        /// <returns>新的 CommentItem 对象</returns>
        public CommentItem Clone()
        {
            CommentItem newObject = new CommentItem();

            newObject.ItemDisplayState = this.ItemDisplayState;

            newObject.RecPath    = this.RecPath;
            newObject.m_bChanged = this.m_bChanged;
            newObject.OldRecord  = this.OldRecord;


            // 放入最新鲜的内容
            newObject.CurrentRecord = this.RecordDom.OuterXml;


            newObject.RecordDom = new XmlDocument();
            newObject.RecordDom.LoadXml(this.RecordDom.OuterXml);

            newObject.Timestamp    = ByteArray.GetCopy(this.Timestamp);
            newObject.ListViewItem = null; // this.ListViewItem;
            newObject.Error        = null; // this.Error;

            return(newObject);
        }
Example #15
0
        //
        /// <summary>
        /// 标记删除指定的事项
        /// </summary>
        /// <param name="bRemoveFromList">是否要从 ListView 中移除这个事项?</param>
        /// <param name="comentitem">要标记删除的事项</param>
        public void MaskDeleteItem(
            bool bRemoveFromList,
            CommentItem comentitem)
        {
            if (comentitem.ItemDisplayState == ItemDisplayState.New)
            {
                PhysicalDeleteItem(comentitem);
                return;
            }


            comentitem.ItemDisplayState = ItemDisplayState.Deleted;
            comentitem.Changed          = true;

            // 从listview中消失?
            if (bRemoveFromList == true)
            {
                comentitem.DeleteFromListView();
            }
            else
            {
                comentitem.RefreshListView();
            }
        }
Example #16
0
        private void commentEditControl_editing_ControlKeyDown(object sender, ControlKeyEventArgs e)
        {
            bool bUp = false;

            if (e.e.KeyCode == Keys.OemOpenBrackets && e.e.Control == true)
            {
                bUp = true; // 从上面拷贝
            }
            else if (e.e.KeyCode == Keys.OemCloseBrackets && e.e.Control == true)
            {
                bUp = false;    // 从下面拷贝
            }
            else
            {
                return;
            }

            string      strError    = "";
            CommentItem commentitem = GetPrevOrNextItem(bUp, out strError);

            if (commentitem == null)
            {
                return;
            }
            switch (e.Name)
            {
            case "Index":
                this.commentEditControl_editing.Index = commentitem.Index;
                break;

            case "State":
                this.commentEditControl_editing.State = commentitem.State;
                break;

            case "Type":
                this.commentEditControl_editing.TypeString = commentitem.TypeString;
                break;

            case "Title":
                this.commentEditControl_editing.Title = commentitem.Title;
                break;

            case "Author":
                this.commentEditControl_editing.Creator = commentitem.Creator;
                break;

            case "Subject":
                this.commentEditControl_editing.Subject = commentitem.Subject;
                break;

            case "Summary":
                this.commentEditControl_editing.Summary = commentitem.Summary;
                break;

            case "Content":
                this.commentEditControl_editing.Content = commentitem.Content;
                break;

            case "CreateTime":
                this.commentEditControl_editing.CreateTime = commentitem.CreateTime;
                break;

            case "LastModified":
                this.commentEditControl_editing.LastModified = commentitem.LastModified;
                break;

            case "RecPath":
                //this.entityEditControl_editing.RecPath = bookitem.RecPath;
                break;

            default:
                Debug.Assert(false, "未知的栏目名称 '" + e.Name + "'");
                return;
            }
        }
Example #17
0
        // 
        /// <summary>
        /// 标记删除指定的事项
        /// </summary>
        /// <param name="bRemoveFromList">是否要从 ListView 中移除这个事项?</param>
        /// <param name="comentitem">要标记删除的事项</param>
        public void MaskDeleteItem(
            bool bRemoveFromList,
            CommentItem comentitem)
        {
            if (comentitem.ItemDisplayState == ItemDisplayState.New)
            {
                PhysicalDeleteItem(comentitem);
                return;
            }


            comentitem.ItemDisplayState = ItemDisplayState.Deleted;
            comentitem.Changed = true;

            // 从listview中消失?
            if (bRemoveFromList == true)
                comentitem.DeleteFromListView();
            else
            {
                comentitem.RefreshListView();
            }
        }
Example #18
0
        /// <summary>
        /// 复制出一个新的 CommentItem 对象
        /// </summary>
        /// <returns>新的 CommentItem 对象</returns>
        public CommentItem Clone()
        {
            CommentItem newObject = new CommentItem();

            newObject.ItemDisplayState = this.ItemDisplayState;

            newObject.RecPath = this.RecPath;
            newObject.m_bChanged = this.m_bChanged;
            newObject.OldRecord = this.OldRecord;


            // 放入最新鲜的内容
            newObject.CurrentRecord = this.RecordDom.OuterXml;


            newObject.RecordDom = new XmlDocument();
            newObject.RecordDom.LoadXml(this.RecordDom.OuterXml);

            newObject.Timestamp = ByteArray.GetCopy(this.Timestamp);
            newObject.ListViewItem = null;  // this.ListViewItem;
            newObject.Error = null; // this.Error;

            return newObject;
        }
Example #19
0
        /// <summary>
        /// 根据一个 XML 字符串内容,构建出集合内的若干事项
        /// </summary>
        /// <param name="nodeCommentCollection">XmlNode对象,本方法将使用其下属的 dprms:comment 元素来构造事项</param>
        /// <param name="list">ListView 对象。构造好的事项会显示到其中</param>
        /// <param name="bRefreshRefID">构造事项的过程中,是否要刷新每个事项的 RefID 成员值</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错。错误信息在 strError 中; 0: 成功</returns>
        public int ImportFromXml(XmlNode nodeCommentCollection,
            ListView list,
            bool bRefreshRefID,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            if (nodeCommentCollection == null)
                return 0;

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
            nsmgr.AddNamespace("dprms", DpNs.dprms);

            XmlNodeList nodes = nodeCommentCollection.SelectNodes("dprms:comment", nsmgr);
            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                CommentItem comment_item = new CommentItem();
                nRet = comment_item.SetData("",
                    node.OuterXml,
                    null,
                    out strError);
                if (nRet == -1)
                    return -1;

                if (bRefreshRefID == true)
                    comment_item.RefID = Guid.NewGuid().ToString();

                this.Add(comment_item);
                comment_item.ItemDisplayState = ItemDisplayState.New;
                comment_item.AddToListView(list);

                comment_item.Changed = true;
            }

            return 0;
        }
Example #20
0
        // 从集合中和视觉上同时删除
        /// <summary>
        /// 从集合中和 ListView 中同时清除指定的事项。
        /// 注意,不是指从数据库删除记录
        /// </summary>
        /// <param name="commentitem"></param>
        public void PhysicalDeleteItem(
            CommentItem commentitem)
        {
            // 从listview中消失
            commentitem.DeleteFromListView();

            this.Remove(commentitem);
        }
Example #21
0
        // Undo标记删除
        // return:
        //      false   没有必要Undo
        //      true    成功Undo
        /// <summary>
        /// 撤销对一个事项的标记删除
        /// </summary>
        /// <param name="commentitem">要撤销标记删除的事项</param>
        /// <returns>false: 没有必要撤销(因为指定的事项不在标记删除状态); true: 成功撤销标记删除</returns>
        public bool UndoMaskDeleteItem(CommentItem commentitem)
        {
            if (commentitem.ItemDisplayState != ItemDisplayState.Deleted)
                return false;   // 要Undo的事项根本就不是Deleted状态,所以谈不上Undo

            // 因为不知道上次标记删除前数据是否改过,因此全当改过
            commentitem.ItemDisplayState = ItemDisplayState.Changed;
            commentitem.Changed = true;

            // 刷新
            commentitem.RefreshListView();
            return true;
        }