private void InsertChar(char ch) { if (((this.doc != null) && (this.activeText != null)) && ((ch >= ' ') || (ch == '\t'))) { ItopVector.DrawArea.CharInfo[] infoArray1 = this.RemoveSelection(); TextUndoOperation operation1 = null; if (infoArray1 != null) { operation1 = new TextUndoOperation(TextAction.Delete, this.selectionstart, infoArray1, this); } bool flag1 = this.doc.AcceptChanges; this.doc.AcceptChanges = false; string text1 = ch.ToString(); XmlText text2 = this.doc.CreateTextNode(text1); this.doc.AcceptChanges = false; ItopVector.DrawArea.CharInfo info1 = new ItopVector.DrawArea.CharInfo(); info1.Font = this.font; info1.TextSvgElement = this.activeText; info1.TextNode = text2; info1.StringFormat = this.sf; info1.StringFormat.LineAlignment = StringAlignment.Near; info1.Paint = this.paint; info1.Stroke = this.stroke; if (this.caretindex >= this.chars.Count) { this.activeText.AppendChild(text2); this.chars.Add(info1); } else if ((this.caretindex >= 0) && (this.caretindex < this.chars.Count)) { this.chars.Insert(this.caretindex, info1); XmlNode node1 = this.activeText.ChildNodes[this.caretindex]; this.activeText.InsertBefore(text2, node1); } ItopVector.DrawArea.CharInfo[] infoArray2 = new ItopVector.DrawArea.CharInfo[1] { info1 } ; TextUndoOperation operation2 = new TextUndoOperation(TextAction.Insert, this.chars.IndexOf(info1), infoArray2, this); info1.PreSibling = info1.TextNode.PreviousSibling; bool flag2 = this.undostack.AcceptChanges; this.undostack.AcceptChanges = true; if (operation1 != null) { TextUndoOperation[] operationArray1 = new TextUndoOperation[2] { operation1, operation2 } ; this.undostack.Push(operationArray1); } else { TextUndoOperation[] operationArray2 = new TextUndoOperation[1] { operation2 } ; this.undostack.Push(operationArray2); } this.undostack.AcceptChanges = flag2; this.caretindex++; this.mouseAreaControl.Invalidate(); this.doc.AcceptChanges = flag1; } }
private bool OnDialogKey(Keys keydata) { int num1 = this.caretindex; bool flag1 = false; Keys keys1 = keydata; if (keys1 <= Keys.Right) { switch (keys1) { case Keys.Back: { if (this.selectionlength > 0) { int num3 = this.selectionstart; ItopVector.DrawArea.CharInfo[] infoArray2 = this.RemoveSelection(); if (infoArray2 != null) { TextUndoOperation operation2 = new TextUndoOperation(TextAction.Delete, num3, infoArray2, this); bool flag3 = this.undostack.AcceptChanges; this.undostack.AcceptChanges = true; TextUndoOperation[] operationArray2 = new TextUndoOperation[1] { operation2 } ; this.undostack.Push(operationArray2); this.undostack.AcceptChanges = flag3; } this.mouseAreaControl.Invalidate(); return flag1; } if (((this.caretindex - 1) >= 0) && ((this.caretindex - 1) < this.chars.Count)) { this.caretindex--; this.Remove(this.caretindex); this.mouseAreaControl.Invalidate(); } return true; } case Keys.Tab: { this.InsertChar(' '); return true; } case Keys.Return: { this.enterUpdate = true; this.PostElement(); this.enterUpdate = false; return true; } case Keys.End: { this.selectionlength = 0; this.CaretIndex = this.chars.Count; this.mouseAreaControl.Invalidate(); return true; } case Keys.Home: { this.CaretIndex = 0; this.selectionlength = 0; this.mouseAreaControl.Invalidate(); return true; } case Keys.Left: { num1--; this.CaretIndex = Math.Max(0, Math.Min(num1, this.chars.Count)); this.selectionlength = 0; this.mouseAreaControl.Invalidate(); return true; } case Keys.Up: { goto Label_04AB; } case Keys.Right: { num1++; this.CaretIndex = Math.Max(0, Math.Min(num1, this.chars.Count)); this.selectionlength = 0; this.mouseAreaControl.Invalidate(); return true; } } } else if (keys1 != Keys.Delete) { switch (keys1) { case (Keys.Shift | Keys.End): { if (this.selectionlength == 0) { this.selectionstart = this.caretindex; } this.caretindex = this.chars.Count; this.selectionlength = this.caretindex - this.selectionstart; this.mouseAreaControl.Invalidate(); return true; } case (Keys.Shift | Keys.Home): { if (this.selectionlength == 0) { this.selectionstart = this.caretindex; } this.caretindex = 0; this.selectionlength = this.selectionstart; this.selectionstart = 0; this.mouseAreaControl.Invalidate(); return true; } case (Keys.Shift | Keys.Left): { if (this.selectionlength == 0) { this.selectionstart = this.caretindex; } num1--; num1 = Math.Max(0, Math.Min(num1, this.chars.Count)); if (num1 > this.selectionstart) { this.selectionlength--; } else { this.selectionlength = (this.selectionstart + this.selectionlength) - num1; this.selectionstart = num1; } this.caretindex = num1; this.mouseAreaControl.Invalidate(); return true; } case (Keys.Shift | Keys.Up): { goto Label_04AB; } case (Keys.Shift | Keys.Right): { if (this.selectionlength == 0) { this.selectionstart = this.caretindex; } num1++; this.caretindex = Math.Max(0, Math.Min(num1, this.chars.Count)); if (this.caretindex > this.selectionstart) { this.selectionlength = this.caretindex - this.selectionstart; } else { this.selectionlength = (this.selectionstart + this.selectionlength) - this.caretindex; this.selectionstart = this.caretindex; } this.mouseAreaControl.Invalidate(); return true; } case (Keys.Control | Keys.A): { int num4; this.caretindex = num4 = 0; this.selectionstart = num4; this.selectionlength = this.chars.Count; this.mouseAreaControl.Invalidate(); return true; } } } else { if (this.selectionlength > 0) { int num2 = this.selectionstart; ItopVector.DrawArea.CharInfo[] infoArray1 = this.RemoveSelection(); if (infoArray1 != null) { TextUndoOperation operation1 = new TextUndoOperation(TextAction.Delete, num2, infoArray1, this); bool flag2 = this.undostack.AcceptChanges; this.undostack.AcceptChanges = true; TextUndoOperation[] operationArray1 = new TextUndoOperation[1] { operation1 } ; this.undostack.Push(operationArray1); this.undostack.AcceptChanges = flag2; } this.mouseAreaControl.Invalidate(); return flag1; } if (this.caretindex < this.chars.Count) { this.Remove(this.caretindex); this.mouseAreaControl.Invalidate(); } return true; } Label_04AB: if ((keydata >= Keys.Space) || (keydata == Keys.Tab)) { flag1 = false; } else { flag1 = true; } return flag1; }
private void Remove(int index) { bool flag1 = this.doc.AcceptChanges; this.doc.AcceptChanges = false; if ((index >= 0) && (index < this.chars.Count)) { ItopVector.DrawArea.CharInfo info1 = (ItopVector.DrawArea.CharInfo) this.chars[index]; XmlNode node1 = info1.TextNode.PreviousSibling; info1.TextNode.ParentNode.RemoveChild(info1.TextNode); if ((info1.firstChild && (info1.TextSvgElement != this.currrentText)) && (((info1.Dx != 0f) || (info1.Dy != 0f)) || ((info1.X != 0f) || (info1.Y != 0f)))) { for (Text text1 = info1.TextSvgElement; text1 != this.currrentText; text1 = (Text) text1.ParentNode) { float single1; float single2; float single3; text1.Y = single1 = 0f; text1.X = single2 = single1; text1.Dy = single3 = single2; text1.Dx = single3; if ((text1.Dx == info1.Dx) && (info1.Dy == info1.Dy)) { break; } } if ((index + 1) < this.chars.Count) { ((ItopVector.DrawArea.CharInfo) this.chars[index + 1]).firstChild = true; } } this.chars.Remove(info1); ItopVector.DrawArea.CharInfo[] infoArray1 = new ItopVector.DrawArea.CharInfo[1] { info1 } ; TextUndoOperation operation1 = new TextUndoOperation(TextAction.Delete, index, infoArray1, this); info1.PreSibling = node1; bool flag2 = this.undostack.AcceptChanges; this.undostack.AcceptChanges = true; TextUndoOperation[] operationArray1 = new TextUndoOperation[1] { operation1 } ; this.undostack.Push(operationArray1); this.undostack.AcceptChanges = flag2; } this.doc.AcceptChanges = flag1; }