public ConfigSpringboard() { NavigationPage.SetHasNavigationBar (this, false); Grid configGrid = new Grid { BackgroundColor = Colours.BG_DARK, Padding = new Thickness(10), RowDefinitions = { new RowDefinition { Height = new GridLength(150, GridUnitType.Absolute) } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } } }; HomeButton UC = new HomeButton (IconLabel.Icon.FAUser, "YOUR INFO", Colours.USERCONFIG_LIGHT, Colours.USERCONFIG_MEDIUM); HomeButton AC = new HomeButton (IconLabel.Icon.FABell, "ALERTS CONFIG", Colours.ALERTSCONFIG_LIGHT, Colours.ALERTSCONFIG_MEDIUM); var alertConfigTapGestureRecognizer = new TapGestureRecognizer (); alertConfigTapGestureRecognizer.Tapped += async (s, e) => { if (AC.IsEnabled) { AC.IsEnabled = false; await AC.ScaleTo(.8, 100); await AC.ScaleTo(1, 100); await Navigation.PushAsync (await AlertConfigContainer.CreateAlertConfigContainer()); AC.IsEnabled = true; } }; AC.GestureRecognizers.Add (alertConfigTapGestureRecognizer); var userConfigTapGestureRecognizer = new TapGestureRecognizer (); userConfigTapGestureRecognizer.Tapped += async (s, e) => { if (UC.IsEnabled) { UC.IsEnabled = false; await UC.ScaleTo(.8, 100); await UC.ScaleTo(1, 100); await Navigation.PushAsync (await YourInfoPageContainer.CreateYourInfoPageContainer()); UC.IsEnabled = true; } }; UC.GestureRecognizers.Add (userConfigTapGestureRecognizer); configGrid.Children.Add (UC, 0, 0); configGrid.Children.Add (AC, 1, 0); ScrollView scrollView = new ScrollView { Orientation = ScrollOrientation.Vertical, Content = configGrid, VerticalOptions = LayoutOptions.FillAndExpand }; Content = scrollView; }
public GridBarChartPage() { InitializeComponent(); List<View> views = new List<View>(); TapGestureRecognizer tapGesture = new TapGestureRecognizer(); tapGesture.Tapped += OnBoxViewTapped; // Create BoxView elements and add to List. for (int i = 0; i < COUNT; i++) { BoxView boxView = new BoxView { Color = Color.Accent, HeightRequest = 300 * random.NextDouble(), VerticalOptions = LayoutOptions.End, StyleId = RandomNameGenerator() }; boxView.GestureRecognizers.Add(tapGesture); views.Add(boxView); } // Add whole List of BoxView elements to Grid. grid.Children.AddHorizontal(views); // Start a timer at the frame rate. Device.StartTimer(TimeSpan.FromMilliseconds(15), OnTimerTick); }
public ConnexionPage() { InitializeComponent (); personConnecte = ""; Poster.Source = ImageSource.FromFile("NoOne.jpg"); var profilImage = new TapGestureRecognizer (); profilImage.Tapped += async (sender, e) => { var action = await DisplayActionSheet("Choisir une action", "Annuler", null, "Phototheque", "Prendre une photo"); if (action == "Phototheque") { await SelectPicture(); } else if (action == "Prendre une photo") { await TakePicture(); } else { Poster.Source = ImageSource.FromFile ("NoOne.jpg"); } }; emailEntry.Text = ""; Poster.GestureRecognizers.Add(profilImage); }
public Springboard () { InitializeComponent (); var tapFirst = new TapGestureRecognizer(); tapFirst.Tapped += async (s, e) => { //firstImage.Opacity = .5; // dim the image for user feedback when tapped //await Task.Delay(100); //firstImage.Opacity = 1; await this.Navigation.PushAsync(new FirstPage()); }; FirstImage.GestureRecognizers.Add(tapFirst); var tapSecond = new TapGestureRecognizer(); tapSecond.Tapped += async (s, e) => { await this.Navigation.PushAsync(new SecondPage()); }; SecondImage.GestureRecognizers.Add(tapSecond); var tapThird = new TapGestureRecognizer(); tapThird.Tapped += async (s, e) => { await this.Navigation.PushAsync(new ThirdPage()); }; ThirdImage.GestureRecognizers.Add(tapThird); }
private void SetupEventHandlers() { firstNameEntry.Completed += (object sender, EventArgs e) => { lastNameEntry.Focus(); }; lastNameEntry.Completed += (object sender, EventArgs e) => { lastNameEntry.Focus(); }; usernameEntry.Completed += (object sender, EventArgs e) => { usernameEntry.Focus(); }; passwordEntry.Completed += (object sender, EventArgs e) => { passwordEntry.Focus(); }; cancelButtonTapped = new TapGestureRecognizer(); cancelButtonTapped.Tapped += (object sender, EventArgs e) => { Navigation.PopModalAsync(); }; cancelButton.GestureRecognizers.Add(cancelButtonTapped); }
public Option() { Label = new Label { Text = "Option", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center }; PagePanel = new PagePanel { HorizontalOptions = LayoutOptions.End, Pages = new List<View> { new Image (), new Image () } }; var layout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { Label, PagePanel } }; var tapGestureRecognizer = new TapGestureRecognizer (); tapGestureRecognizer.Tapped += (sender, e) => OnTapped (); GestureRecognizers.Add (tapGestureRecognizer); Content = layout; SetImageState (); SetLabelState (); }
public ArticlePage() { InitializeComponent(); this.BackgroundColor = Color.White; BindingContext = new ArticleViewModel(); var tgr = new TapGestureRecognizer (); tgr.Tapped +=(s,e)=>ExpandLabelClicked(); lblExpand.GestureRecognizers.Add(tgr); artStackLayout.SizeChanged += ArticleStackLayout_SizeChanged; #region WebView Navigation webView1.Navigating += (s, e) => { if (e.Url.StartsWith("http") || e.Url.StartsWith("mailto")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception) { } e.Cancel = true; } }; #endregion }
void CreateTabs() { if(Children != null && Children.Count > 0) Children.Clear(); foreach(var item in ItemsSource) { var index = Children.Count; var tab = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Padding = new Thickness(7), }; Device.OnPlatform( iOS: () => { tab.Children.Add(new Image { Source = "pin.png", HeightRequest = 20 }); tab.Children.Add(new Label { Text = "Tab " + (index + 1), FontSize = 11 }); }, Android: () => { tab.Children.Add(new Image { Source = "pin.png", HeightRequest = 25 }); } ); var tgr = new TapGestureRecognizer(); tgr.Command = new Command(() => { SelectedItem = ItemsSource[index]; }); tab.GestureRecognizers.Add(tgr); Children.Add(tab, index, 0); } }
public SelectPlacePage() { InitializeComponent (); NavigationPage.SetHasNavigationBar(this, false); TapGestureRecognizer placesTapGestureRecognizer = new TapGestureRecognizer(); List<CWPlaceButton> PlaceButtons = new List<CWPlaceButton> (); for (int i = 0; i < PlacesStack.Children.Count; i++) { if (PlacesStack.Children [i].GetType () == typeof(CWPlaceButton)) { PlaceButtons.Add((CWPlaceButton)PlacesStack.Children[i]); } } placesTapGestureRecognizer.Tapped += async (object sender, EventArgs e) => { CWPlaceButton btn = (CWPlaceButton)sender; App.SetPlace(btn.Place); if(btn.Place == Place.Walk) await Navigation.PushModalAsync(new SelectWalkTimePage()); else await Navigation.PushModalAsync(new LoadingPage()); }; for (int i = 0; i < PlaceButtons.Count; i++) { PlaceButtons [i].GestureRecognizers.Add (placesTapGestureRecognizer); } }
public ManageEventTemplate () { InitializeComponent (); TapGestureRecognizer tgr = new TapGestureRecognizer(); tgr = new TapGestureRecognizer(); tgr.Tapped += async (sender, e) => { EventForLists eveFL = (EventForLists)this.BindingContext; Event eve = eveFL.eve; bool success = false; if (App.userProfile.EventsFollowed.Exists(ef => ef == eve.EventId)) { success = await _dataManager.AttendTrackEvent(eve, false, false); if (success) { trackImg.Foreground = App.HowlOutFade; } } else { success = await _dataManager.AttendTrackEvent(eve, true, false); if (success) { trackImg.Foreground = App.HowlOut; } } }; trackImg.GestureRecognizers.Add(tgr); setFollowButton(); }
public CardView() { HeightRequest = 6*UiConst.LINE_HEIGHT; WidthRequest = 320; BackgroundColor = Color.Maroon; Padding = new Thickness(2); var t = new TapGestureRecognizer(); t.Tapped += new DenyAction<object, EventArgs>(MAnimation, 800).OnEvent; GestureRecognizers.Add(t); Content = (_rootLayout = new RelativeLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = UiConst.COLOR_DF_BG }); Content.GestureRecognizers.Add(t); // init component _rootLayout.Children.Add(new MyLabel { BackgroundColor = Color.Pink }, null, null, null, Constraint.Constant(UiConst.LINE_HEIGHT)); }
private void PopulateProductsLists(List<Product> productsList){ var lastHeight = "100"; var y = 0; var column = LeftColumn; var productTapGestureRecognizer = new TapGestureRecognizer(); productTapGestureRecognizer.Tapped += OnProductTapped; for (var i = 0; i < productsList.Count; i++) { var item = new ProductGridItemTemplate(); if (i > 0) { if (i == 3 || i == 4 || i == 7 || i == 8 || i == 11 || i == 12) { lastHeight = "100"; } else { lastHeight = "190"; } if (i % 2 == 0) { column = LeftColumn; y++; } else { column = RightColumn; } } productsList[i].ThumbnailHeight = lastHeight; item.BindingContext = productsList[i]; item.GestureRecognizers.Add( productTapGestureRecognizer ); column.Children.Add( item ); } }
public MenuPage () { InitializeComponent (); Icon = "Icons/menu.png"; Title = "menu"; Globals.Settings.NotifyEvent = Changes; var tgr = new TapGestureRecognizer (); tgr.Tapped += (sender, e) => (App.Current.MainPage as RootPage).NavigateToPage (new InfoPage ()); gridInfo.GestureRecognizers.Add (tgr); listViewMenu.ItemSelected += (s, e) => { if (OnMenuSelected != null) { var item = listViewMenu.SelectedItem as MenuItem; if (item != null) { if (item.Add) { Globals.Settings.Items.Add (new SettingValues ()); Globals.Settings.ChangAndRebuild (); (App.Current.MainPage as RootPage).NavigateToMenu (null); Globals.Settings.Write (); } else OnMenuSelected (item); } } }; BindingContext = this; }
public MyToolBar(string labelText, string leftIconText, string rightIconText) { _toolbarInfoLabel = new Label { Text = labelText, TextColor = Color.White, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center, }; LeftIcon = new Label { Text = leftIconText, TextColor = Color.White, HorizontalOptions = LayoutOptions.EndAndExpand, }; LeftIconGestureRecognizer = new TapGestureRecognizer (); RightIcon = new Label { Text = rightIconText, TextColor = Color.White, HorizontalOptions = LayoutOptions.End }; RightIconGestureRecognizer = new TapGestureRecognizer (); Children.Add (_toolbarInfoLabel); Children.Add (LeftIcon); Children.Add (RightIcon); BackgroundColor = Color.Silver; HeightRequest = 20; Orientation = StackOrientation.Horizontal; Padding = new Thickness (12, 12, 12, 12); }
private void ActivateOrDeactivateMenu() { if (isMenuAnimationWorking) return; else isMenuAnimationWorking = true; Rectangle menuRectangle; Rectangle midRectangle; if (!IsMenuOpen) { menuRectangle = new Rectangle (new Point (MyDevice.GetScaledSize(mMenuWidth), 0), new Size (mMenuLayout.Bounds.Width, mMenuLayout.Bounds.Height)); midRectangle = new Rectangle (new Point (MyDevice.GetScaledSize (mMenuWidth), 0), new Size (mMidLayout.Bounds.Width, mMidLayout.Bounds.Height)); mainRelativeLayout.Children.Add (InputBlockerForSwipeMenu, Constraint.Constant (MyDevice.GetScaledSize (mMenuWidth)), Constraint.Constant (0) ); var tapRecognizer = new TapGestureRecognizer (); if (InputBlockerForSwipeMenu.GestureRecognizers.Count == 0) { tapRecognizer.Tapped += (sender, e) => { ActivateOrDeactivateMenu(); }; } InputBlockerForSwipeMenu.GestureRecognizers.Add(tapRecognizer); } else { menuRectangle = new Rectangle (new Point (MyDevice.GetScaledSize (0), 0), new Size (mMenuLayout.Bounds.Width, mMenuLayout.Bounds.Height)); midRectangle = new Rectangle (new Point (0, 0), new Size (mMidLayout.Bounds.Width, mMidLayout.Bounds.Height)); mainRelativeLayout.Children.Remove (InputBlockerForSwipeMenu); } mMenuLayout.TranslateTo (menuRectangle.X,menuRectangle.Y, MyDevice.AnimationTimer, Easing.Linear).ContinueWith(antecendent => isMenuAnimationWorking=false); mMidLayout.TranslateTo (midRectangle.X,midRectangle.Y, MyDevice.AnimationTimer, Easing.Linear); IsMenuOpen = !IsMenuOpen; }
public SelectSexPage() { InitializeComponent (); BindingContext = new { SvgAssembly = typeof(App).GetTypeInfo ().Assembly }; NavigationPage.SetHasNavigationBar(this, false); //App.SetSex(Sex.Male); //Navigation.PushModalAsync(new SelectPlacePage()); TapGestureRecognizer maleTapGestureRecognizer = new TapGestureRecognizer(); TapGestureRecognizer femaleTapGestureRecognizer = new TapGestureRecognizer(); MaleButton.GestureRecognizers.Add(maleTapGestureRecognizer); FemaleButton.GestureRecognizers.Add(femaleTapGestureRecognizer); maleTapGestureRecognizer.Tapped += async (object sender, EventArgs e) => { App.SetSex(Sex.Male); await Navigation.PushModalAsync(new SelectPlacePage()); }; femaleTapGestureRecognizer.Tapped += async (object sender, EventArgs e) => { App.SetSex(Sex.Female); await Navigation.PushModalAsync(new SelectPlacePage()); }; }
public void BuildLayout() { mainStack.Spacing = 20; mainStack.Padding = 50; mainStack.VerticalOptions = LayoutOptions.Center; userNameEntry.Placeholder = "Username"; passwordEntry.Placeholder = "Password"; passwordEntry.IsPassword = true; Button loginButton = new Button(); loginButton.Text = "Login"; loginButton.TextColor = Color.Black; loginButton.BackgroundColor = Color.FromHex("77D065"); var tapGesture = new TapGestureRecognizer { Command = new Command(LoginTap)}; loginButton.GestureRecognizers.Add(tapGesture); mainStack.Children.Add(userNameEntry); mainStack.Children.Add(passwordEntry); mainStack.Children.Add(loginButton); }
public ScanPage() { InitializeComponent(); ToolbarItems.Add(new ToolbarItem("change", "Icons/Settings.png", new Action(() => { Navigation.PushAsync(new SettingPage { SettingValues = CurrentSettingValues }, true); }))); labelBarcode.TextColor = Globals.Color.Barcode; labelBarcode.FontAttributes = FontAttributes.Bold; labelBarcode.FontSize = 24; labelBarcode.HorizontalOptions = LayoutOptions.CenterAndExpand; labelBarcode.VerticalOptions = LayoutOptions.CenterAndExpand; labelResult.TextColor = Globals.Color.REST; labelResult.FontAttributes = FontAttributes.Bold; labelResult.FontSize = 24; labelResult.HorizontalOptions = LayoutOptions.CenterAndExpand; labelResult.VerticalOptions = LayoutOptions.CenterAndExpand; circleImageStart.BackgroundColor = Color.Red; circleImageStart.BorderColor = Color.Black; circleImageStart.BorderThickness = 5; circleImageStart.Source = ImageSource.FromResource("ScanAndREST.Resources.Icons.ScanAndRESTStart.png"); circleImageStart.Aspect = Aspect.AspectFill; circleImageStart.BindingContext = this; circleImageStart.HeightRequest = circleImageStart.Width; circleImageStart.HorizontalOptions = LayoutOptions.CenterAndExpand; circleImageStart.VerticalOptions = LayoutOptions.CenterAndExpand; TapGestureRecognizer gesture = new TapGestureRecognizer(); gesture.Tapped += circleImageStartTapped; circleImageStart.GestureRecognizers.Add(gesture); }
public ExpandableCell(Layout header, Layout body, Layout footer) { this.Padding = 0; this.Spacing = 0; this.Children.Add (header); this.Children.Add (body); this.Children.Add (footer); this.body = body; this.IsClippedToBounds = true; var gestureRecognizer = new TapGestureRecognizer () { }; gestureRecognizer.Tapped += (sender, e) => { double start = expanded ? bodyHeight : 0; // the starting height double offset = expanded ? -bodyHeight : bodyHeight; // the change over the animation expanded = !expanded; this.body.Animate ( name: "set height", animation: new Xamarin.Forms.Animation((val) => { this.body.HeightRequest = start + offset*val; }), length: 250, easing: Easing.CubicInOut ); }; header.GestureRecognizers.Add (gestureRecognizer); }
public QuantityButton () { tap = new TapGestureRecognizer (); tap.Tapped += Tap_Tapped; GestureRecognizers.Add (tap); }
public HomeView() { InitializeComponent(); #region ChooseView TapGestureRecognizer chooseTapGestureRecognizer = new TapGestureRecognizer(); chooseTapGestureRecognizer.Tapped += (async (o2, e2) => { App.MealManager.Reset(); var page = new ChooseView(); NavigationPage.SetHasBackButton(page, true); await Navigation.PushAsync(page, false); }); ChooseStack.GestureRecognizers.Add(chooseTapGestureRecognizer); #endregion #region OverviewView TapGestureRecognizer overviewTapGestureRecognizer = new TapGestureRecognizer(); overviewTapGestureRecognizer.Tapped += (async (o2, e2) => { var page = new OverviewView(); NavigationPage.SetHasBackButton(page, true); await Navigation.PushAsync(page, false); }); OverviewStack.GestureRecognizers.Add(overviewTapGestureRecognizer); #endregion }
public static void SetupStepView(RelativeLayout rLayout, ScrollView helpSv, StackLayout questionContainer, Command questionTappedCmd) { var tgr = new TapGestureRecognizer() { Command = new Command((obj) => { var oldBound = helpSv.Bounds; if (oldBound.Height == 40) { // Need to show. var newBound = new Rectangle(0, rLayout.Height - 200, rLayout.Width, 200); helpSv.LayoutTo(newBound, 250, Easing.CubicInOut); } else { // Need to hide. var newBound = new Rectangle(0, rLayout.Height - 40, rLayout.Width, 40); helpSv.LayoutTo(newBound, 250, Easing.CubicInOut); } }) }; helpSv.GestureRecognizers.Add(tgr); var qControls = questionContainer.Children.Where(x => x is QuestionLayout).Cast<QuestionLayout>(); var currIdx = 0; foreach (var qControl in qControls) { var questionTgr = new TapGestureRecognizer() { Command = questionTappedCmd, CommandParameter = currIdx, }; qControl.GestureRecognizers.Add(questionTgr); currIdx++; } }
void AddMoodOptions() { //hardcoded to be 3x3 int rows = 3; int cols = 3; //we get all the filenames to prepare to display the images var filenames = new List<string>(vm.moods.Keys); //images cannot handle taps out of the box var tapRecognizer = new TapGestureRecognizer(); //tapRecognizer.NumberOfTapsRequired = 1; tapRecognizer.Tapped += OnTapGestureRecognizerTapped; //to iterate through every image int k = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++, k++) { var moodImg = new Image { Source = filenames[k], Opacity = CONST.DEFAULT_OPACITY }; moodImg.GestureRecognizers.Add(tapRecognizer); grdMoods.Children.Add(moodImg, j, i); } } }
public LeagueCardView(LeagueItem context) { BindingContext = context; Grid grid = new Grid { Padding = new Thickness(1,1,2,2), RowSpacing = 0, ColumnSpacing = 0, BackgroundColor = Color.FromHex ("E3E3E3").MultiplyAlpha(0.5), RowDefinitions = { new RowDefinition { Height = new GridLength (100, GridUnitType.Absolute) } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength (4, GridUnitType.Absolute) }, new ColumnDefinition { } } }; grid.Children.Add ( new FixtureCardStatusView () ,0,0); grid.Children.Add (new LeagueCardDetailsView (LeagueItem), 1, 0); var tgr = new TapGestureRecognizer { NumberOfTapsRequired = 1 }; tgr.Tapped += (sender, args) => { OnCardClicked?.Invoke (LeagueItem); }; grid.GestureRecognizers.Add (tgr); Content = grid; }
public MyViewCell() { var image = new Image { Source = ImageSource.FromFile ("monkey.jpg"), HeightRequest = 50, }; var tapGestureRecognizer = new TapGestureRecognizer (); tapGestureRecognizer.Tapped += (object sender, EventArgs e) => { if (image.HeightRequest < 250) { image.HeightRequest = image.Height + 100; ForceUpdateSize (); } }; image.GestureRecognizers.Add (tapGestureRecognizer); var stackLayout = new StackLayout { Padding = new Thickness (20, 5, 5, 5), Orientation = StackOrientation.Horizontal, Children = { image, new Label { Text = "Monkey", VerticalOptions = LayoutOptions.Center } } }; View = stackLayout; }
public static void AnimateWithAction(this Label label, Command command = null, ScaleType type = ScaleType.After) { var tapGesture = new TapGestureRecognizer (); tapGesture.Tapped += async (sender, args) => { switch (type) { case ScaleType.First: command?.Execute (null); await label.ScaleTo (0.75, 100, Easing.CubicOut); await label.ScaleTo (1, 100, Easing.CubicIn); break; case ScaleType.Midle: await label.ScaleTo (0.75, 100, Easing.CubicOut); command?.Execute (null); await label.ScaleTo (1, 100, Easing.CubicIn); break; case ScaleType.After: await label.ScaleTo (0.75, 100, Easing.CubicOut); await label.ScaleTo (1, 100, Easing.CubicIn); command?.Execute (null); break; default: break; } }; label.GestureRecognizers.Add (tapGesture); }
public XamagonXuzzlePage() { InitializeComponent(); // Loop through the rows and columns. for (int row = 0; row < NUM; row++) { for (int col = 0; col < NUM; col++) { // But skip the last one! if (row == NUM - 1 && col == NUM - 1) break; // Get the bitmap for each tile and instantiate it. ImageSource imageSource = ImageSource.FromResource("XamagonXuzzle.Images.Bitmap" + row + col + ".png"); XamagonXuzzleTile tile = new XamagonXuzzleTile(row, col, imageSource); // Add tap recognition. TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer { Command = new Command(OnTileTapped), CommandParameter = tile }; tile.GestureRecognizers.Add(tapGestureRecognizer); // Add it to the array and the AbsoluteLayout. tiles[row, col] = tile; absoluteLayout.Children.Add(tile); } } }
public ClubMemberViewCell() { nameTGR = new TapGestureRecognizer(); nameTGR.Tapped += NameTGR_Tapped; ch = new ColorHandler(); iEmoji = new Image { Aspect = Aspect.AspectFit, WidthRequest = 75, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center }; iEmoji.SetBinding(Image.SourceProperty, "Emoji"); lUsername = new Label { HorizontalOptions = LayoutOptions.CenterAndExpand, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), VerticalOptions = LayoutOptions.Center }; lUsername.SetBinding(Label.TextProperty, "Username"); lUsername.SetBinding(Label.TextColorProperty, "UserColor", converter: new ColorConverter()); lUsername.GestureRecognizers.Add(nameTGR); updateView(); }
private void CreateOrRemoveGestureRecognizer() { if (Command == null) { if (_tapGestureRecognizer == null) return; GestureRecognizers.Remove(_tapGestureRecognizer); _tapGestureRecognizer = null; } else { if (_tapGestureRecognizer != null) return; _tapGestureRecognizer = new TapGestureRecognizer { Command = new RelayCommand(p => { if (Command != null) Command.Execute(CommandParameter ?? p); }, p => Command == null || Command.CanExecute(CommandParameter ?? p)) }; GestureRecognizers.Add(_tapGestureRecognizer); } }
public TapGestureRecognizerHandler(NativeComponentRenderer renderer, XF.TapGestureRecognizer tapGestureRecognizerControl) : base(renderer, tapGestureRecognizerControl) { TapGestureRecognizerControl = tapGestureRecognizerControl ?? throw new ArgumentNullException(nameof(tapGestureRecognizerControl)); ConfigureEvent( eventName: "ontapped", setId: id => TappedEventHandlerId = id, clearId: id => { if (TappedEventHandlerId == id) { TappedEventHandlerId = 0; } }); TapGestureRecognizerControl.Tapped += (s, e) => { if (TappedEventHandlerId != default) { renderer.Dispatcher.InvokeAsync(() => renderer.DispatchEventAsync(TappedEventHandlerId, null, e)); } }; }
public SampleNavigation() { Orientation = StackOrientation.Horizontal; HorizontalOptions = LayoutOptions.Fill; Margin = new Thickness(0, 20, 0, 0); Children.Add(new Label() { ClassId = "LabelText", Text = "示例 1:设置高度500,宽度200的堆栈布局", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.StartAndExpand, HorizontalTextAlignment = TextAlignment.Start }); var lookCode = new Label() { ClassId = "LabelCodeUrl", Text = "查看代码", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, TextColor = Color.FromHex("#0a6cff") }; var tapGestureRecognizer = new Xamarin.Forms.TapGestureRecognizer(); tapGestureRecognizer.Tapped += (object sender, EventArgs e) => { var url = "https://github.com/hexu6788/XamarinForms-Samples/blob/master/Code/Samples/Samples/"; var xaml = string.Format("{0}{1}", url, XamlCodeUrl); var csharp = string.Format("{0}{1}", url, CSharpCodeUrl); App.CurrentPage.Navigation.PushAsync(new CodeViewNavigation(xaml, csharp)); }; lookCode.GestureRecognizers.Add(tapGestureRecognizer); Children.Add(lookCode); }
public void InitializeComponent() { try { this.LoadFromXaml (typeof(UsagePage)); ProgressBarData = this.FindByName<ProgressBar>("ProgressBarData"); ProgressBarCall = this.FindByName<ProgressBar>("ProgressBarCall"); ButtonUsageReport = this.FindByName<Image>("UsageReportButton"); ButtonUsagePage = this.FindByName<Image>("UsageButton"); ButtonUsageDetails = this.FindByName<Image>("UsageDetailsButton"); SlUsagePage= this.FindByName<StackLayout>("SlUsagePage"); SlUsageReport= this.FindByName<StackLayout>("SlUsageReport"); SlUsageDetail = this.FindByName<StackLayout>("SlUsageDetail"); TabButtonTouchRecognizer = new TapGestureRecognizer(); TabButtonTouchRecognizer.Tapped+= TabButtonTouchRecognizer_Tapped; ButtonUsageReport.GestureRecognizers.Add(TabButtonTouchRecognizer); ButtonUsagePage.GestureRecognizers.Add(TabButtonTouchRecognizer); ButtonUsageDetails.GestureRecognizers.Add(TabButtonTouchRecognizer); } catch (Exception ex) { //TODO::Log Reporting. int i=0; i++; } }