Beispiel #1
0
        /// <summary>
        /// 关闭选项卡
        /// </summary>
        private void CloseTabItem()
        {
            if (string.IsNullOrEmpty(Name) || Name != "PART_Close_TabItem")
            {
                return;
            }

            TabItem itemclose = VisualTreeHelperEx.FindVisualParent <TabItem>(this);

            if (itemclose == null)
            {
                return;
            }

            (itemclose.Parent as TabControl).Items.Remove(itemclose);
            var args = new RoutedEventArgs(TabItemClose.CloseItemEvent, itemclose);

            itemclose.RaiseEvent(args);
        }
Beispiel #2
0
        protected override void OnActivated(bool isFirstTimeActivated)
        {
            if (isFirstTimeActivated)
            {
                Container.Resolve <RightRegionControlService>();

                Container.Resolve <ApplicationStateChangeHandler>();

                var mainFrameRegionProvider = Container.Resolve <IMainFrameRegionProvider>();
                mainFrameRegionProvider.SetContent(
                    MainFrameRegion.Background,
                    new Image()
                {
                    Source = new BitmapImage(new Uri("ms-appx:///Resources/logo460.png")),
                    Height = 460,
                    Width  = 460,
                    Margin = new Thickness(20),
                    HorizontalAlignment = HorizontalAlignment.Right,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Opacity             = 0.02
                });

                mainFrameRegionProvider.SetContent(MainFrameRegion.BottomAppBarRightZone, Container.Resolve <IPlayerView>());
                mainFrameRegionProvider.SetContent(MainFrameRegion.SnappedView, Container.Resolve <ISnappedPlayerView>());
                mainFrameRegionProvider.SetContent(MainFrameRegion.TopAppBarRightZone, new LogoView());

                var page = (Page)Window.Current.Content;
                VisualTreeHelperEx.GetVisualChild <Panel>(page).Children.Add(Container.Resolve <MediaElement>());

                MainMenu.Initialize(
                    Container.Resolve <IMainFrame>(),
                    Container.Resolve <IApplicationResources>(),
                    Container.Resolve <IApplicationStateService>(),
                    Container.Resolve <ISettingsService>(),
                    Container.Resolve <IEventAggregator>());
                ApplicationSettingViews.Initialize(Container.Resolve <IApplicationSettingViewsService>(), Container.Resolve <IApplicationResources>());

                Container.Resolve <MediaControlIntegration>();
                Container.Resolve <ScreenLocker>();

                Container.Resolve <INavigationService>().NavigateTo <IStartPageView>();
            }
        }
        private async void OnSelectedMoveChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox list = (ListBox)sender;

            if (list.SelectedItem == null)
            {
                return;
            }

            await Dispatcher.RunIdleAsync((o) =>
            {
                var scrollViewer = VisualTreeHelperEx.FindChild <ScrollViewer>(list);
                ListBoxItem item = list.ContainerFromItem(list.SelectedItem) as ListBoxItem;
                if (item != null)
                {
                    scrollViewer.ScrollToElement(item);
                }
            });
        }
Beispiel #4
0
        private void LoginWnd_Loaded(object sender, RoutedEventArgs e)
        {
            var tb  = VisualTreeHelperEx.FindDescendantByName(this, "tbUserName");
            var tb2 = VisualTreeHelperEx.FindDescendantByName(this, "tbPassword");

            if (tb is TextBox tbUserName)
            {
                if (tbUserName.IsEnabled)
                {
                    tbUserName.Focus();
                }
            }
            else if (tb2 is TextBox tbPassword)
            {
                if (tbPassword.IsEnabled)
                {
                    tbPassword.Focus();
                }
            }
        }
 private void TreeListView_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (e.ChangedButton != System.Windows.Input.MouseButton.Right)
     {
         return;
     }
     if (sender is TreeListView tree)
     {
         //右键选中
         var p = e.GetPosition(tree);
         if (tree.InputHitTest(p) is DependencyObject item)
         {
             if (VisualTreeHelperEx.FindAncestorByType(item, typeof(TreeListViewItem), true) is TreeListViewItem node)
             {
                 node.IsSelected = true;
                 return;
             }
         }
     }
 }
Beispiel #6
0
        private void SetPropertyes()
        {
            var image      = AssociatedObject;
            var imageWidth = _iConfigurationModel.ThumbnailWidth;

            if (imageWidth != 0 && (Math.Abs(image.Width - imageWidth) > 0.0001 || double.IsNaN(image.Width)))
            {
                image.Width = imageWidth;
                //var cell = image.FindVisualAncestorByType<DataGridCell>();
                var cell           = VisualTreeHelperEx.FindVisualAncestorByType <DataGridCell>(image);
                var column         = cell.Column;
                var parentDataGrid = VisualTreeHelperEx.FindVisualAncestorByType <DataGrid>(image);
                if (parentDataGrid != null && column != null)
                {
                    column.Width = 0;
                    parentDataGrid.UpdateLayout();
                    column.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
                }
            }
        }
Beispiel #7
0
        //static ICommand listViewLoadMoreCommand;

        private static void element_Loaded(object sender, RoutedEventArgs e)
        {
            var d      = sender as FrameworkElement;
            var scroll = VisualTreeHelperEx.FindVisualChildByName <ScrollViewer>(d, "ScrollViewer");

            if (scroll != null)
            {
                //var scrollBar = VisualTreeHelperEx.FindVisualChildByName<ScrollBar>(scroll, "VerticalScrollBar");
                //if (scrollBar != null)
                //{
                //    scrollBar.Foreground = new SolidColorBrush(Color.FromArgb(255, 176, 14, 37));
                //    //Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;
                //}

                var command = GetLoadMoreCommand(d);
                if (command != null)
                {
                    //scroll.ViewChanged -= Scroll_ViewChanged;
                    scroll.ViewChanged += (s, a) =>
                    {
                        //Debug.WriteLine("scroll.VerticalOffset : " + scroll.VerticalOffset + "scroll.ScrollableHeight : " + scroll.ScrollableHeight +  "  scroll.ScrollableHeight - 0.5 : " + (scroll.ScrollableHeight - 0.5));

                        if (scroll.VerticalOffset >= scroll.ScrollableHeight)
                        {
                            //if (!next)
                            //{
                            //next = true;
                            if (command.CanExecute(null))
                            {
                                command.Execute(null);
                            }
                            // }
                            //else
                            //{
                            //next = false;
                            //}
                        }
                    };
                }
            }
        }
Beispiel #8
0
        public void Load(IPdfSource source, string password = null)
        {
            this.scrollViewer  = VisualTreeHelperEx.FindChild <ScrollViewer>(this);
            this.imageProvider = new PdfImageProvider(source, this.parent.TotalPages,
                                                      new PageDisplaySettings(this.parent.GetPagesPerRow(), this.parent.ViewType, this.parent.HorizontalMargin, this.parent.Rotation), false, password);

            currentPageIndex = 0;

            if (this.parent.ZoomType == ZoomType.Fixed)
            {
                this.SetItemsSource();
            }
            else if (this.parent.ZoomType == ZoomType.FitToHeight)
            {
                this.ZoomToHeight();
            }
            else if (this.parent.ZoomType == ZoomType.FitToWidth)
            {
                this.ZoomToWidth();
            }
        }
        void ViewModel_ProgressChanged(object sender, EventArgs e)
        {
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                var loadingProgress = VisualTreeHelperEx.FindChild <ProgressBar>(this, "LoadingProgress");
                if (loadingProgress == null)
                {
                    return;
                }

                if (_progressBarAnimation != null)
                {
                    _progressBarAnimation.Completed -= ProgressBarAnimation_Completed;
                }

                var duration                     = new Duration(TimeSpan.FromSeconds((this.ViewModel.LoadingProgress - loadingProgress.Value) / 0.5));
                _progressBarAnimation            = new DoubleAnimation(this.ViewModel.LoadingProgress, duration);
                _progressBarAnimation.Completed += ProgressBarAnimation_Completed;
                loadingProgress.BeginAnimation(RangeBase.ValueProperty, _progressBarAnimation);
            }));
        }
        //static ICommand listViewLoadMoreCommand;

        private static void myElement_Loaded(object sender, RoutedEventArgs e)
        {
            var d      = sender as FrameworkElement;
            var scroll = VisualTreeHelperEx.FindVisualChildByName <ScrollViewer>(d, "ScrollViewer");

            if (scroll != null)
            {
                var command = GetScrollCommand(d);
                if (command != null)
                {
                    //scroll.ViewChanged -= Scroll_ViewChanged;
                    scroll.ViewChanged += (s, a) =>
                    {
                        if (command.CanExecute(null))
                        {
                            command.Execute(null);
                        }
                    };
                }
            }
        }
Beispiel #11
0
            public static int CalculateDropIndex(Panel panel, UIElementCollection children, Orientation orientation, Point position)
            {
                HitTestResult    HitTestResult = VisualTreeHelper.HitTest(panel, position);
                DependencyObject HitItem;

                if (HitTestResult != null)
                {
                    DependencyObject[] Ancestors = VisualTreeHelperEx.GetVisualAncestors(HitTestResult.VisualHit, panel);

                    HitItem = Ancestors.Length >= 1 ? Ancestors[1] : null;
                }
                else
                {
                    HitItem = null;
                }

                if (HitItem is UIElement)
                {
                    int  ItemIndex = children.IndexOf((UIElement)HitItem);
                    Rect Bounds    = ((Visual)HitItem).TransformToAncestor(panel).TransformBounds(VisualTreeHelperEx.GetBounds((Visual)HitItem));

                    Rect FirstHalfBounds = orientation == Orientation.Vertical
                        ? new Rect(Bounds.Left, Bounds.Top, Bounds.Width, Bounds.Height / 2)
                        : new Rect(Bounds.Left, Bounds.Top, Bounds.Width / 2, Bounds.Height);

                    if (FirstHalfBounds.Contains(position))
                    {
                        return(ItemIndex);
                    }
                    else
                    {
                        return(ItemIndex + 1);
                    }
                }
                else
                {
                    // Hit cannot be processed or is on the panel -> return index to insert at the end
                    return(children.Count);
                }
            }
Beispiel #12
0
        /// <summary>
        /// New table
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewTableCommand_OnCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            var parent = VisualTreeHelperEx.FindAncestorByType <MainWindow>(this);

            if (parent == null)
            {
                return;
            }
            var focus           = FocusManager.GetFocusedElement(parent);
            var isSenderAllowed = focus is ScrollViewer || focus is Button;

            if (!isSenderAllowed)
            {
                e.ContinueRouting = true;
                e.CanExecute      = false;
            }
            else
            {
                e.ContinueRouting = false;
                e.CanExecute      = true;
            }
        }
Beispiel #13
0
        public void FocusNextTextBox(bool reverse = false)
        {
            var textBoxes = VisualTreeHelperEx.GetChildren(mUnitPriceItemsControl, true)
                            .OfType <TextBox>()
                            .Where(textbox => !textbox.IsReadOnly && textbox.IsEnabled);

            if (reverse)
            {
                textBoxes = textBoxes.Reverse();
            }

            TextBox first = null;
            var     lastTextBoxIsFocused = false;
            var     focusChanged         = false;

            foreach (var textBox in textBoxes)
            {
                if (first == null)
                {
                    first = textBox;
                }

                if (lastTextBoxIsFocused)
                {
                    textBox.Focus();
                    focusChanged = true;
                    break;
                }
                else
                {
                    lastTextBoxIsFocused = ReferenceEquals(FocusManager.GetFocusedElement(), textBox);
                }
            }

            if (!focusChanged && first != null)
            {
                first.Focus();
            }
        }
Beispiel #14
0
        /// <summary>
        /// Dimensions changed
        /// </summary>
        /// <returns></returns>
        public async Task CanvasDimensionsChanged()
        {
            var settings = new MetroDialogSettings()
            {
                AnimateHide = true,
                AnimateShow = false
            };

            var parent = VisualTreeHelperEx.FindAncestorByType <MetroWindow>(this);

            var progressController = await parent.ShowProgressAsync("Please wait...", "Guidelines are updating", false, settings);

            await UpdateLines();

            await progressController.CloseAsync();

            StreamGeometry geometry = DesignerCanvas.CreateGridWithStreamGeometry(ViewModel.CanvasHeight, ViewModel.CanvasWidth,
                                                                                  DesignerCanvas.GridCellWidth);

            ModelDesignerCanvas.RefreshGuideLines(geometry);

            ViewModel.OnComputedPropertyChanged();
        }
        public void VerifyAutoSuggestBoxCornerRadius()
        {
            /*
             * if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
             * {
             *  Log.Warning("AutoSuggestBox CornerRadius property is not available pre-rs5");
             *  return;
             * }
             */

            var autoSuggestBox = SetupAutoSuggestBox();

            RunOnUIThread.Execute(() =>
            {
                autoSuggestBox.CornerRadius = new CornerRadius(2);
                autoSuggestBox.Focus(/*FocusState.Keyboard*/);
                autoSuggestBox.Text = "123";
            });
            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                var textBox = TestUtilities.FindDescendents <TextBox>(autoSuggestBox).Where(e => e.Name == "TextBox").Single();
                Verify.AreEqual(new CornerRadius(2, 2, 0, 0), textBox.GetCornerRadius());

                var overlayCornerRadius = new CornerRadius(0, 0, 0, 0);
                var radius = App.Current.Resources["OverlayCornerRadius"];
                if (radius != null)
                {
                    overlayCornerRadius = (CornerRadius)radius;
                }
                var popup       = VisualTreeHelperEx.GetOpenPopups(WindowEx.Current).Last();
                var popupBorder = TestUtilities.FindDescendents <Border>(popup).First();

                Verify.AreEqual(new CornerRadius(0, 0, overlayCornerRadius.BottomRight, overlayCornerRadius.BottomLeft), popupBorder.CornerRadius);
            });
        }
Beispiel #16
0
        /// <summary>
        /// TransitionProperty property changed handler.
        /// </summary>
        /// <param name="d">TransitioningContentControl that changed its Transition.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnTransitionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TransitioningContentControl source = (TransitioningContentControl)d;
            string oldTransition = e.NewValue as string;
            string newTransition = e.NewValue as string;

            if (source.IsTransitioning)
            {
                source.AbortTransition();
            }

            // find new transition
            Storyboard newStoryboard = source.GetStoryboard(newTransition);

            // unable to find the transition.
            if (newStoryboard == null)
            {
                // could be during initialization of xaml that presentationgroups was not yet defined
                if (VisualTreeHelperEx.TryGetVisualStateGroup(source, PresentationGroup) == null)
                {
                    // will delay check
                    source.CurrentTransition = null;
                }
                else
                {
                    // revert to old value
                    source.SetValue(TransitionProperty, oldTransition);

                    throw new ArgumentException(
                              string.Format(CultureInfo.CurrentCulture, "Transition '{0}' was not defined.", newTransition));
                }
            }
            else
            {
                source.CurrentTransition = newStoryboard;
            }
        }
Beispiel #17
0
        private static void OnIDChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue is null || !(d is UIElement))
            {
                return;
            }

            var parentPresenter = VisualTreeHelperEx.FindAncestorByType <SwitchPresenter>(d);

            if (parentPresenter is not null)
            {
                parentPresenter.RegisterID(e.NewValue as string, d as FrameworkElement);
            }
            else
            {
                d.Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
                                         (ThreadStart) delegate
                {
                    parentPresenter = VisualTreeHelperEx.FindAncestorByType <SwitchPresenter>(d);
                    if (parentPresenter is not null)
                    {
                        parentPresenter.RegisterID(e.NewValue as string, d as FrameworkElement);
                    }
                });
        public void VerifyComboBoxEditModeCornerRadius()
        {
            /*
             * if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
             * {
             *  Log.Warning("ComboBox corner radius is not available pre-rs5");
             *  return;
             * }
             */

            var comboBox = SetupComboBox();

            RunOnUIThread.Execute(() =>
            {
                comboBox.SetCornerRadius(new CornerRadius(2));
                comboBox.IsEditable     = true;
                comboBox.IsDropDownOpen = true;
            });
            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                var editableText = TestUtilities.FindDescendents <TextBox>(comboBox).Where(e => e.Name == "PART_EditableTextBox").Single();
                Verify.AreEqual(new CornerRadius(2, 2, 0, 0), editableText.GetCornerRadius());

                var overlayCornerRadius = new CornerRadius(0, 0, 0, 0);
                var radius = App.Current.Resources["OverlayCornerRadius"];
                if (radius != null)
                {
                    overlayCornerRadius = (CornerRadius)radius;
                }
                var popup       = VisualTreeHelperEx.GetOpenPopups(WindowEx.Current).Last();
                var popupBorder = TestUtilities.FindDescendents <Border>(popup).Where(e => e.Name == "PopupBorder").Single();
                Verify.AreEqual(new CornerRadius(0, 0, overlayCornerRadius.BottomRight, overlayCornerRadius.BottomLeft), popupBorder.CornerRadius);
            });
        }
Beispiel #19
0
            public static Rect CalculateDropMarker(Panel panel, UIElementCollection children, Orientation orientation, int dropIndex)
            {
                Rect DropMarker;

                if (children.Count > 0)
                {
                    if (dropIndex == 0)
                    {
                        Rect ItemRect = children[0].TransformToVisual(panel).TransformBounds(VisualTreeHelperEx.GetBounds(children[0]));
                        DropMarker = orientation == Orientation.Vertical
                            ? new Rect(ItemRect.Left, ItemRect.Top, ItemRect.Width, 0)
                            : new Rect(ItemRect.Left, ItemRect.Top, 0, ItemRect.Height);
                    }
                    else
                    {
                        Rect ItemRect = children[dropIndex - 1].TransformToVisual(panel).TransformBounds(VisualTreeHelperEx.GetBounds(children[dropIndex - 1]));
                        DropMarker = orientation == Orientation.Vertical
                            ? new Rect(ItemRect.Left, ItemRect.Bottom, ItemRect.Width, 0)
                            : new Rect(ItemRect.Right, ItemRect.Top, 0, ItemRect.Height);
                    }
                }
                else
                {
                    DropMarker = new Rect();
                }

                return(DropMarker);
            }
Beispiel #20
0
        public async void OnNavigatedTo(NavigationEventArgs e)
        {
            //一定要写在执行动画前面,这样就能Pivot设定好选择索引之后再显示Pivot
            if (e.SourcePageType == typeof(ChampionPage) || e.SourcePageType == typeof(ActPage) || e.SourcePageType == typeof(PlayPage) || e.SourcePageType == typeof(TeachPage) || e.SourcePageType == typeof(OfficialPage) || e.SourcePageType == typeof(SuperPage))
            {
                Pivot p = VisualTreeHelperEx.FindVisualChildByName <Pivot>(e.Content as DependencyObject, "pi");
                if (p != null)
                {
                    //New模式表明是从首页来的
                    if (e.NavigationMode == NavigationMode.New)
                    {
                        //这句话是在New的方式进入到NewsListPage的时候正确定位Pivot的Item的Index
                        p.SelectedIndex = DicStore.GetValueOrDefault <int>(AppCommonConst.CUR_PIVOT_SELECTED_INDEX, 0);
                    }
                    //back说明是返回的,从其他页面返回,此时应当回到进入其他页面之前的Pivot的Item的索引值
                    else
                    {
                        //p.SelectedIndex = DicStore.GetValueOrDefault<int>(AppCommonConst.CUR_PIVOT_SELECTED_INDEX, 0);
                    }
                }
            }

            var animationGrid = CommonHelper.Instance.GetCurrentAnimationGrid();

            if (e.NavigationMode == NavigationMode.Back)
            {
                if (animationGrid != null)
                {
                    if (AppEnvironment.IsPhone)
                    {
                        await animationGrid.AnimateAsync(new FadeInUpAnimation()
                        {
                            Distance = 400, Duration = 0.25
                        });
                    }
                    else
                    {
                        await animationGrid.AnimateAsync(new FadeInRightAnimation()
                        {
                            Duration = 0.13, Distance = 600
                        });
                    }
                }
            }

            var frameState = SuspensionManager.SessionStateForFrame(this.Frame);

            this._pageKey = "Page-" + this.Frame.BackStackDepth;

            if (e.NavigationMode == NavigationMode.New)
            {
                // Clear existing state for forward navigation when adding a new page to the
                // navigation stack
                var nextPageKey   = this._pageKey;
                int nextPageIndex = this.Frame.BackStackDepth;
                while (frameState.Remove(nextPageKey))
                {
                    nextPageIndex++;
                    nextPageKey = "Page-" + nextPageIndex;
                }

                // Pass the navigation parameter to the new page
                if (this.LoadState != null)
                {
                    this.LoadState(this, new LoadStateEventArgs(e.Parameter, null));
                }
            }
            else
            {
                // Pass the navigation parameter and preserved page state to the page, using
                // the same strategy for loading suspended state and recreating pages discarded
                // from cache
                if (this.LoadState != null)
                {
                    this.LoadState(this, new LoadStateEventArgs(e.Parameter, (Dictionary <String, Object>)frameState[this._pageKey]));
                }
            }

            if (animationGrid != null)
            {
                if (e.NavigationMode == NavigationMode.New)
                {
                    if (e.SourcePageType != typeof(NewsDetailPage))
                    {
                        //对非类别基页的进入动画
                        if (e.SourcePageType == typeof(ChampionPage) || e.SourcePageType == typeof(ActPage) || e.SourcePageType == typeof(PlayPage) || e.SourcePageType == typeof(TeachPage) || e.SourcePageType == typeof(OfficialPage) || e.SourcePageType == typeof(SuperPage))
                        {
                            if (AppEnvironment.IsPhone)
                            {
                                await animationGrid.AnimateAsync(new FadeInDownAnimation()
                                {
                                    Distance = 250, Duration = 0.3
                                });
                            }
                            else
                            {
                                await animationGrid.AnimateAsync(new FadeInLeftAnimation()
                                {
                                    Duration = 0.13, Distance = 600
                                });
                            }
                        }
                        //这里是类别切换进入动画
                        else
                        {
                            if (e.SourcePageType != typeof(MapPage) && e.SourcePageType != typeof(EncyPage))
                            {
                                if (AppEnvironment.IsPhone)
                                {
                                    await animationGrid.AnimateAsync(new FadeInLeftAnimation()
                                    {
                                        Duration = 0.25, Distance = 400
                                    });
                                }
                                else
                                {
                                    await animationGrid.AnimateAsync(new FadeInLeftAnimation()
                                    {
                                        Duration = 0.13, Distance = 600
                                    });
                                }
                            }
                        }
                    }
                }
                else if (e.NavigationMode == NavigationMode.Back)
                {
                    //TO-DO:做些事
                }
            }
        }
        public void VerifyPrimaryCommandsCanOverflowToSecondaryItemsControl()
        {
            /*
             * if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
             * {
             *  Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
             *  return;
             * }
             */

            CommandBarFlyout flyout       = null;
            Button           flyoutTarget = null;

            RunOnUIThread.Execute(() =>
            {
                flyout = new CommandBarFlyout()
                {
                    Placement = FlyoutPlacementMode.Right
                };

                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 1"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 2"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 3"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 4"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 5"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 6"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 7"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 8"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 9"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 10"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 11"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 12"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 13"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 14"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 15"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 16"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 17"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 18"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 19"
                });
                flyout.PrimaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 20"
                });

                flyout.SecondaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 21"
                });
                flyout.SecondaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 22"
                });
                flyout.SecondaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 23"
                });
                flyout.SecondaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 24"
                });
                flyout.SecondaryCommands.Add(new AppBarButton()
                {
                    Label = "Item 25"
                });

                flyoutTarget = new Button()
                {
                    Content = "Click for flyout"
                };
                Content = flyoutTarget;
                Content.UpdateLayout();
            });

            OpenFlyout(flyout, flyoutTarget);

            RunOnUIThread.Execute(() =>
            {
                Popup flyoutPopup     = VisualTreeHelperEx.GetOpenPopups(WindowEx.Current).Reverse().Skip(1).First();
                CommandBar commandBar = TestUtilities.FindDescendents <CommandBar>(flyoutPopup).Single();

                IList <ItemsControl> itemsControls = TestUtilities.FindDescendents <ItemsControl>(commandBar);

                Log.Comment("We expect there to be 2 ItemsControls inside the CommandBar; {0} were found.", itemsControls.Count);
                Verify.AreEqual(2, itemsControls.Count);

                ItemsControl primaryItemsControl   = itemsControls[0];
                ItemsControl secondaryItemsControl = itemsControls[1];

                Log.Comment("We expect there to be 9 items located inside the primary ItemsControl; {0} were found.", primaryItemsControl.Items.Count);
                Verify.AreEqual(9, primaryItemsControl.Items.Count);
                Log.Comment("We expect there to be 17 items located inside the secondary ItemsControl (16 + autogenerated separator); {0} were found.", secondaryItemsControl.Items.Count);
                Verify.AreEqual(17, secondaryItemsControl.Items.Count);
            });

            CloseFlyout(flyout);
        }
 private Popup GetFlyoutPopup()
 {
     return(VisualTreeHelperEx.GetOpenPopups(WindowEx.Current).Reverse().First(
                p => p.Child.FindDescendant <CommandBar>() != null));
 }
Beispiel #23
0
 private void SinglePageMoonPdfPanel_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     this.scrollViewer = VisualTreeHelperEx.FindChild <ScrollViewer>(this);
 }
Beispiel #24
0
 private void ContinuousMoonPdfPanel_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     scrollViewer = VisualTreeHelperEx.FindChild <ScrollViewer>(this);
 }