|
using System.Windows;
using System.Windows.Controls;
using Multitouch.Framework.WPF.Input;
using VirtualDreams.TouchReader.View;
using VirtualDreams.TouchReader.ViewModel;
namespace VirtualDreams.TouchReader.Factory
{
class TouchablePanelRssViewFactory : IPanelViewFactory
{
public Panel Panel { get; set; }
public void CreateViewFromDataContext(object dataContext, Point position)
{
var viewModel = dataContext as RssViewModelBase;
if (viewModel == null) return;
FrameworkElement newView;
if (viewModel is FeedItemViewModel)
newView = new FeedItemView();
else
newView = new FolderAndFeedView();
newView.DataContext = viewModel;
newView.SetValue(Canvas.LeftProperty, position.X);
newView.SetValue(Canvas.TopProperty, position.Y);
MultitouchScreen.AddContactEnterHandler(newView, ElementCaptureHandler);
Panel.Children.Add(newView);
}
private static void ElementCaptureHandler(object sender, ContactEventArgs e)
{
var element = sender as IInputElement;
if (element != null)
e.Contact.Capture(element);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Hi! I'm Roberto. I'm a Brazilian Engineering student at the University of São Paulo and the Ecole Centrale de Lille (France).
I've participated in the
Imagine Cup competition and went to the world finals every year from 2005 to 2009. I also won the 1st place award in 2006, in India, for the Interface Design invitational, in 2007 in Korea, for the Embedded Development invitational, and in 2009 in Egypt for the Windows Mobile Award.
Currently I keep a blog (in English and Portuguese) at
http://virtualdreams.com.br/blog/ and a weekly webcast about WPF and Silverlight (in Portuguese) at
http://www.xamlcast.net.