示例#1
0
        private void RevealCategoriesDialog()
        {
            var inflater = GetSystemService(Context.LayoutInflaterService) as LayoutInflater;

            _categoriesList.RemoveAllViews();
            View view = this.CurrentFocus;

            if (view != null)
            {
                (this.GetSystemService(InputMethodService) as InputMethodManager)
                .HideSoftInputFromWindow(view.WindowToken, 0);
            }
            foreach (var category in NoteStorage.GetCurrentCategories(this))
            {
                View entry = inflater.Inflate(Resource.Layout.CategoriesDialogItem, null);
                entry.FindViewById <Button>(Resource.Id.categoriesDialogEntryText).Text     = category;
                entry.FindViewById <Button>(Resource.Id.categoriesDialogEntryText).Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/MINIONPRO-REGULAR.OTF");
                entry.Click += (object sender, EventArgs e)
                               => { _categoriesListButton.Text = category;
                                    _categoriesListButton.Tag  = NoteStorage.GetCurrentCategories(this).IndexOf(category);
                                    FindViewById <RelativeLayout>(Resource.Id.categoriesDialogBG).Visibility = ViewStates.Invisible; };
                _categoriesList.AddView(entry);
            }
            FindViewById <RelativeLayout>(Resource.Id.categoriesDialogBG).Visibility = ViewStates.Visible;
        }
示例#2
0
        /// <summary>
        /// UI views acquisition and initialization
        /// </summary>
        private void InitializeUI()
        {
            _noteText                    = FindViewById <EditText>(Resource.Id.noteText);
            _saveButton                  = FindViewById <ImageButton>(Resource.Id.saveNoteButton);
            _categoriesListButton        = FindViewById <Button>(Resource.Id.categoriesListButton);
            _categoriesList              = FindViewById <LinearLayout>(Resource.Id.categoriesDialogEntriesList);
            _categoriesListButton.Click += (object sender, EventArgs e) => RevealCategoriesDialog();
            FindViewById <RelativeLayout>(Resource.Id.categoriesDialogBG).Click      += (object sender, EventArgs e) => (sender as RelativeLayout).Visibility = ViewStates.Invisible;
            FindViewById <LinearLayout>(Resource.Id.categoriesDialogContainer).Click += (object sender, EventArgs e) => { };
            FindViewById <TextView>(Resource.Id.categoriesDialogTitle).Typeface       = Typeface.CreateFromAsset(this.Assets, "fonts/MINIONPRO-REGULAR.OTF");
            _categoriesListButton.Typeface = Typeface.CreateFromAsset(this.Assets, "fonts/MINIONPRO-REGULAR.OTF");
            _saveButton.Click += (object sender, EventArgs e) => UpdateNotes();

            if (_originalNote != null)
            {
                _noteText.Text             = _originalNote.Text;
                _categoriesListButton.Text = NoteStorage.GetCurrentCategories(this)[_originalNote.CategoryId];
                _categoriesListButton.Tag  = _originalNote.CategoryId;
            }
            else
            {
                _categoriesListButton.Text = NoteStorage.GetCurrentCategories(this)[0];
                _categoriesListButton.Tag  = 0;
            }
        }
示例#3
0
        /// <summary>
        /// Populate list with categories
        /// </summary>
        /// <param name="layout">List layout</param>
        private void PopulateList(LinearLayout layout)
        {
            layout.RemoveAllViews();

            View entry = View.Inflate(_rootActivity, Resource.Layout.CategoriesListItem, null);

            entry.FindViewById <TextView>(Resource.Id.categoryName).Text = _rootActivity.GetString(Resource.String.All);
            entry.FindViewById <TextView>(Resource.Id.categoryName).SetTextColor(BuildColor(_rootActivity.GetString(Resource.String.All)));
            entry.FindViewById <TextView>(Resource.Id.categoryName).Typeface = Typeface.CreateFromAsset(_rootActivity.Assets, "fonts/MINIONPRO-REGULAR.OTF");
            entry.FindViewById <TextView>(Resource.Id.notesCount).Text       = $"({NoteStorage.Notes.Count.ToString()})";

            entry.Click += (object sender, EventArgs e) =>
            {
                if (_selectedEntrys.Count == 0)
                {
                    NotesListFragment.ChangeDataSet(NoteStorage.Notes);
                    MainPageActivity.Navigation.SetCurrentItem(0, true);
                    _selectedCategory = _rootActivity.GetString(Resource.String.All);
                    Refresh(layout);
                }
            };
            entry.LongClick += (object sender, View.LongClickEventArgs e) => { };
            layout.AddView(entry);

            foreach (string category in NoteStorage.GetCurrentCategories(_rootActivity))
            {
                int id = NoteStorage.GetCurrentCategories(_rootActivity).IndexOf(category);
                entry = View.Inflate(_rootActivity, Resource.Layout.CategoriesListItem, null);
                entry.FindViewById <TextView>(Resource.Id.categoryName).Text = category;
                entry.FindViewById <TextView>(Resource.Id.categoryName).SetTextColor(BuildColor(category));
                entry.FindViewById <TextView>(Resource.Id.categoryName).Typeface = Typeface.CreateFromAsset(_rootActivity.Assets, "fonts/MINIONPRO-REGULAR.OTF");
                entry.FindViewById <TextView>(Resource.Id.notesCount).Text       = $"({NoteStorage.Notes.Where(n => n.CategoryId == id).Count().ToString()})";
                entry.Click += (object sender, EventArgs e) =>
                {
                    if (_selectedEntrys.Count == 0)
                    {
                        NotesListFragment.ChangeDataSet(NoteStorage.Notes.Where(n => n.CategoryId == id).ToList());
                        MainPageActivity.Navigation.SetCurrentItem(0, true);
                        _selectedCategory = category;
                        Refresh(layout);
                    }
                };
                if (category != NoteStorage.GetCurrentCategories(_rootActivity)[0])
                {
                    entry.Click += (object sender, EventArgs e) => { if (_selectedEntrys.Count > 0)
                                                                     {
                                                                         LongClickSelectEntry(sender as View);
                                                                     }
                    };
                    entry.LongClick += (object sender, View.LongClickEventArgs e) => LongClickSelectEntry(sender as View);
                }
                else
                {
                    entry.LongClick += (object sender, View.LongClickEventArgs e) => { }
                };
                layout.AddView(entry);
            }
        }
示例#4
0
 /// <summary>
 /// Refreshing list method
 /// </summary>
 /// <param name="layout">List layout</param>
 private void Refresh(LinearLayout layout)
 {
     layout.GetChildAt(0).FindViewById <TextView>(Resource.Id.categoryName).SetTextColor(BuildColor(_rootActivity.GetString(Resource.String.All)));
     for (int i = 1; i < layout.ChildCount; i++)
     {
         layout.GetChildAt(i).FindViewById <TextView>(Resource.Id.categoryName).SetTextColor(BuildColor(NoteStorage.GetCurrentCategories(_rootActivity)[i - 1]));
     }
 }
示例#5
0
 /// <summary>
 /// Remove selected categories
 /// </summary>
 private void RemoveCategories()
 {
     foreach (string category in _selectedEntrys
              .Select(view => view.FindViewById <TextView>(Resource.Id.categoryName).Text))
     {
         foreach (Note note in NoteStorage.Notes.Where(note => note.CategoryId == NoteStorage.GetCurrentCategories(_rootActivity).IndexOf(category)))
         {
             note.CategoryId = 0;
         }
         NoteStorage.RemoveCategory(_rootActivity, category);
     }
     SecurityProvider.SaveNotesAsync();
     _selectedEntrys.Clear();
     HideDeleteButton();
     PopulateList(_list);
 }