コード例 #1
0
        /// <summary>
        /// Register touch event callback for the Tap, the Long Tap and the Line behavior.
        /// </summary>
        /// <param name="args"> A Image element changed event's argument </param>
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Image> args)
        {
            base.OnElementChanged(args);

            if (Control == null || Element == null)
            {
                return;
            }

            if (GestureRecognizer == null)
            {
                GestureRecognizer = new ElmSharp.GestureLayer(Control);
                GestureRecognizer.Attach(Control);
            }

            if (args.NewElement == null)
            {
                GestureRecognizer.ClearCallbacks();
                return;
            }

            Control.Color = RegularColor;

            GestureRecognizer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.Start, x => KeyDown());
            GestureRecognizer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, x => ExecuteTapCommand());
            GestureRecognizer.SetTapCallback(GestureLayer.GestureType.LongTap, GestureLayer.GestureState.End, x => KeyUp());
            GestureRecognizer.SetTapCallback(GestureLayer.GestureType.LongTap, GestureLayer.GestureState.Abort, x => KeyUp());
            GestureRecognizer.SetLineCallback(GestureLayer.GestureState.Move, x => KeyUp());
        }
コード例 #2
0
        /// <summary>
        /// Making a button with a image and set the image's color and blending color by inputted background color.
        /// Register touch event callback for the Tap, the Long Tap and the Line behaviour. </summary>
        /// <remarks>
        /// When the button is touched, This class should change the image for each touch down/up situation.
        /// Even a button touching  starts at the Tap touch down, but touch up will be happen in several situations such as the Tap, the Long Tap, the Line.
        /// </remarks>
        /// <param name="args"> A Image element changed event's argument </param>
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Image> args)
        {
            base.OnElementChanged(args);

            if (Control == null)
            {
                return;
            }

            if (GestureRecognizer == null)
            {
                GestureRecognizer = new ElmSharp.GestureLayer(Control);
                GestureRecognizer.Attach(Control);
                GestureRecognizer.LongTapTimeout = 0.001;
            }

            if (args.NewElement == null)
            {
                GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.Tap, ElmSharp.GestureLayer.GestureState.Start, null);
                GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.Tap, ElmSharp.GestureLayer.GestureState.End, null);
                GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.LongTap, ElmSharp.GestureLayer.GestureState.End, null);
                GestureRecognizer.SetLineCallback(ElmSharp.GestureLayer.GestureState.End, null);
                return;
            }

            ElementButton BtnElement = args.NewElement as ElementButton;

            if (BtnElement == null)
            {
                return;
            }

            Image imageControl = Control as Image;

            imageControl.Color           = BlendingColor;
            imageControl.BackgroundColor = GetColor(BtnElement.BackgroundColor, 1f);

            GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.Tap, ElmSharp.GestureLayer.GestureState.Start, x =>
            {
                KeyDown();
            });
            GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.Tap, ElmSharp.GestureLayer.GestureState.End, x =>
            {
                KeyUp();
            });
            GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.LongTap, ElmSharp.GestureLayer.GestureState.End, x =>
            {
                KeyUp();
            });
            GestureRecognizer.SetLineCallback(GestureLayer.GestureState.End, x =>
            {
                KeyUp();
            });
        }
コード例 #3
0
        /// <summary>
        /// Making a button with a image and set the image's color and blending color by inputted background color.
        /// Register touch event callback for the Tap, the Long Tap and the Line behavior. </summary>
        /// <remarks>
        /// When the button is touched, This class should change the image for each touch down/up situation.
        /// Even a button touching  starts at the Tap touch down, but touch up will be happen in several situations such as the Tap, the Long Tap, the Line.
        /// </remarks>
        /// <param name="args"> A Image element changed event's argument </param>
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Image> args)
        {
            base.OnElementChanged(args);

            if (Control == null)
            {
                return;
            }

            if (GestureRecognizer == null)
            {
                GestureRecognizer = new ElmSharp.GestureLayer(Control);
                GestureRecognizer.Attach(Control);
            }

            if (args.NewElement == null)
            {
                GestureRecognizer.ClearCallbacks();
                return;
            }
            else
            {
                Control.Clicked += SendClicked;
            }

            ImageButton BtnElement = args.NewElement as ImageButton;

            if (BtnElement == null)
            {
                return;
            }

            GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.Tap, ElmSharp.GestureLayer.GestureState.Start, x =>
            {
                KeyDown();
            });
            GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.Tap, ElmSharp.GestureLayer.GestureState.End, x =>
            {
                KeyUp();
            });
            GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.LongTap, ElmSharp.GestureLayer.GestureState.End, x =>
            {
                KeyUp();
            });
            GestureRecognizer.SetTapCallback(ElmSharp.GestureLayer.GestureType.LongTap, ElmSharp.GestureLayer.GestureState.Abort, x =>
            {
                KeyUp();
            });
        }