2 using System.Collections.Generic;
5 using System.Diagnostics;
6 using System.Reflection;
7 using System.Runtime.InteropServices;
8 using System.Globalization;
10 using DotNetTextStore.UnmanagedAPI.TSF;
11 using DotNetTextStore.UnmanagedAPI.TSF.TextStore;
12 using DotNetTextStore.UnmanagedAPI.WinDef;
13 using DotNetTextStore.UnmanagedAPI.WinError;
15 namespace DotNetTextStore
19 //========================================================================================
24 /// 各ドキュメント毎に実装すべき部分をイベントとして切り離して、テキストストアの実装を楽に
28 /// 使用側としては各イベントハンドラの実装、フォーカスを取得した時に SetFocus() メソッドの
29 /// 呼び出し、選択やテキストが変更された時に NotifySelectionChanged() メソッドや
30 /// NotifyTextChange() メソッドの呼び出しを行う必要がある。
32 public sealed class TextStore : TextStoreBase,IDisposable, ITextStoreACP, ITfContextOwnerCompositionSink
34 public delegate IntPtr GetHWndHandler();
35 public event GetHWndHandler GetHWnd;
44 GC.SuppressFinalize(this);
48 #region ITextStoreACPの実装
49 public void GetWnd(int i_viewCookie, out IntPtr o_hwnd)
52 using(var dbgout = new DebugOut("{0}()", DebugOut.GetCaller()) )
63 #region TSF 関連のラッパメソッド
68 /// <exception cref="COMException">
69 /// スレッドマネージャーの生成に失敗した場合。
71 protected override void CreateThreadMgr()
73 if( _threadMgr == null )
75 TextFrameworkFunctions.TF_GetThreadMgr(out _threadMgr);
76 if( _threadMgr == null )
78 Type clsid = Marshal.GetTypeFromCLSID(TfDeclarations.CLSID_TF_ThreadMgr);
79 _threadMgr = Activator.CreateInstance(clsid) as ITfThreadMgr;
81 if( _threadMgr == null )
83 const string message = "スレッドマネージャーの生成に失敗しました。";
84 Debug.WriteLine(message);
85 throw new COMException(message, HRESULT.E_NOTIMPL);