/// <summary> /// Fetches the a text data set for the given 'TextDataType' /// </summary> /// <param name="type"></param> /// <returns></returns> public static JSONNode GetDataSource(TextDataType type) { Initialise(); if (type == TextDataType.None) { Debug.LogError("There are not data source for the given type: " + type); } return(_datas[(int)type]); }
protected override TextData Read(ContentReader input, TextData existingInstance) { if (existingInstance != null) { return(existingInstance); } TextDataType type = (TextDataType)input.ReadByte(); string value = input.ReadString(); return(new TextData(type, value)); }
/// <summary> /// Sets content of the system clipboard. /// </summary> /// <param name="text">Text data to set.</param> /// <param name="dataType">Type of the data to set.</param> /// <remarks> /// <para> /// This method set content of the system clipboard. /// If <paramref name="dataType"/> is TextDataType.Normal, /// the text data will be just a character sequence. /// If <paramref name="dataType"/> is TextDataType.Line or TextDataType.Rectangle, /// stored text data would be special format that is compatible with Microsoft Visual Studio. /// </para> /// </remarks> public void SetClipboardText(string text, TextDataType dataType) { Int32 rc; // result code IntPtr dataHdl; bool clipboardOpened = false; try { // open clipboard rc = WinApi.OpenClipboard(IntPtr.Zero); if (rc == 0) { return; } clipboardOpened = true; // clear clipboard first WinApi.EmptyClipboard(); // set normal text data dataHdl = Utl.MyStringToHGlobalUni(text); WinApi.SetClipboardData(WinApi.CF_UNICODETEXT, dataHdl); // set addional text data if (dataType == TextDataType.Line) { // allocate dummy text (this is needed for PocketPC) dataHdl = Utl.MyStringToHGlobalUni(""); WinApi.SetClipboardData(_CF_LINEOBJECT, dataHdl); } else if (dataType == TextDataType.Rectangle) { // allocate dummy text (this is needed for PocketPC) dataHdl = Utl.MyStringToHGlobalUni(""); WinApi.SetClipboardData(_CF_RECTSELECT, dataHdl); } } finally { if (clipboardOpened) { WinApi.CloseClipboard(); } } }
/// <summary> /// Gets content of the system clipboard. /// </summary> /// <param name="dataType">The type of the text data in the clipboard</param> /// <returns>Text content retrieved from the clipboard if available. Otherwise null.</returns> /// <remarks> /// <para> /// This method gets text from the system clipboard. /// If stored text data is a special format (line or rectangle,) /// its data type will be set to <paramref name="dataType"/> parameter. /// </para> /// </remarks> /// <seealso cref="Sgry.Azuki.TextDataType">TextDataType enum</seealso> public string GetClipboardText(out TextDataType dataType) { Int32 rc; // result code bool clipboardOpened = false; IntPtr dataHandle = IntPtr.Zero; IntPtr dataPtr = IntPtr.Zero; uint formatID = UInt32.MaxValue; string data = null; dataType = TextDataType.Normal; try { // open clipboard rc = WinApi.OpenClipboard(IntPtr.Zero); if (rc == 0) { return(null); } clipboardOpened = true; // distinguish type of data in the clipboard if (WinApi.IsClipboardFormatAvailable(_CF_LINEOBJECT) != 0) { formatID = WinApi.CF_UNICODETEXT; dataType = TextDataType.Line; } else if (WinApi.IsClipboardFormatAvailable(_CF_RECTSELECT) != 0) { formatID = WinApi.CF_UNICODETEXT; dataType = TextDataType.Rectangle; } else if (WinApi.IsClipboardFormatAvailable(WinApi.CF_UNICODETEXT) != 0) { formatID = WinApi.CF_UNICODETEXT; } else if (WinApi.IsClipboardFormatAvailable(WinApi.CF_TEXT) != 0) { formatID = WinApi.CF_TEXT; } if (formatID == UInt32.MaxValue) { return(null); // no text data was in clipboard } // get handle of the clipboard data dataHandle = WinApi.GetClipboardData(formatID); if (dataHandle == IntPtr.Zero) { return(null); } // get data pointer by locking the handle dataPtr = Utl.MyGlobalLock(dataHandle); if (dataPtr == IntPtr.Zero) { return(null); } // retrieve data if (formatID == WinApi.CF_TEXT) { data = Utl.MyPtrToStringAnsi(dataPtr); } else { data = Marshal.PtrToStringUni(dataPtr); } } finally { // unlock handle if (dataPtr != IntPtr.Zero) { Utl.MyGlobalUnlock(dataHandle); } if (clipboardOpened) { WinApi.CloseClipboard(); } } return(data); }
public ProcessedTextData(TextDataType type, string value) { Type = type; Value = value; }
public TextDataFile(FileStream data, TextDataType type) { Data = data; Type = type; }
public TextData(TextDataType type, string value) { Type = type; Value = value; }