void TouchInputChanged(string input) { if (Keyboard.InputChanged) { FullString.Reset(input, false); var sel = Keyboard.selection; int start = sel.start; int end = sel.start + sel.length; if (end != start) { TextCom.GetPress(start, ref startPress); TextCom.GetPress(end, ref endPress); } else { TextCom.GetPress(start, ref startPress); endPress = startPress; } SetShowText(); TextCom.Populate(); } if (OnValueChanged != null) { OnValueChanged(this); } }
/// <summary> /// 删除选中文本内容 /// </summary> /// <returns></returns> public bool DeleteSelectString() { int si = TextCom.GetIndex(ref startPress); int ei = TextCom.GetIndex(ref endPress); if (si > ei) { FullString.RmoveTextElements(ei, si - ei); startPress = endPress; SetShowText(); TextCom.Populate(); TextCom.Move(ref startPress); return(true); } else if (si < ei) { FullString.RmoveTextElements(si, ei - si); endPress = startPress; SetShowText(); TextCom.Populate(); TextCom.Move(ref startPress); return(true); } return(false); }
public void gHook_MouseUp(object sender, MouseEventArgs e) { PressInfo press = new PressInfo() { point = new POINT() }; press.point.x = e.X; press.point.y = e.Y; switch (e.Button) { case MouseButtons.Left: { press.eventType = Event.LMouseUp; break; } case MouseButtons.Right: { press.eventType = Event.RMouseUp; break; } case MouseButtons.Middle: { press.eventType = Event.MMouseUp; break; } } double time = (DateTime.Now - lastTime).TotalMilliseconds; lastTime = DateTime.Now; record.Enqueue(time); record.Enqueue(press); }
public bool DeletePress(PressInfo u) { int k = PressInfoDal.Instance.Delete(u.ID); if (k > 0) { return(true); } else { return(false); } }
public void gHook_KeyUp(object sender, KeyEventArgs e) { PressInfo press = new PressInfo() { eventType = Event.KeyUp, key = e.KeyCode }; double time = (DateTime.Now - lastTime).TotalMilliseconds; lastTime = DateTime.Now; record.Enqueue(time); record.Enqueue(press); lastPress = press; //listBox1.Items.Add(string.Format("{0} up, {1}", e.KeyCode, Math.Round(time))); }
/// <summary> /// 更新光标 /// </summary> void UpdateCaret() { if (Caret != null) { hs.Clear(); tris.Clear(); switch (TextOperation.Style) { case 1: if (!ReadOnly) { time += UserAction.TimeSlice; if (time > 1000f) { time = 0; } else if (time > 400f) { Caret.gameObject.SetActive(false); } else { Caret.gameObject.SetActive(true); PressInfo start = TextOperation.GetStartPress(); InputEvent.GetPointer(tris, hs, ref PointColor, ref start); Caret.LoadFromMesh(hs, tris); PressInfo end = TextOperation.GetEndPress(); InputEvent.SetCursorPos(ref end); } } else { Caret.gameObject.SetActive(false); } break; case 2: Caret.gameObject.SetActive(true); PressInfo s = TextOperation.GetStartPress(); PressInfo e = TextOperation.GetEndPress(); InputEvent.GetSelectArea(tris, hs, ref SelectionColor, ref s, ref e); Caret.LoadFromMesh(hs, tris); break; default: Caret.gameObject.SetActive(false); break; } } }
/// <summary> /// 鼠标按压 /// </summary> /// <param name="action">用户事件</param> /// <param name="press">按压基本信息</param> public void OnMouseDown(UserAction action, ref PressInfo press) { TextOperation.contentType = m_ctpye; TextOperation.ChangeText(TextCom, FullString); SetShowText(); TextOperation.SetPress(ref press); #if UNITY_STANDALONE_WIN || UNITY_EDITOR if (!ReadOnly) { Editing = true; } //Input.imeCompositionMode = IMECompositionMode.On; #endif }
public void gHook_MouseMove(object sender, MouseEventArgs e) { PressInfo press = new PressInfo() { point = new POINT(), eventType = Event.MouseWheel }; press.point.x = e.X; press.point.y = e.Y; double time = (DateTime.Now - lastTime).TotalMilliseconds; lastTime = DateTime.Now; record.Enqueue(time); record.Enqueue(press); }
/// <summary> /// 用户单击 /// </summary> /// <param name="action">用户事件</param> public void OnClick(UserAction action) { endPress = startPress; if (!ReadOnly) { Input.imeCompositionMode = IMECompositionMode.On; Editing = true; if (!Keyboard.active) { bool pass = contentType == ContentType.Password ? true : false; bool multiLine = lineType == LineType.MultiLineNewline ? true : false; Keyboard.OnInput(FullString.FullString, touchType, multiLine, pass, CharacterLimit); } } }
/// <summary> /// 鼠标按压 /// </summary> /// <param name="action">用户事件</param> /// <param name="press">按压基本信息</param> public void OnMouseDown(UserAction action) { if (InputString != "" & InputString != null) { TextCom.CheckPoint(InputEvent, action, ref startPress); endPress = startPress; } #if UNITY_STANDALONE_WIN || UNITY_EDITOR if (!ReadOnly) { Editing = true; } Input.imeCompositionMode = IMECompositionMode.On; #endif SetShowText(); }
public string UpdatePress(PressInfo u) { string msg = "操作成功。"; int k = PressInfoDal.Instance.Update(u); if (k > 0) { msg = "操作成功。"; } else { msg = "操作失败。"; } return(new JsonMessage { Data = k.ToString(), Message = msg, Success = k > 0 }.ToString()); }
public void gHook_MouseWheel(object sender, MouseEventArgs e) { PressInfo press = new PressInfo() { point = new POINT(), eventType = Event.MouseWheel }; press.point.x = e.X; press.point.y = e.Y; press.wheelCount = e.Delta; double time = (DateTime.Now - lastTime).TotalMilliseconds; lastTime = DateTime.Now; record.Enqueue(time); record.Enqueue(press); listBox1.Items.Add(string.Format("Wheel {0}", (e.Delta > 0) ? "up" : "down")); }
string OnInputChanged(string input) { if (ReadOnly) { return(""); } if (input == null | input == "") { return(""); } input = CharOperation.Validate(characterValidation, input, input.Length); if (input == null | input == "") { return(""); } if (CharacterLimit > 0) { int c = CharacterLimit - FullString.Length; if (c <= 0) { TextCom.stringEx.Reset(FullString.FullString, false); TextCom.Populate(); TextCom.m_vertexChange = true; return(""); } int[] o = StringInfo.ParseCombiningCharacters(input); if (o.Length > c) { input = new StringInfo(input).SubstringByTextElements(0, o[c - 1]); } } DeleteSelectString(); int len = FullString.Length; int index = TextCom.GetIndex(ref startPress); FullString.InsertTextElements(index, input); SetShowText(); len = FullString.Length - len; TextCom.Populate(); TextCom.MoveRight(ref startPress, len); endPress = startPress; return(input); }
/// <summary> /// 删除光标前面的字符 /// </summary> /// <returns></returns> public bool DeleteLast() { if (DeleteSelectString()) { return(true); } int index = TextCom.GetIndex(ref startPress); if (index > 0) { int row = startPress.Row; TextCom.MoveLeft(ref startPress); endPress = startPress; FullString.RmoveTextElements(index - 1, 1); SetShowText(); TextCom.Populate(); TextCom.Move(ref startPress); return(true); } return(false); }
public void gHook_KeyDown(object sender, KeyEventArgs e) { PressInfo press = new PressInfo() { eventType = Event.KeyDown, key = e.KeyCode }; if (checkBoxText.Checked || !press.Equals(lastPress)) { if (!press.Equals(lastPress)) { listBox1.Items.Add(e.KeyCode); } //listBox1.Items.Add(string.Format("{0} down, {1}", e.KeyCode, Math.Round(time))); double time = (DateTime.Now - lastTime).TotalMilliseconds; lastTime = DateTime.Now; record.Enqueue(time); record.Enqueue(press); lastPress = press; } }
public void gHook_MouseDown(object sender, MouseEventArgs e) { PressInfo press = new PressInfo() { point = new POINT() }; press.point.x = e.X; press.point.y = e.Y; switch (e.Button) { case MouseButtons.Left: { press.eventType = Event.LMouseDown; break; } case MouseButtons.Right: { press.eventType = Event.RMouseDown; break; } case MouseButtons.Middle: { press.eventType = Event.MMouseDown; break; } } double time = (DateTime.Now - lastTime).TotalMilliseconds; lastTime = DateTime.Now; record.Enqueue(time); record.Enqueue(press); listBox1.Items.Add(string.Format("{2} button ({0}; {1})", e.X, e.Y, e.Button)); }
/// <summary> /// 光标向右移动 /// </summary> public void PointerMoveRight() { TextCom.MoveRight(ref startPress, 1); endPress = startPress; }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var json = HttpContext.Current.Request["json"]; var rpm = new RequestParamModel <bookhelp.Model.PressInfo>(context) { CurrentContext = context, Action = context.Request["action"], KeyId = PublicMethod.GetInt(context.Request["id"]) }; if (!string.IsNullOrEmpty(json)) { rpm = JSONhelper.ConvertToObject <RequestParamModel <bookhelp.Model.PressInfo> >(json); rpm.CurrentContext = context; //rpm.KeyId = PublicMethod.GetInt(context.Request["id"]); } int k = 0; switch (rpm.Action) { case "add": //添加 string textPressName = context.Request["textPressName"]; string textPressAddress = context.Request["textPressAddress"]; string textPressPhone = context.Request["textPressPhone"]; PressInfo info = new PressInfo(); info.PressName = textPressName; info.PressAddress = textPressAddress; info.PressPhone = textPressPhone; PressInfoBll.Instance.SavePress(info); context.Response.Write(new JsonMessage { Data = k.ToString(), Message = "添加成功", Success = true }.ToString()); break; case "edit": //修改 string uid = context.Request["ID"]; string utextPressName = context.Request["textPressName"]; string utextPressAddress = context.Request["textPressAddress"]; string utextPressPhone = context.Request["textPressPhone"]; PressInfo uinfo = new PressInfo(); uinfo.ID = Int32.Parse(uid); uinfo.PressName = utextPressName; uinfo.PressAddress = utextPressAddress; uinfo.PressPhone = utextPressPhone; PressInfoBll.Instance.UpdatePress(uinfo); context.Response.Write(new JsonMessage { Data = k.ToString(), Message = "修改成功", Success = true }.ToString()); break; case "delete": string did = context.Request["id"]; PressInfo dinfo = new PressInfo(); dinfo.ID = Int32.Parse(did); //bool result = BookInfoBll.DeleteBook(dinfo); PressInfoBll bll = new PressInfoBll(); //bll.DeleteBook(dinfo); if (bll.DeletePress(dinfo)) { context.Response.Write("ok"); } else { context.Response.Write("no"); } break; case "search": //string bookName = context.Request["bookName"]; //string pressName = context.Request["pressName"]; //string sn = context.Request["sn"]; //string priceLow = context.Request["priceLow"]; //string priceHigh = context.Request["priceHigh"]; context.Response.Write(JsonDataForEasyUIdataGrid(rpm.Pageindex, rpm.Pagesize, rpm.Filter)); break; case "list": var r = PressInfoBll.Instance.GetPressInfo(); context.Response.Write(r); //context.Response.Write(JsonDataForEasyUIdataGrid2(rpm.Pageindex, rpm.Pagesize, rpm.Filter)); break; default: context.Response.Write(JsonDataForEasyUIdataGrid(rpm.Pageindex, rpm.Pagesize, rpm.Filter)); break; } }
/// <summary> /// 拖动选择 /// </summary> /// <param name="action">用户事件</param> /// <param name="press">当前按压信息</param> public void OnDrag(UserAction action, ref PressInfo press) { TextOperation.SetEndPress(ref press); }
/// <summary> /// 光标移动到文本结尾 /// </summary> public void PointerMoveEnd() { TextCom.MoveEnd(ref startPress); endPress = startPress; }
/// <summary> /// 更新显示内容 /// </summary> /// <param name="time">时间片</param> public override void Update(float time) { #if UNITY_STANDALONE_WIN || UNITY_EDITOR if (InputEvent.Focus) { var state = KeyPressed(); if (state == EditState.Continue) { if (Keyboard.InputChanged) { OnInputChanged(Keyboard.InputString); } else if (CompositionString != Keyboard.CompositionString) { SetShowText(); } } else if (state == EditState.Finish) { if (!ReadOnly) { if (OnSubmit != null) { OnSubmit(this); } } } else if (state == EditState.NewLine) { if (!ReadOnly) { if (lineType == LineType.SingleLine) { if (OnSubmit != null) { OnSubmit(this); } } else { OnInputChanged("\n"); } } } #else if (Editing) { TouchInputChanged(Keyboard.TouchString); if (Keyboard.status == TouchScreenKeyboard.Status.Done) { if (OnDone != null) { OnDone(this); } return; } #endif UpdateCaret(); } else { if (Caret != null) { Caret.activeSelf = false; } } } float time; /// <summary> /// 更新光标 /// </summary> void UpdateCaret() { if (Caret != null) { hs.Clear(); tris.Clear(); if (startPress.Row == endPress.Row & startPress.Offset == endPress.Offset) { if (!ReadOnly) { time += UserAction.TimeSlice; if (time > 1000f) { time = 0; } else if (time > 400f) { Caret.activeSelf = false; } else { Caret.activeSelf = true; PressInfo press = startPress; string cs = Keyboard.CompositionString; if (cs != null) { press.Offset += cs.Length; } TextCom.GetPointer(tris, hs, ref PointColor, ref press); Caret.LoadFromMesh(hs, tris); TextCom.SetCursorPos(ref endPress); } } else { Caret.activeSelf = false; } } else { Caret.activeSelf = true; int si = TextCom.GetIndex(ref startPress); int ei = TextCom.GetIndex(ref endPress); if (si > ei) { TextCom.GetSelectArea(tris, hs, ref SelectionColor, ref endPress, ref startPress); } else { TextCom.GetSelectArea(tris, hs, ref SelectionColor, ref startPress, ref endPress); } Caret.LoadFromMesh(hs, tris); } } } void KeySpeedUp() { KeySpeed *= 0.8f; if (KeySpeed < MaxSpeed) { KeySpeed = MaxSpeed; } KeyPressTime = KeySpeed; } EditState KeyPressed() { KeyPressTime -= UserAction.TimeSlice; if (Keyboard.GetKey(KeyCode.Backspace)) { if (!ReadOnly) { if (KeyPressTime <= 0) { DeleteLast(); KeySpeedUp(); } } return(EditState.Done); } if (Keyboard.GetKey(KeyCode.Delete)) { if (!ReadOnly) { if (KeyPressTime <= 0) { DeleteNext(); KeySpeedUp(); } } return(EditState.Done); } if (Keyboard.GetKey(KeyCode.LeftArrow)) { if (KeyPressTime <= 0) { PointerMoveLeft(); KeySpeedUp(); } return(EditState.Done); } if (Keyboard.GetKey(KeyCode.RightArrow)) { if (KeyPressTime <= 0) { PointerMoveRight(); KeySpeedUp(); } return(EditState.Done); } if (Keyboard.GetKey(KeyCode.UpArrow)) { if (KeyPressTime <= 0) { PointerMoveUp(); KeySpeedUp(); } return(EditState.Done); } if (Keyboard.GetKey(KeyCode.DownArrow)) { if (KeyPressTime <= 0) { PointerMoveDown(); KeySpeedUp(); } return(EditState.Done); } KeySpeed = 220f; if (Keyboard.GetKeyDown(KeyCode.Home)) { PointerMoveStart(); return(EditState.Done); } if (Keyboard.GetKeyDown(KeyCode.End)) { PointerMoveEnd(); return(EditState.Done); } if (Keyboard.GetKeyDown(KeyCode.A)) { if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl)) { TextCom.GetEnd(ref endPress); startPress.Row = 0; startPress.Offset = 0; return(EditState.Done); } } if (Keyboard.GetKeyDown(KeyCode.X))//剪切 { if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl)) { GUIUtility.systemCopyBuffer = GetSelectString(); if (!ReadOnly) { DeleteSelectString(); } return(EditState.Done); } } if (Keyboard.GetKeyDown(KeyCode.C))//复制 { if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl)) { GUIUtility.systemCopyBuffer = GetSelectString(); return(EditState.Done); } } if (Keyboard.GetKeyDown(KeyCode.V))//粘贴 { if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl)) { OnInputChanged(Keyboard.systemCopyBuffer); return(EditState.Done); } } if (Keyboard.GetKeyDown(KeyCode.Return) | Keyboard.GetKeyDown(KeyCode.KeypadEnter)) { if (lineType == LineType.MultiLineNewline) { if (Keyboard.GetKey(KeyCode.RightControl)) { return(EditState.Finish); } return(EditState.NewLine); } else { return(EditState.Finish); } } if (Keyboard.GetKeyDown(KeyCode.Escape)) { return(EditState.Finish); } return(EditState.Continue); } }
public void RecordPlay() { Queue recordTape = new Queue(record); recordTape.Dequeue(); recordTape.Dequeue(); while (recordTape.Count > 2) { int time = (int)((double)recordTape.Dequeue()); Thread.Sleep(time); PressInfo press = (PressInfo)recordTape.Dequeue(); switch (press.eventType) { case Event.KeyDown: { IntPtr ptr = (IntPtr)User32.GetForegroundWindow(); User32.PostMessage(ptr, (int)Event.KeyDown, (int)press.key, 0); break; } case Event.KeyUp: { if (checkBoxText.Checked) { break; } IntPtr ptr = (IntPtr)User32.GetForegroundWindow(); User32.PostMessage(ptr, (int)Event.KeyUp, (int)press.key, 0); break; } case Event.LMouseDown: { Cursor.Position = new System.Drawing.Point(press.point.x, press.point.y); User32.mouse_event(User32.MOUSEEVENTF_LEFTDOWN, press.point.x, press.point.y, 0, 0); break; } case Event.RMouseDown: { Cursor.Position = new System.Drawing.Point(press.point.x, press.point.y); User32.mouse_event(User32.MOUSEEVENTF_RIGHTDOWN, press.point.x, press.point.y, 0, 0); break; } case Event.MMouseDown: { Cursor.Position = new System.Drawing.Point(press.point.x, press.point.y); User32.mouse_event(User32.MOUSEEVENTF_MIDDLEDOWN, press.point.x, press.point.y, 0, 0); break; } case Event.LMouseUp: { Cursor.Position = new System.Drawing.Point(press.point.x, press.point.y); User32.mouse_event(User32.MOUSEEVENTF_LEFTUP, press.point.x, press.point.y, 0, 0); break; } case Event.RMouseUp: { Cursor.Position = new System.Drawing.Point(press.point.x, press.point.y); User32.mouse_event(User32.MOUSEEVENTF_RIGHTUP, press.point.x, press.point.y, 0, 0); break; } case Event.MMouseUp: { Cursor.Position = new System.Drawing.Point(press.point.x, press.point.y); User32.mouse_event(User32.MOUSEEVENTF_MIDDLEUP, press.point.x, press.point.y, 0, 0); break; } case Event.MouseWheel: { Cursor.Position = new System.Drawing.Point(press.point.x, press.point.y); User32.mouse_event(MOUSEEVENTF_WHEEL, press.point.x, press.point.y, press.wheelCount, 0); break; } case Event.MouseMove: { User32.mouse_event(User32.MOUSEEVENTF_MOVE, press.point.x, press.point.y, press.wheelCount, 0); break; } } } state = State.Wait; labelStatus.Invoke((MethodInvoker)(() => labelStatus.Text = "Ожидание")); Invoke((Updater)LabelUpdate); return; }