/// <summary> /// 设置成对出现字符串 /// </summary> /// <param name="lnpro"></param> /// <param name="startC"></param> /// <param name="endC"></param> /// <param name="index"></param> /// <param name="lineIndex"></param> private void SetCouple(LineNodeProperty lnpro, char startC, char endC, int index, int lineIndex, ECouplePropertyDirection epd) { var coupleProperty = new CoupleProperty() { FindChar = endC, PChar = startC, WordIndex = index, LineIndex = lineIndex, LNProperty = lnpro, PECouplePropertyDirection = epd }; if (lnpro.Couple == null) { lnpro.Couple = new Dictionary <int, CoupleProperty>(); } lnpro.Couple.Add(lineIndex, coupleProperty); if (this.pCoupleProperty == null) { this.pCoupleProperty = coupleProperty; } else { var last = pCoupleProperty; last.NextNode = coupleProperty; coupleProperty.UpNode = last; this.pCoupleProperty = coupleProperty; } }
//private int pWIStyleY; /// <summary> /// 获取行字符串 /// </summary> /// <param name="line"></param> /// <returns></returns> public LineString GetLineString(string line /*, int y*/) { this.pCoupleProperty = null; var pUseWord = new List <Tuple <Word, UseWordFont> >(); line = line.TrimEnd(CharCommand.Char_Enter); int length = 0; int index = 0; Word w; WFontColor wfc; WordIncluedStyle wiStyle = null; LineNodeProperty lnProperty = null; var lineString = GetLineString(); lineString.PWord = new List <Word>(); lineString.Text = string.Empty; while (length < line.Length) { bool isSetWFC = true; char c = line[length]; w = new Word(); switch (c) { case CharCommand.Char_Tab: //for (var i = 0; i < this.pLanguageMode.TabSpaceCount - 1; i++) { // var wSpace = new Word(); // wSpace.Text = " "; // wSpace.PEWordType = EWordType.Space; // lineString.Text += wSpace.Text; // wSpace.LineIndex = index++; // lineString.PWord.Add(wSpace); //} //w = new Word(); w.PEWordType = EWordType.Space; w.Text = " "; line = line.Substring(0, length) + " ".PadLeft(this.pLanguageMode.TabSpaceCount) + line.Substring(length + 1); break; case CharCommand.Char_Space: //w = new Word(); w.PEWordType = EWordType.Space; w.Text = c.ToString(); break; default: if (pLanguageMode.CompartChars.Contains(c)) { w.PEWordType = EWordType.Compart; w.Text = c.ToString(); if (pLanguageMode.CompartCharFont.TryGetValue(c, out wfc)) { w.PFont = wfc; } #region 包含不换行颜色 if (wiStyle == null) { wiStyle = GetIncludeFont(c, wiStyle, line, ref length); if (wiStyle != null) { w.Text = wiStyle.Text; wiStyle = SetMoreLineStartStyle(wiStyle, lineString, index); } } else if (wiStyle.IsEndStr) { if (EndIncludeFont(c, wiStyle, w, line, ref length)) { w.PIncluedFont = wiStyle.PFontColor; wiStyle = null; isSetWFC = false; } } SetMoreLineEndStyle(lineString, c, w, line, index, ref length); #endregion #region 是否行属性 if (wiStyle == null) { lnProperty = GetLineNodeProperty(c, length, index, /*y,*/ lnProperty); } #endregion } else { //w = new Word(); w.PEWordType = EWordType.Word; w.Text = c.ToString() + GetTag(line, ref length); if (pLanguageMode.WordFonts.TryGetValue(w.Text, out wfc)) { w.PFont = wfc; } if (w.PEWordType == EWordType.Word && this.pIEdit.SetWordStyleEvent != null && w.PFont == null) { w.PFont = this.pIEdit.SetWordStyleEvent(w.Text); } } #region 自定义样式 if (pLanguageMode.UseBefore != null) { if (pLanguageMode.UseBefore.ContainsKey(w.Text)) { pUseWord.Add(Tuple.Create(w, pLanguageMode.UseBefore[w.Text])); } } if (pLanguageMode.UseAfter != null) { if (pLanguageMode.UseAfter.ContainsKey(w.Text)) { pUseWord.Add(Tuple.Create(w, pLanguageMode.UseAfter[w.Text])); } } #endregion break; } lineString.Text += w.Text; w.LineIndex = index++; if (wiStyle != null && isSetWFC) { w.PIncluedFont = wiStyle.PFontColor; } lineString.PWord.Add(w); length++; } lineString.PLNProperty = lnProperty; this.SetUseWordFont(pUseWord, lineString.PWord); return(lineString); }
/// <summary> /// 清除属性 /// </summary> public void ClearProperty() { //this.pLineNodeProperty = null; this.pCoupleProperty = null; }