Beispiel #1
0
        public bool InsertDomain(HCDomainItem aMouldDomain)
        {
            if (!CanEdit())
            {
                return(false);
            }

            bool         Result      = false;
            HCDomainItem vDomainItem = null;

            Undo_GroupBegin(SelectInfo.StartItemNo, SelectInfo.StartItemOffset);
            try
            {
                this.BeginBatchInsert();
                try
                {
                    // 插入头
                    vDomainItem = CreateDefaultDomainItem() as HCDomainItem;
                    if (aMouldDomain != null)
                    {
                        vDomainItem.Assign(aMouldDomain);
                    }

                    vDomainItem.MarkType = MarkType.cmtBeg;
                    if (FActiveDomain.BeginNo >= 0)
                    {
                        vDomainItem.Level = (byte)((Items[FActiveDomain.BeginNo] as HCDomainItem).Level + 1);
                    }

                    Result = InsertItem(vDomainItem);

                    if (Result)  // 插入尾
                    {
                        vDomainItem = CreateDefaultDomainItem() as HCDomainItem;
                        if (aMouldDomain != null)
                        {
                            vDomainItem.Assign(aMouldDomain);
                        }

                        vDomainItem.MarkType = MarkType.cmtEnd;
                        if (FActiveDomain.BeginNo >= 0)
                        {
                            vDomainItem.Level = (byte)((Items[FActiveDomain.BeginNo] as HCDomainItem).Level + 1);
                        }

                        Result = InsertItem(vDomainItem);
                    }
                }
                finally
                {
                    this.EndBatchInsert();
                }
            }
            finally
            {
                Undo_GroupEnd(SelectInfo.StartItemNo, SelectInfo.StartItemOffset);
            }

            return(Result);
        }
Beispiel #2
0
        public void TraverseItem(HCItemTraverse aTraverse)
        {
            if (aTraverse != null)
            {
                HCDomainInfo vDomainInfo;
                for (int i = 0; i <= Items.Count - 1; i++)
                {
                    if (aTraverse.Stop)
                    {
                        break;
                    }

                    if (Items[i] is HCDomainItem)
                    {
                        if (HCDomainItem.IsBeginMark(Items[i]))
                        {
                            vDomainInfo = new HCDomainInfo();
                            GetDomainFrom(i, HC.OffsetAfter, vDomainInfo);
                            aTraverse.DomainStack.Push(vDomainInfo);
                        }
                        else
                        {
                            aTraverse.DomainStack.Pop();
                        }
                    }

                    aTraverse.Process(this, i, aTraverse.Tag, aTraverse.DomainStack, ref aTraverse.Stop);
                    if (Items[i].StyleNo < HCStyle.Null)
                    {
                        (Items[i] as HCCustomRectItem).TraverseItem(aTraverse);
                    }
                }
            }
        }
Beispiel #3
0
        public bool InsertDomain(HCDomainItem aMouldDomain)
        {
            HCFunction vEvent = delegate()
            {
                return(FData.InsertDomain(aMouldDomain));
            };

            return(DataChangeByAction(vEvent));
        }
Beispiel #4
0
        /// <summary> 获取DomainItem配对的另一个ItemNo </summary>
        public int GetDomainAnother(int aItemNo)
        {
            int Result = -1;

            // 请外部保证AItemNo对应的是THCDomainItem
            HCDomainItem vDomainItem = this.Items[aItemNo] as HCDomainItem;

            if (vDomainItem.MarkType == MarkType.cmtEnd)
            {
                for (int i = aItemNo - 1; i >= 0; i--)  // 找起始标识
                {
                    if (Items[i].StyleNo == HCStyle.Domain)
                    {
                        if ((Items[i] as HCDomainItem).MarkType == MarkType.cmtBeg)
                        {
                            if ((Items[i] as HCDomainItem).Level == vDomainItem.Level)
                            {
                                Result = i;
                                break;
                            }
                        }
                    }
                }
            }
            else  // 是起始标识
            {
                for (int i = aItemNo + 1; i <= this.Items.Count - 1; i++)  // 找结束标识
                {
                    if (Items[i].StyleNo == HCStyle.Domain)
                    {
                        if ((Items[i] as HCDomainItem).MarkType == MarkType.cmtEnd)
                        {
                            if ((Items[i] as HCDomainItem).Level == vDomainItem.Level)
                            {
                                Result = i;
                                break;
                            }
                        }
                    }
                }
            }

            return(Result);
        }
Beispiel #5
0
        public void GetDomainStackFrom(int aItemNo, int aOffset, Stack <HCDomainInfo> aDomainStack)
        {
            HCDomainInfo vDomainInfo;

            for (int i = 0; i < aItemNo; i++)
            {
                if (Items[i] is HCDomainItem)
                {
                    if (HCDomainItem.IsBeginMark(Items[i]))
                    {
                        vDomainInfo         = new HCDomainInfo();
                        vDomainInfo.Data    = this;
                        vDomainInfo.BeginNo = i;
                        aDomainStack.Push(vDomainInfo);
                    }
                    else
                    {
                        aDomainStack.Pop();
                    }
                }
            }
        }
Beispiel #6
0
        /// <summary> 获取DomainItem配对的另一个ItemNo </summary>
        public int GetDomainAnother(int AItemNo)
        {
            int Result  = -1;
            int vIgnore = 0;

            // 请外部保证AItemNo对应的是THCDomainItem
            HCDomainItem vDomain = this.Items[AItemNo] as HCDomainItem;

            if (vDomain.MarkType == MarkType.cmtEnd)
            {
                for (int i = AItemNo - 1; i >= 0; i--)  // 找起始标识
                {
                    if (Items[i].StyleNo == HCStyle.Domain)
                    {
                        if ((Items[i] as HCDomainItem).MarkType == MarkType.cmtBeg)
                        {
                            if (vIgnore == 0)
                            {
                                Result = i;
                                break;
                            }
                            else
                            {
                                vIgnore--;
                            }
                        }
                        else
                        {
                            vIgnore++;
                        }
                    }
                }
            }
            else  // 是起始标识
            {
                for (int i = AItemNo + 1; i <= this.Items.Count - 1; i++)  // 找结束标识
                {
                    if (Items[i].StyleNo == HCStyle.Domain)
                    {
                        if ((Items[i] as HCDomainItem).MarkType == MarkType.cmtEnd)
                        {
                            if (vIgnore == 0)
                            {
                                Result = i;
                                break;
                            }
                            else
                            {
                                vIgnore--;
                            }
                        }
                        else
                        {
                            vIgnore++;
                        }
                    }
                }
            }

            return(Result);
        }