/// <summary> /// <inheritdoc/> /// </summary> public SlidableLayout() { Padding = 0; Margin = 0; HorizontalOptions = LayoutOptions.FillAndExpand; VerticalOptions = LayoutOptions.FillAndExpand; Config = new SliderConfig(int.MinValue, int.MaxValue); m_rec = new PanGestureRecognizer(); if (Device.RuntimePlatform == Device.iOS) { GestureRecognizers.Add(m_rec); m_rec.PanUpdated += Rec_PanUpdated; } }
public BottomDrawer() { BackgroundColor = Color.White; CornerRadius = 8; HasShadow = true; var panGestures = new PanGestureRecognizer(); panGestures.PanUpdated += OnPanChanged; GestureRecognizers.Add(panGestures); var tapGestures = new TapGestureRecognizer(); tapGestures.Tapped += OnTapped; GestureRecognizers.Add(tapGestures); }
public RoundedRectangleView() { _canvasView = new SKCanvasView(); _canvasView.PaintSurface += PaintContents; _root = new Grid { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; _root.Children.Add(_canvasView); Content = _root; GestureRecognizers.Add(new TapGestureRecognizer((obj) => Clicked?.Invoke(this, new EventArgs()))); }
public DotButton() { var clickCheck = new TapGestureRecognizer() { Command = new Command(() => { if (Clicked != null) { Clicked(this); } }) }; GestureRecognizers.Add(clickCheck); }
private void Initialize() { _toggleImage = new Image(); GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => { Checked = !Checked; }) }); _toggleImage.Source = UnCheckedImage; Content = _toggleImage; }
public LabelCustomBorder() { InitializeComponent(); GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { UnTouch(); if (EventClick != null) { EventClick(ValueLabel); } }) }); }
public void Initialize() { GestureRecognizers.Add(new TapGestureRecognizer() { Command = AnimationCommand }); //Content = new Label() //{ // VerticalOptions = LayoutOptions.Center, // HorizontalOptions = LayoutOptions.Center, // Text = this.Text, // TextColor = this.TextColor, // FontSize = this.FontSize //}; }
public MyBoxView() { UpdateColor(); GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { // 何らかのタイミングで活性判定を行い実行する if (Command.CanExecute(CommandParameter)) { Command.Execute(CommandParameter); } }) }); }
public MySecondView() { InitializeComponent(); InitializeComponent(); BackgroundColor = Color.White; /*var source = new List<string>() { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; * * myList.ItemsSource = source;*/ var tapGesture = new TapGestureRecognizer((obj) => Debug.WriteLine("Second View tapped")); GestureRecognizers.Add(tapGesture); }
public AtomZoomView() { this.BackgroundColor = Color.White; if (Device.RuntimePlatform != Device.Android) { var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add(panGesture); } }
public SvgImage() { PaintSurface += OnPaintSurface; WidthRequest = _iconSize + _padding * 2; HeightRequest = _iconSize + _padding * 2; if (App.Instance.IsDesignMode) { BackgroundColor = Color.FromHex("#7000"); } #pragma warning disable CS0618 // Type or member is obsolete GestureRecognizers.Add(new TapGestureRecognizer((obj) => Clicked?.Invoke(this, new EventArgs()))); #pragma warning restore CS0618 // Type or member is obsolete }
private void CreateControl() { var checkboxControlTapGuesture = new TapGestureRecognizer(); checkboxControlTapGuesture.Tapped += OnCheckboxControlTapped; GestureRecognizers.Add(checkboxControlTapGuesture); _checkboxImage = new Image(); _checkboxTextLabel = new Label(); _checkboxImage.VerticalOptions = LayoutOptions.CenterAndExpand; _checkboxTextLabel.VerticalTextAlignment = TextAlignment.Center; _checkboxImage.Source = ImageSource.FromFile(UnCheckIcon); if (CheckBoxPosition == CheckboxPosition.Right) { RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); Children.Add(_checkboxTextLabel, 0, 0); Children.Add(_checkboxImage, 1, 0); ColumnSpacing = 5; } else { ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); this.Children.Add(_checkboxImage, 0, 0); this.Children.Add(_checkboxTextLabel, 1, 0); ColumnSpacing = 0; } VerticalOptions = LayoutOptions.CenterAndExpand; HorizontalOptions = LayoutOptions.FillAndExpand; Margin = new Thickness(0); Padding = new Thickness(8.0); RowSpacing = 0; }
/// <param name="propertyName">The name of the property that changed.</param> /// <summary> /// Call this method from a child class to notify that a change happened on a property. /// </summary> /// <remarks> /// <para> /// A <see cref="T:Xamarin.Forms.BindableProperty"/> triggers this by itself. An inheritor only needs to call this for properties without <see cref="T:Xamarin.Forms.BindableProperty"/> as the backend store. /// </para> /// </remarks> protected override void OnPropertyChanged(string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName == "NavigateCommand") { this.GestureRecognizers.Remove(_tapGestureRecognizer); _tapGestureRecognizer = new TapGestureRecognizer() { Command = NavigateCommand }; GestureRecognizers.Add(_tapGestureRecognizer); } }
private void Initialize() { GestureRecognizers.Add(new TapGestureRecognizer { Command = ImagePressedCommand }); TapGestureRecognizer tappedGesture = new TapGestureRecognizer(); tappedGesture.Tapped += (sender, e) => { Pressed?.Invoke(this, new EventArgs()); }; GestureRecognizers.Add(tappedGesture); }
public View3(Stopwatch stopwatch) { _stopwatch = stopwatch; canvasView = new SKCanvasView(); canvasView.PaintSurface += OnCanvasViewPaintSurface; Content = canvasView; var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += (s, e) => { Console.WriteLine("TAPPED"); }; GestureRecognizers.Add(tapGestureRecognizer); }
/// <summary> /// Initializes a new instance of the <see cref="HyperLinkLabel"/> class. /// </summary> public HyperLinkLabel() { NavigateCommand = new Command(() => { var device = Resolver.Resolve <IDevice>(); device.LaunchUriAsync(new Uri(NavigateUri)); }); _tapGestureRecognizer = new TapGestureRecognizer() { Command = NavigateCommand }; GestureRecognizers.Add(_tapGestureRecognizer); }
public WellcomeBlock() { TapCommand = new Command(OnTapped); InitializeComponent(); BindingContext = this; TapGestureRecognizer tc = new TapGestureRecognizer { Command = new Command(() => { OnTapped(); }) }; GestureRecognizers.Add(tc); }
public BGPrevFrame() { VerticalOptions = LayoutOptions.Start; HorizontalOptions = LayoutOptions.Start; Padding = new Thickness(2); GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Task.Run(async() => { await this.ScaleTo(0.8, 100); await this.ScaleTo(1, 100); MessagingCenter.Send(this, "BGPrevFrame", BGName); })) }); }
public PanContainer() { Image = CropperLayout.inputImage; var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add(panGesture); CropperContainer = new Grid { Margin = -600, RowSpacing = 0, ColumnSpacing = 0, }; Initialize(); Content = CropperContainer; }
public CheckBox() { InitializeComponent(); _fontSize = TxtLabel.FontSize; TxtLabel.FontSize = _fontSize; ChkLabel.FontSize = _fontSize; ChkLabel.WidthRequest = _fontSize; ChkLabel.HeightRequest = _fontSize; var TapGesture = new TapGestureRecognizer(); TapGesture.Tapped += TapGestureOnTapped; GestureRecognizers.Add(TapGesture); }
public Checkbox() { var TapGesture = new TapGestureRecognizer(); TapGesture.Tapped += TapGestureOnTapped; GestureRecognizers.Add(TapGesture); ContentGrid = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; ContentGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(42) }); ContentGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ContentGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); ImageContainer = new Image { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, }; ImageContainer.HeightRequest = 42; ImageContainer.WidthRequest = 42; ContentGrid.Children.Add(ImageContainer); ContentContainer = new ContentView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; Grid.SetColumn(ContentContainer, 1); TextContainer = new Label { TextColor = Color.White, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, }; ContentContainer.Content = TextContainer; ContentGrid.Children.Add(ContentContainer); base.Content = ContentGrid; this.Image.Source = "Image_Unchecked.png"; this.BackgroundColor = Color.Transparent; }
public void AddPinch() { var pinch = new PinchGestureRecognizer(); double xOffset = 0; double yOffset = 0; double startScale = 1; pinch.PinchUpdated += (sender, e) => { if (e.Status == GestureStatus.Started) { startScale = Content.Scale; Content.AnchorX = Content.AnchorY = 0; } if (e.Status == GestureStatus.Running) { _currentScale += (e.Scale - 1) * startScale; _currentScale = Math.Max(1, _currentScale); var renderedX = Content.X + xOffset; var deltaX = renderedX / Width; var deltaWidth = Width / (Content.Width * startScale); var originX = (e.ScaleOrigin.X - deltaX) * deltaWidth; var renderedY = Content.Y + yOffset; var deltaY = renderedY / Height; var deltaHeight = Height / (Content.Height * startScale); var originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight; double targetX = xOffset - (originX * Content.Width) * (_currentScale - startScale); double targetY = yOffset - (originY * Content.Height) * (_currentScale - startScale); Content.TranslationX = targetX.Clamp(-Content.Width * (_currentScale - 1), 0); Content.TranslationY = targetY.Clamp(-Content.Height * (_currentScale - 1), 0); Content.Scale = _currentScale; } if (e.Status == GestureStatus.Completed) { xOffset = Content.TranslationX; yOffset = Content.TranslationY; } }; GestureRecognizers.Add(pinch); }
public ExampleTemplateCarousel() { InitializeComponent(); var gesture = new PanGestureRecognizer(); gesture.PanUpdated += (sender, e) => { if (e.StatusType == GestureStatus.Started) { _initialY = Y; } if (e.StatusType == GestureStatus.Running) { if (e.TotalY < _minYScroll) { var scaledValue = 1 - (Math.Abs(e.TotalY) / _maxYScroll); this.ScaleTo(0.9); this.FadeTo(scaledValue); this.TranslateTo(X, Y + e.TotalY); } if (e.TotalY < _diffYScroll) { _delete = true; } } if (e.StatusType == GestureStatus.Completed || e.StatusType == GestureStatus.Canceled) { if (_delete) { this.FadeTo(0.1); this.TranslateTo(X, Y - 1000); MessagingCenter.Send(this, "remove"); } else { this.ScaleTo(1); this.FadeTo(1); this.TranslateTo(X, _initialY); } } }; GestureRecognizers.Add(gesture); }
public ClickableImageLabel() { Orientation = StackOrientation.Horizontal; HorizontalOptions = LayoutOptions.Center; Padding = new Thickness(15, 8); icon = new Image(); title = new Label() { TextColor = Color.White, VerticalOptions = LayoutOptions.Center, }; Children.Add(icon); Children.Add(title); GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => RaiseOnClick()), }); }
public MySKGLView() : base() { EnableTouchEvents = true; Touch += OnTouch; var pinch = new PinchGestureRecognizer(); pinch.PinchUpdated += PinchUpdated; GestureRecognizers.Add(pinch); base.MeasureInvalidated += MySKGLView_MeasureInvalidated; base.SizeChanged += MySKGLView_SizeChanged; OnLoad(null); }
public LikeButton() { WidthRequest = weight; HeightRequest = weight; VerticalOptions = LayoutOptions.Center; Source = CommonData.IsNightMode ? MediaResoursesHelper.GetMediaPath("like_dark_icon.png") : MediaResoursesHelper.GetMediaPath("like_light_icon.png"); GestureRecognizers.Add( new TapGestureRecognizer { Command = new Command(async() => { MessagingCenter.Send <LikeButton>(this, MessagingCenterConstants.LikeButtonPushed); await this.ScaleTo(0.95, 100); await this.ScaleTo(1, 100); }) }); }
private void clickOnLink() { NavigateCommand = new Command(() => { if (!String.IsNullOrEmpty(NavigateUri)) { Device.OpenUri(new Uri(NavigateUri)); } }); _tapGestureRecognizer = new TapGestureRecognizer() { Command = NavigateCommand }; GestureRecognizers.Add(_tapGestureRecognizer); }
public PanContainer() { BackgroundColor = Color.FromHex("#50D3D3D3"); var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add(panGesture); statusBarHeight = DependencyService.Get <IStatusBar>().GetHeight(); pageHeight = App.ScreenHeight - statusBarHeight; _myCollectionview = new mycollectionview(); _box = new BoxView { Margin = 2, HeightRequest = 3, CornerRadius = 3, WidthRequest = 50, BackgroundColor = Color.FromHex("#D3D3D3"), HorizontalOptions = LayoutOptions.Center }; _bottomSheetFrame = new Frame { CornerRadius = 20, Content = new StackLayout { Children = { _box, _myCollectionview.stackLayout , new StackLayout { HeightRequest = 100 } } } }; y = pageHeight / 9; _bottomSheetFrame.TranslationY = y; _myCollectionview.collectionView.HeightRequest = pageHeight - 300; Content = _bottomSheetFrame; }
public HyperlinkSpan() { TextDecorations = TextDecorations.Underline; TextColor = Color.Blue; GestureRecognizers.Add(new TapGestureRecognizer { // Launcher.OpenAsync is provided by Xamarin.Essentials. Command = new Command(async() => await Browser.OpenAsync(Url, new BrowserLaunchOptions {//Have to add Https:// to the link before opening it so it won't crash LaunchMode = BrowserLaunchMode.SystemPreferred, TitleMode = BrowserTitleMode.Show, PreferredToolbarColor = Color.FromHex("#006738"), //RiE Green(I took the hex for this but i don't know how to access the colour dict for this) PreferredControlColor = Color.White, }) ) }); }
/// ------------------------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------------------------ #region Public Constructors /// ------------------------------------------------------------------------------------------------ /// /// <summary> /// Initializes a new instance of the <see cref="T:HyperLinkLabel"/> class. /// </summary> public HyperLinkLabel(string value) { try { InitializeComponent(); Text = value; InputValue = string.Empty; _getText = value; TapGestureRecognizer tapInput = new TapGestureRecognizer(); tapInput.Tapped += InputTapped; GestureRecognizers.Add(tapInput); } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }