public override void InitializeField() { base.InitializeField(); if (FActiveDomain != null) { FActiveDomain.Clear(); } if (FHotDomain != null) { FHotDomain.Clear(); } }
private void GetDomainFrom(int aItemNo, int aOffset, HCDomainInfo aDomainInfo) { aDomainInfo.Clear(); if ((aItemNo < 0) || (aOffset < 0)) { return; } /* 找起始标识 }*/ int vCount = 0; byte vLevel = 0; // 确定往前找的起始位置 int vStartNo = aItemNo; int vEndNo = aItemNo; if (Items[aItemNo] is HCDomainItem) { if ((Items[aItemNo] as HCDomainItem).MarkType == MarkType.cmtBeg) { if (aOffset == HC.OffsetAfter) { aDomainInfo.BeginNo = aItemNo; // 当前即为起始标识 vLevel = (Items[aItemNo] as HCDomainItem).Level; vEndNo = aItemNo + 1; } else // 光标在前面 { if (aItemNo > 0) { vStartNo = aItemNo - 1; // 从前一个往前 } else // 是在第一个前面 { return; // 不用找了 } } } else // 查找位置是结束标记 { if (aOffset == HC.OffsetAfter) { if (aItemNo < Items.Count - 1) { vEndNo = aItemNo + 1; } else // 是最后一个后面 { return; // 不用找了 } } else // 光标在前面 { aDomainInfo.EndNo = aItemNo; vStartNo = aItemNo - 1; } } } if (aDomainInfo.BeginNo < 0) { vCount = 0; if (vStartNo < Items.Count / 2) // 在前半程 { for (int i = vStartNo; i >= 0; i--) // 先往前找起始 { if (Items[i] is HCDomainItem) { if ((Items[i] as HCDomainItem).MarkType == MarkType.cmtBeg) // 起始标记 { if (vCount != 0) { vCount--; } else { aDomainInfo.BeginNo = i; vLevel = (Items[i] as HCDomainItem).Level; break; } } else // 结束标记 { vCount++; // 有嵌套 } } } if ((aDomainInfo.BeginNo >= 0) && (aDomainInfo.EndNo < 0)) // 找结束标识 { for (int i = vEndNo; i <= Items.Count - 1; i++) { if (Items[i] is HCDomainItem) { if ((Items[i] as HCDomainItem).MarkType == MarkType.cmtEnd) // 是结尾 { if ((Items[i] as HCDomainItem).Level == vLevel) { aDomainInfo.EndNo = i; break; } } } } if (aDomainInfo.EndNo < 0) { throw new Exception("异常:获取数据组结束出错!"); } } } else // 在后半程 { for (int i = vEndNo; i <= this.Items.Count - 1; i++) // 先往后找结 { if (Items[i] is HCDomainItem) { if ((Items[i] as HCDomainItem).MarkType == MarkType.cmtEnd) { if (vCount > 0) { vCount--; } else { aDomainInfo.EndNo = i; vLevel = (Items[i] as HCDomainItem).Level; break; } } else { vCount++; } } } if ((aDomainInfo.EndNo >= 0) && (aDomainInfo.BeginNo < 0)) { for (int i = vStartNo; i >= 0; i--) { if (Items[i] is HCDomainItem) { if ((Items[i] as HCDomainItem).MarkType == MarkType.cmtBeg) { if ((Items[i] as HCDomainItem).Level == vLevel) { aDomainInfo.BeginNo = i; break; } } } } if (aDomainInfo.BeginNo < 0) { throw new Exception("异常:获取域起始位置出错!"); } } } } else if (aDomainInfo.EndNo < 0) { for (int i = vEndNo; i <= this.Items.Count - 1; i++) { if (Items[i] is HCDomainItem) { if ((Items[i] as HCDomainItem).MarkType == MarkType.cmtEnd) // 是结尾 { if ((Items[i] as HCDomainItem).Level == vLevel) { aDomainInfo.EndNo = i; break; } } } } if (aDomainInfo.EndNo < 0) { throw new Exception("异常:获取域起始位置出错!"); } } }