private void CreateBtnAction()
        {
            BtnAction = new CustomButton();
            BtnAction.HorizontalOptions = new LayoutOptions(LayoutAlignment.End, false);
            BtnAction.VerticalOptions   = new LayoutOptions(LayoutAlignment.Start, false);

            BtnAction.CornerRadius = 2;
            BtnAction.Padding      = new Thickness(2, 2, 0, 0);
            BtnAction.Margin       = new Thickness(1, 2, 2, 2);

            BtnAction.HeightRequest = 22;
            BtnAction.WidthRequest  = 22;
            BtnAction.ImageSize     = 20;

            btnActionMouseCommands = new MouseOverAndOutModel();
            btnActionMouseCommands.MouseOverCommand = new RelayCommand <object>(new Action <object>(BtnActionMouseOverCommand));
            btnActionMouseCommands.MouseOutCommand  = new RelayCommand <object>(new Action <object>(BtnActionMouseOutCommand));

            //Add mouse over effect
            MouseOverEffect.SetCommand(RootGrid, btnActionMouseCommands.MouseOverCommand);

            //Add mouse out effect
            MouseOutEffect.SetCommand(RootGrid, btnActionMouseCommands.MouseOutCommand);

            BtnAction.Command = new RelayCommand <object>(new Action <object>(BtnActionCommand));
        }
        private void AddMouseOverAndOutEffects()
        {
            if (Helper.IsDesktopPlatform())
            {
                // Create mouse over / out commands
                mouseCommands = new MouseOverAndOutModel();
                mouseCommands.MouseOverCommand = new RelayCommand <object>(new Action <object>(MouseOverCommand));
                mouseCommands.MouseOutCommand  = new RelayCommand <object>(new Action <object>(MouseOutCommand));

                //Add mouse over / out effects
                MouseOverEffect.SetCommand(ContentView, mouseCommands.MouseOverCommand);
                MouseOutEffect.SetCommand(ContentView, mouseCommands.MouseOutCommand);
            }
        }
Exemple #3
0
        private void AddMouseOverAndOutEffects()
        {
            bool removeEffects = true;

            if (Helper.IsDesktopPlatform())
            {
                if (!thumbnailUsed)
                {
                    // If there is no upload and no  download in progress, we want to offer download action
                    if ((!uploadState) && (!downloadState))
                    {
                        removeEffects = false;

                        // Create Image used when "mouse over"
                        imageSourceOnOver = Helper.GetImageSourceFromFont("Font_FileDownload|" + Label.TextColor.ToHex());

                        // Create Mouse Commands if necessary
                        if (mouseCommands == null)
                        {
                            mouseCommands = new MouseOverAndOutModel();
                            mouseCommands.MouseOverCommand = new RelayCommand <object>(new Action <object>(MouseOverCommand));
                            mouseCommands.MouseOutCommand  = new RelayCommand <object>(new Action <object>(MouseOutCommand));
                        }

                        //Add mouse over / out effects
                        MouseOverEffect.SetCommand(Image, mouseCommands.MouseOverCommand);
                        MouseOutEffect.SetCommand(Image, mouseCommands.MouseOutCommand);

                        // Create/Add Tap Gesture Recognizer if necessary
                        if (tapGestureRecognizer == null)
                        {
                            tapGestureRecognizer         = new TapGestureRecognizer();
                            tapGestureRecognizer.Tapped += TapGestureRecognizer_Tapped;
                            Image.GestureRecognizers.Add(tapGestureRecognizer);
                        }
                    }
                    else
                    {
                        // Remove Image used when "mouse over"
                        imageSourceOnOver = null;
                    }
                }

                if (removeEffects)
                {
                    Helper.RemoveEffect(Image, typeof(MouseOverEffect));
                    Helper.RemoveEffect(Image, typeof(MouseOutEffect));
                }
            }
        }