Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Actualización: noviembre 2007
Obtiene o establece un valor que indica si el almacenamiento de datos en caché está habilitado para el objeto DynamicRenderer.
Espacio de nombres: Microsoft.StylusInput
Ensamblado: Microsoft.Ink (en Microsoft.Ink.dll)
Sintaxis
'Declaración
Public Property EnableDataCache As Boolean
'Uso
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)
Valor de propiedad
Tipo: System.Boolean
Es true si el almacenamiento de datos en caché está habilitado; en caso contrario, es false.
Comentarios
Al establecer la propiedad EnableDataCache en true, se puede controlar el hecho de que los procesos lentos bloqueen la cola de salida. Si pasa un tiempo desde que el objeto DynamicRenderer dibuja los trazos hasta que se invalida la ventana, es posible que haya que esperar hasta que se puedan volver a dibujar los trazos recopilados. Al colocar los trazos de DynamicRenderer en una memoria caché, los éstos pueden volver a dibujarse mediante una llamada al método Refresh. No obstante, una vez recopilados los trazos, deben liberarse de la memoria caché mediante una llamada al método ReleaseCachedData. Generalmente, la liberación se produce en el método CustomStylusDataAdded.
Otra circunstancia en que es útil establecer la propiedad EnableDataCache en true es cuando se desea mostrar los trazos a medida que se dibujan, pero una vez que se haya hecho algo con ellos, ya no es necesario almacenarlos. En este caso, almacene los identificadores de datos en el parámetro data del método CustomStylusDataAdded y, después, libere los datos cuando ya no necesite los trazos almacenados en memoria caché.
Si esta propiedad es true, debe llamar al método ReleaseCachedData para los trazos que se han almacenado en el objeto recopilador de entrada manuscrita. Si es false, no necesita llamar al método ReleaseCachedData. El inconveniente de establecerla en false es que los datos de trazo representados dinámicamente en un principio pero invalidados después por operaciones varias no se representan hasta que los datos de trazo alcanzan el objeto de recopilación de entrada manuscrita, que es el lugar donde se representan.
Al establecer esta propiedad en false, se borran los datos almacenados en caché. Por lo tanto, se provoca una excepción de argumento cuando el código llama al método ReleaseCachedData para cualquier objeto DynamicRendererCachedData pendiente en la cola después de establecer la propiedad EnableDataCache en false.
Para obtener información más detallada sobre esta propiedad, vea Dynamic-Renderer Plug-ins.
Ejemplos
Este ejemplo de C# amplía el ejemplo RealTimeStylus Ink Collection Sample que se proporciona en la sección relativa a la Tecnología táctil y Tablet PC del SDK de Windows. Tras habilitar DynamicRenderer, theDynamicRenderer, la propiedad EnableDataCache se establece en true. La propiedad DataInterest se modifica para que se agregue DataInterestMask. El método CustomStylusDataAdded busca datos con el identificador de campo DynamicRendererCachedDataGuid y, a continuación, los libera mediante la propiedad CachedDataId de los datos.
// ...
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);
}
}
// ...
En este ejemplo de C# se colocan los datos de un objeto DynamicRenderer en una memoria caché. De esta forma, se garantiza que una invalidación de ventana no borra los trazos. En el ejemplo los trazos se borran después, mediante programación. Tras habilitar el objeto DynamicRenderer, theDynamicRenderer, la propiedad EnableDataCache se establece en true. En el controlador de eventos Paint, el ejemplo llama a DynamicRenderer.Refresh para volver a dibujar los datos del lápiz de Tablet PC en la memoria caché. La propiedad DataInterest se modifica para que se agregue DataInterestMask. El método CustomStylusDataAdded busca datos con el identificador del campo DynamicRendererCachedDataGuid y almacena el identificador de los datos en un objeto ArrayList, cachedIds. El método ClearStrokes llama a ReleaseCachedData en todos los identificadores de cachedIds y después llama a Refresh en el Control.
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()
}
}
En este ejemplo de Microsoft Visual Basic .NET, se colocan los datos de un objeto DynamicRenderer en una memoria caché. De esta forma, se garantiza que una invalidación de ventana no borra los trazos. En el ejemplo los trazos se borran después, mediante programación. Tras habilitar el objeto DynamicRenderer, theDynamicRenderer, la propiedad EnableDataCache se establece en true. En el controlador de eventos Paint, el ejemplo llama a DynamicRenderer.Refresh para volver a dibujar los datos del lápiz de Tablet PC en la memoria caché. La propiedad DataInterest se modifica para que se agregue DataInterestMask. El método CustomStylusDataAdded busca datos con el identificador del campo DynamicRendererCachedDataGuid y almacena el identificador de los datos en un objeto ArrayList, cachedIds. El método ClearStrokes llama a ReleaseCachedData en todos los identificadores de cachedIds y después llama a Refresh en el Control.
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
Plataformas
Windows Vista, Windows XP SP2, Windows Server 2003
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Información de versión
.NET Framework
Compatible con: 3.0
Vea también
Referencia
Microsoft.StylusInput (Espacio de nombres)
DynamicRenderer.ReleaseCachedData