protected override void OnCreate(Bundle savedInstanceState)
        {
            ViewModelState.Initialise(new NavigationService(this), new DeviceIntegration(this));

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.MovieDetails);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            ViewModelMovieDetails viewModel = new ViewModelMovieDetails();

            viewModel.Initialise();

            SupportActionBar.Title     = viewModel.Title;
            viewModel.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(ViewModelMovieDetails.Title))
                {
                    SupportActionBar.Title = viewModel.Title;
                }
            };

            new ConnectorImageView(FindViewById <ImageView>(Resource.Id.poster), viewModel, nameof(ViewModelMovieDetails.PosterURL));
            new ConnectorListView <ListItemMovieAttributeBase>(this, FindViewById <ListView>(Resource.Id.attributes), viewModel, nameof(ViewModelMovieDetails.Attributes), null,
                                                               (item) =>
            {
                if (item is ListItemMovieAttributeLabel)
                {
                    return(Resource.Layout.TemplateListItemAttributeLabel);
                }
                return(Resource.Layout.TemplateListItemAttributeValue);
            },
                                                               (context, item, view, parent) =>
            {
                LayoutInflater layoutInflator = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;

                if (item is ListItemMovieAttributeLabel)
                {
                    ListItemMovieAttributeLabel label = (ListItemMovieAttributeLabel)item;

                    view = layoutInflator.Inflate(Resource.Layout.TemplateListItemAttributeLabel, parent, false);
                    view.FindViewById <TextView>(Resource.Id.listItemMovieAttributeLabel).Text = label.Label;
                }
                else
                {
                    ListItemMovieAttributeValue value = item as ListItemMovieAttributeValue;
                    view = layoutInflator.Inflate(Resource.Layout.TemplateListItemAttributeValue, parent, false);

                    view.FindViewById <TextView>(Resource.Id.listItemMovieAttributeValue).Text = value.Value;
                }

                return(view);
            });
            new ConnectorTextView(FindViewById <TextView>(Resource.Id.plot), viewModel, nameof(ViewModelMovieDetails.Plot));
            new ConnectorButton(FindViewById <Button>(Resource.Id.imdbWebsite), viewModel.CommandBrowseToMovie);
        }
예제 #2
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            Window = new UIWindow(UIScreen.MainScreen.Bounds)
            {
                RootViewController = UIStoryboard.FromName("Main", null).InstantiateInitialViewController()
            };

            Window.MakeKeyAndVisible();
            Style.Initialise();
            ViewModelState.Initialise(new NavigationService(Window.RootViewController as UINavigationController), new DeviceIntegration());

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            NavigationService navigationService = new NavigationService(rootFrame);
            DeviceIntegration deviceIntegration = new DeviceIntegration();

            Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (sender, args) =>
            {
                navigationService.NavigateBack();
                args.Handled = true;
            };
            ViewModelState.Initialise(navigationService, deviceIntegration);

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(PageSearch), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
예제 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ViewModelState.Initialise(new NavigationService(this), new DeviceIntegration(this));

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Search);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "Search";

            ViewModelSearch viewModel  = new ViewModelSearch();
            EditText        searchTerm = FindViewById <EditText>(Resource.Id.searchTerm);

            new ConnectorEditText(searchTerm, viewModel.SearchTerm);
            _connectorListView = new ConnectorListView <ListItemMovie>(this, FindViewById <ListView>(Resource.Id.searchResults), viewModel, nameof(ViewModelSearch.SearchResults), nameof(ViewModelSearch.TappedSearchResult),
                                                                       (item) => Resource.Layout.TemplateListItemMovie,
                                                                       (context, movie, view, parent) =>
            {
                if (view == null)
                {
                    LayoutInflater layoutInflator = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;

                    view = layoutInflator.Inflate(Resource.Layout.TemplateListItemMovie, parent, false);
                }

                view.FindViewById <TextView>(Resource.Id.listItemMovieTitle).Text        = movie.Title;
                view.FindViewById <TextView>(Resource.Id.listItemMovieYearAndGenre).Text = movie.YearAndGenre;

                return(view);
            });

            searchTerm.EditorAction += (sender, args) =>
            {
                viewModel.CommandSearch.Execute(null);
            };
        }