//method yg dijalankan saat request success harus memiliki parameter bertipe HttpResponseBundle private void setViewSuccessLogin(HttpResponseBundle _response) { if (_response.getHttpResponseMessage().Content != null) { Application.Current.Resources["email"] = _response.getJObject()["user"]["email"]; Application.Current.Resources["ha_id"] = _response.getJObject()["user"]["health_agency_id"]; String role = _response.getJObject()["user"]["role"].ToString(); String saveStr = _response.getJObject()["user"]["email"] + "," + _response.getJObject()["access_token"].ToString() + "," + _response.getJObject()["user"]["role"] + "," + _response.getJObject()["user"]["health_agency_id"]; TextOperation.writeToFile("../../assets/user.txt", saveStr); client.setAuthorizationToken(_response.getJObject()["access_token"].ToString()); string status = _response.getHttpResponseMessage().ReasonPhrase; if (role == "Admin" || role == "Super Admin") { getView().callMethod("setLoginSuccess", status, role); } else { getView().callMethod("restrictNoAuthentication", status); } } }
/// <summary> /// 插入字符串 /// </summary> /// <param name="str">字符串</param> public void InsertString(string str) { var es = new EmojiString(str); TextOperation.DeleteSelectString(); TextOperation.InsertContent(es); }
private List <XRect> GetColoredText(Doc doc, string color) { var rects = new List <XRect>(); var op = new TextOperation(doc); op.PageContents.AddPages(doc.PageNumber); var txt = op.GetText(); var fragments = op.Select(0, txt.Length); var link = new List <TextFragment>(); foreach (var fragment in fragments) { var isLink = fragment.FontColor.ToString() == color; if ((!isLink) && (link.Count > 0)) { rects.AddRange(op.Group(link) .Select(@group => @group.Rect)); link.Clear(); } if (isLink) { link.Add(fragment); } } if (link.Count > 0) { rects.AddRange(op.Group(link) .Select(@group => @group.Rect)); } return(rects); }
private void button1_Click(object sender, System.EventArgs e) { // Here we look at an area on the page and redact the text in it XRect toRedact = new XRect(textBoxRect.Text); using (Doc doc = new Doc()) { doc.Read(_src); TextOperation op = new TextOperation(doc); op.PageContents.AddPages(1); string text = op.GetText(toRedact, 1); IList <TextFragment> fragments = op.Select(0, text.Length); if (radioButtonCoarse.Checked) { SimpleRedaction.RedactTextOps(doc, fragments); } else { FineRedaction.RedactCharacters(doc, fragments); } doc.Flatten(); string dst = Path.Combine(Directory.GetParent(_src).FullName, "_" + Path.GetRandomFileName() + ".pdf"); doc.Save(dst); _src = dst; UpdateDoc(); } }
void TouchInputChanged(string input) { if (Keyboard.InputChanged) { FullString.FullString = input; TextOperation.ChangeText(TextCom, FullString); var sel = Keyboard.selection; int start = sel.start; int end = sel.start + sel.length; if (end != start) { TextOperation.SetStartPressIndex(start); TextOperation.SetEndPressIndex(end); } else { bool lc = false; TextOperation.SetPressIndex(start, ref lc); } SetShowText(); } if (OnValueChanged != null) { OnValueChanged(this); } }
private List <TextFragment> FindText(Doc doc) { TextOperation op = new TextOperation(doc); op.PageContents.AddPages(1); // hardwired to page one for these examples string text = op.GetText(); List <TextFragment> fragments = new List <TextFragment>(); foreach (string candidate in textBoxFind.Lines) { if (candidate.Length == 0) { continue; } int pos = -1; while (true) { pos = text.IndexOf(candidate, pos + 1); if (pos < 0) { break; } fragments.AddRange(op.Select(pos, candidate.Length)); } } return(fragments); }
private List <TextFragment> FindFont(Doc doc, List <TextFragment> others) { TextOperation op = new TextOperation(doc); op.PageContents.AddPages(1); // hardwired to page one for these examples string text = op.GetText(); List <TextFragment> fragments = new List <TextFragment>(); if (text.Length > 0) { IList <TextFragment> candidates = op.Select(0, text.Length); foreach (TextFragment candidate in candidates) { if (candidate.Font.BaseFont.Contains(textBoxFont.Text)) { fragments.Add(candidate); } else if (others != null) { others.Add(candidate); } } } return(fragments); }
private void annotateButton_Click(object sender, EventArgs e) { if (_doc == null) { return; } Properties props = Properties.FromDoc(_doc, false); foreach (Page page in _doc.ObjectSoup.Catalog.Pages.GetPageArrayAll()) { Reader oc = Reader.FromPage(props, page); TextOperation op = new TextOperation(_doc); op.PageContents.AddPages(); string text = op.GetText(); IList <TextFragment> fragments = op.Select(0, text.Length); _doc.FontSize = 12; _doc.Width = 0.1; foreach (TextFragment fragment in fragments) { _doc.Rect.String = fragment.Rect.String; List <OptionalContent.Layer> states = oc.GetLayersFromStreamAndPosition(fragment.StreamID, fragment.StreamOffset); string[] names = new string[states.Count]; for (int i = 0; i < names.Length; i++) { names[i] = states[i].Group != null ? states[i].Group.EntryName.Text : "Membership Dictionary"; } if (names.Length > 0) { _doc.AddText(string.Join(" ", names)); } _doc.FrameRect(); } } UpdatePreview(); }
/// <summary> /// 删除光标后面的字符 /// </summary> /// <returns></returns> public bool DeleteNext() { if (TextOperation.DeleteNext()) { SetShowText(); return(true); } return(false); }
public static void TestCommandPattern() { TextOperation.Do(new CopyCommand(), "test copy"); TextOperation.Do(new CutCommand(), "test cut"); TextOperation.Do(new MarkCommand(), "test mark"); TextOperation.Do(new PasteCommand(), "test paste"); }
protected override void OnDrag(UserAction action) { if (Pressed) { if (action.CanPosition != action.LastPosition) { if (!entry) { float oy = action.CanPosition.y - GlobalPosition.y; float py = GlobalScale.y * text.SizeDelta.y * 0.5f; if (oy > 0) { oy -= py; } else { oy += py; } if (oy > overDistance) { oy = overDistance; } float per = 5000 / oy; if (per < 0) { per = -per; } overTime += UserAction.TimeSlice; if (overTime >= per) { overTime -= per; if (oy > 0) { if (TextOperation.ContentMoveUp()) { input.SetShowText(); } } else { if (TextOperation.ContentMoveDown()) { input.SetShowText(); } } } } PressInfo press = new PressInfo(); CheckPointer(action, ref press); input.OnDrag(action, ref press); } } base.OnDrag(action); }
/// <summary> /// 光标移动到文本结尾 /// </summary> public void PointerMoveEnd() { bool lc = false; if (TextOperation.SetPressIndex(999999999, ref lc)) { if (lc) { SetShowText(); } } }
/// <summary> /// 光标向下移动 /// </summary> public void PointerMoveDown() { bool lc = false; if (TextOperation.PointerMoveDown(ref lc)) { if (lc) { SetShowText(); } } }
/// <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 }
/// <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> public void SetShowText() { var str = FullString.FullString; if (Editing) { if (TextCom == null) { return; } str = TextOperation.GetShowContent();//GetShowString(); TextCom.MainColor = textColor; if (contentType == ContentType.Password) { str = new string('●', str.Length); } TextCom.Text = str; InputEvent.ChangeText(str); ShowString = str; } else if (str != "" & str != null) { if (TextCom == null) { return; } TextCom.MainColor = textColor; if (contentType == ContentType.Password) { str = new string('●', str.Length); } TextCom.Text = str; ShowString = str; InputEvent.ChangeText(str); } else { TextCom.MainColor = m_tipColor; TextCom.Text = m_TipString; ShowString = m_TipString; InputEvent.ChangeText(""); } }
internal override void OnMouseWheel(UserAction action) { float oy = action.MouseWheelDelta; if (oy > 0) { if (TextOperation.ContentMoveUp()) { input.SetShowText(); } } else { if (TextOperation.ContentMoveDown()) { input.SetShowText(); } } base.OnMouseWheel(action); }
/// <summary> /// 拖动选择 /// </summary> /// <param name="action">用户事件</param> /// <param name="press">当前按压信息</param> public void OnDrag(UserAction action, ref PressInfo press) { TextOperation.SetEndPress(ref press); }
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)) { TextOperation.SelectAll(); return(EditState.Done); } } if (Keyboard.GetKeyDown(KeyCode.X))//剪切 { if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl)) { string str = TextOperation.GetSelectString(); if (!ReadOnly) { DeleteSelectString(); } GUIUtility.systemCopyBuffer = str; return(EditState.Done); } } if (Keyboard.GetKeyDown(KeyCode.C))//复制 { if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl)) { string str = TextOperation.GetSelectString(); GUIUtility.systemCopyBuffer = str; 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); }