다음을 통해 공유


DynamicRenderer.EnableDataCache 속성

업데이트: 2007년 11월

DynamicRenderer 개체에 데이터 캐싱을 사용할지 여부를 나타내는 값을 가져오거나 설정합니다.

네임스페이스:  Microsoft.StylusInput
어셈블리:  Microsoft.Ink(Microsoft.Ink.dll)

구문

‘선언
Public Property EnableDataCache As Boolean
‘사용 방법
Dim instance As DynamicRenderer
Dim value As Boolean

value = instance.EnableDataCache

instance.EnableDataCache = value
public bool EnableDataCache { get; set; }
public:
property bool EnableDataCache {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_EnableDataCache()
/** @property */
public  void set_EnableDataCache(boolean value)
public function get EnableDataCache () : boolean
public function set EnableDataCache (value : boolean)

속성 값

형식: System.Boolean
데이터 캐싱이 사용되면 true이고, 그렇지 않으면 false입니다.

설명

EnableDataCache 속성을 true로 설정하면 속도가 느린 프로세스로 인해 출력 큐가 지체되는 현상을 해결할 수 있습니다. DynamicRenderer 개체에서 스트로크를 그린 후 창이 무효화되는 시간 간격이 있는 경우 수집된 스트로크를 그릴 수 있을 때까지 시간이 지연될 수 있습니다. DynamicRenderer의 스트로크를 캐시에 배치하면 Refresh 메서드를 호출하여 스트로크를 다시 그릴 수 있습니다. 그러나 스트로크가 수집된 후에는 ReleaseCachedData 메서드를 호출하여 캐시에서 스트로크를 해제해야 합니다. 일반적으로 CustomStylusDataAdded 메서드에서 해제가 수행됩니다.

EnableDataCache 속성을 true로 설정할 수 있는 또 다른 경우로는 그려지는 스트로크를 표시하면서 스트로크를 처리한 후 계속 저장해야 하는 경우가 있습니다. 이러한 경우 CustomStylusDataAdded 메서드의 data 매개 변수에 데이터 식별자를 저장한 다음 캐시된 스트로크가 더 이상 필요하지 않을 때 데이터를 해제합니다.

이 속성이 true이면 잉크 수집 개체에 저장된 스트로크에 대해 ReleaseCachedData 메서드를 호출해야 합니다. 이 속성이 false인 경우에는 ReleaseCachedData 메서드를 호출할 필요가 없습니다. 이 속성을 false로 설정하면 스트로크 데이터가 잉크 수집 개체에 도달하여 렌더링될 때까지 초기에 동적으로 렌더링되었지만 기타 작업에 의해 무효화된 스트로크 데이터가 렌더링되지 않는다는 단점이 있습니다.

이 속성을 false로 설정하면 캐시된 데이터가 지워집니다. 따라서 EnableDataCache 속성을 false로 설정한 후 큐에서 보류 중인 DynamicRendererCachedData 개체에 대해 ReleaseCachedData 메서드를 호출하면 인수 예외가 발생합니다.

이 속성에 대한 자세한 내용은 Dynamic-Renderer Plug-ins을를 참조하십시오.

예제

이 C# 예제는 Windows SDK의 Tablet 및 Touch 기술 섹션에 제공된 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
    myRealTimeStylus.Enabled = true;
    myDynamicRenderer.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.
    myDynamicRenderer.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 개체를 활성화하면 theDynamicRendererEnableDataCache 속성이 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 dynamic renderer to the synchronous plugin notification chain.
        // Synchronous notifications occur on the pen thread.
        myRealTimeStylus.SyncPluginCollection.Add(myDynamicRenderer);

        // 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.
        myRealTimeStylus.AsyncPluginCollection.Add(this);

        // Enable the real time stylus and the dynamic renderer
        myRealTimeStylus.Enabled = true;
        myDynamicRenderer.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.
        myDynamicRenderer.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 개체를 활성화하면 theDynamicRendererEnableDataCache 속성이 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 클래스

DynamicRenderer 멤버

Microsoft.StylusInput 네임스페이스

DynamicRendererCachedData

DynamicRenderer.ReleaseCachedData

DynamicRenderer.Refresh

기타 리소스

Dynamic-Renderer Plug-ins