Font Resizer

Toolkits.FontResizer History

Hide minor edits - Show changes to output

Added lines 1-3:
[[ProximityToolkit | << Back to Proximity Toolkit]]
----
May 21, 2010, at 03:51 PM by 174.0.52.43 -
Changed lines 114-118 from:
[[Attach:ViconWPFTest.rar| Download the source code]]
to:
* [[Attach:ViconWPFTest.zip|Version 1.0]]
** Initial working version. (by Miaosen Wang)
May 21, 2010, at 03:45 PM by 174.0.52.43 -
Added lines 111-112:

Now you are done! Build and run your code.
May 21, 2010, at 03:44 PM by 174.0.52.43 -
Changed lines 38-39 from:
Then add a reference to the ProximityToolkit.dll. Select Project->Add Reference. A new window will appear and select the Browse tab. Browse to the proximity folder and select ProximityToolkit.dll
to:
Then add a reference to the ProximityToolkit.dll. Select Project->Add Reference. A new window will appear and select the Browse tab. Browse to the proximity folder and select ProximityToolkit.dll and add the following code at the top of your program:
(:source lang=csharp tabwidth=2 :) [=
using ProximityToolkit;
using ProximityToolkit.Networking;
using ProximityToolkit.Presence;
=]
Changed lines 73-74 from:
!!! [[#SourceCode|]] [[Attach: | Download]] the source code
to:
Then we want to detect the distance change between the objects th and the display. We also want to hook up a event handler when the distance changes.
(:source lang=csharp tabwidth=2 :) [=
space.StartMonitor(pencil, smartboard, ProximityRelation.Location);
space.StartMonitor(smartboard, jagerHat, ProximityRelation.Location);

space.RelationUpdated += new SpaceRelationHandler(space_RelationUpdated);
=]
Last, we want to implement the event handler. All events related with space relation changes will trigger this callback,so it is important for us to identify the events. In this example, we used the presenceA property of the ProximityEventArgs to find out if the event is trigger by pencil or the hat.

The callback happens on a different thread from the main thread where it contains all the UI controls. Therefore, we need to dispatch the text font change actions through a message rather than changing it directly.
(:source lang=csharp tabwidth=2 :)
[=
void space_RelationUpdated(ProximitySpace space, ProximityEventArgs args)
{
if(args.PresenceA == pencil)
{

TextBlock1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
TextBlock1.FontSize = 1 + (int)(250 - args.Location.HorizontalDistance / 10);
}
));

}
else if (args.PresenceA == smartboard)
{
TextBlock2.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
TextBlock2.FontSize = 1 + (int)(250 - args.Location.HorizontalDistance / 10);
}
));
}
}
=]
!!! [[#SourceCode|]] Download
[[Attach:ViconWPFTest.rar| Download the source code]]
May 21, 2010, at 03:28 PM by 174.0.52.43 -
Changed line 7 from:
*[[#Program | Construct the software ]]
to:
*[[#Program | Writing the software ]]
Changed lines 11-19 from:
You will first need to use markers to create two objects: a pencil and hat. Please refer to the Vicon manual on how to complete the task[link].


!!! [[#Program|]] Construct the software

!!!!!Create the WPF application

!!! [[#SourceCode|]] Download the source code
to:
This example is focused on showing you how to use the toolkit to write a software. However, you will need to do the following first:

# Use markers to create two objects that can be tracked by Vicon Cameras: a pencil and hat.
# Define the space that are tracked by the Vicon cameras.
# Define the computer display's location and dimension.
# Launch the Proximity Toolkit's sever application.

!!! [[#Program|]] Writing the software

The example here are developed using Visual Studio 2008 and .NET Framework 3.5.

First create a new WPF application in Visual Studio. Switch to the window1.xmal, add two text blocks to the window. The XMAL code will look like this:
(:source lang=csharp tabwidth=2 :) [=
<Window x:Class="ViconWPFTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ViconWPFTest" Height="300" Width="612" WindowState="Maximized">
<StackPanel VerticalAlignment="Center">
<Grid>
<TextBlock Name="TextBlock1" Text="Pencil" FontSize="20" HorizontalAlignment="Left" Margin="400"/>
<TextBlock Name="TextBlock2" FontSize="20" Text="Hat" HorizontalAlignment="Right" Margin="400"/>
</Grid>
</StackPanel>
</Window>
=]
Note that the TextBlock's Margin size should be a value that is suitable to your display.

Then add a reference to the ProximityToolkit.dll. Select Project->Add Reference. A new window will appear and select the Browse tab. Browse to the proximity folder and select ProximityToolkit.dll

Now we want to declare the member variables being used in the project:
(:source lang=csharp tabwidth=2 :) [=
private ClientDictionaryManager client = null;
private ProximitySpace space = null;
private PresenceBase pencil = null;
private PresenceBase smartboard = null;
private PresenceBase jagerHat = null;
=]
ClientDictionaryManager is the class responsible for communicating with the shared dictionary on the server side, ProximitySpace is the class define the space that the vicon camera sees. PresenceBase is the base class for artifacts in the space.

Then you want to initialize these objects.
(:source lang=csharp tabwidth=2 :)
[=
client = new ClientDictionaryManager();
client.Start("127.0.0.1", 888, true);

space = client.GetSpace();

pencil = space.GetPresence("Pencil");
smartboard = space.GetDisplay("Smartboard");
jagerHat = space.GetPresence("JagerHat");

pencil.WaitForEmbodiment(0);
smartboard.WaitForEmbodiment(0);
jagerHat.WaitForEmbodiment(0);
=]
Note that it takes some time for the GetPresence() to return a valid object for the first time that it is called. Therefore, WaitForEmbodiment() is used to block the program until a valid object is obtained.

!!! [[#SourceCode|]] [[Attach: | Download]] the source code
May 21, 2010, at 01:50 PM by 174.0.52.43 -
Changed lines 2-4 from:
Here we will show you step by step how to construct a simple WPF application by using the Proximity Toolkit.
to:
Here we will show you step by step how to construct a simple WPF application by using the Proximity Toolkit. The software will have two words on its main window: pencil and hat. Each word is corresponding to a physical object tagged with markers that can be tracked by Vicon cameras. The words will become larger when the corresponding objects approaching the computer display. [video or pic]
Added line 6:
*[[#DeviceSetup| Device Setup]]
Added lines 10-13:
!!! [[DeviceSetup|]] Device Setup
You will first need to use markers to create two objects: a pencil and hat. Please refer to the Vicon manual on how to complete the task[link].
Added lines 15-17:

!!!!!Create the WPF application
May 21, 2010, at 01:23 PM by 174.0.52.43 -
Added lines 1-11:
!! Font Resizer - An Introductory Example of Using the Proximity Toolkit
Here we will show you step by step how to construct a simple WPF application by using the Proximity Toolkit.


!!! Contents
*[[#Program | Construct the software ]]
*[[#SourceCode | Download the source code]]

!!! [[#Program|]] Construct the software
!!! [[#SourceCode|]] Download the source code