public bool Input(EditorEditArea area, int pos, EditorContent content) { if (content == null || content.GetType() != typeof(EditorImage)) return false; area.ContentList.Insert(area.SelectIndex, content); area.SelectIndex = pos + 1; return false; }
public bool Input(EditorEditArea area, int pos, EditorContent content) { if (content.GetType() != typeof(EditorMouse)) return false; EditorMouse mouse = (EditorMouse)content; if (mouse.KeyType != EditorMouse.MouseKeyType.LeftDown && mouse.KeyType != EditorMouse.MouseKeyType.RightDown) return false; this.SetCaretPos(area, mouse.Rectangle.Left, mouse.Rectangle.Top); // 设置光标位置 return false; }
public bool Input(EditorEditArea area, int pos, EditorContent content) { if (content == null || content.GetType() != typeof(EditorChar)) return false; Regex regex = new Regex("[\u4e00-\u9fa5_a-zA-Z0-9_\r,.;:\"'`~!@#$%^&*(){}\\| ]{1}"); if (!regex.IsMatch(content.getText())) return false; // 如果不是数字英文中文等普通字符,则返回false area.ContentList.Insert(pos, content); area.SelectIndex = pos+1; return true; }
public bool Input(EditorEditArea area, int pos, EditorContent content) { if (content.GetType() != typeof(EditorKey)) return false; // 如果没当作按键,返回true,但不处理操作。 if (pos <= 0) return false; // 如果插入位置在0位,就不处理。 if (content == null || content.getText() != "\b") return false; // 如果不是退格键,返回false if ((area.SelectStart - area.SelectEnd) == 0){ area.Remove(pos - 1, pos); } else { area.Remove(area.SelectStart, area.SelectEnd); } return false; }
private int m_selectStartIndex = -1; // 旋转开始的索引位置 public bool Input(EditorEditArea area, int pos, EditorContent content) { if (content.GetType() != typeof(EditorMouse)) return false; EditorMouse mouse = (EditorMouse)content; switch (mouse.KeyType) { case EditorMouse.MouseKeyType.LeftDown: // 鼠标左键按下 this.m_isMouseDown = true; m_selectStartIndex = this.Pos2Index(area, content.Rectangle.Left, content.Rectangle.Top); area.SelectStart = m_selectStartIndex; area.SelectEnd = m_selectStartIndex; break; case EditorMouse.MouseKeyType.LeftUp: // 鼠标左键抬起 this.m_isMouseDown = false; break; case EditorMouse.MouseKeyType.Move: // 鼠标移动 if (!this.m_isMouseDown) break; // 如果鼠标没点下,不执行已下代码 int endIndex = this.Pos2Index(area, content.Rectangle.Left, content.Rectangle.Top); if (this.m_selectStartIndex < endIndex) { area.SelectStart = this.m_selectStartIndex; area.SelectEnd = endIndex + 1; }else if(this.m_selectStartIndex > endIndex) { area.SelectEnd = this.m_selectStartIndex + 1; area.SelectStart = endIndex; }else if (this.m_selectStartIndex == endIndex) { area.SelectStart = this.m_selectStartIndex; area.SelectEnd = this.m_selectStartIndex; } area.Caret.Hide(); // 隐藏光标 #if DEBUG Console.WriteLine(string.Format("select editor index:start={0} end={1}", area.SelectStart, area.SelectEnd)); #endif break; } return false; }