コード例 #1
0
 protected override void OnDetached()
 {
     try
     {
         _effect.Control         = null;
         _effect                 = null;
         Container.LayoutChange -= LayoutChange;
         if (Container != null)
         {
             Container.Touch -= OnTouch;
         }
         if (Control != null)
         {
             Control.Touch -= OnTouch;
         }
         if (_viewOverlay != null)
         {
             Container.RemoveView(_viewOverlay);
             _viewOverlay.Pressed    = false;
             _viewOverlay.Foreground = null;
             _viewOverlay.Dispose();
             _ripple?.Dispose();
         }
     }
     catch (ObjectDisposedException)
     {
         //suppress exception
     }
     _isHoverSupported = false;
 }
コード例 #2
0
        protected override void OnAttached()
        {
            _effect         = Element.GetTouchEff();
            _effect.Control = Element as VisualElement;
            _effect.ForceUpdateState(false);

            if (Container != null)
            {
                Container.Touch += OnTouch;
            }
            else if (Control != null)
            {
                Control.Touch += OnTouch;
            }

            if (_effect.NativeAnimation)
            {
                View.Clickable     = true;
                View.LongClickable = true;
                _viewOverlay       = new FrameLayout(Container.Context)
                {
                    LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                    Clickable        = false,
                    Focusable        = false,
                };
                View.LayoutChange += LayoutChange;

                _ripple                 = CreateRipple();
                _ripple.Radius          = (int)(View.Context.Resources.DisplayMetrics.Density * _effect.NativeAnimationRadius);
                _viewOverlay.Background = _ripple;

                Container.AddView(_viewOverlay);
                _viewOverlay.BringToFront();
            }
        }
コード例 #3
0
 protected override void OnDetached()
 {
     Container?.RemoveGestureRecognizer(_gesture);
     _gesture?.Dispose();
     _gesture        = null;
     _effect.Control = null;
     _effect         = null;
 }
コード例 #4
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _effect    = null;
         _container = null;
     }
     base.Dispose(disposing);
 }
コード例 #5
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _effect  = null;
         Delegate = null;
     }
     base.Dispose(disposing);
 }
コード例 #6
0
 protected override void OnDetached()
 {
     _effect.Control = null;
     _effect         = null;
     if (Container != null)
     {
         Container.Touch -= OnTouch;
     }
 }
コード例 #7
0
        protected override void OnAttached()
        {
            _effect = Element.PickTouchEff();
            if (_effect.IsDisabled)
            {
                return;
            }

            _effect.Control = Element as VisualElement;

            _effect.ForceUpdateState(false);
            if (_effect.NativeAnimation)
            {
                var nativeControl = Container;
                if (String.IsNullOrEmpty(nativeControl.Name))
                {
                    nativeControl.Name = Guid.NewGuid().ToString();
                }

                if (nativeControl.Resources.ContainsKey("PointerDownAnimation"))
                {
                    _pointerDownStoryboard = (Storyboard)nativeControl.Resources["PointerDownAnimation"];
                }
                else
                {
                    _pointerDownStoryboard = new Storyboard();
                    var downThemeAnimation = new PointerDownThemeAnimation();
                    Storyboard.SetTargetName(downThemeAnimation, nativeControl.Name);
                    _pointerDownStoryboard.Children.Add(downThemeAnimation);
                    nativeControl.Resources.Add(new KeyValuePair <object, object>("PointerDownAnimation", _pointerDownStoryboard));
                }

                if (nativeControl.Resources.ContainsKey("PointerUpAnimation"))
                {
                    _pointerUpStoryboard = (Storyboard)nativeControl.Resources["PointerUpAnimation"];
                }
                else
                {
                    _pointerUpStoryboard = new Storyboard();
                    var upThemeAnimation = new PointerUpThemeAnimation();
                    Storyboard.SetTargetName(upThemeAnimation, nativeControl.Name);
                    _pointerUpStoryboard.Children.Add(upThemeAnimation);
                    nativeControl.Resources.Add(new KeyValuePair <object, object>("PointerUpAnimation", _pointerUpStoryboard));
                }
            }

            if (Container != null)
            {
                Container.PointerPressed     += OnPointerPressed;
                Container.PointerReleased    += OnPointerReleased;
                Container.PointerCanceled    += OnPointerCanceled;
                Container.PointerExited      += OnPointerExited;
                Container.PointerEntered     += OnPointerEntered;
                Container.PointerCaptureLost += OnPointerCaptureLost;
            }
        }
コード例 #8
0
        protected override void OnAttached()
        {
            _effect         = Element.GetTouchEff();
            _effect.Control = Element as VisualElement;
            _effect.ForceUpdateState(false);

            if (Container != null)
            {
                Container.Touch += OnTouch;
            }
        }
コード例 #9
0
 protected override void OnAttached()
 {
     _effect         = Element.GetTouchEff();
     _effect.Control = Element as VisualElement;
     _effect.ForceUpdateState(false);
     if (Container != null)
     {
         _gesture = new TouchNSClickGestureRecognizer(_effect, Container);
         Container.AddGestureRecognizer(_gesture);
     }
 }
コード例 #10
0
 protected override void OnDetached()
 {
     _effect.Control = null;
     _effect         = null;
     if (Container != null)
     {
         Container.PointerPressed  -= OnPointerPressed;
         Container.PointerReleased -= OnPointerReleased;
         Container.PointerCanceled -= OnPointerCanceled;
     }
 }
コード例 #11
0
        protected override void OnAttached()
        {
            _effect = Element.PickTouchEff();
            if (_effect?.IsDisabled ?? true)
            {
                return;
            }

            _effect.Control = Element as VisualElement;
            _gestureLayer   = new TouchTapGestureRecognizer(Control, _effect);
        }
コード例 #12
0
 protected override void OnAttached()
 {
     _effect         = Element.GetTouchEff();
     _effect.Control = Element as VisualElement;
     _effect.ForceUpdateState(false);
     _gesture = new TouchUITapGestureRecognizer(_effect);
     if (Container != null)
     {
         Container.AddGestureRecognizer(_gesture);
         Container.UserInteractionEnabled = true;
     }
 }
コード例 #13
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_trackingArea != null)
         {
             RemoveTrackingArea(_trackingArea);
             _trackingArea.Dispose();
         }
         _effect = null;
     }
     base.Dispose(disposing);
 }
コード例 #14
0
        protected override void OnAttached()
        {
            _effect         = Element.GetTouchEff();
            _effect.Control = Element as VisualElement;
            _effect.ForceUpdateState(false);

            if (Container != null)
            {
                Container.PointerPressed  += OnPointerPressed;
                Container.PointerReleased += OnPointerReleased;
                Container.PointerCanceled += OnPointerCanceled;
            }
        }
コード例 #15
0
 protected override void OnDetached()
 {
     _mouseTrackingView?.RemoveFromSuperview();
     _mouseTrackingView?.Dispose();
     _mouseTrackingView = null;
     _effect.Control    = null;
     _effect            = null;
     if (_gesture != null)
     {
         Container?.RemoveGestureRecognizer(_gesture);
     }
     _gesture?.Dispose();
     _gesture = null;
 }
コード例 #16
0
        protected override void OnDetached()
        {
            if (_effect?.Control == null)
            {
                return;
            }

            if (_gestureLayer != null)
            {
                _gestureLayer.ClearCallbacks();
                _gestureLayer.Unrealize();
                _gestureLayer = null;
            }
            _effect.Control = null;
            _effect         = null;
        }
コード例 #17
0
        protected override void OnDetached()
        {
            _effect.Control = null;
            _effect         = null;
            if (Container != null)
            {
                Container.PointerPressed     -= OnPointerPressed;
                Container.PointerReleased    -= OnPointerReleased;
                Container.PointerCanceled    -= OnPointerCanceled;
                Container.PointerExited      -= OnPointerExited;
                Container.PointerEntered     -= OnPointerEntered;
                Container.PointerCaptureLost -= OnPointerCaptureLost;

                _pressed = false;
            }
        }
コード例 #18
0
        protected override void OnAttached()
        {
            _effect = Element.PickTouchEff();
            if (_effect?.IsDisabled ?? true)
            {
                return;
            }

            _effect.Control = Element as VisualElement;

            _gesture = new TouchUITapGestureRecognizer(_effect);
            if (Container != null)
            {
                Container.AddGestureRecognizer(_gesture);
                Container.UserInteractionEnabled = true;
            }
        }
コード例 #19
0
        protected override void OnAttached()
        {
            _effect = Element.PickTouchEff();
            if (_effect?.IsDisabled ?? true)
            {
                return;
            }

            _effect.Control = Element as VisualElement;

            if (Container != null)
            {
                _gesture = new TouchNSClickGestureRecognizer(_effect, Container);
                Container.AddGestureRecognizer(_gesture);
                Container.AddSubview(_mouseTrackingView = new MouseTrackingView(_effect));
            }
        }
コード例 #20
0
        protected override void OnDetached()
        {
            if (_effect?.Control == null)
            {
                return;
            }
            try
            {
                if (_accessibilityManager != null)
                {
                    _accessibilityManager.RemoveAccessibilityStateChangeListener(_accessibilityListener);
                    _accessibilityManager.RemoveTouchExplorationStateChangeListener(_accessibilityListener);
                    _accessibilityListener.Dispose();
                    _accessibilityManager = null;
                    _accessibilityManager = null;
                }

                if (View != null)
                {
                    View.LayoutChange -= LayoutChange;
                    View.Touch        -= OnTouch;
                    View.Click        -= OnClick;
                }

                _effect.Control = null;
                _effect         = null;

                if (_viewOverlay != null)
                {
                    if (Group != null)
                    {
                        Group.RemoveView(_viewOverlay);
                    }

                    _viewOverlay.Pressed    = false;
                    _viewOverlay.Foreground = null;
                    _viewOverlay.Dispose();
                    _ripple?.Dispose();
                }
            }
            catch (ObjectDisposedException)
            {
                //suppress exception
            }
            _isHoverSupported = false;
        }
コード例 #21
0
        private ColorStateList GetColorStateList()
        {
            int color;
            var defaultcolor = TouchEff.GetNativeAnimationColor(Element);

            if (defaultcolor != Xamarin.Forms.Color.Default)
            {
                color = defaultcolor.ToAndroid();
            }
            else
            {
                color = Color.Argb(31, 0, 0, 0);
            }

            return(new ColorStateList(
                       new[] { new int[] { } },
                       new[] { color, }));
        }
コード例 #22
0
        protected override void OnAttached()
        {
            if (View == null)
            {
                return;
            }
            _effect = Element.PickTouchEff();
            if (_effect?.IsDisabled ?? true)
            {
                return;
            }

            _effect.Control = Element as VisualElement;

            View.Touch += OnTouch;
            UpdateClickHandler();

            _accessibilityManager = View.Context.GetSystemService(Context.AccessibilityService) as AccessibilityManager;
            if (_accessibilityManager != null)
            {
                _accessibilityListener = new AccessibilityListener(this);
                _accessibilityManager.AddAccessibilityStateChangeListener(_accessibilityListener);
                _accessibilityManager.AddTouchExplorationStateChangeListener(_accessibilityListener);
            }

            if (_effect.NativeAnimation && Group != null && AndroidOS.Build.VERSION.SdkInt >= AndroidOS.BuildVersionCodes.Lollipop)
            {
                View.Clickable     = true;
                View.LongClickable = true;
                _viewOverlay       = new FrameLayout(Group.Context)
                {
                    LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                    Clickable        = false,
                    Focusable        = false,
                };
                View.LayoutChange += LayoutChange;

                CreateRipple();
                _viewOverlay.Background = _ripple;
                Group.AddView(_viewOverlay);
                _viewOverlay.BringToFront();
            }
        }
コード例 #23
0
 protected override void OnDetached()
 {
     try
     {
         _effect.Control = null;
         _effect         = null;
         if (Container != null)
         {
             Container.Touch -= OnTouch;
         }
         if (Control != null)
         {
             Control.Touch -= OnTouch;
         }
     }
     catch (ObjectDisposedException)
     {
         //suppress exception
     }
 }
コード例 #24
0
 public MouseTrackingView(TouchEff effect)
 {
     _effect          = effect;
     AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;
 }
コード例 #25
0
        public GamePage()
        {
            _gameMap = new AbsoluteLayout
            {
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Margin            = new Thickness(15)
            };
            _gameMap.SetBinding(BindingContextProperty, nameof(GameViewModel.Numbers));
            _gameMap.BindingContextChanged += OnGameMapBindingContextChanged;
            AbsoluteLayout.SetLayoutBounds(_gameMap, new Rectangle(.5, .5, -1, -1));
            AbsoluteLayout.SetLayoutFlags(_gameMap, AbsoluteLayoutFlags.PositionProportional);

            var isClosing = false;

            var mainMenuButton = new PancakeView
            {
                BackgroundColor = Color.Black.MultiplyAlpha(.65),
                CornerRadius    = new CornerRadius(0, 10, 10, 0),
                Padding         = new Thickness(10, 5),
                Margin          = new Thickness(15, Device.RuntimePlatform == Device.iOS ? 40 : 20),
                BorderColor     = Color.White,
                BorderThickness = 2,
                HeightRequest   = 40,
                Content         = new Label
                {
                    FontSize                = 30,
                    Text                    = "< MENU",
                    TextColor               = Color.White,
                    FontFamily              = "MandaloreRegular",
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center
                }
            };

            AbsoluteLayout.SetLayoutBounds(mainMenuButton, new Rectangle(0, 0, -1, -1));
            AbsoluteLayout.SetLayoutFlags(mainMenuButton, AbsoluteLayoutFlags.PositionProportional);
            Task.Run(async() =>
            {
                await Task.Delay(300);
                TouchEff.SetCommand(mainMenuButton, new Command(() =>
                {
                    if (isClosing || Navigation.NavigationStack.OfType <GamePage>().Count() > 1)
                    {
                        return;
                    }
                    isClosing = true;
                    if (Preferences.Get("ShouldPlaySound", true))
                    {
                        DependencyService.Resolve <IAudioService>().Play("click.mp3", false);
                    }
                    Navigation.PopAsync();
                }));
            });


            TouchEff.SetNativeAnimation(mainMenuButton, true);

            var newGameButton = new PancakeView
            {
                BackgroundColor = Color.Black.MultiplyAlpha(.65),
                CornerRadius    = new CornerRadius(0, 10, 10, 0),
                Padding         = new Thickness(10, 5),
                Margin          = new Thickness(15, Device.RuntimePlatform == Device.iOS ? 40 : 20),
                BorderColor     = Color.White,
                BorderThickness = 2,
                HeightRequest   = 40,
                Content         = new Label
                {
                    FontSize                = 30,
                    Text                    = "NEW GAME",
                    TextColor               = Color.White,
                    FontFamily              = "MandaloreRegular",
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center
                }
            };

            AbsoluteLayout.SetLayoutBounds(newGameButton, new Rectangle(1, 0, -1, -1));
            AbsoluteLayout.SetLayoutFlags(newGameButton, AbsoluteLayoutFlags.PositionProportional);
            Task.Run(async() =>
            {
                await Task.Delay(300);
                TouchEff.SetCommand(newGameButton, new Command(async() =>
                {
                    if (isClosing)
                    {
                        return;
                    }
                    isClosing = true;
                    if (Preferences.Get("ShouldPlaySound", true))
                    {
                        DependencyService.Resolve <IAudioService>().Play("click.mp3", false);
                    }
                    await Navigation.PushAsync(new GamePage()
                    {
                        BindingContext = new GameViewModel()
                    });
                    Navigation.RemovePage(this);
                }));
            });
            TouchEff.SetNativeAnimation(newGameButton, true);


            var swapsCountLabel = new Label();

            swapsCountLabel.SetBinding(Label.TextProperty, nameof(GameViewModel.SwapsCount));

            var backImage = new Image
            {
                IsVisible = Device.RuntimePlatform != Device.Android,
                Opacity   = 0.98,
                Source    = "back",
                Aspect    = Aspect.AspectFill
            };

            AbsoluteLayout.SetLayoutBounds(backImage, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(backImage, AbsoluteLayoutFlags.All);

            var blurFrame = new PancakeView
            {
                CornerRadius    = new CornerRadius(50, 10, 10, 50),
                BorderColor     = Color.Red,
                BackgroundColor = Color.Black.MultiplyAlpha(.65)
            };

            AbsoluteLayout.SetLayoutBounds(blurFrame, new Rectangle(.5, .5, -1, -1));
            AbsoluteLayout.SetLayoutFlags(blurFrame, AbsoluteLayoutFlags.PositionProportional);

            var countLabel = new Label
            {
                FontSize   = 50,
                TextColor  = Color.White,
                FontFamily = "MandaloreHalftone"
            };

            countLabel.SetBinding(Label.TextProperty, nameof(GameViewModel.SwapsCount));

            var labelStack = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label
                    {
                        FontSize   = 50,
                        TextColor  = Color.White,
                        Text       = "SWAPS:",
                        FontFamily = "MandaloreHalftone"
                    },
                    countLabel
                }
            };

            AbsoluteLayout.SetLayoutBounds(labelStack, new Rectangle(.5, .5, -1, -1));
            AbsoluteLayout.SetLayoutFlags(labelStack, AbsoluteLayoutFlags.PositionProportional);

            _gameMap.SizeChanged += (s, e) =>
            {
                using (blurFrame.Batch())
                {
                    blurFrame.WidthRequest  = _gameMap.Width;
                    blurFrame.HeightRequest = _gameMap.Height;
                }
                labelStack.TranslationY = -_gameMap.Height / 2 - labelStack.Height / 2 - 20;
            };

            Content = new AbsoluteLayout
            {
                Children =
                {
                    backImage,
                    mainMenuButton,
                    newGameButton,
                    labelStack,
                    blurFrame,
                    _gameMap
                }
            };

            PerformTransitionCommand = new Command(p =>
            {
                var transition        = (TransitionModel)p;
                var item              = _items[transition.Value - 1];
                item.InputTransparent = true;
                var fromPosition      = GetPosition(transition.FromIndex);
                var toPosition        = GetPosition(transition.ToIndex);
                var isVertical        = Math.Abs(fromPosition.X - toPosition.X) < Math.Abs(fromPosition.Y - toPosition.Y);

                var start = fromPosition.X;
                var end   = toPosition.X;
                if (isVertical)
                {
                    start = fromPosition.Y;
                    end   = toPosition.Y;
                }

                item.Animate("PerformTransition", new Animation(v =>
                {
                    var x = v;
                    var y = fromPosition.Y;
                    if (isVertical)
                    {
                        x = fromPosition.X;
                        y = v;
                    }
                    AbsoluteLayout.SetLayoutBounds(item, new Rectangle(x, y, fromPosition.Width, fromPosition.Height));
                }, start, end), 16, 250, Easing.CubicInOut, (d, b) =>
                {
                    item.InputTransparent = false;
                    if (!b)
                    {
                        item.BorderThickness = transition.ToIndex == transition.Value - 1
                            ? 2
                            : 0;
                    }
                });
            });

            HandleWinCommand = new Command(v =>
            {
                var okButton = new PancakeView
                {
                    Margin          = new Thickness(0, 30, 0, 0),
                    HeightRequest   = 60,
                    BorderColor     = Color.White,
                    BorderThickness = 2,
                    Content         = new Label
                    {
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment   = TextAlignment.Center,
                        FontSize   = 40,
                        Text       = "HOORAY!",
                        TextColor  = Color.White,
                        FontFamily = "MandaloreRegular",
                    }
                };
                TouchEff.SetPressedOpacity(okButton, 0.7);
                TouchEff.SetPressedScale(okButton, 0.95);
                TouchEff.SetCommand(okButton, new Command(async() =>
                {
                    if (Preferences.Get("ShouldPlaySound", true))
                    {
                        DependencyService.Resolve <IAudioService>().Play("click.mp3", false);
                    }
                    await Navigation.PushAsync(new GamePage()
                    {
                        BindingContext = new GameViewModel()
                    });
                    Navigation.RemovePage(this);
                }));

                var popupView = new PancakeView
                {
                    Scale                   = 0,
                    Margin                  = new Thickness(25, 0),
                    Padding                 = new Thickness(25, 10, 25, 20),
                    CornerRadius            = new CornerRadius(50, 10, 10, 50),
                    BackgroundGradientStops = new GradientStopCollection
                    {
                        new GradientStop
                        {
                            Color  = Color.FromRgb(41, 36, 88),
                            Offset = .3f
                        },
                        new GradientStop
                        {
                            Color  = Color.FromRgb(16, 15, 29),
                            Offset = .7f
                        },
                        new GradientStop
                        {
                            Color  = Color.Black,
                            Offset = 1f
                        }
                    },
                    BorderColor     = Color.White,
                    BorderThickness = 2,
                    Content         = new StackLayout
                    {
                        Spacing  = 0,
                        Children =
                        {
                            new Label
                            {
                                HorizontalTextAlignment = TextAlignment.Center,
                                FontSize   = 50,
                                Text       = "CONGRATILATIONS",
                                TextColor  = Color.White,
                                FontFamily = "MandaloreHalftone",
                            },
                            new Label
                            {
                                HorizontalTextAlignment = TextAlignment.Center,
                                FontSize   = 40,
                                Text       = $"YOUR SCORE IS: {v}",
                                TextColor  = Color.White,
                                FontFamily = "MandaloreHalftone",
                            },
                            okButton
                        }
                    }
                };
                AbsoluteLayout.SetLayoutBounds(popupView, new Rectangle(.5, .5, 1, -1));
                AbsoluteLayout.SetLayoutFlags(popupView, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);

                var popup = new AbsoluteLayout
                {
                    Opacity         = 0,
                    BackgroundColor = Color.Black.MultiplyAlpha(.85),
                    Children        =
                    {
                        popupView
                    }
                };
                AbsoluteLayout.SetLayoutBounds(popup, new Rectangle(0, 0, 1, 1));
                AbsoluteLayout.SetLayoutFlags(popup, AbsoluteLayoutFlags.All);
                (Content as AbsoluteLayout).Children.Add(popup);
                popup.FadeTo(1, 350, Easing.CubicInOut);
                popupView.ScaleTo(1, 500, Easing.CubicInOut);
                if (Preferences.Get("ShouldPlaySound", true))
                {
                    Vibration.Vibrate(250);
                }
            });

            this.SetBinding(PerformTransitionCommandProperty, nameof(GameViewModel.PerformTransitionCommand));
            this.SetBinding(HandleWinCommandProperty, nameof(GameViewModel.HandleWinCommand));

            NavigationPage.SetHasNavigationBar(this, false);
        }
コード例 #26
0
 public TouchTapGestureRecognizer(EvasObject parent, TouchEff effect) : this(parent)
 {
     Attach(parent);
     _effect = effect;
 }
コード例 #27
0
 public TouchNSClickGestureRecognizer(TouchEff effect, NSView container)
 {
     _effect    = effect;
     _container = container;
 }
コード例 #28
0
        public SettingsPage()
        {
            BindingContext = new SettingsViewModel();

            var backImage = new Image
            {
                IsVisible = Device.RuntimePlatform != Device.Android,
                Opacity   = 0.98,
                Source    = "back",
                Aspect    = Aspect.AspectFill
            };

            AbsoluteLayout.SetLayoutBounds(backImage, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(backImage, AbsoluteLayoutFlags.All);

            var musicLabel = new Label
            {
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize   = 40,
                Text       = "MUSIC",
                TextColor  = Color.White,
                FontFamily = "MandaloreRegular",
            };

            AbsoluteLayout.SetLayoutBounds(musicLabel, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(musicLabel, AbsoluteLayoutFlags.All);

            var musicCrossOne = new BoxView
            {
                VerticalOptions = LayoutOptions.Center,
                Color           = Color.White,
                HeightRequest   = 2,
                Rotation        = 10
            };

            musicCrossOne.SetBinding(IsVisibleProperty, nameof(SettingsViewModel.IsMusicDisabled));
            AbsoluteLayout.SetLayoutBounds(musicCrossOne, new Rectangle(0, .5, 1, 2));
            AbsoluteLayout.SetLayoutFlags(musicCrossOne, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);

            var musicCrossTwo = new BoxView
            {
                VerticalOptions = LayoutOptions.Center,
                Color           = Color.White,
                HeightRequest   = 2,
                Rotation        = -10
            };

            musicCrossTwo.SetBinding(IsVisibleProperty, nameof(SettingsViewModel.IsMusicDisabled));
            AbsoluteLayout.SetLayoutBounds(musicCrossTwo, new Rectangle(0, .5, 1, 2));
            AbsoluteLayout.SetLayoutFlags(musicCrossTwo, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);


            var musicLayout = new PancakeView
            {
                Margin          = new Thickness(0, 30, 0, 0),
                HeightRequest   = 60,
                BorderColor     = Color.White,
                BorderThickness = 2,
                Content         = new AbsoluteLayout
                {
                    Children =
                    {
                        musicLabel,
                        musicCrossOne,
                        musicCrossTwo
                    }
                }
            };

            musicLayout.SetBinding(TouchEff.CommandProperty, nameof(SettingsViewModel.ChangeSettingCommand));
            TouchEff.SetCommandParameter(musicLayout, "music");
            TouchEff.SetNativeAnimation(musicLayout, true);

            var soundLabel = new Label
            {
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontSize   = 40,
                Text       = "SOUND",
                TextColor  = Color.White,
                FontFamily = "MandaloreRegular",
            };

            AbsoluteLayout.SetLayoutBounds(soundLabel, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(soundLabel, AbsoluteLayoutFlags.All);

            var soundCrossOne = new BoxView
            {
                VerticalOptions = LayoutOptions.Center,
                Color           = Color.White,
                HeightRequest   = 2,
                Rotation        = 10
            };

            soundCrossOne.SetBinding(IsVisibleProperty, nameof(SettingsViewModel.IsSoundDisabled));
            AbsoluteLayout.SetLayoutBounds(soundCrossOne, new Rectangle(0, .5, 1, 2));
            AbsoluteLayout.SetLayoutFlags(soundCrossOne, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);

            var soundCrossTwo = new BoxView
            {
                VerticalOptions = LayoutOptions.Center,
                Color           = Color.White,
                HeightRequest   = 2,
                Rotation        = -10
            };

            soundCrossTwo.SetBinding(IsVisibleProperty, nameof(SettingsViewModel.IsSoundDisabled));
            AbsoluteLayout.SetLayoutBounds(soundCrossTwo, new Rectangle(0, .5, 1, 2));
            AbsoluteLayout.SetLayoutFlags(soundCrossTwo, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);

            var soundLayout = new PancakeView
            {
                Margin          = new Thickness(0, 15, 0, 0),
                HeightRequest   = 60,
                BorderColor     = Color.White,
                BorderThickness = 2,
                Content         = new AbsoluteLayout
                {
                    Children =
                    {
                        soundLabel,
                        soundCrossOne,
                        soundCrossTwo
                    }
                }
            };

            soundLayout.SetBinding(TouchEff.CommandProperty, nameof(SettingsViewModel.ChangeSettingCommand));
            TouchEff.SetCommandParameter(soundLayout, "sound");
            TouchEff.SetNativeAnimation(soundLayout, true);


            var decreaseMapSizeLayout = new PancakeView
            {
                HeightRequest   = 60,
                WidthRequest    = 60,
                BorderColor     = Color.White,
                BorderThickness = 2,
                Content         = new Label
                {
                    HorizontalOptions       = LayoutOptions.CenterAndExpand,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    FontSize   = 50,
                    Text       = "-",
                    TextColor  = Color.White,
                    FontFamily = "MandaloreRegular",
                }
            };

            decreaseMapSizeLayout.SetBinding(TouchEff.CommandProperty, nameof(SettingsViewModel.ChangeSettingCommand));
            TouchEff.SetCommandParameter(decreaseMapSizeLayout, "decreaseMapSize");
            TouchEff.SetNativeAnimation(decreaseMapSizeLayout, true);

            var increaseMapSizeLayout = new PancakeView
            {
                HeightRequest   = 60,
                WidthRequest    = 60,
                BorderColor     = Color.White,
                BorderThickness = 2,
                Content         = new Label
                {
                    HorizontalOptions       = LayoutOptions.CenterAndExpand,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    FontSize   = 50,
                    Text       = "+",
                    TextColor  = Color.White,
                    FontFamily = "MandaloreRegular",
                }
            };

            increaseMapSizeLayout.SetBinding(TouchEff.CommandProperty, nameof(SettingsViewModel.ChangeSettingCommand));
            TouchEff.SetCommandParameter(increaseMapSizeLayout, "increaseMapSize");
            TouchEff.SetNativeAnimation(increaseMapSizeLayout, true);

            var mapSizeLabel = new Label
            {
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize   = 30,
                TextColor  = Color.White,
                FontFamily = "MandaloreRegular",
            };

            mapSizeLabel.SetBinding(Label.TextProperty, nameof(SettingsViewModel.MapSizeText));

            var buttonsView = new PancakeView
            {
                Margin          = new Thickness(Device.Idiom == TargetIdiom.Phone ? 15 : 125, 0),
                Padding         = new Thickness(25),
                CornerRadius    = new CornerRadius(50, 10, 10, 50),
                BackgroundColor = Color.Black.MultiplyAlpha(.65),
                Content         = new StackLayout
                {
                    Spacing  = 0,
                    Children =
                    {
                        new Label
                        {
                            HorizontalTextAlignment = TextAlignment.Center,
                            VerticalTextAlignment   = TextAlignment.Center,
                            FontSize   = 50,
                            Text       = "SETTINGS",
                            TextColor  = Color.White,
                            FontFamily = "MandaloreHalftone",
                        },
                        musicLayout,
                        soundLayout,
                        new StackLayout
                        {
                            HeightRequest = 60,
                            Margin        = new Thickness(0, 15, 0, 0),
                            Orientation   = StackOrientation.Horizontal,
                            Children      =
                            {
                                decreaseMapSizeLayout,

                                new StackLayout
                                {
                                    Spacing           = 0,
                                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                                    Children          =
                                    {
                                        new Label
                                        {
                                            HorizontalTextAlignment = TextAlignment.Center,
                                            FontSize   = 30,
                                            Text       = "MAP SIZE",
                                            TextColor  = Color.White,
                                            FontFamily = "MandaloreRegular",
                                        },
                                        mapSizeLabel
                                    }
                                },

                                increaseMapSizeLayout
                            }
                        }
                    }
                }
            };

            AbsoluteLayout.SetLayoutBounds(buttonsView, new Rectangle(.5, .5, 1, -1));
            AbsoluteLayout.SetLayoutFlags(buttonsView, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);

            var mainMenuButton = new PancakeView
            {
                BackgroundColor = Color.Black.MultiplyAlpha(.65),
                CornerRadius    = new CornerRadius(0, 10, 10, 0),
                Padding         = new Thickness(10, 5),
                Margin          = new Thickness(15, Device.RuntimePlatform == Device.iOS ? 40 : 20),
                BorderColor     = Color.White,
                BorderThickness = 2,
                HeightRequest   = 40,
                Content         = new Label
                {
                    FontSize                = 30,
                    Text                    = "< MENU",
                    TextColor               = Color.White,
                    FontFamily              = "MandaloreRegular",
                    VerticalTextAlignment   = TextAlignment.Center,
                    HorizontalTextAlignment = TextAlignment.Center
                }
            };

            AbsoluteLayout.SetLayoutBounds(mainMenuButton, new Rectangle(0, 0, -1, -1));
            AbsoluteLayout.SetLayoutFlags(mainMenuButton, AbsoluteLayoutFlags.PositionProportional);
            TouchEff.SetCommand(mainMenuButton, new Command(() =>
            {
                if (Preferences.Get("ShouldPlaySound", true))
                {
                    DependencyService.Resolve <IAudioService>().Play("click.mp3", false);
                }
                Navigation.PopAsync();
            }));
            TouchEff.SetNativeAnimation(mainMenuButton, true);

            Content = new AbsoluteLayout
            {
                Children =
                {
                    backImage,
                    mainMenuButton,
                    buttonsView
                }
            };

            NavigationPage.SetHasNavigationBar(this, false);
        }
コード例 #29
0
 public TouchUITapGestureRecognizer(TouchEff effect)
 {
     _effect = effect;
     CancelsTouchesInView = false;
     Delegate             = new TouchUITapGestureRecognizerDelegate();
 }
コード例 #30
0
 public TouchUITapGestureRecognizer(TouchEff effect)
 => _effect = effect;