タブレット ペン データを DynamicRenderer オブジェクトのキャッシュから解放します。
名前空間 : Microsoft.StylusInput
アセンブリ : Microsoft.Ink (Microsoft.Ink.dll 内)
構文
'宣言
Public Sub ReleaseCachedData ( _
cachedDataId As Integer _
)
'使用
Dim instance As DynamicRenderer
Dim cachedDataId As Integer
instance.ReleaseCachedData(cachedDataId)
public void ReleaseCachedData(
int cachedDataId
)
public:
void ReleaseCachedData(
int cachedDataId
)
public void ReleaseCachedData(
int cachedDataId
)
public function ReleaseCachedData(
cachedDataId : int
)
パラメータ
- cachedDataId
型 : System.Int32
解放されるデータの識別子。
解説
このメソッドは、EnableDataCache プロパティが true に設定されている場合にだけ使用されます。
EnableDataCache プロパティを true に設定すると、低速なプロセスによって出力キューがブロックされる状況に対処できます。ストロークが DynamicRenderer オブジェクトによって描画された後でしばらくウィンドウが無効になる場合は、収集されたストロークが再描画されるまでに遅延が発生している可能性があります。DynamicRenderer のストロークをキャッシュに入れることにより、Refresh メソッドを呼び出してストロークを再描画できます。ただし、ストロークが収集されたら、ReleaseCachedData メソッドを呼び出して、キャッシュからストロークを解放してください。通常、この解放は CustomStylusDataAdded メソッドで行われます。
EnableDataCache プロパティを true に設定することが役立つもう 1 つの状況は、ストロークを描画されたとおりに表示するが、ストロークを使用した後は長く保存する必要がない場合です。この場合は、データ識別子を CustomStylusDataAdded メソッドの data パラメータに格納し、キャッシュされたストロークが不要になった時点でデータを解放します。
例
この C# の例は、Windows SDK の「タブレットおよびタッチ テクノロジ」セクションで提供されている「RealTimeStylus Ink Collection Sample」を拡張したものです。DynamicRenderer、theDynamicRenderer を有効にした後、EnableDataCache プロパティを true に設定します。DataInterest プロパティは、DataInterestMask が追加されるように変更されます。CustomStylusDataAdded メソッドは、DynamicRendererCachedDataGuid フィールドの識別子を使用してデータを検索し、そのデータの CachedDataId プロパティを使用してデータを解放します。
// ...
private void InkCollection_Load(object sender, System.EventArgs e)
{
// ...
// Enable the real time stylus and the dynamic renderer
theRealTimeStylus.Enabled = true;
theDynamicRenderer.Enabled = true;
// Enable caching. If a refresh happens during inking, then
// the stroke will still be displayed. However, we have to
// release the cached data later.
theDynamicRenderer.EnableDataCache = true;
// ...
}
// ...
public DataInterestMask DataInterest
{
get
{
return DataInterestMask.StylusDown |
DataInterestMask.Packets |
DataInterestMask.StylusUp |
DataInterestMask.Error |
DataInterestMask.CustomStylusDataAdded;
}
}
public void CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data)
{
// Release any cached data that's shown up.
if (data.CustomDataId == DynamicRenderer.DynamicRendererCachedDataGuid)
{
DynamicRendererCachedData cachedData = (DynamicRendererCachedData) data.Data;
cachedData.DynamicRenderer.ReleaseCachedData(cachedData.CachedDataId);
}
}
// ...
この C# の例では、DynamicRenderer オブジェクトのデータをキャッシュに配置します。これにより、ウィンドウが無効になってもストロークが消去されなくなります。その後、プログラムでストロークを消去します。DynamicRenderer オブジェクト theDynamicRenderer を有効にした後、EnableDataCache プロパティは true に設定されます。Paint イベント ハンドラで、DynamicRenderer.Refresh を呼び出して、キャッシュ内のタブレット ペン データを再描画します。DataInterest プロパティは、DataInterestMask が追加されるように変更されます。CustomStylusDataAdded メソッドは、DynamicRendererCachedDataGuid フィールドの識別子を使用してデータを検索し、そのデータ識別子を ArrayList の cachedIds に格納します。ClearStrokes メソッドは、cachedIds のすべての識別子に対して ReleaseCachedData を呼び出し、Control の Refresh を呼び出します。
using Microsoft.StylusInput;
using Microsoft.StylusInput.PluginData;
// ...
public class InkCollection : Form, IStylusAsyncPlugin
{
private RealTimeStylus theRealTimeStylus;
private DynamicRenderer theDynamicRenderer;
private ArrayList cachedIds = new ArrayList();
// ...
private void TempInkCollection_Load(object sender, System.EventArgs e)
{
theDynamicRenderer = new DynamicRenderer(this);
theRealTimeStylus = new RealTimeStylus(this, true);
// Add the dynamic renderer to the synchronous plugin notification chain.
// Synchronous notifications occur on the pen thread.
theRealTimeStylus.SyncPluginCollection.Add(theDynamicRenderer);
// Add the form to the asynchronous plugin notification chain. This plugin
// will be used to collect stylus data into an ink object. Asynchronous
// notifications occur on the UI thread.
theRealTimeStylus.AsyncPluginCollection.Add(this);
// Enable the real time stylus and the dynamic renderer
theRealTimeStylus.Enabled = true;
theDynamicRenderer.Enabled = true;
// Enable caching. If a refresh happens during inking, then
// the stroke will still be displayed. However, we have to
// release the cached data later.
theDynamicRenderer.EnableDataCache = true;
}
// ...
private void InkCollection_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
// Refresh the dynamic renderer, since it's possible that a stroke is being
// collected at the time Paint occurs. In this case, the portion of the stroke
// that has already been collected will need to be redrawn.
theDynamicRenderer.ClipRectangle = e.ClipRectangle;
theDynamicRenderer.Refresh();
}
// ...
public DataInterestMask DataInterest
{
get
{
return DataInterestMask.CustomStylusDataAdded;
}
}
public void CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data)
{
// Release any cached data that's shown up.
if (data.CustomDataId == DynamicRenderer.DynamicRendererCachedDataGuid)
{
DynamicRendererCachedData cachedData = (DynamicRendererCachedData) data.Data;
cachedIds.Add(cachedData.CachedDataId);
}
}
// ...
private void ClearStrokes()
{
// Release all data
foreach int dataId in cachedIds
{
theDynamicRenderer.ReleaseCachedData(dataId);
}
// Clear our stored list of Ids
cachedIds.Clear();
// Refresh the window
this.Refresh()
}
}
この Microsoft Visual Basic .NET の例では、DynamicRenderer オブジェクトのデータをキャッシュに配置します。これにより、ウィンドウが無効になってもストロークが消去されなくなります。その後、プログラムでストロークを消去します。DynamicRenderer オブジェクト theDynamicRenderer を有効にした後、EnableDataCache プロパティは true に設定されます。Paint イベント ハンドラで、DynamicRenderer.Refresh を呼び出して、キャッシュ内のタブレット ペン データを再描画します。DataInterest プロパティは、DataInterestMask が追加されるように変更されます。CustomStylusDataAdded メソッドは、DynamicRendererCachedDataGuid フィールドの識別子を使用してデータを検索し、そのデータ識別子を ArrayList の cachedIds に格納します。ClearStrokes サブルーチンは、cachedIds のすべての識別子に対して ReleaseCachedData を呼び出し、Control の Refresh を呼び出します。
Imports Microsoft.StylusInput
Imports Microsoft.StylusInput.PluginData
' ...
Public Class TempInkCollector
Inherits System.Windows.Forms.Form
Implements Microsoft.StylusInput.IStylusAsyncPlugin
Private theRealTimeStylus As RealTimeStylus
Private theDynamicRenderer As DynamicRenderer
Private cachedIds As ArrayList = New ArrayList()
' ...
Private Sub TempInkCollector_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
theDynamicRenderer = New DynamicRenderer(Me)
theRealTimeStylus = New RealTimeStylus(Me, True)
' Add the dynamic renderer to the synchronous plugin notification chain.
' Synchronous notifications occur on the pen thread.
theRealTimeStylus.SyncPluginCollection.Add(theDynamicRenderer)
' Add the form to the asynchronous plugin notification chain. This plugin
' will be used to collect stylus data into an ink object. Asynchronous
' notifications occur on the UI thread.
theRealTimeStylus.AsyncPluginCollection.Add(Me)
' Enable the real time stylus and the dynamic renderer
theRealTimeStylus.Enabled = True
theDynamicRenderer.Enabled = True
theDynamicRenderer.EnableDataCache = True
End Sub
' ...
Private Sub InkCollector_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Refresh the dynamic renderer, since it's possible that a stroke is being
' collected at the time Paint occurs. In this case, the portion of the stroke
' that has already been collected will need to be redrawn.
theDynamicRenderer.ClipRectangle = e.ClipRectangle
theDynamicRenderer.Refresh()
End Sub
'...
Overridable Overloads ReadOnly Property DataInterest() As DataInterestMask Implements IStylusAsyncPlugin.DataInterest
Get
Return DataInterestMask.CustomStylusDataAdded
End Get
End Property
Public Sub CustomStylusDataAdded(ByVal sender As Microsoft.StylusInput.RealTimeStylus, ByVal data As Microsoft.StylusInput.PluginData.CustomStylusData) Implements Microsoft.StylusInput.IStylusAsyncPlugin.CustomStylusDataAdded
If data.CustomDataId.Equals(DynamicRenderer.DynamicRendererCachedDataGuid) Then
' Convert to DynamicRendererCachedData
Dim cachedData As DynamicRendererCachedData = data.Data
' Add to list of ids.
cachedIds.Add(cachedData.CachedDataId)
End If
End Sub
' ...
Private Sub ClearStrokes()
' Release all data
Dim dataId As Integer
For Each dataId In cachedIds
theDynamicRenderer.ReleaseCachedData(dataId)
Next
' Clear our stored list of Ids
cachedIds.Clear()
' Refresh the window
Me.Refresh()
End Sub
End Class
プラットフォーム
Windows Vista, Windows XP SP2, Windows Server 2003
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0
参照
参照
DynamicRenderer.EnableDataCache