Skip to content

Latest commit

 

History

History
50 lines (30 loc) · 2.35 KB

HelloWorld.md

File metadata and controls

50 lines (30 loc) · 2.35 KB

Multitouch "Hello World" program

Start Visual Studio and create a new WPF project and name it "MultitouchHelloWorld".

Add reference to Multitouch.Framework.WPF.dll assembly.

In Window1.xaml add a new namespace: xmlns:mt="http://schemas.multitouch.com/Multitouch/2008/04", and change root object to mt:Window. Don't forget to close it with _</mt:Window>. Then open Window1.cs and change Window1 base object from Window to Multitouch.Framework.WPF.Controls.Window. Your xaml should look like this:

and cs file like this:

Now add a TouchablePanel as a child of Grid and TextBlock as a child of TouchablePanel. Set the Text property of TextBlock to "Hello World!!!". Let's make this text bigger, so we could easily touch it. Set FontSize property to 72, FontWeight to Bold and make Foreground White and Background LightBlue.

Our program is ready. Before you start it, you have to start multitouch service. For example by executing Multitouch.Service.Console.exe. Now hit F5 to start the program. Your program will look like this and you can touch the text and move and rotate it around.

Let's make our program a little more useful. Replace TouchablePanel with ItemsControl and set its ItemsPanel to TouchablePanel. Now bind ItemsSource to Photos property with {Binding Photos}.

Now let's write some code. Open Window1.cs file. And add a new DependencyProperty Photos of type _ObservableCollection. In constructor, before InitializeComponent is executed, set DataContext to this. Now override OnInitialized method and add this code:

{{ foreach(string file in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "*.jpg").Take(5)) { Photos.Add(file); } }}

It will take 5 pictures from you Pictures folder, so make sure you have them. Finally let's get back to Window1.xaml and add a DataTemplate to display strings as Images.

Now start the program and enjoy your Multitouch Photo Album :)