/// <summary> /// 添加字符串 /// </summary> /// <param name="c"></param> public void AddChar(char c) { //this.SetSurosrPointLocal(); this.PInsertChar = c; if (this.PParser.GetSelectPartPoint != null) { this.isDelectString = true; base.Execute(); #region 记忆删除字符 var selectBgs = this.GetSelectBg(); this.pDeleteString = this.DeleteSelectPart(out this.PDeleteLineCount, false); this.SetDrawBgClearSelectAndPucker(selectBgs); this.ChangeIncrementLine(this.GetDeleteLineCount * -1); #endregion } #region 插入单个字符串 if (this.PActionOperation == null) { base.Execute(); } this.SetSurosrPoint(); var lnpID = this.PParser.GetLineString.GetLnpAndId(); string insertString = c.ToString(); if (c == CharCommand.Char_Tab) { insertString = " ".PadLeft(this.PParser.PLanguageMode.TabSpaceCount, ' '); } this.PInsertString = insertString; var text = this.GetLineStringEffectualText(); text = text.Insert(this.PParser.PCursor.CousorPointForWord.X + 1, insertString); this.SetResetLineString(this.PParser.GetLineString, text); this.RemovePuckerLeavingOnly(lnpID, this.PParser.GetLineString); int with = CharCommand.GetCharWidth(this.PParser.PIEdit.GetGraphics, insertString, FontContainer.DefaultFont); this.PCharWidth = with; this.PParser.PCursor.CousorPointForEdit.X += with; this.PParser.PCursor.CousorPointForWord.X += insertString.Length; if (this.PParser.PCursor.CousorPointForEdit.X > this.PParser.PIEdit.GetWidth - 20) { if (this.PParser.PCursor.CousorPointForEdit.X > this.PParser.GetMaxWidth + this.PParser.GetLeftSpace) { this.PParser.PIEdit.SetMaxScollMaxWidth(this.PParser.PCursor.CousorPointForEdit.X); } this.PParser.PCursor.CousorPointForEdit.X -= with; this.PParser.PIEdit.SetHorizontalScrollValue(with + this.PParser.PIEdit.GetHorizontalScrollValue, 1); } this.PParser.PCursor.SetPosition(this.PParser.PCursor.CousorPointForEdit.X, -1, this.PParser.GetLeftSpace); this.PParser.PCursor.SetPosition(); //this.PParser.ResetLineLNPAndClearPucker(formerly, this.PParser.GetLineString); this.PParser.PIEdit.Invalidate(); this.End(); #endregion }
/// <summary> /// /// </summary> private void BackSpaceChar() { LineString lineString = null; string lineText = string.Empty; var lnpID = this.PParser.GetLineString.GetLnpAndId(); if (this.PParser.PCursor.CousorPointForWord.X < 0) { if (this.PParser.PCursor.CousorPointForWord.Y == 0) { this.PIsAddUndo = false; return; } this.pEBackSpaceType = EBackSpaceType.Enter; this.SetOperationAction(); string leavings = this.PParser.GetLineString.Text; var nowLine = this.PParser.GetLineString; this.PParser.PLineString.RemoveAt(this.PParser.PCursor.CousorPointForWord.Y); this.PParser.PCursor.CousorPointForWord.Y--; this.PParser.PCursor.CousorPointForEdit.Y -= FontContainer.FontHeight; if (this.PParser.PCursor.CousorPointForWord.Y < 0) { this.PParser.PCursor.CousorPointForWord.Y = 0; return; } lineString = this.PParser.GetLineString; this.MergeLineString(lineString, nowLine); this.ChangeIncrementLine(-1); } else { pEBackSpaceType = EBackSpaceType.Char; this.SetOperationAction(); lineString = this.PParser.GetLineString; this.pChar = lineString.Text[this.PParser.PCursor.CousorPointForWord.X]; lineText = this.GetLineStringEffectualText(lineString).Remove(this.PParser.PCursor.CousorPointForWord.X, 1); int with = CharCommand.GetCharWidth(this.PParser.PIEdit.GetGraphics, this.pChar.ToString(), FontContainer.DefaultFont); this.PParser.PCursor.XForLeft -= with; this.PParser.PCursor.CousorPointForEdit.X -= with; this.PParser.PCursor.CousorPointForWord.X -= 1; this.SetResetLineString(lineString, lineText); this.RemovePuckerLeavingOnly(lnpID, lineString); this.EndInsertChar(); } this.SetSurosrPoint(); this.PParser.PCursor.SetPosition(); }
/// <summary> /// 注释所有的行 /// </summary> /// <param name="startY"></param> /// <param name="count"></param> private void CommentAllLine(int startY, int count) { count = startY + count; for (; startY < count; startY++) { var ls = this.PParser.PLineString[startY]; if (string.IsNullOrWhiteSpace(ls.Text) || (this.CommentYs != null && this.CommentYs.Contains(startY))) { continue; } //ls.PWord.Insert(this.minInsertWordIndex, ls.Text = ls.Text.Insert(this.minInsertLineIndex, this.PCommentStartStr); this.SetResetLineString(ls); if (this.PCommentStartWidth == -1) { var w = ls.PWord[this.minInsertWordIndex]; this.PCommentStartWidth = CharCommand.GetCharWidth(this.PParser.PIEdit.GetGraphics, this.PCommentStartStr, w.PIncluedFont == null ? null : w.PIncluedFont.PFont); } } }