protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            TitleBar.ShowProgressRing();
            FeedReplyList.ItemsSource = replys;

            var reply = e.Parameter as FeedReplyModel;

            TitleBar.Title      = $"回复({reply.Replynum})";
            id                  = reply.Id;
            reply.ShowreplyRows = false;
            replys.Add(reply);
            GetReplys(false);
            TitleBar.HideProgressRing();

            Task.Run(async() =>
            {
                await Task.Delay(200);
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    VScrollViewer              = VisualTree.FindDescendantByName(FeedReplyList, "ScrollViewer") as ScrollViewer;
                    VScrollViewer.ViewChanged += VScrollViewer_ViewChanged;
                });
            });
        }
Esempio n. 2
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     object[] vs = e.Parameter as object[];
     //initialPage = vs[2] as InitialPage;
     if ((bool)vs[1])
     {
         TitleBar.Visibility = Visibility.Collapsed;
     }
     pageUrl = vs[0] as string;
     TitleBar.BackButtonVisibility = Visibility.Visible;
     if (pageUrl.Contains("&title="))
     {
         TitleBar.Title = pageUrl.Substring(pageUrl.LastIndexOf("&title=") + 7);
     }
     if (pageUrl.IndexOf("/page") == -1 && pageUrl != "/main/indexV8")
     {
         pageUrl = "/page/dataList?url=" + pageUrl;
     }
     else if (pageUrl.IndexOf("/page") == 0 && !pageUrl.Contains("/page/dataList"))
     {
         pageUrl = pageUrl.Replace("/page", "/page/dataList");
     }
     pageUrl = pageUrl.Replace("#", "%23");
     index   = -1;
     GetUrlPage();
     Task.Run(async() =>
     {
         await Task.Delay(1000);
         await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
         {
             (VisualTree.FindDescendantByName(listView, "ScrollViewer") as ScrollViewer).ViewChanged += ScrollViewer_ViewChanged;
         });
     });
 }
Esempio n. 3
0
        /*=========================*/
        #endregion

        #region Creatives
        /*=========================*/

        /// <summary>
        /// Open the dialog
        /// </summary>
        private void Creative_dialog_Open(object sender, RoutedEventArgs e)
        {
            Dialog_Open <Oltp.CreativeDataTable, Oltp.CreativeRow>
            (
                // dialog:
                Creative_dialog,

                // listTable:
                _listTable,

                // clickedItem:
                _listTable.GetParentListViewItem(e.OriginalSource as FrameworkElement) as ListViewItem,

                // allowBatch:
                true,

                // dialogTitle:
                (row, isBatch) => row.Title,

                // dialogTooltip:
                (row, isBatch) => isBatch ? null : "GK #" + row.GK.ToString(),

                // batchFlatten:
                col =>
                col.ColumnName == _creatives.GKColumn.ColumnName ? null :
                col.ColumnName == _creatives.TitleColumn.ColumnName ? "(multiple creatives)" as object :
                DBNull.Value as object
            );

            VisualTree.GetChild <TabItem>(Creative_dialog, "_tabAssociation").Visibility = Creative_dialog.IsBatch ? Visibility.Collapsed : Visibility.Visible;
            if (Creative_dialog.IsBatch)
            {
                VisualTree.GetChild <TabItem>(Creative_dialog, "_tabSegments").Focus();
            }
        }
        public ReplyDialogPresenter(object o, Popup popup)
        {
            this.InitializeComponent();
            Tools.ShowProgressBar();
            Height = Window.Current.Bounds.Height;
            Width  = Window.Current.Bounds.Width;
            HorizontalAlignment         = HorizontalAlignment.Center;
            Window.Current.SizeChanged += WindowSizeChanged;
            TitleBar.BackButtonClick   += (s, e) => popup.Hide();
            popup.Closed += (s, e) => Window.Current.SizeChanged -= WindowSizeChanged;
            FeedReplyViewModel reply = o as FeedReplyViewModel;

            TitleBar.Title         = $"回复({reply.replynum})";
            TitleBar.RefreshEvent += (s, e) => GetReplys(true);
            id = reply.id;
            FeedReplyList.ItemsSource = replys;
            reply.showreplyRows       = false;
            replys.Add(reply);
            GetReplys(false);
            Tools.HideProgressBar();
            Task.Run(async() =>
            {
                await Task.Delay(200);
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    VScrollViewer              = VisualTree.FindDescendantByName(FeedReplyList, "ScrollViewer") as ScrollViewer;
                    VScrollViewer.ViewChanged += VScrollViewer_ViewChanged;
                });
            });
        }
Esempio n. 5
0
        public SearchBox(string initialText = "", string placeholder = "Search", ContextMenu contextMenu = null)
        {
            _textBox = new TextBox(initialText);

            if (!string.IsNullOrEmpty(placeholder))
            {
                _textBox.HtmlElement.SetAttribute("placeholder", placeholder);
            }

            _textBox.TextInput += (sender, args) =>
            {
                TextInput?.Invoke(sender, args);
            };

            this.SetClass("search-box");

            this.VisualTree.Add(_textBox);

            this.VisualTree.Add(new Icon(Icons.Magnify));

            if (contextMenu != null)
            {
                VisualTree.Add(contextMenu);
            }
        }
Esempio n. 6
0
        private void SetFocusEngagement()
        {
            var pFocusManager = VisualTree.GetFocusManagerForElement(this);

            if (pFocusManager != null)
            {
                if (IsFocusEngaged)
                {
                    bool hasFocusedElement = FocusProperties.HasFocusedElement(this);
                    //Check to see if the element or any of it's descendants has focus
                    if (!hasFocusedElement)
                    {
                        IsFocusEngaged = false;
                        throw new InvalidOperationException("Can't engage focus when the control nor any of its descendants has focus.");
                    }
                    if (!IsFocusEngagementEnabled)
                    {
                        IsFocusEngaged = false;
                        throw new InvalidOperationException("Can't engage focus when IsFocusEngagementEnabled is false on the control.");
                    }

                    //Control is focused and has IsFocusEngagementEnabled set to true
                    pFocusManager.EngagedControl = this;
                    UpdateEngagementState(true /*engaging*/);
                }
                else if (pFocusManager.EngagedControl != null)                 //prevents re-entrancy because we set the property to false above in error cases.
                {
                    pFocusManager.EngagedControl = null; /*No control is now engaged*/;
                    UpdateEngagementState(false /*Disengage*/);

                    var popupRoot = VisualTree.GetPopupRootForElement(this);
                    popupRoot?.ClearWasOpenedDuringEngagementOnAllOpenPopups();
                }
            }
        }
Esempio n. 7
0
        public FilterPanel(IEnumerable <T> records, Func <string, Func <T, bool> > predicate)
        {
            var txtSearch = new SearchBox();

            var refreshPanel = new RefreshPanel(new[] { txtSearch }, () =>
            {
                var searchText = txtSearch.Text.Trim();

                var linq = records;

                if (!string.IsNullOrEmpty(searchText))
                {
                    linq = linq.Where(predicate(searchText));
                }

                if (linq.Any())
                {
                    return(new EntityGrid <T>(linq).Render());
                }
                else
                {
                    return("No matching records.");
                }
            });

            VisualTree.Add(Layout.Vertical(txtSearch, refreshPanel));
        }
Esempio n. 8
0
        internal override void UpdateVisualState(bool useTransitions = true)
        {
            var focusManager = VisualTree.GetFocusManagerForElement(this);

            // CommonStates & FocusStates are combined
            //
            // NOTES: Pressed state is the same as Focused
            //        PointerFocused state is the same as Focused
            if (!IsEnabled)
            {
                VisualStateManager.GoToState(this, "Disabled", true);
            }
            else if (_forceFocusedVisualState || (FocusState != FocusState.Unfocused && focusManager.IsPluginFocused()))
            {
                VisualStateManager.GoToState(this, "Focused", true);
            }
            else if (_isPointerOver)
            {
                VisualStateManager.GoToState(this, "PointerOver", true);
            }
            else
            {
                VisualStateManager.GoToState(this, "Normal", true);
            }
        }
Esempio n. 9
0
        public static void ReceiveFocusNative(int handle)
        {
            if (_isCallingFocusNative)
            {
                // We triggered this callback by calling focusView() ourselves, ignore it so we don't overwrite the FocusState
                return;
            }
            var focused = GetFocusElementFromHandle(handle);

            if (_log.Value.IsEnabled(LogLevel.Debug))
            {
                _log.Value.LogDebug($"{nameof(ReceiveFocusNative)}({focused?.ToString() ?? "[null]"})");
            }

            if (focused is Control control)
            {
                ProcessControlFocused(control);
            }
            else if (focused != null)
            {
                ProcessElementFocused(focused);
            }
            else
            {
                // This might occur if a non-Uno element receives focus
                var focusManager = VisualTree.GetFocusManagerForElement(Window.Current.RootElement);
                focusManager.ClearFocus();
            }
        }
Esempio n. 10
0
        private static T GetKeyValue <T>(FrameworkElement element, string key)
        {
            IFieldDefinitionContainer container = VisualTree.FindAncestorOfType <IFieldDefinitionContainer>(element)
                                                  ?? throw Ensure.Exception.InvalidOperation("Missing field container.");

            return(container.Definition.Metadata.Get(key, default(T)));
        }
Esempio n. 11
0
        private static DependencyObject?FindLastFocusableElementImpl(DependencyObject?pSearchScope)
        {
            DependencyObject?searchStartDO = pSearchScope;

            DependencyObject?element = null;

            if (searchStartDO != null)
            {
                var pFocusManager = VisualTree.GetFocusManagerForElement(searchStartDO);
                element = pFocusManager?.GetLastFocusableElement(searchStartDO);
            }
            else
            {
                // For compat reasons, these FocusManager static APIs need to always use the CoreWindow as the
                // ContentRoot, so explicitly return the CoreWindow content root.
                var contentRoot = DXamlCore.Current.GetHandle().ContentRootCoordinator.CoreWindowContentRoot;

                if (contentRoot == null)
                {
                    return(null);
                }

                element = contentRoot.FocusManager.GetFirstFocusableElementFromRoot(useReverseDirection: true);
            }

            return(element);
        }
Esempio n. 12
0
        public void FocusEquationTextBox(EquationViewModel equation)
        {
            int index = Equations.IndexOf(equation);

            if (index < 0)
            {
                return;
            }
            var container = (UIElement)EquationInputList.ContainerFromIndex(index);

            if (container != null)
            {
                container.StartBringIntoView();

                var equationInput = VisualTree.FindDescendantByName(container, "EquationInputButton");
                if (equationInput == null)
                {
                    return;
                }
                var equationTextBox = equationInput as EquationTextBox;
                if (equationTextBox != null)
                {
                    equationTextBox.FocusTextBox();
                }
            }
        }
        protected void OnItemDoubleClicked(object sender, MouseButtonEventArgs e)
        {
            DependencyObject originalSource = e.OriginalSource as DependencyObject;

            if (originalSource != null)
            {
                if (originalSource is System.Windows.Documents.Run)
                {
                    originalSource = (originalSource as System.Windows.Documents.Run).Parent;
                }
                if ((originalSource is Visual) && !MainWindow.IsQZoneFlag(originalSource))
                {
                    ListBox     ancestorByType = VisualTree.GetAncestorByType(originalSource, typeof(ListBox)) as ListBox;
                    ListBoxItem container      = VisualTree.GetAncestorByType(originalSource, typeof(ListBoxItem)) as ListBoxItem;
                    if ((ancestorByType != null) && (container != null))
                    {
                        Buddy buddy = ancestorByType.ItemContainerGenerator.ItemFromContainer(container) as Buddy;
                        if (buddy != null)
                        {
                            Util_Buddy.OpenContactSessionWindow(buddy);
                        }
                        else
                        {
                            InstanceAnswerPro.Core.Community.Community community = ancestorByType.ItemContainerGenerator.ItemFromContainer(container) as InstanceAnswerPro.Core.Community.Community;
                            if (community != null)
                            {
                                Util_Buddy.OpenCommunitySessionWindow(community);
                            }
                        }
                        e.Handled = true;
                    }
                }
            }
        }
Esempio n. 14
0
        internal static IList <DependencyObject> GetPopupChildrenOpenedDuringEngagement(DependencyObject element)
        {
            var popupRoot = VisualTree.GetPopupRootForElement(element);

            if (popupRoot == null ||
                popupRoot.GetOpenPopups() is var openedPopups)
            {
                return(new List <DependencyObject>());
            }

            // TODO Uno:Implement
            return(Array.Empty <DependencyObject>());
            //var popupChildrenDuringEngagement = new List<DependencyObject>(openedPopups.Length);

            //for (int index = 0; index < openPopupsCount; index++)
            //{
            //	Popup popup = openedPopups[index];
            //	if (popup != null && popup.WasOpenedDuringEngagement())
            //	{
            //		popupChildrenDuringEngagement.Add(popup.Child);
            //	}
            //}

            //delete[] openedPopups;

            //return popupChildrenDuringEngagement;
        }
Esempio n. 15
0
        private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount < 2)
            {
                return;
            }


            TextBlock source       = sender as TextBlock;
            var       segmentValue = (Oltp.SegmentValueRow)source.DataContext;

            // Don't allow editing 'all accounts' values
            if (segmentValue.AccountID != Window.CurrentAccount.ID)
            {
                return;
            }

            source.Visibility = Visibility.Collapsed;
            TextBox target = VisualTree.GetChild <TextBox>(source.Parent);

            target.Visibility = Visibility.Visible;
            target.Focus();

            var segmentRule = (SegmentValueValidationRule)target.GetBindingExpression(TextBox.TextProperty).ParentBinding.ValidationRules[2];

            segmentRule.Row = segmentValue;

            e.Handled = true;
        }
Esempio n. 16
0
        /// <summary>
        /// Open the dialog
        /// </summary>
        private void Segment_dialog_Open(object sender, RoutedEventArgs e)
        {
            // Set dataItem as current item
            ListViewItem currentItem = _listTable.GetParentListViewItem(e.OriginalSource as FrameworkElement);

            Oltp.SegmentRow row = currentItem.Content as Oltp.SegmentRow;

            // Show the dialog
            Segment_dialog.Title        = row.Name;
            Segment_dialog.TitleTooltip = row.SegmentID.ToString();

            Segment_dialog.BeginEdit(
                Dialog_MakeEditVersion <Oltp.SegmentDataTable, Oltp.SegmentRow>(row),
                row
                );

            TabControl tabs    = VisualTree.GetChild <TabControl>(Segment_dialog);
            TabItem    tabItem = (TabItem)tabs.ItemContainerGenerator.ContainerFromIndex(tabs.SelectedIndex);

            if (tabItem != null)
            {
                tabItem.RaiseEvent(new RoutedEventArgs(TabItem.GotFocusEvent, tabItem));
            }

            // When opening, select it only if no more than one is already selected
            if (_listTable.ListView.SelectedItems.Count < 2)
            {
                _listTable.ListView.SelectedItems.Clear();
                currentItem.IsSelected = true;
            }
        }
Esempio n. 17
0
        private void TabSegments_GotFocus(object sender, RoutedEventArgs e)
        {
            if (_tabSegmentsInitialized)
            {
                return;
            }

            foreach (KeyValuePair <Oltp.SegmentRow, Oltp.SegmentValueDataTable> pair in _segmentValueTables)
            {
                // Ignore segments that aren't creative related
                if ((pair.Key.AssociationFlags & SegmentAssociationFlags.AdgroupCreative) == 0)
                {
                    continue;
                }

                StackPanel segmentPanel = VisualTree.GetChild <StackPanel>(Creative_dialog, "_segment" + pair.Key.SegmentNumber.ToString());
                if (segmentPanel == null)
                {
                    continue;
                }

                segmentPanel.Visibility = Visibility.Visible;

                VisualTree.GetChild <Label>(segmentPanel).Content        = pair.Key.Name;
                VisualTree.GetChild <ComboBox>(segmentPanel).ItemsSource = pair.Value.Rows;
            }

            _tabSegmentsInitialized = true;
        }
Esempio n. 18
0
 private void InvalidateFocusVisual()
 {
     if (_focusManager == null)
     {
         _focusManager = VisualTree.GetFocusManagerForElement(Windows.UI.Xaml.Window.Current?.RootElement);
     }
     _focusManager?.FocusRectManager?.RedrawFocusVisual();
 }
 internal static void SetVisualTree(this DependencyObject dependencyObject, VisualTree visualTree)
 {
     //TODO: This should work for non-UIElement as well! #8978
     if (dependencyObject is UIElement uiElement)
     {
         uiElement.VisualTreeCache = visualTree;
     }
 }
Esempio n. 20
0
        /// <summary>
        ///
        /// </summary>
        private void TabAssociations_GotFocus(object sender, RoutedEventArgs e)
        {
            if (!(Creative_dialog.TargetContent is Oltp.CreativeRow))
            {
                return;
            }

            // Show
            if (_assoc_Campaigns == null)
            {
                _assoc_Campaigns = VisualTree.GetChild <ItemsControl>(Creative_dialog, "_assoc_Campaigns");
            }

            if (_assoc_Campaigns.ItemsSource != null)
            {
                return;
            }

            Oltp.CreativeRow creative = (Creative_dialog.TargetContent as Oltp.CreativeRow);
            List <CampaignAdgroupCombination> duos = null;

            Window.AsyncOperation(delegate()
            {
                using (OltpProxy proxy = new OltpProxy())
                {
                    duos = new List <CampaignAdgroupCombination>();
                    Oltp.AdgroupDataTable adgroups = proxy.Service.Adgroup_GetByCreative(creative.GK);

                    if (adgroups.Rows.Count > 0)
                    {
                        // Get all parent campaign IDs
                        List <long> campaignGKs = new List <long>();
                        foreach (Oltp.AdgroupRow ag in adgroups.Rows)
                        {
                            if (!campaignGKs.Contains(ag.CampaignGK))
                            {
                                campaignGKs.Add(ag.CampaignGK);
                            }
                        }

                        // Now get the campaigns themselves
                        Oltp.CampaignDataTable campaigns = proxy.Service.Campaign_GetIndividualCampaigns(campaignGKs.ToArray());
                        foreach (Oltp.AdgroupRow ag in adgroups.Rows)
                        {
                            DataRow[] rs = campaigns.Select(String.Format("GK = {0}", ag.CampaignGK));
                            if (rs.Length > 0)
                            {
                                duos.Add(new CampaignAdgroupCombination(rs[0] as Oltp.CampaignRow, ag));
                            }
                        }
                    }
                }
            },
                                  delegate()
            {
                _assoc_Campaigns.ItemsSource = duos;
            });
        }
Esempio n. 21
0
        private static object?FindNextFocus(
            FocusNavigationDirection focusNavigationDirection,
            XYFocusOptions xyFocusOptions)
        {
            if (focusNavigationDirection == FocusNavigationDirection.None)
            {
                throw new ArgumentOutOfRangeException(nameof(focusNavigationDirection));
            }

            var core = DXamlCore.Current;

            if (core == null)
            {
                throw new InvalidOperationException("XamlCore is not set.");
            }

            FocusManager?focusManager = null;

            if (xyFocusOptions.SearchRoot is DependencyObject searchRoot)
            {
                focusManager = VisualTree.GetFocusManagerForElement(searchRoot);
            }
            else if (core.GetHandle().InitializationType == InitializationType.IslandsOnly)
            {
                // Return error if searchRoot is not valid in islands/ desktop mode
                throw new ArgumentException("The search root must not be null.");
            }
            else
            {
                // For compat reasons, these FocusManager static APIs need to always use the CoreWindow as the
                // ContentRoot, so explicitly return the CoreWindow content root.
                var contentRootCoordinator = core.GetHandle().ContentRootCoordinator;
                var contentRoot            = contentRootCoordinator?.CoreWindowContentRoot;

                if (contentRoot == null)
                {
                    return(null);
                }

                focusManager = contentRoot.FocusManager;
            }

            if (focusManager == null)
            {
                return(null);
            }

            var root  = focusManager.ContentRoot;
            var scale = RootScale.GetRasterizationScaleForContentRoot(root);

            ConvertOptionsRectsToPhysical(scale, xyFocusOptions);

            var candidate = focusManager.FindNextFocus(
                new FindFocusOptions(focusNavigationDirection),
                xyFocusOptions);

            return(candidate);
        }
Esempio n. 22
0
 private void InvalidateOverlays()
 {
     _focusManager ??= VisualTree.GetFocusManagerForElement(Windows.UI.Xaml.Window.Current?.RootElement);
     _focusManager?.FocusRectManager?.RedrawFocusVisual();
     if (_focusManager?.FocusedElement is TextBox textBox)
     {
         textBox.TextBoxView?.Extension?.InvalidateLayout();
     }
 }
Esempio n. 23
0
        private static void FocusNative(UIElement control)
        {
            var focusManager = VisualTree.GetFocusManagerForElement(control);

            if (control?.CanBecomeFirstResponder == true &&
                focusManager?.InitialFocus == false)                  // Do not focus natively on initial focus so the soft keyboard is not opened
            {
                control.BecomeFirstResponder();
            }
        }
Esempio n. 24
0
        protected override void OnVisualParentChanged(DependencyObject oldParent)
        {
            base.OnVisualParentChanged(oldParent);

            FieldValueProviderCollection providers = VisualTree.FindFieldValueProviderCollection(this);

            if (providers != null)
            {
                VisualTree.WithFieldDefinitionContainer(this, definition => providers.Add(definition.Identifier, this));
            }
        }
Esempio n. 25
0
        internal static bool SetFocusedElementWithDirection(
            DependencyObject pElement,
            FocusState focusState,
            bool animateIfBringIntoView,
            bool forceBringIntoView,
            FocusNavigationDirection focusNavigationDirection)
        {
            DependencyObject spElementToFocus = pElement;
            Control?         spControlToFocus;
            bool             pFocusUpdated = false;

            if (pElement == null)
            {
                throw new ArgumentNullException(nameof(pElement));
            }

            spControlToFocus = spElementToFocus as Control;
            if (spControlToFocus != null)
            {
                // For control, use IControl.Focus, for safer backward compat
                if (animateIfBringIntoView)
                {
                    // Set the flag that indicates that the Focus change operation
                    // needs to use an animation if the element is brouhgt into view.
                    (spControlToFocus as Control).SetAnimateIfBringIntoView();
                }

                pFocusUpdated = (spControlToFocus as Control).FocusWithDirection(focusState, focusNavigationDirection);
            }
            else
            {
                bool isShiftPressed  = (focusNavigationDirection == FocusNavigationDirection.Previous);
                bool isProcessingTab = (focusNavigationDirection == FocusNavigationDirection.Next) || isShiftPressed;

                // Set focus on non-controls, like Hyperlink.
                DependencyObject?spElementToFocusDO;
                spElementToFocusDO = spElementToFocus as DependencyObject;
                FocusManager? focusManager = VisualTree.GetFocusManagerForElement(spElementToFocusDO);
                FocusMovement movement     = new FocusMovement(
                    spElementToFocusDO,
                    focusNavigationDirection,
                    focusState);
                movement.ForceBringIntoView     = forceBringIntoView;
                movement.AnimateIfBringIntoView = animateIfBringIntoView;
                movement.IsProcessingTab        = isProcessingTab;
                movement.IsShiftPressed         = isShiftPressed;
                var result = focusManager?.SetFocusedElement(movement);
                pFocusUpdated = result?.WasMoved ?? false;
            }

            return(pFocusUpdated);
        }
Esempio n. 26
0
        internal bool TryHandleDirectionalFocus(VirtualKey originalKey)
        {
            var contentRoot = VisualTree.GetContentRootForElement(_rootVisual);

            if (contentRoot == null)
            {
                return(false);
            }
            contentRoot.InputManager.LastInputDeviceType = InputDeviceType.Keyboard;

            var focusManager   = VisualTree.GetFocusManagerForElement(_rootVisual);
            var focusDirection = FocusSelection.GetNavigationDirectionForKeyboardArrow(originalKey);

            if (focusManager == null || focusDirection == FocusNavigationDirection.None)
            {
                return(false);
            }

            var source = focusManager.FocusedElement;             // Uno specific: This should actually bubble up with the event from the source element to the root visual.

            var  directionalFocusEnabled = false;
            var  focusCandidateFound     = false;
            bool handled = false;

            while (source != null && !focusCandidateFound)
            {
                var directionalFocusInfo = FocusSelection.TryDirectionalFocus(focusManager, focusDirection, source);
                handled |= directionalFocusInfo.Handled;

                focusCandidateFound     |= directionalFocusInfo.FocusCandidateFound;
                directionalFocusEnabled |= directionalFocusInfo.DirectionalFocusEnabled;

                if (!directionalFocusInfo.ShouldBubble)
                {
                    break;
                }

                if (!focusCandidateFound)
                {
                    source = source.GetParent() as DependencyObject;
                }
            }

            // Only raise NoFocusCandidateFound if XYDirectionalFocus was ever set to enabled and a
            // focus candidate was never found.
            if (directionalFocusEnabled && !focusCandidateFound)
            {
                focusManager.RaiseNoFocusCandidateFoundEvent(focusDirection);
            }

            return(handled);
        }
        private void PermissionCopy_dialog_Open(object sender, RoutedEventArgs e)
        {
            if (_copyToAccountsListBox != null)
            {
                List <CheckBox> checkboxes = VisualTree.GetChildren <CheckBox>(_copyToAccountsListBox);
                foreach (CheckBox cb in checkboxes)
                {
                    cb.IsChecked = false;
                }
            }

            PermissionCopy_dialog.IsOpen = true;
        }
Esempio n. 28
0
        internal static void ProcessControlFocused(Control control)
        {
            if (_log.Value.IsEnabled(LogLevel.Debug))
            {
                _log.Value.LogDebug($"{nameof(ProcessControlFocused)}() focusedElement={GetFocusedElement()}, control={control}");
            }

            if (FocusProperties.IsFocusable(control))
            {
                var focusManager = VisualTree.GetFocusManagerForElement(control);
                focusManager?.UpdateFocus(new FocusMovement(control, FocusNavigationDirection.None, FocusState.Pointer));
            }
        }
Esempio n. 29
0
 public UserListPage()
 {
     this.InitializeComponent();
     UserList.ItemsSource = infos;
     Task.Run(async() =>
     {
         await Task.Delay(300);
         await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
         {
             VScrollViewer              = VisualTree.FindDescendantByName(UserList, "ScrollViewer") as ScrollViewer;
             VScrollViewer.ViewChanged += ScrollViewer_ViewChanged;
         });
     });
 }
Esempio n. 30
0
        private protected override void OnLoaded()
        {
            base.OnLoaded();

            var spCurrentFocusedElement = this.GetFocusedElement();

            var  focusManager    = VisualTree.GetFocusManagerForElement(this);
            bool setDefaultFocus = focusManager?.IsPluginFocused() == true;

            if (setDefaultFocus && spCurrentFocusedElement == null)
            {
                // Uno specific: If the page is focusable itself, we want to
                // give it focus instead of the first element.
                if (FocusProperties.IsFocusable(this))
                {
                    this.SetFocusedElement(
                        this,
                        FocusState.Programmatic,
                        animateIfBringIntoView: false);
                    return;
                }

                // Set the focus on the first focusable control
                var spFirstFocusableElementCDO = focusManager?.GetFirstFocusableElement(this);

                if (spFirstFocusableElementCDO != null && focusManager != null)
                {
                    var spFirstFocusableElementDO = spFirstFocusableElementCDO;

                    focusManager.InitialFocus = true;

                    TrySetFocusedElement(spFirstFocusableElementDO);

                    focusManager.InitialFocus = false;
                }

                if (spFirstFocusableElementCDO == null)
                {
                    // Narrator listens for focus changed events to determine when the UI Automation tree needs refreshed. If we don't set default focus (on Phone) or if we fail to find a focusable element,
                    // we will need notify the narror of the UIA tree change when page is loaded.
                    var bAutomationListener = AutomationPeer.ListenerExistsHelper(AutomationEvents.AutomationFocusChanged);

                    if (bAutomationListener)
                    {
                        Uno.UI.Xaml.Core.CoreServices.Instance.UIARaiseFocusChangedEventOnUIAWindow(this);
                    }
                }
            }
        }