private void TouchFeedbackStatus(bool enable) { Stylus.SetIsTouchFeedbackEnabled(this, enable); Stylus.SetIsTapFeedbackEnabled(this, enable); Stylus.SetIsPressAndHoldEnabled(this, enable); Cursor = enable ? Cursors.Arrow : Cursors.None; }
//</snippet10> private void PressAndHoldSnippets() { //<Snippet9> if (!Stylus.GetIsPressAndHoldEnabled(horizontalSlider1)) { Stylus.SetIsPressAndHoldEnabled(horizontalSlider1, true); } //</Snippet9> }
private UserControl CreateUserStoryControl(UserStory userStory, int cptTop = 0) { GroupBox gbx = columns.Where(c => c.Tag == userStory.State).First(); //Create userStory frame TextBlock content = new TextBlock { Text = userStory.ToString(), TextWrapping = TextWrapping.Wrap }; UserControl userControl = new UserControl { Content = content, Tag = userStory, Height = 50, Width = gbx.Width - 20, BorderBrush = Brushes.Black, Cursor = Cursors.Hand }; // Set background color by limit date if (userStory.DateLimit != null) { if (DateTime.Now > userStory.DateLimit) { userControl.Background = Brushes.LightBlue; } else { userControl.Background = Brushes.LightPink; } } else { userControl.Background = Brushes.LightGray; } userControl.MouseDoubleClick += UsrCtrlUserStory_Click; userControl.TouchUp += UsrCtrlUserStory_Click; //Events for drag'n'drop userControl.PreviewTouchDown += UserStory_PreviewTouchDown; Stylus.SetIsPressAndHoldEnabled(userControl, false); //Add to lists, positionning and return cnvsSprint.Children.Add(userControl); Canvas.SetLeft(userControl, Canvas.GetLeft(gbx) + 10); Canvas.SetTop(userControl, Canvas.GetTop(gbx) + 30 + 60 * cptTop); userStories.Add(userControl); return(userControl); }
public AwesomeButton() { InitializeComponent(); Stylus.SetIsPressAndHoldEnabled(this, false); Stylus.SetIsFlicksEnabled(this, false); this.MouseEnter += AwesomeButton_MouseEnter; this.MouseLeave += AwesomeButton_MouseLeave; this.PreviewMouseDown += AwesomeButton_PreviewMouseDown; this.PreviewMouseUp += AwesomeButton_PreviewMouseUp; this.TouchDown += AwesomeButton_TouchDown; this.TouchUp += AwesomeButton_TouchUp; this.Loaded += AwesomeButton_Loaded; }
public MainWindow() { InitializeComponent(); if (System.Windows.Forms.Screen.AllScreens.Length >= 2) { screen0 = System.Windows.Forms.Screen.AllScreens[0].Bounds; screen1 = System.Windows.Forms.Screen.AllScreens[1].Bounds; STATICS.SCREEN_WIDTH = screen0.Width; STATICS.SCREEN_HEIGHT = screen0.Height; STATICS.SCREEN_NUM = 2; System.Drawing.Rectangle screenBounds = System.Windows.Forms.Screen.AllScreens[0].Bounds; this.Left = screenBounds.Left; this.Top = screenBounds.Top; InitializeCloudView(); } else { STATICS.SCREEN_WIDTH = (int)SystemParameters.PrimaryScreenWidth; STATICS.SCREEN_HEIGHT = (int)SystemParameters.PrimaryScreenHeight; STATICS.SCREEN_NUM = 1; //STATICS.DEAULT_CARD_SIZE = new Size(0.08333 * STATICS.SCREEN_WIDTH, 0.11111 * STATICS.SCREEN_HEIGHT); //STATICS.DEAULT_CARD_SIZE_WITH_BORDER = new Size(0.08333 * STATICS.SCREEN_WIDTH + 5, 0.11111 * STATICS.SCREEN_HEIGHT + 5); this.Width = STATICS.SCREEN_WIDTH; this.Height = STATICS.SCREEN_HEIGHT; this.WindowState = System.Windows.WindowState.Maximized; this.Left = 0; } boundary = new Rect(0, 0, STATICS.SCREEN_WIDTH, STATICS.SCREEN_HEIGHT); Stylus.SetIsPressAndHoldEnabled(this, false); Stylus.SetIsTapFeedbackEnabled(this, false); Stylus.SetIsFlicksEnabled(this, false); Stylus.SetIsTouchFeedbackEnabled(this, false); this.Loaded += Window_Loaded; Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 28 }); controlWindow = new Control_Window(this); controlWindow.Show(); this.Visibility = Visibility.Hidden; this.KeyDown += MainWindow_KeyDown; }
void Win7TouchVeMapLoaded(object sender, RoutedEventArgs e) { if (!Handler.DigitizerCapabilities.IsMultiTouchReady) { return; } //the current window is not available during construction, so the current window will haved to be obtained in another event, such as loaded Window parentWindow = Window.GetWindow(this); Factory.EnableStylusEvents(parentWindow); Stylus.SetIsPressAndHoldEnabled(this, true); Stylus.SetIsFlicksEnabled(this, false); Stylus.SetIsTapFeedbackEnabled(this, true); Stylus.SetIsTouchFeedbackEnabled(this, true); _manipulationProcessor = new ManipulationInertiaProcessor(ProcessorManipulations.ALL, Factory.CreateTimer()); _manipulationProcessor.BeforeInertia += ManipulationProcessorBeforeInertia; _manipulationProcessor.ManipulationDelta += ManipulationProcessorManipulationDelta; }
public static void AttachTouchTapEvent(this FrameworkElement element, Action <Point> tapEvent) { Stylus.SetIsPressAndHoldEnabled(element, false); Stylus.SetIsTapFeedbackEnabled(element, false); element.PreviewTouchDown += (sender, ex) => { if (tapTrace.ContainsKey(ex.TouchDevice.Id) == false) { TapInfo info = new TapInfo(); info.Key = ex.TouchDevice.Id; info.Position = ex.GetTouchPoint(Application.Current.MainWindow).Position; info.Timestamp = ex.Timestamp; tapTrace.Add(ex.TouchDevice.Id, info); } }; element.PreviewTouchUp += (sender, ex) => { if (tapTrace.ContainsKey(ex.TouchDevice.Id)) { TapInfo info = tapTrace[ex.TouchDevice.Id]; tapTrace.Remove(ex.TouchDevice.Id); int timeStampDiff = (ex.Timestamp - info.Timestamp); if (timeStampDiff < 400)//0.4 seconds { Point newPos = ex.GetTouchPoint(Application.Current.MainWindow).Position; Point result = newPos.Sub(info.Position); if (result.Length() < GestureConsts.Current.DoubleTapDistance) { tapEvent(info.Position); } } } }; }
private void Refresh() { int nbMindMaps = project.MindMaps.Count; foreach (UserControl mindmapControl in mindMapControls) { cnvsMindMaps.Children.Remove(mindmapControl); } mindMapControls.Clear(); for (int i = 0; i < nbMindMaps; i++) { MindMap mindMap = project.MindMaps[i]; //Create Sprint frame UserControl mindmapControl = new UserControl { Content = mindMap.ToString(), Width = cnvsMindMaps.Width - 40, BorderThickness = new Thickness(1), BorderBrush = Brushes.Black, Cursor = Cursors.Hand, Height = 50, Tag = mindMap }; mindmapControl.MouseDoubleClick += MindmapControl_Click; mindmapControl.TouchDown += MindmapControl_Click; cnvsMindMaps.Children.Add(mindmapControl); mindMapControls.Add(mindmapControl); Canvas.SetLeft(mindmapControl, 5); Canvas.SetTop(mindmapControl, 60 * i); } int nbSprints = project.Sprints.Count; foreach (UserControl sprintControl in sprintUserControls) { cnvsSprints.Children.Remove(sprintControl); } sprintUserControls.Clear(); for (int i = 0; i < nbSprints; i++) { Sprint sprint = project.Sprints[i]; //Create Sprint frame UserControl sprintControl = new UserControl { Content = sprint.ToString(), Width = cnvsSprints.Width - 40, BorderThickness = new Thickness(1), BorderBrush = Brushes.Black, Cursor = Cursors.Hand, Height = 50, Tag = sprint }; sprintControl.MouseDoubleClick += Sprint_Click; sprintControl.TouchDown += Sprint_Click; sprintControl.PreviewTouchUp += Sprint_PreviewTouchUp; sprintControl.TouchEnter += Sprint_TouchEnter; sprintControl.TouchLeave += Sprint_TouchLeave; //Change Color by DateRange if (DateTime.Now > sprint.Begin && DateTime.Now < sprint.End) { //Actual sprintControl.Background = Brushes.LightBlue; } else if (DateTime.Now < sprint.Begin) { //Not beginned sprintControl.Background = Brushes.LightGray; } else { //Already passed sprintControl.Background = Brushes.LightPink; } cnvsSprints.Children.Add(sprintControl); sprintUserControls.Add(sprintControl); Canvas.SetLeft(sprintControl, 5); Canvas.SetTop(sprintControl, 60 * i); } int nbUserStories = project.AllUserStories.Count; foreach (UserControl userStoryControl in userStoriesControls) { cnvsUserStories.Children.Remove(userStoryControl); } userStoriesControls.Clear(); for (int i = 0; i < nbUserStories; i++) { UserStory userStory = project.AllUserStories[i]; //Create userStory frame TextBlock content = new TextBlock { Text = userStory.ToString(), TextWrapping = TextWrapping.Wrap }; UserControl userStoryControl = new UserControl { Content = content, Cursor = Cursors.Hand, Height = 50, Tag = userStory, Width = cnvsUserStories.Width - 40, BorderBrush = Brushes.Black, BorderThickness = new Thickness(1) }; // Change color by limit date (if exists and happened or not) if (userStory.DateLimit != null) { if (DateTime.Now > userStory.DateLimit) { userStoryControl.Background = Brushes.LightPink; } else { userStoryControl.Background = Brushes.LightBlue; } } else { userStoryControl.Background = Brushes.LightGray; } userStoryControl.MouseDoubleClick += UserStory_MouseDoubleClick; userStoryControl.PreviewTouchDown += UserStory_PreviewTouchDown; userStoryControl.TouchUp += UsrCtrlUserStory_TouchUp; Stylus.SetIsPressAndHoldEnabled(userStoryControl, false); cnvsUserStories.Children.Add(userStoryControl); userStoriesControls.Add(userStoryControl); Canvas.SetLeft(userStoryControl, 5); Canvas.SetTop(userStoryControl, 60 * i); } }