public MainWindow() { InitializeComponent(); MouseTouchDevice.RegisterEvents(this); for (int i = 0; i < 1000; i++) { List.Add("StackOverflow " + i); } }
static void LostMouseCapture(object sender, MouseEventArgs e) { if (device != null && device.IsActive) { device.Position = e.GetPosition(null); device.ReportUp(); device.Deactivate(); device = null; } }
public MultiScaleImage() { MouseTouchDevice.RegisterEvents(this); _levelChangeThrottle = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(ThrottleIntervalMilliseconds), IsEnabled = false }; _levelChangeThrottle.Tick += (s, e) => { _spatialSource.CurrentLevel = _desiredLevel; _levelChangeThrottle.IsEnabled = false; }; }
private static void MouseDown(object sender, MouseButtonEventArgs e) { if (device != null && device.IsActive) { device.ReportUp(); device.Deactivate(); device = null; } device = new MouseTouchDevice(e.MouseDevice.GetHashCode()); device.SetActiveSource(e.MouseDevice.ActiveSource); device.Position = e.GetPosition(null); device.Activate(); device.ReportDown(); }
public SurfaceWindow() { InitializeComponent(); // Add handlers for Application activation events ApplicationServices.WindowInteractive += OnWindowInteractive; ApplicationServices.WindowNoninteractive += OnWindowNoninteractive; ApplicationServices.WindowUnavailable += OnWindowUnavailable; #if DEBUG if (System.Windows.SystemParameters.WorkArea.Width > 1920 || System.Windows.SystemParameters.WorkArea.Height > 1080) { // Shrink down when running on giant monitors Width = Math.Min(System.Windows.SystemParameters.WorkArea.Width, 1920); Height = Math.Min(System.Windows.SystemParameters.WorkArea.Height, 1080); WindowState = WindowState.Normal; } #endif if (!SurfaceEnvironment.IsSurfaceEnvironmentAvailable) { // running in simulator. Startup(); } // Add the configuable color resources. Resources["NewsThemeColor"] = Settings.Default.NewsThemeColor; Resources["NewsForegroundColor"] = Settings.Default.NewsForegroundColor; Resources["SocialThemeColor"] = Settings.Default.SocialThemeColor; Resources["SocialForegroundColor"] = Settings.Default.SocialForegroundColor; Resources["NewItemBorderColor"] = Settings.Default.NewItemBorderColor; // Don't put all the binding errors in the output window PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Critical; if (!DesignerProperties.GetIsInDesignMode(this)) { _layoutRoot.Opacity = 0; } // Promote mouse clicks to touch events. MouseTouchDevice.RegisterEvents(this); }