コード例 #1
0
        public MyPopupPage()
        {
            InitializeComponent();

            app = new ApolloDictionary();

            //Layout
            typedWord = new Entry {
                Placeholder = "New word"
            };
            typedDefinition = new Entry {
                Placeholder = "Word definition..."
            };
            typedCategory = new Entry {
                Placeholder = "Category (e.g. Acronyms)"
            };

            addItemButton = new Button
            {
                Text = "Add"
            };

            layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                BackgroundColor = Color.Accent,
                Padding         = new Thickness(5, 5, 5, 5),
                Children        = { typedWord, typedDefinition, typedCategory, addItemButton }
            };

            Content = layout;

            addItemButton.Clicked += AddItemButton_Clicked;
        }
コード例 #2
0
        public HistoryPage()
        {
            InitializeComponent();

            app = new ApolloDictionary();

            //Creating ListView
            historyList             = new ListView();
            historyList.ItemsSource = UserProperties.HistoryList;

            layout = new StackLayout
            {
                Padding  = new Thickness(5, 5, 5, 5),
                Children = { historyList }
            };
            Content = layout;

            //When item is tapped
            historyList.ItemTapped += HistoryList_ItemTapped;

            //When a new word is added the list is refreshed
            MessagingCenter.Subscribe <SearchPage>(this, "newWordHistory", (sender) =>
            {
                layout.Children.Remove(historyList);
                historyList.ItemsSource = UserProperties.HistoryList.ToList();
                layout.Children.Add(historyList);
            });
        }
コード例 #3
0
        public CategoriesPage()
        {
            InitializeComponent();

            app = new ApolloDictionary();

            list_words           = ShowListCategories();
            isCategoriesOnScreen = true;

            //Creating SearchBar
            search_field = new SearchBar
            {
                Placeholder = "Search here..."
            };

            //Adding items to Content
            layout = new StackLayout
            {
                Margin   = new Thickness(0, 5, 0, 0),
                Spacing  = 5,
                Children = { list_words }
            };
            Content = layout;

            //Search when press the Search button
            search_field.SearchButtonPressed += Search_field_SearchButtonPressed;

            //When the person clicks to cancel the search or erase the word
            search_field.TextChanged += Search_field_TextChanged;

            //Click on the item
            list_words.ItemTapped += List_words_ItemTapped;

            //When a new word is added the list is refreshed
            MessagingCenter.Subscribe <MyPopupPage>(this, "newWord", (sender) => {
                layout.Children.Remove(list_words);
                list_words = ShowListCategories();
                layout.Children.Add(list_words);
            });

            //fileReadingDone
            MessagingCenter.Subscribe <ReadDictFiles>(this, "fileReadingDone", (sender) => {
                layout.Children.Remove(list_words);
                list_words = ShowListCategories();
                layout.Children.Add(list_words);
            });
        }
コード例 #4
0
        public SearchPage()
        {
            InitializeComponent();

            app = new ApolloDictionary();

            //Creating ListView
            list_words = new ListView
            {
                ItemTemplate = new DataTemplate(typeof(TextCell))
                {
                    Bindings =
                    {
                        { TextCell.TextProperty, new Binding("Name") }
                    }
                },

                GroupDisplayBinding   = new Binding("Key"),
                GroupShortNameBinding = new Binding("Key"),
                IsGroupingEnabled     = true,
                ItemsSource           = Listing()
            };

            //Add New Item Button
            addNewItemButton = new Button
            {
                Text = "Add New Word",
            };

            //Creating SearchBar
            search_field = new SearchBar
            {
                Placeholder  = "Search here...",
                WidthRequest = 225
            };

            //Adding items to Content
            layout = new StackLayout
            {
                Margin  = new Thickness(0, 5, 0, 0),
                Spacing = 5,

                Children =
                {
                    new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children    = { search_field, addNewItemButton }
                    },
                    list_words
                }
            };
            Content = layout;

            //Search when press the Search button
            search_field.SearchButtonPressed += Search_field_SearchButtonPressed;

            //When the person clicks to cancel the search or erase the word
            search_field.TextChanged += Search_field_TextChanged;

            //Click on the item
            list_words.ItemTapped += List_words_ItemTapped;

            //Click on Add New Item Button
            addNewItemButton.Clicked += AddNewItemButton_Clicked;

            //When a new word is added the list is refreshed
            MessagingCenter.Subscribe <MyPopupPage>(this, "newWord", (sender) => {
                layout.Children.Remove(list_words);
                list_words.ItemsSource = Listing();
                layout.Children.Add(list_words);
            });

            //When reading the user words from file, updates the list
            MessagingCenter.Subscribe <ReadDictFiles>(this, "fileReadingDone", (sender) => {
                layout.Children.Remove(list_words);
                list_words.ItemsSource = Listing();
                layout.Children.Add(list_words);
            });
        }