Ejemplo n.º 1
0
        public void NavigateTo(AppViews pageKey, object parameter)
        {
            lock (_pagesByKey)
            {
                if (_pagesByKey.ContainsKey(pageKey))
                {
                    var             type = _pagesByKey[pageKey];
                    ConstructorInfo constructor;
                    object[]        parameters = new object[] { };

                    constructor = type.GetTypeInfo()
                                  .DeclaredConstructors
                                  .FirstOrDefault();

                    if (constructor == null)
                    {
                        throw new InvalidOperationException(
                                  "No suitable constructor found for page " + pageKey);
                    }

                    var page = constructor.Invoke(parameters) as Page;
                    _currentRootView.Navigate(page.GetType(), parameter);
                }
                else
                {
                    throw new ArgumentException(
                              string.Format(
                                  "No such page: {0}. Did you forget to call NavigationService.Configure?",
                                  pageKey), nameof(pageKey));
                }
            }
        }
Ejemplo n.º 2
0
        public void GoTo(AppViews navTarget, object navParam = null)
        {
            var viewTypeName = string.Format(ViewTypeNameTemplate, navTarget);
            var viewType     = Type.GetType(viewTypeName);

            _rootFrame.Navigate(viewType, navParam);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Выполнить преход в указанное представление с очисткорй журнала переходов.
 /// </summary>
 /// <param name="view">Представление, в которое требуется перейти.</param>
 /// <param name="parameter">Параметр навигации.</param>
 public static void NavigateClear(AppViews view, object parameter = null)
 {
     Messenger.Default.Send <NavigateToPageMessage>(new NavigateToPageMessage
     {
         Page      = view,
         Operation = NavigationType.NewClear,
         Parameter = parameter
     });
 }
        public void NavigateTo(AppViews viewKey, object parameter)
        {
            lock (_pagesByKey)
            {
                if (_pagesByKey.ContainsKey(viewKey))
                {
                    var             type = _pagesByKey[viewKey];
                    ConstructorInfo constructor;
                    object[]        parameters = new object[] { };

                    constructor = type.GetTypeInfo()
                                  .DeclaredConstructors
                                  .FirstOrDefault();

                    if (constructor == null)
                    {
                        throw new InvalidOperationException(
                                  "No suitable constructor found for page " + viewKey);
                    }

                    if (parameter != null)
                    {
                        parameters = new object[] { parameter };
                    }

                    var page = constructor.Invoke(parameters);

                    if (page.GetType().IsSubclassOf(typeof(Window)))
                    {
                        var test = page as Window;
                        test.Show();
                    }

                    else
                    {
                        if (parameter == null)
                        {
                            _rootView.NavigationService.Navigate(page);
                        }
                        else
                        {
                            _rootView.NavigationService.Navigate(page, parameter);
                        }
                    }
                }
                else
                {
                    throw new ArgumentException(
                              string.Format(
                                  "No such page: {0}. Did you forget to call NavigationService.Configure?",
                                  viewKey), nameof(viewKey));
                }
            }
        }
Ejemplo n.º 5
0
        // NavigateTo method to navigate between pages with passing parameter:
        public void NavigateTo(AppViews pageKey, object parameter)
        {
            lock (_pagesByKey)
            {
                if (_pagesByKey.ContainsKey(pageKey))
                {
                    var             type = _pagesByKey[pageKey];
                    ConstructorInfo constructor;
                    object[]        parameters;

                    if (parameter == null)
                    {
                        constructor = type.GetTypeInfo()
                                      .DeclaredConstructors
                                      .FirstOrDefault(c => !c.GetParameters().Any());

                        parameters = new object[]
                        {
                        };
                    }
                    else
                    {
                        constructor = type.GetTypeInfo()
                                      .DeclaredConstructors
                                      .FirstOrDefault(
                            c =>
                        {
                            var p = c.GetParameters();
                            return(p.Count() == 1 &&
                                   p[0].ParameterType == parameter.GetType());
                        });

                        parameters = new[]
                        {
                            parameter
                        };
                    }

                    if (constructor == null)
                    {
                        throw new InvalidOperationException(
                                  "No suitable constructor found for page " + pageKey);
                    }

                    var page = constructor.Invoke(parameters) as Page;
                    _navigation.PushAsync(page);
                }
                else
                {
                    throw new ArgumentException(
                              $"No such page: {pageKey}. Did you forget to call NavigationService.Configure?", nameof(pageKey));
                }
            }
        }
Ejemplo n.º 6
0
 public void Configure(AppViews pageKey, Type pageType)
 {
     lock (_pagesByKey)
     {
         if (_pagesByKey.ContainsKey(pageKey))
         {
             _pagesByKey[pageKey] = pageType;
         }
         else
         {
             _pagesByKey.Add(pageKey, pageType);
         }
     }
 }
Ejemplo n.º 7
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form1 form1 = new Form1();

            appViews      = new AppViews(form1);
            appControlers = new AppControlers();
            models        = new Models();
            appComponents = new AppComponents();

            appControlers.init();
            appViews.init();
            models.init();
            appComponents.init();

            //AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(form1);
        }
 public void NavigationInvoked(AppViews viewKey, object parameter)
 {
     NavigationService.NavigateTo(viewKey, parameter);
 }
 public void NavigationInvoked(AppViews viewKey)
 {
     NavigationService.NavigateTo(viewKey);
 }
Ejemplo n.º 10
0
 public void NavigateTo(AppViews pageKey)
 {
     NavigateTo(pageKey, null);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Возвращает тип страницы по ее имени.
        /// </summary>
        /// <param name="view">Название представления.</param>
        private Type GetPageTypeFromName(AppViews view)
        {
            switch (view)
            {
            case AppViews.LoginView:
                return(typeof(LoginView));

            case AppViews.NewsView:
                return(typeof(NewsView));

            case AppViews.FriendsView:
                return(typeof(FriendsView));

            case AppViews.ErrorView:
                return(typeof(ErrorView));

            case AppViews.PostView:
                return(typeof(PostView));

            case AppViews.ImageView:
                return(typeof(ImageView));

            case AppViews.AudiosView:
                return(typeof(AudiosView));

            case AppViews.VideosView:
                return(typeof(VideosView));

            case AppViews.VideoInfoView:
                return(typeof(VideoInfoView));

            case AppViews.VideoAlbumView:
                return(typeof(VideoAlbumView));

            case AppViews.GroupsView:
                return(typeof(GroupsView));

            case AppViews.MessagesView:
                return(typeof(MessagesView));

            case AppViews.TestView:
                return(typeof(TestPageOld));

            case AppViews.BotView:
                return(typeof(BotView));

            case AppViews.GroupInfoView:
                return(typeof(GroupInfoView));

            case AppViews.ProfileView:
                return(typeof(ProfileView));

            case AppViews.SettingsView:
                return(typeof(SettingsView));

            case AppViews.ChangeStatusView:
                return(typeof(ChangeStatusView));

            case AppViews.PhotosView:
                return(typeof(PhotosView));

            case AppViews.AccessDeniedView:
                return(typeof(AccessDeniedView));

            case AppViews.PlayerView:
                return(typeof(PlayerView));

            case AppViews.NewPostView:
                return(typeof(NewPostView));

            case AppViews.NotificationsSettingsView:
                return(typeof(NotificationsSettingsView));

            case AppViews.CommonSettingsView:
                return(typeof(CommonSettigsView));

            case AppViews.ConversationView:
                return(typeof(ConversationView));

            case AppViews.AboutView:
                return(typeof(AboutView));

            case AppViews.ChatSettingsView:
                return(typeof(ChatSettingsView));

            case AppViews.ChoiceFriendsView:
                return(typeof(ChoiceFriendsView));

            case AppViews.FeedbackView:
                return(typeof(FeedbackView));

            case AppViews.PromoView:
                return(typeof(PromoView));

            case AppViews.AllPromosView:
                return(typeof(AllPromosView));

            case AppViews.AttachmentsManagerView:
                return(typeof(AttachmentsManagerView));
            }
            return(typeof(ErrorView));
        }
Ejemplo n.º 12
0
 public void NavigateTo(AppViews viewKey)
 {
     NavigateTo(viewKey, null);
 }