本文整理汇总了C#中Xamarin.Forms.TapGestureRecognizer类的典型用法代码示例。如果您正苦于以下问题:C# TapGestureRecognizer类的具体用法?C# TapGestureRecognizer怎么用?C# TapGestureRecognizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TapGestureRecognizer类属于Xamarin.Forms命名空间,在下文中一共展示了TapGestureRecognizer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AnimateWithAction
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);
}
开发者ID:RobertoOFonseca,项目名称:MySafety,代码行数:27,代码来源:Extensions.cs
示例2: MyToolBar
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);
}
开发者ID:TheTekton,项目名称:GRNavIssue,代码行数:32,代码来源:MyToolBar.cs
示例3: ExpandableCell
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);
}
开发者ID:naturalistic,项目名称:AnimatedTables,代码行数:27,代码来源:ExpandableCell.cs
示例4: BuildLayout
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);
}
开发者ID:hieumoscow,项目名称:WeAreReady,代码行数:25,代码来源:ScanView.cs
示例5: ActivateOrDeactivateMenu
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;
}
开发者ID:jiletx,项目名称:Bluemart,代码行数:35,代码来源:SettingsPage.xaml.cs
示例6: HomeView
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
}
开发者ID:jacobduijzer,项目名称:WatEtenWeDezeWeek,代码行数:35,代码来源:HomeView.xaml.cs
示例7: CreateOrRemoveGestureRecognizer
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);
}
}
开发者ID:jimbobbennett,项目名称:JimLib.Xamarin,代码行数:25,代码来源:ExtendedLabel.cs
示例8: ConfigSpringboard
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;
}
开发者ID:DaveCaldeira,项目名称:NavigationTest,代码行数:60,代码来源:ConfigSpringboard.cs
示例9: GridBarChartPage
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);
}
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:28,代码来源:GridBarChartPage.xaml.cs
示例10: ConnexionPage
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);
}
开发者ID:StartupMobilite,项目名称:Playdate,代码行数:31,代码来源:ConnexionPage.xaml.cs
示例11: Springboard
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);
}
开发者ID:mhalkovitch,项目名称:Xamarim,代码行数:29,代码来源:Springboard.xaml.cs
示例12: SetupEventHandlers
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);
}
开发者ID:yue9944882,项目名称:FaceEmojiXamarin,代码行数:26,代码来源:SignUpPage.xaml.cs
示例13: Option
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 ();
}
开发者ID:davidjcaton,项目名称:glowingbrain-data-capture,代码行数:33,代码来源:Option.cs
示例14: ArticlePage
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
}
开发者ID:bencrispin,项目名称:ScrollInWeb,代码行数:35,代码来源:Page.xaml.cs
示例15: AddMoodOptions
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);
}
}
}
开发者ID:vash47,项目名称:ihbi-project,代码行数:25,代码来源:WellnessView.xaml.cs
示例16: CreateTabs
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);
}
}
开发者ID:entdark,项目名称:xamarin-forms-carouselview,代码行数:35,代码来源:PagerIndicatorTabs.cs
示例17: LeagueCardView
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;
}
开发者ID:codnee,项目名称:Scores-App,代码行数:32,代码来源:LeagueCardView.cs
示例18: SetupStepView
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++;
}
}
开发者ID:NamXH,项目名称:Orchard,代码行数:35,代码来源:ViewUtils.cs
示例19: PopulateProductsLists
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 );
}
}
开发者ID:ahdproduction,项目名称:ConnectPeople,代码行数:33,代码来源:ProductsGridVariant.xaml.cs
示例20: CardView
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));
}
开发者ID:manhvvhtth,项目名称:xm-form,代码行数:26,代码来源:CardView.cs
注:本文中的Xamarin.Forms.TapGestureRecognizer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论