Exemplo n.º 1
0
        //private void GnosisTileWPF_LostFocus(object sender, RoutedEventArgs e)
        //{
        //    this.BorderBrush = (Brush)Application.Current.FindResource("BorderColor");
        //    this.BorderThickness = GnosisContainer.NormalThickness;
        //}

        //private void GnosisTileWPF_GotFocus(object sender, RoutedEventArgs e)
        //{
        //    this.BorderBrush = (Brush)Application.Current.FindResource("BorderFocusColor");
        //    this.BorderThickness = GnosisContainer.FocusThickness;
        //}

        public void ShowVisibleTileOrder(int visibleOrder)
        {
            if (!layoutMode)
            {
                gdOverlay = new OverlayGrid();
                gdOverlay.SetTileOrder(visibleOrder);
                contentGrid.Children.Add(gdOverlay);
                layoutMode = true;
            }
            else
            {
                gdOverlay.SetTileOrder(visibleOrder);
            }
        }
        private void ShowAnimatedOverlay()
        {
            if (OverlayGrid is null)
            {
                throw new InvalidOperationException("Cannot find overlay in Associated object");
            }

            if (OverlayGrid.Visibility == Visibility.Visible && _overlayStoryboard is null)
            {
                return;
            }

            if (ActiveContentContainer.Visibility == Visibility.Hidden)
            {
                ActiveContentContainer.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Visible);
            }

            Dispatcher.VerifyAccess();

            var storyboard = AnimationService.GetFadeInAnimation(OverlayGrid);

            _overlayStoryboard = storyboard;

            if (TryGetOverlayFadingStoryboardAnimation(storyboard, out var animation))
            {
                OverlayGrid.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Visible);

                animation.SetCurrentValue(DoubleAnimation.ToProperty, (double?)0.7);

                EventHandler completionHandler = null;
                completionHandler = (sender, args) =>
                {
                    storyboard.Completed -= completionHandler;
                    if (_overlayStoryboard == storyboard)
                    {
                        _overlayStoryboard = null;
                    }
                };

                storyboard.Completed += completionHandler;
                OverlayGrid.BeginStoryboard(storyboard);
            }
            else
            {
                ShowOverlay();
            }
        }
        private SizeChangedEventHandler SetupAndShowOverlay(UIElement overlayContent)
        {
            overlayContent.SetCurrentValue(Panel.ZIndexProperty, (int)OverlayGrid.GetValue(Panel.ZIndexProperty) + 1);

            overlayContent.SetCurrentValue(FrameworkElement.MinHeightProperty, AssociatedObject.ActualHeight / 4.0);
            overlayContent.SetCurrentValue(FrameworkElement.MaxHeightProperty, AssociatedObject.ActualHeight);

            SizeChangedEventHandler sizeHandler = (sender, args) =>
            {
                overlayContent.SetCurrentValue(FrameworkElement.MinHeightProperty, AssociatedObject.ActualHeight / 4.0);
                overlayContent.SetCurrentValue(FrameworkElement.MaxHeightProperty, AssociatedObject.ActualHeight);
            };

            AssociatedObject.SizeChanged += sizeHandler;

            AddContentToOverlay(overlayContent);
            ShowAnimatedOverlay();

            return(sizeHandler);
        }
Exemplo n.º 4
0
        public ScanPage(Action <string> callback)
            : base(updateActivity: false)
        {
            _zxing = new ZXingScannerView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                AutomationId      = "zxingScannerView",
                Options           = new ZXing.Mobile.MobileBarcodeScanningOptions
                {
                    UseNativeScanning = true,
                    PossibleFormats   = new List <ZXing.BarcodeFormat> {
                        ZXing.BarcodeFormat.QR_CODE
                    },
                    AutoRotate = false
                }
            };

            _zxing.OnScanResult += (result) =>
            {
                // Stop analysis until we navigate away so we don't keep reading barcodes
                _zxing.IsAnalyzing = false;
                _zxing.IsScanning  = false;

                Uri uri;
                if (!string.IsNullOrWhiteSpace(result.Text) && Uri.TryCreate(result.Text, UriKind.Absolute, out uri) &&
                    !string.IsNullOrWhiteSpace(uri.Query))
                {
                    var queryParts = uri.Query.Substring(1).ToLowerInvariant().Split('&');
                    foreach (var part in queryParts)
                    {
                        if (part.StartsWith("secret="))
                        {
                            callback(part.Substring(7)?.ToUpperInvariant());
                            return;
                        }
                    }
                }

                callback(null);
            };

            _overlay = new OverlayGrid
            {
                AutomationId = "zxingDefaultOverlay"
            };

            _overlay.TopLabel.Text    = AppResources.CameraInstructionTop;
            _overlay.BottomLabel.Text = AppResources.CameraInstructionBottom;

            var grid = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          = { _zxing, _overlay }
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
            }

            Title   = AppResources.ScanQrTitle;
            Content = grid;
        }
 private void HideOverlay()
 {
     OverlayGrid.SetCurrentValue(Grid.OpacityProperty, 0d);
     OverlayGrid.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Hidden);
 }
 private void ShowOverlay()
 {
     OverlayGrid.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Visible);
     OverlayGrid.SetCurrentValue(Grid.OpacityProperty, 0.7);
 }