public AddCompletedCheckBoxTests()
        {
            MockForms.Init();
            var newItem = new NewItemPage();

            content = newItem.Content as StackLayout;
        }
コード例 #2
0
        public async Task ViewModel_MessageCenter_ItemsViewModel_MessageCenter_AddData_Should_Pass()
        {
            MockForms.Init();

            // Get State of the DataStore, and set to run on the Mock
            var myDataStoreEnum = MasterDataStore.GetDataStoreMockFlag();

            MasterDataStore.ToggleDataStore(DataStoreEnum.Mock);

            var myViewModel = new ItemsViewModel();
            var myData      = DefaultModels.ItemDefault(ItemLocationEnum.Feet, AttributeEnum.Attack);

            var myPage = new NewItemPage();

            MessagingCenter.Send(myPage, "AddData", myData);

            var Actual = await myViewModel.GetAsync(myData.Id);

            var Expected = myData;

            // Return state
            MasterDataStore.ToggleDataStore(myDataStoreEnum);

            // Validate the controller can stand up and has a Title
            Assert.AreEqual(Expected.Id, Actual.Id, TestContext.CurrentContext.Test.Name);
        }
コード例 #3
0
        public void AddNewItem()
        {
            //Arrange
            const string itemName        = "Item Name";
            const string itemDescription = "Item Description";

            //Act
            ItemsPage.TapAddToolbarButton();
            NewItemPage.EnterItemName(itemName);
            NewItemPage.EnterItemDescription(itemDescription);
            NewItemPage.TapSaveToolbarButton();
            //Assert
            Assert.IsTrue(ItemsPage.IsPageVisible);
            Assert.IsTrue(app.Query(itemName).Length > 0);
        }
        public async Task <T> NavigateToModal <T>(string modalName)
        {
            var source = new TaskCompletionSource <T>();

            if (modalName == nameof(NewItemPage))
            {
                var page = new NewItemPage();
                page.PageDisapearing += (result) =>
                {
                    var res = (T)Convert.ChangeType(result, typeof(T));
                    source.SetResult(res);
                };
                await App.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(page));
            }
            return(await source.Task);
        }
コード例 #5
0
        async void EditItem()
        {
            var waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
            var page       = new NewItemPage(Item, $"Edit {Item.Title}");

            page.Disappearing += (sender, e) =>
            {
                waitHandle.Set();
            };
            await App.Current.MainPage.Navigation.PushAsync(page, false);

            await Task.Run(() => waitHandle.WaitOne());

            MessagingCenter.Send(this, "EditItem", Item);
            await App.Current.MainPage.Navigation.PopAsync(false);
        }
コード例 #6
0
        public App()
        {
            InitializeComponent();

            AboutPage      = new AboutPage();
            AddRecipe      = new AddRecipe();
            ItemDetailPage = new ItemDetailPage();
            NewItemPage    = new NewItemPage();
            Recipes        = new Recipes();
            TakePhoto      = new TakePhoto();
            EditRecipe     = new EditRecipe();

            NaviService = _container.Resolve <INavigationService>() as NavigationService;

            var pageFactory = _container.Resolve <IPageFactory>();
            var home        = pageFactory.GetPage(Pages.MainPage) as TabbedPage;

            StartupPage = home;
            MainPage    = StartupPage;
        }
コード例 #7
0
        protected override async void OnStart()
        {
            await NewItemPage.LoadCitiesList();

            var selectedCitiesExists = File.Exists(Path.Combine(selectedCitiesPath, selectedCitiesFileName));
            var directoryExists      = Directory.Exists(selectedCitiesPath);

            CitiesFromFile = JsonConvert.DeserializeObject <List <City> >(File.ReadAllText(Path.Combine(selectedCitiesPath, selectedCitiesFileName)));
            if (selectedCitiesExists)
            {
                foreach (var city in CitiesFromFile)
                {
                    await DataStore.AddItemAsync(city);
                }
            }
            if (!directoryExists)
            {
                Directory.CreateDirectory(selectedCitiesPath);
            }
        }
コード例 #8
0
        private async void IncluirPlacar(NewItemPage source, Placar placar)
        {
            var clas = ((await DataStore.GetItemsAsync(true)) ?? new Classificacao[0])
                       .OrderBy(a => a.Posicao)
                       .ToArray();

            var novoPlacar = placar as Placar;

            var clasJA = clas.FirstOrDefault(a => a.Jogador == novoPlacar.JogadorA.Nome);
            var clasJB = clas.FirstOrDefault(a => a.Jogador == novoPlacar.JogadorB.Nome);

            var ultimaPosicao = clas[clas.Length - 1].Posicao;

            novoPlacar.PosicaoA    = (clasJA?.Posicao) ?? (++ultimaPosicao);
            novoPlacar.PosicaoAntA = (clasJA?.PosicaoAnterior);
            novoPlacar.PosicaoB    = (clasJB?.Posicao) ?? (++ultimaPosicao);
            novoPlacar.PosicaoAntB = (clasJB?.PosicaoAnterior);

            await PlacarDataStore.AddItemAsync(novoPlacar);

            RecalcularClassificacaoAsync(null);
        }
コード例 #9
0
        void AppActions_OnAppAction(object sender, AppActionEventArgs e)
        {
            // Don't handle events fired for old application instances
            // and cleanup the old instance's event handler
            if (Application.Current != this && Application.Current is App app)
            {
                AppActions.OnAppAction -= app.AppActions_OnAppAction;
                return;
            }

            Device.BeginInvokeOnMainThread(async() =>
            {
                Page targetPage = null;

                // Determine the app action type or id which user selected
                switch (e.AppAction.Id)
                {
                case Helpers.ActionType.AddNote:
                    targetPage = new NewItemPage();
                    break;

                case Helpers.ActionType.ViewFavourites:
                    // targetPage = new FavouritesPage();
                    break;

                // Other id cases:

                default:
                    break;
                }

                // Handle the navigation to target page
                if (targetPage != null)
                {
                    await Current.MainPage.Navigation.PushModalAsync(new NavigationPage(new NewItemPage()));
                }
            });
        }
コード例 #10
0
 async Task AddFeedAsync(NewItemPage obj, RssFeedModel item)
 {
     try
     {
         var     newItem = item as RssFeedModel;
         RssFeed newFeed = new RssFeed(newItem.Url);
         await _feedReader.GetFeedArticles(newFeed).ContinueWith(async(t) =>
         {
             if (t.IsCanceled || t.IsFaulted)
             {
                 Device.BeginInvokeOnMainThread(async() => await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Error", "There was an issue adding the RSS feed.", "OK"));
             }
             else
             {
                 await SaveEntity(newFeed, obj);
                 Items.Add(new RssFeedModel(newFeed));
             }
         });
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
コード例 #11
0
        private void PageChanged(int pageIndex)
        {
            this.pageIndex = pageIndex;
            switch (pageIndex)
            {
            case 0:
                newClientPage     = new NewClientPage(CloseFrame);
                MainFrame.Content = newClientPage;
                break;

            case 1:
                newOrderPage      = new NewOrderPage(CloseFrame);
                MainFrame.Content = newOrderPage;
                break;

            case 2:
                newProjectPage    = new NewProjectPage(CloseFrame);
                MainFrame.Content = newProjectPage;
                break;

            case 3:
                newEmployeePage   = new NewEmployeePage(CloseFrame);
                MainFrame.Content = newEmployeePage;
                break;

            case 4:
                clientsPage       = new ClientsPage(CloseFrame);
                MainFrame.Content = clientsPage;
                break;

            case 5:
                ordersPage        = new OrdersPage(CloseFrame);
                MainFrame.Content = ordersPage;
                break;

            case 6:
                employeesPage     = new EmployeesPage(CloseFrame);
                MainFrame.Content = employeesPage;
                break;

            case 7:
                allprojectsPage   = new AllProjectsPage(CloseFrame);
                MainFrame.Content = allprojectsPage;
                break;

            case 8:
                lifeprojectsPage  = new ProjectLifePage(CloseFrame);
                MainFrame.Content = lifeprojectsPage;
                break;

            case 9:
                notopened         = new NotOpenedProjectsPage(CloseFrame);
                MainFrame.Content = notopened;
                break;

            case 10:
                alltasksPage      = new TasksPage(CloseFrame);
                MainFrame.Content = alltasksPage;
                break;

            case 11:
                newTaskPage       = new NewTaskPage(CloseFrame);
                MainFrame.Content = newTaskPage;
                break;

            case 12:
                newItemPage       = new NewItemPage(CloseFrame);
                MainFrame.Content = newItemPage;
                break;

            case 13:
                itemsPage         = new ItemsPage(CloseFrame);
                MainFrame.Content = itemsPage;
                break;
            }
        }
コード例 #12
0
 internal static Task DeleteItemAsync(NewItemPage todoItem)
 {
     throw new NotImplementedException();
 }
コード例 #13
0
 public async void Edit()
 {
     NewItemPage editPage = new NewItemPage(item.GetName(), item.GetNotes(), item.GetTags(), item.GetId(), item, item.GetContainer());
     await Navigation.PushAsync(editPage);
 }