Ora che sono ampiamente disponibili e documentati SDK per dispositivi multitouch e surface SDK, ho faticato un po' a mettere insieme le informazioni per utilizzare il riconoscimento della grafia su un dispositivo senza tastiera con windows embedded 2009 o Windows XP SP3.
Installare il motore di riconoscimento della grafia in Windows XP SP3
Prima di tutto bisogna installare il Software Developers Kit for Windows Tablet PC version 1.7 scaricandolo da qui http://www.microsoft.com/download/en/details.aspx?id=20989.
Poi bisogna installare il Windows XP Tablet PC 2005 Recogniser Pack scaricabile da qui: http://www.microsoft.com/downloads/it-it/details.aspx?familyid=080184dd-5e92-4464-b907-10762e9f918b&displaylang=it.
Utilizzare Tablet PC SDK 1.7 in una applicazione WPF .NET 4.0
Il riconoscimento della grafia viene ottenuto con la classe InkAnalyzer accessibile aggiungendo nel progetto una referenza alla libreria IaWinFX.dll che dovrebbe trovarsi in C:\Programmi\Reference Assemblies\Microsoft\Tablet PC\v1.7.
I pacchetti installati in precedenza non copiano però nessuna cartella in Reference Assemblies, per cui ho dovuto recuperare IaWinFX.dll da http://amazingwpfcontrols.codeplex.com/
Durante il runtime ho ottenuto però errori di questo tipo:
Error Message: "Could not load file or assembly 'IALoader, Version=1.7.5333.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."
che spariscono installando il pacchetto Ink Analysis and Input Supplement for the Windows XP Tablet PC Edition Development Kit 1.7 da qui http://www.microsoft.com/download/en/details.aspx?id=10462.
Infine bisogna aggiungere nel file app.config useLegacyV2RuntimeActivationPolicy="true":
domenica 14 agosto 2011
giovedì 11 agosto 2011
Choosing a DataTemplate based on properties or status of items
If you have a collection of the same type of data objects you could create a different DataTemplate for items that are of the same type but want to give it a completely different look based on a property or a status of the item itself.
Using the ItemTemplateSelector property of the ListBox could not be the right choice if the new DataTemplate should be triggered on a property change (e.g: change the DataTemplate when the item is selected)
I found out a solution here:
http://codingcontext.wordpress.com/2008/09/28/changing-the-data-template-for-the-currently-selected-item/
A easy solution could be create a new ItemContainerStyle for the ListBox. The ItemTemplate property must not be assigned.
<ListBox Width="400" Margin="10"
ItemsSource="{Binding myList}"
ItemContainerStyle="{StaticResource myListBoxItemStyle}"
HorizontalContentAlignment="Stretch"/>
<Style x:Key="myListBoxItemStyle" TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource ListBoxItemStyle} >
<Setter Property="ContentTemplate" Value="{StaticResource myNormalDataTemplate}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSpecial}" Value="True">
<Setter Property="ContentTemplate" Value="{StaticResource mySpecialDataTemplate}"/>
</DataTrigger>
</Style.Triggers>
</Style>
You can download a sample here
Using the ItemTemplateSelector property of the ListBox could not be the right choice if the new DataTemplate should be triggered on a property change (e.g: change the DataTemplate when the item is selected)
I found out a solution here:
http://codingcontext.wordpress.com/2008/09/28/changing-the-data-template-for-the-currently-selected-item/
A easy solution could be create a new ItemContainerStyle for the ListBox. The ItemTemplate property must not be assigned.
<ListBox Width="400" Margin="10"
ItemsSource="{Binding myList}"
ItemContainerStyle="{StaticResource myListBoxItemStyle}"
HorizontalContentAlignment="Stretch"/>
<Style x:Key="myListBoxItemStyle" TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource ListBoxItemStyle} >
<Setter Property="ContentTemplate" Value="{StaticResource myNormalDataTemplate}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSpecial}" Value="True">
<Setter Property="ContentTemplate" Value="{StaticResource mySpecialDataTemplate}"/>
</DataTrigger>
</Style.Triggers>
</Style>
You can download a sample here
mercoledì 10 agosto 2011
Setting a minimum height of the thumb on a vertical scrollbar
This topic has been discussed here http://social.msdn.microsoft.com/Forums/en/wpf/thread/1a7f71bd-d64f-4341-9b7f-9db90afa6e8b
Developing a touch application, the size and the shape of the thumb is very important. In a standard Windows application, the thumb's size is automatically calculated. When the content is very large, the thumb size could be too small to be touched.
To force a minimal size for the thumb:
<Style TargetType="ScrollBar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollBar">
<Track Name="PART_Track"
IsDirectionReversed="true">
<Track.Resources>
<!-- Thumb's minimum height is half of this metric -->
<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarButtonHeightKey}">
100
</sys:Double>
</Track.Resources>
<Track.DecreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageUpCommand"/>
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageDownCommand"/>
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb/>
</Track.Thumb>
</Track>
<ControlTemplate.Triggers>
<Trigger SourceName="PART_Track" Property="IsEnabled" Value="false">
<Setter TargetName="PART_Track" Property="Visibility" Value="Hidden"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Add this in the namespaces section of the control to access System library:
xmlns:sys="clr-namespace:System;assembly=mscorlib"
http://stackoverflow.com/questions/2003372/how-to-represent-system-constants-in-xaml-like-double-maxvalue.
Developing a touch application, the size and the shape of the thumb is very important. In a standard Windows application, the thumb's size is automatically calculated. When the content is very large, the thumb size could be too small to be touched.
To force a minimal size for the thumb:
<Style TargetType="ScrollBar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollBar">
<Track Name="PART_Track"
IsDirectionReversed="true">
<Track.Resources>
<!-- Thumb's minimum height is half of this metric -->
<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarButtonHeightKey}">
100
</sys:Double>
</Track.Resources>
<Track.DecreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageUpCommand"/>
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageDownCommand"/>
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb/>
</Track.Thumb>
</Track>
<ControlTemplate.Triggers>
<Trigger SourceName="PART_Track" Property="IsEnabled" Value="false">
<Setter TargetName="PART_Track" Property="Visibility" Value="Hidden"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Add this in the namespaces section of the control to access System library:
xmlns:sys="clr-namespace:System;assembly=mscorlib"
http://stackoverflow.com/questions/2003372/how-to-represent-system-constants-in-xaml-like-double-maxvalue.
Iscriviti a:
Post (Atom)