Esempio n. 1
0
 private void OnFlyoutClosing(Windows.UI.Xaml.Controls.Primitives.FlyoutBase sender, Windows.UI.Xaml.Controls.Primitives.FlyoutBaseClosingEventArgs args)
 {
     if (!(DialogContent as IWvvDialogContent)?.Closing(this) ?? true)
     {
         args.Cancel = true;
     }
 }
 private static void GroupHeaderFlyoutOpenerDataContextSetToTag(Windows.UI.Xaml.Controls.Primitives.FlyoutBase flyoutbase, object dataContextToTag)
 {
     if (flyoutbase is MenuFlyout menuFlyout)
     {
         foreach (var menuItem in menuFlyout.Items)
         {
             GroupHeaderRecurciveSettingDataContext(menuItem, dataContextToTag);
         }
     }
     else if (flyoutbase is Flyout flyout)
     {
         if (flyout.Content is FrameworkElement fe)
         {
             //                    fe.DataContext = dataContext;
             fe.Tag = dataContextToTag;
         }
     }
 }
Esempio n. 3
0
        internal void ShowHideChildren()
        {
            var repeater = m_repeater;

            if (repeater != null)
            {
                bool shouldShowChildren = IsExpanded;
                var  visibility         = shouldShowChildren ? Visibility.Visible : Visibility.Collapsed;
                repeater.Visibility = visibility;

                if (ShouldRepeaterShowInFlyout())
                {
                    if (shouldShowChildren)
                    {
                        // Verify that repeater is parented correctly
                        if (!m_isRepeaterParentedToFlyout)
                        {
                            ReparentRepeater();
                        }

                        // There seems to be a race condition happening which sometimes
                        // prevents the opening of the flyout. Queue callback as a workaround.

                        // TODO: Uno specific - Queue callback for composition rendering is not implemented yet - #4690
                        //SharedHelpers.QueueCallbackForCompositionRendering(() =>
                        //{
                        FlyoutBase.ShowAttachedFlyout(m_rootGrid);
                        //});
                    }
                    else
                    {
                        var flyout = FlyoutBase.GetAttachedFlyout(m_rootGrid);
                        if (flyout != null)
                        {
                            flyout.Hide();
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// User wants to use custom pairing with the selected ceremony types and Default protection level
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void PairButton_Click(object sender, RoutedEventArgs e)
        {
            // Use the pair button on the bluetoothDeviceListView.SelectedItem to get the data context
            BluetoothDeviceInformationDisplay deviceInfoDisp =
                ((Button)sender).DataContext as BluetoothDeviceInformationDisplay;
            string formatString        = BluetoothDeviceInformationDisplay.GetResourceString("BluetoothAttemptingToPairFormat");
            string confirmationMessage = string.Format(formatString, deviceInfoDisp.Name, deviceInfoDisp.Id);

            DisplayMessagePanelAsync(confirmationMessage, MessageType.InformationalMessage);

            // Save the pair button
            Button pairButton = sender as Button;

            inProgressPairButton = pairButton;

            // Save the flyout and set to null so it doesn't pop up unless we want it
            savedPairButtonFlyout       = pairButton.Flyout;
            inProgressPairButton.Flyout = null;

            // Disable the pair button until we are done
            pairButton.IsEnabled = false;

            // Get ceremony type and protection level selections
            DevicePairingKinds ceremoniesSelected = GetSelectedCeremonies();
            // Get protection level
            DevicePairingProtectionLevel protectionLevel = DevicePairingProtectionLevel.Default;

            // Specify custom pairing with all ceremony types and protection level EncryptionAndAuthentication
            DeviceInformationCustomPairing customPairing = deviceInfoDisp.DeviceInformation.Pairing.Custom;

            customPairing.PairingRequested += PairingRequestedHandler;
            DevicePairingResult result = await customPairing.PairAsync(ceremoniesSelected, protectionLevel);

            if (result.Status == DevicePairingResultStatus.Paired)
            {
                formatString        = BluetoothDeviceInformationDisplay.GetResourceString("BluetoothPairingSuccessFormat");
                confirmationMessage = string.Format(formatString, deviceInfoDisp.Name, deviceInfoDisp.Id);
            }
            else
            {
                formatString        = BluetoothDeviceInformationDisplay.GetResourceString("BluetoothPairingFailureFormat");
                confirmationMessage = string.Format(formatString, result.Status.ToString(), deviceInfoDisp.Name,
                                                    deviceInfoDisp.Id);
            }
            // Display the result of the pairing attempt
            DisplayMessagePanelAsync(confirmationMessage, MessageType.InformationalMessage);

            // If the watcher toggle is on, clear any devices in the list and stop and restart the watcher to ensure state is reflected in list
            if (BluetoothToggle.IsOn)
            {
                bluetoothDeviceObservableCollection.Clear();
                StopWatcher();
                StartWatcher();
            }
            else
            {
                // If the watcher is off this is an inbound request so just clear the list
                bluetoothDeviceObservableCollection.Clear();
            }

            // Re-enable the pair button
            inProgressPairButton = null;
            pairButton.IsEnabled = true;
        }
Esempio n. 5
0
        protected override void OnApplyTemplate()
        {
            // TODO: Uno specific: NavigationView may not be set yet, wait for later #4689
            if (GetNavigationView() is null)
            {
                // Postpone template application for later
                return;
            }

            // Stop UpdateVisualState before template is applied. Otherwise the visuals may be unexpected
            m_appliedTemplate = false;

            UnhookEventsAndClearFields();

            base.OnApplyTemplate();

            // Find selection indicator
            // Retrieve pointers to stable controls
            //IControlProtected controlProtected = this;
            m_helper.Init(this);

            var rootGrid = GetTemplateChild(c_rootGrid) as Grid;

            if (rootGrid != null)
            {
                m_rootGrid = rootGrid;

                var flyoutBase = FlyoutBase.GetAttachedFlyout(rootGrid);
                if (flyoutBase != null)
                {
                    flyoutBase.Closing += OnFlyoutClosing;
                    m_flyoutClosingRevoker.Disposable = Disposable.Create(() => flyoutBase.Closing -= OnFlyoutClosing);
                }
            }

            HookInputEvents();

            IsEnabledChanged += OnIsEnabledChanged;
            m_isEnabledChangedRevoker.Disposable = Disposable.Create(() => IsEnabledChanged -= OnIsEnabledChanged);

            m_toolTip = (ToolTip)GetTemplateChild("ToolTip");

            var splitView = GetSplitView();

            if (splitView != null)
            {
                PrepNavigationViewItem(splitView);
            }
            else
            {
                // If the NVI is not prepared in an ItemPresenter, it will not have reference to SplitView. So check OnLoaded
                // if it the reference has been manually set in NavigationViewItemBase::OnLoaded().
                Loaded -= OnLoaded;
                Loaded += OnLoaded;
            }

            // Retrieve reference to NavigationView
            var nvImpl = GetNavigationView();

            if (nvImpl != null)
            {
                var repeater = GetTemplateChild(c_repeater) as ItemsRepeater;
                if (repeater != null)
                {
                    m_repeater = repeater;

                    // Primary element setup happens in NavigationView
                    repeater.ElementPrepared += nvImpl.OnRepeaterElementPrepared;
                    m_repeaterElementPreparedRevoker.Disposable = Disposable.Create(() => repeater.ElementPrepared -= nvImpl.OnRepeaterElementPrepared);
                    repeater.ElementClearing += nvImpl.OnRepeaterElementClearing;
                    m_repeaterElementClearingRevoker.Disposable = Disposable.Create(() => repeater.ElementClearing -= nvImpl.OnRepeaterElementClearing);

                    repeater.ItemTemplate = nvImpl.GetNavigationViewItemsFactory();
                }

                UpdateRepeaterItemsSource();
            }

            m_flyoutContentGrid = (Grid)GetTemplateChild(c_flyoutContentGrid);

            m_appliedTemplate = true;

            UpdateItemIndentation();
            UpdateVisualStateNoTransition();
            ReparentRepeater();
            // We dont want to update the repeater visibilty during OnApplyTemplate if NavigationView is in a mode when items are shown in a flyout
            if (!ShouldRepeaterShowInFlyout())
            {
                ShowHideChildren();
            }

            var visual = ElementCompositionPreview.GetElementVisual(this);

            NavigationView.CreateAndAttachHeaderAnimation(visual);

            _fullyInitialized = true;
        }
Esempio n. 6
0
        /// <summary>
        /// User wants to use custom pairing with the selected ceremony types and Default protection level
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void PairButton_Click(object sender, RoutedEventArgs e)
        {
            // Use the pair button on the bluetoothDeviceListView.SelectedItem to get the data context
            BluetoothDeviceInformationDisplay deviceInfoDisp =
                ((Button) sender).DataContext as BluetoothDeviceInformationDisplay;
            string formatString = BluetoothDeviceInformationDisplay.GetResourceString("BluetoothAttemptingToPairFormat");
            string confirmationMessage = string.Format(formatString, deviceInfoDisp.Name, deviceInfoDisp.Id);
            DisplayMessagePanel(confirmationMessage, MessageType.InformationalMessage);

            // Save the pair button
            Button pairButton = sender as Button;
            inProgressPairButton = pairButton;

            // Save the flyout and set to null so it doesn't pop up unless we want it
            savedPairButtonFlyout = pairButton.Flyout;
            inProgressPairButton.Flyout = null;

            // Disable the pair button until we are done
            pairButton.IsEnabled = false;

            // Get ceremony type and protection level selections
            DevicePairingKinds ceremoniesSelected = GetSelectedCeremonies();
            // Get protection level
            DevicePairingProtectionLevel protectionLevel = DevicePairingProtectionLevel.Default;

            // Specify custom pairing with all ceremony types and protection level EncryptionAndAuthentication
            DeviceInformationCustomPairing customPairing = deviceInfoDisp.DeviceInformation.Pairing.Custom;

            customPairing.PairingRequested += PairingRequestedHandler;
            DevicePairingResult result = await customPairing.PairAsync(ceremoniesSelected, protectionLevel);

            if (result.Status == DevicePairingResultStatus.Paired)
            {
                formatString = BluetoothDeviceInformationDisplay.GetResourceString("BluetoothPairingSuccessFormat");
                confirmationMessage = string.Format(formatString, deviceInfoDisp.Name, deviceInfoDisp.Id);
            }
            else
            {
                formatString = BluetoothDeviceInformationDisplay.GetResourceString("BluetoothPairingFailureFormat");
                confirmationMessage = string.Format(formatString, result.Status.ToString(), deviceInfoDisp.Name,
                    deviceInfoDisp.Id);
            }
            // Display the result of the pairing attempt
            DisplayMessagePanel(confirmationMessage, MessageType.InformationalMessage);

            // If the watcher toggle is on, clear any devices in the list and stop and restart the watcher to ensure state is reflected in list
            if (BluetoothWatcherToggle.IsOn)
            {
                bluetoothDeviceObservableCollection.Clear();
                StopWatcher();
                StartWatcher();
            }
            else
            {
                // If the watcher is off this is an inbound request so just clear the list
                bluetoothDeviceObservableCollection.Clear();
            }

            // Re-enable the pair button
            inProgressPairButton = null;
            pairButton.IsEnabled = true;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FlyoutBase"/> class, a
 /// Wpf-enabled wrapper for <see cref="windows.UI.Xaml.Controls.Primitives.FlyoutBase"/>
 /// </summary>
 public FlyoutBase(windows.UI.Xaml.Controls.Primitives.FlyoutBase instance)
 {
     this.UwpInstance = instance;
 }
Esempio n. 8
0
 private void Flyout_Closing(Windows.UI.Xaml.Controls.Primitives.FlyoutBase sender, Windows.UI.Xaml.Controls.Primitives.FlyoutBaseClosingEventArgs args)
 {
     _ignoreFlyout = false;
     Debug.WriteLine("CLOSING");
 }
 private void MenuFlyout_Closing(Windows.UI.Xaml.Controls.Primitives.FlyoutBase sender, Windows.UI.Xaml.Controls.Primitives.FlyoutBaseClosingEventArgs args)
 {
     //var navFlyout = sender as MenuFlyout;
     //navFlyout?.Items.Clear();
 }
 public static void SetCompatibleContextFlyout(FrameworkElement obj, Windows.UI.Xaml.Controls.Primitives.FlyoutBase value)
 {
     obj.SetValue(CompatibleContextFlyoutProperty, value);
 }