Пример #1
0
 public MainPage(IThemeControl themeControl, IPageControl pageControl, IInjectionControl injectionControl)
 {
     InitializeComponent();
     _themeControl     = themeControl;
     _pageControl      = pageControl;
     _injectionControl = injectionControl;
 }
Пример #2
0
        /// <summary>
        /// Navigates to a page control.
        /// </summary>
        public void NavigateToPageControlByArguments(string arguments)
        {
            IPageControl pageControl = null;
            object       parameter   = arguments;

            if (string.IsNullOrEmpty(arguments))
            {
                pageControl = new FavoritesPageControl();
            }
            else
            {
                PageInitializationParameters parameters;
                if (PageInitializationParameters.TryCreate(arguments, out parameters))
                {
                    string pageControlName = parameters.GetParameter <string>("pageControl");
                    if (!string.IsNullOrEmpty(pageControlName))
                    {
                        // Make sure the type is a valid page control:
                        Type pageControlType = Type.GetType(pageControlName, false);
                        if (pageControlType != null)
                        {
                            pageControl = Activator.CreateInstance(pageControlType) as IPageControl;
                            parameter   = parameters;
                        }
                    }
                }
            }

            // Important: to make sure we don't time out opening OBA on ARM devices, load the page control when we idle.
            var ignored = this.Dispatcher.RunIdleAsync(async() =>
            {
                await NavigationController.Instance.NavigateToPageControlAsync(pageControl, parameter);
            });
        }
Пример #3
0
        private void OnSelectedPageChanged(object sender, EventArgs e)
        {
            IPageControl control = _wizardControl.SelectedPage.Tag as IPageControl;

            if (control != null)
            {
                control.NowVisible();
            }
        }
        public static async Task <TResponse> OpenPopupAsync <TViewModel, TResponse>(this IPageControl pageControl, Action <TViewModel> addData = null)
            where TViewModel : PopupViewModelBase <TResponse>
        {
            var completionSource = new TaskCompletionSource <TResponse>();
            await pageControl.PushModalAsync <TViewModel>(vm => {
                vm.TaskCompletionSource = completionSource;
                addData?.Invoke(vm);
            });

            return(await completionSource.Task);
        }
Пример #5
0
        private void NotifyConnected()
        {
            foreach (TabPage page in tabMain.TabPages)
            {
                IPageControl ctrl = page.Controls[0] as IPageControl;
                if (ctrl == null)
                {
                    continue;
                }

                ctrl.onConnected();
            }
        }
Пример #6
0
        /// <summary>
        /// Returns true if the page control is currently pinned.
        /// </summary>
        public async Task<bool> PageControlIsCurrentlyPinned(IPageControl pageControl)
        {
            IPinablePageControl pinnablePageControl = pageControl as IPinablePageControl;
            if (pinnablePageControl != null)
            {
                // See if we're pinned to start:
                var query = from tile in await SecondaryTile.FindAllAsync()
                            where string.Equals(pinnablePageControl.TileId, tile.TileId, StringComparison.OrdinalIgnoreCase)
                            select tile;

                return query.Count() > 0;
            }

            return false;
        }
        /// <summary>
        /// Returns true if the page control is currently pinned.
        /// </summary>
        public async Task <bool> PageControlIsCurrentlyPinned(IPageControl pageControl)
        {
            IPinablePageControl pinnablePageControl = pageControl as IPinablePageControl;

            if (pinnablePageControl != null)
            {
                // See if we're pinned to start:
                var query = from tile in await SecondaryTile.FindAllAsync()
                                where string.Equals(pinnablePageControl.TileId, tile.TileId, StringComparison.OrdinalIgnoreCase)
                            select tile;

                return(query.Count() > 0);
            }

            return(false);
        }
        /// <summary>
        /// Navigates to a page control by parsing an argument string. If the argument string is null or empty,
        /// then we default to the favorites page. If the string begins with "?" then we try and parse it as a
        /// deep link. If the string is anything else then we assume it's a search.
        /// </summary>
        public void NavigateToPageControlByArguments(string arguments)
        {
            IPageControl pageControl = null;
            object       parameter   = arguments;

            if (string.IsNullOrEmpty(arguments))
            {
                pageControl = new FavoritesPageControl();
            }
            else
            {
                PageInitializationParameters parameters;
                if (PageInitializationParameters.TryCreate(arguments, out parameters))
                {
                    string pageControlName = parameters.GetParameter <string>("pageControl");
                    if (!string.IsNullOrEmpty(pageControlName))
                    {
                        // Make sure the type is a valid page control:
                        Type pageControlType = Type.GetType(pageControlName, false);
                        if (pageControlType != null)
                        {
                            pageControl = Activator.CreateInstance(pageControlType) as IPageControl;
                            parameter   = parameters;
                        }
                    }
                }

                // We have a query string, but it's not structured in a way we expect, so let's assume it's a search query:
                if (pageControl == null)
                {
                    pageControl = new SearchResultsPageControl();
                }
            }

            // Important: to make sure we don't time out opening OBA on ARM devices, load the page control when we idle.
            var ignored = this.Dispatcher.RunIdleAsync(async cb =>
            {
                await NavigationController.Instance.NavigateToPageControlAsync(pageControl, parameter);
                await this.TryRegisterBackgroundTask();
            });
        }
        /// <summary>
        /// This overload takes a specific page control. Used in cases where we are activated via a URL.
        /// </summary>
        public async Task NavigateToPageControlAsync(IPageControl newPageControl, object parameter)
        {
            if (this.CurrentPageControl != null)
            {
                newPageControl.ViewModel.MapControlViewModel.CopyFrom(this.CurrentPageControl.ViewModel.MapControlViewModel);
            }

            this.MainPage.SetPageView(newPageControl);

            if (this.CurrentPageControl != null)
            {
                this.pageControls.Push(this.CurrentPageControl);
            }

            this.CurrentPageControl = newPageControl;
            this.FirePropertyChanged("CanGoBack");

            await newPageControl.InitializeAsync(parameter);

            await this.UpdateIsPinnableAsync(newPageControl);

            await this.RestartRefreshLoopAsync();
        }
 /// <summary>
 /// Checks to see whether the new page control is pinned to start or not.
 /// </summary>
 public async Task UpdateIsPinnableAsync(IPageControl pageControl)
 {
     // If this is a pinnable page control, see if we're pinned or not:
     this.IsCurrentControlPinned = await ServiceRepository.TileService.PageControlIsCurrentlyPinned(pageControl);
 }   
        /// <summary>
        /// This overload takes a specific page control. Used in cases where we are activated via a URL.
        /// </summary>
        public async Task NavigateToPageControlAsync(IPageControl newPageControl, object parameter)
        {
            if (this.CurrentPageControl != null)
            {
                newPageControl.ViewModel.MapControlViewModel.CopyFrom(this.CurrentPageControl.ViewModel.MapControlViewModel);
            }
                        
            this.MainPage.SetPageView(newPageControl);
            
            if (this.CurrentPageControl != null)
            {
                this.pageControls.Push(this.CurrentPageControl);
            }

            this.SetBackButtonVisibility();

            this.CurrentPageControl = newPageControl;
            this.FirePropertyChanged("CanGoBack");
            
            await newPageControl.InitializeAsync(parameter);
            await this.UpdateIsPinnableAsync(newPageControl);
            await this.RestartRefreshLoopAsync();            
        }
Пример #12
0
 public ThemeControl(IPageControl pageControl)
 {
     _pageControl = pageControl;
 }
        /// <summary>
        /// Navigates to a page control.
        /// </summary>
        public async Task NavigateToPageControlAsync(PageControlTypes type, object parameter)
        {
            IPageControl newPageControl = ServiceRepository.PageControlService.CreatePageControl(type);

            await NavigateToPageControlAsync(newPageControl, parameter);
        }
 public PopupViewModelBase(IPageControl pageControl)
 {
     CloseCmd    = new Command(async() => await SetResultAsync(CancelResponse));
     SubmitCmd   = new Command <TResponse>(async response => await SetResultAsync(response));
     PageControl = pageControl;
 }
 /// <summary>
 /// Sets the page view.  All we need to do here is replace the content in the
 /// scroll viewer and set the data context.
 /// </summary>
 public void SetPageView(IPageControl pageControl)
 {
     this.scrollViewer.Content = pageControl;
     this.DataContext          = pageControl.ViewModel;
 }
 /// <summary>
 /// Checks to see whether the new page control is pinned to start or not.
 /// </summary>
 public async Task UpdateIsPinnableAsync(IPageControl pageControl)
 {
     // If this is a pinnable page control, see if we're pinned or not:
     this.IsCurrentControlPinned = await ServiceRepository.TileService.PageControlIsCurrentlyPinned(pageControl);
 }
Пример #17
0
 public PageViewModel(IPage content, IPageControl control) : this(content)
 {
     Control = control ?? throw new ArgumentNullException(nameof(control));
 }
Пример #18
0
 /// <summary>
 /// Sets the page view.  All we need to do here is replace the content in the 
 /// scroll viewer and set the data context.
 /// </summary>
 public void SetPageView(IPageControl pageControl)
 {
     this.scrollViewer.Content = pageControl;
     this.DataContext = pageControl.ViewModel;
 }
Пример #19
0
 public Task <bool> PageControlIsCurrentlyPinned(IPageControl pageControl)
 {
     return(Task.FromResult <bool>(false));
 }