public void ClickGesture() => AssertExperimental(() => { var gestureElement = new TGestureElement(); ClickGestureRecognizer gestureRecognizer = null; gestureElement.ClickGesture(g => gestureRecognizer = g); AssertHasGestureRecognizer(gestureElement, gestureRecognizer); });
public static ClickGestureRecognizer BindCommandClickGestureRecognizer(this ClickGestureRecognizer self, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null, object converterParameter = null, string stringFormat = null, object source = null, object targetNullValue = null, object fallbackValue = null) => self.Bind(ClickGestureRecognizer.CommandProperty, path, mode, converter, converterParameter, stringFormat, source, targetNullValue, fallbackValue);
public MainPage() { InitializeComponent(); //Create mock data ShopItems = new List <ItemPair> { new ItemPair(new ShopItem("Bags"), new ShopItem("Accesories")), new ItemPair(new ShopItem("Accesories"), new ShopItem("Travel")), new ItemPair(new ShopItem("Travel"), new ShopItem("Bags")) }; FilterList = new List <Filter> { new Filter("Bags", 0), new Filter("Accesories", 1), new Filter("Shoes", 2), new Filter("Travel", 3), new Filter("Other", 4), new Filter("Earings", 5), new Filter("Dress", 6) }; //ProductFilter.ItemsSource = FilterList; ProductList.ItemsSource = ShopItems; // Binding ListView to Products List foreach (var filter in FilterList) { Label elem = new Label(); elem.Text = filter.FilterName; ClickGestureRecognizer clickRecognizer = new ClickGestureRecognizer(); clickRecognizer.Clicked += ClickGestureRecognizer_OnClicked; TapGestureRecognizer tapGesture = new TapGestureRecognizer(); tapGesture.Tapped += ClickGestureRecognizer_OnTappedAsync; elem.GestureRecognizers.Add(clickRecognizer); elem.GestureRecognizers.Add(tapGesture); Object res; this.Resources.TryGetValue("CarouselLabelStyle", out res); Style labsStyle = (Style)res; elem.Style = labsStyle; elem.FontAttributes = FontAttributes.None; elem.FontSize = 15; elem.Opacity = 0.7; elem.Margin = new Thickness(5); FilterIem.Children.Add(elem); } elemindex = 0; }
public HyperLinkLabel() { InitializeComponent(); ClickGestureRecognizer gestClick = new ClickGestureRecognizer { NumberOfClicksRequired = 1 }; gestClick.Clicked += GestOpenLink; TapGestureRecognizer gestTap = new TapGestureRecognizer(); gestTap.Tapped += GestOpenLink; GestureRecognizers.Add(gestClick); GestureRecognizers.Add(gestTap); }
public FontAwesomeLabel() { InitializeComponent(); FontFamily = FontAwesomeName; ClickGestureRecognizer GestClick = new ClickGestureRecognizer { NumberOfClicksRequired = 1 }; GestClick.Clicked += GestClick_Clicked; TapGestureRecognizer GestTap = new TapGestureRecognizer(); GestTap.Tapped += GestTap_Tapped; GestureRecognizers.Add(GestClick); GestureRecognizers.Add(GestTap); }
public void AddGithubInfo(string source, string Header, string command = null, string commandParameter = null) { var cnt = GithubGrid.ColumnDefinitions?.Count() ?? 0; GithubGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); var sl = new StackLayout(); if (command != null) { { var gr = new TapGestureRecognizer(); gr.SetBinding(TapGestureRecognizer.CommandProperty, command); gr.SetBinding(TapGestureRecognizer.CommandParameterProperty, commandParameter); sl.GestureRecognizers.Add(gr); } { var gr = new ClickGestureRecognizer(); gr.SetBinding(ClickGestureRecognizer.CommandProperty, command); gr.SetBinding(ClickGestureRecognizer.CommandParameterProperty, commandParameter); sl.GestureRecognizers.Add(gr); } } var fc = new FontSizeConverter(); { var label = new Label() { HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.CenterAndExpand, FontSize = (double)fc.ConvertFromInvariantString("Large"), FontAttributes = FontAttributes.Bold }; label.SetBinding(Label.TextProperty, source); sl.Children.Add(label); } sl.Children.Add(new Label() { Text = Header, HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.CenterAndExpand, TextColor = new Color(0.0, 0.0, 0.0, 0.5) }); Grid.SetColumn(sl, cnt); GithubGrid.Children.Add(sl); }
Action <NSClickGestureRecognizer> CreateRecognizerHandler(WeakReference weakEventTracker, WeakReference weakRecognizer, ClickGestureRecognizer clickRecognizer) { return(new Action <NSClickGestureRecognizer>((sender) => { var eventTracker = weakEventTracker.Target as EventTracker; var view = eventTracker?._renderer?.Element as View; var childGestures = GetChildGestures(sender, weakEventTracker, weakRecognizer, eventTracker, view); if (childGestures?.GetChildGesturesFor <TapGestureRecognizer>(x => x.NumberOfTapsRequired == (int)sender.NumberOfClicksRequired).Count() > 0) { return; } if (weakRecognizer.Target is ClickGestureRecognizer clickGestureRecognizer && view != null) { clickGestureRecognizer.SendClicked(view, clickRecognizer.Buttons); } })); }
public ClickGestureGalleryPage() { clickCommand = new Command <Color>(HandleClickCommand); var vertical = new StackLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Spacing = 40 }; var horizontal = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 20, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }; vertical.Children.Add(horizontal); var singleClickLabel = new Label { Text = "Click me!", BackgroundColor = Color.PaleGreen }; var singleClickGesture = new ClickGestureRecognizer { Command = clickCommand, CommandParameter = Color.PaleGreen, NumberOfClicksRequired = 1, Buttons = ButtonsMask.Primary }; singleClickLabel.GestureRecognizers.Add(singleClickGesture); horizontal.Children.Add(singleClickLabel); var doubleClickLabel = new Label { Text = "Double click me!!", BackgroundColor = Color.Aqua }; var doubleClickGesture = new ClickGestureRecognizer { Command = clickCommand, CommandParameter = Color.Aqua, NumberOfClicksRequired = 2, Buttons = ButtonsMask.Primary }; doubleClickLabel.GestureRecognizers.Add(doubleClickGesture); horizontal.Children.Add(doubleClickLabel); var tripleClicklabel = new Label { Text = "Triple click me!!!", BackgroundColor = Color.Olive }; var tripleClickGesture = new ClickGestureRecognizer { Command = clickCommand, CommandParameter = Color.Olive, NumberOfClicksRequired = 3, Buttons = ButtonsMask.Primary }; tripleClicklabel.GestureRecognizers.Add(tripleClickGesture); horizontal.Children.Add(tripleClicklabel); var rightClickLabel = new Label { Text = "Right click me¡", BackgroundColor = Color.Coral }; var rigthClickGesture = new ClickGestureRecognizer { Command = clickCommand, CommandParameter = Color.Coral, NumberOfClicksRequired = 1, Buttons = ButtonsMask.Secondary }; rightClickLabel.GestureRecognizers.Add(rigthClickGesture); horizontal.Children.Add(rightClickLabel); var doubleRightClickLabel = new Label { Text = "Double right click me¡¡", BackgroundColor = Color.Gold }; var doubleRigthClickGesture = new ClickGestureRecognizer { Command = clickCommand, CommandParameter = Color.Gold, NumberOfClicksRequired = 2, Buttons = ButtonsMask.Secondary }; doubleRightClickLabel.GestureRecognizers.Add(doubleRigthClickGesture); horizontal.Children.Add(doubleRightClickLabel); changeColorBoxView = new BoxView { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, WidthRequest = 200, HeightRequest = 50 }; vertical.Children.Add(changeColorBoxView); Content = vertical; }
Action <NSClickGestureRecognizer> CreateRecognizerHandler(WeakReference weakEventTracker, WeakReference weakRecognizer, ClickGestureRecognizer clickRecognizer) { return(new Action <NSClickGestureRecognizer>((sender) => { var eventTracker = weakEventTracker.Target as EventTracker; var view = eventTracker?._renderer?.Element as View; var originPoint = sender.LocationInView(null); originPoint = NSApplication.SharedApplication.KeyWindow.ContentView.ConvertPointToView(originPoint, eventTracker._renderer.NativeView); var childGestures = view.GetChildElements(new Point(originPoint.X, originPoint.Y)); if (childGestures?.GetChildGesturesFor <TapGestureRecognizer>(x => x.NumberOfTapsRequired == (int)sender.NumberOfClicksRequired).Count() > 0) { return; } if (weakRecognizer.Target is ClickGestureRecognizer clickGestureRecognizer && view != null) { clickGestureRecognizer.SendClicked(view, clickRecognizer.Buttons); } })); }