public void SetTitleInfo(Category category) { if (category != null && !category.Equals(Category)) { if (category.ImagePath != null) { try { _imageCategoryView.SetImageBitmap(BitmapFactory.DecodeFile(category.ImagePath)); } catch (Exception) { //TODO : log error } LayoutParams param = (LayoutParams)_textCategoryView.LayoutParameters; param.SetMargins(60,0,60,0); _textCategoryView.LayoutParameters = param; } else { LayoutParams param = (LayoutParams)_textCategoryView.LayoutParameters; param.SetMargins(120,0,60,0); _textCategoryView.LayoutParameters = param; _imageCategoryView.SetImageDrawable(new ColorDrawable(Color.Red)); } _textCategoryView.Text = category.Text; _category = category; } }
private void OnCategorySelected(Category category) { MessageDialogService.DismissDialog(DialogId); if (SelectedCallback != null) { SelectedCallback(category); } }
private void GoIntoAction(Category category) { if (!category.HasChildren) { var trad = DependencyService.Container.Resolve<ILocalizationService>(); var message = trad.GetString("Collection_CategoryEmpty", "Text"); LazyResolver<IPopupService>.Service.DisplayPopup(message); } else { PushCategory(category); } }
#pragma warning disable 1998 public async Task InitializeAsync() #pragma warning restore 1998 { string dbPath = LazyResolver<IStorageService>.Service.DatabasePath; // Initialize connection _connection = new SQLiteConnection(_platform, dbPath); _connection.CreateTable<IndiagramSql>(); // Load all the database _databaseContent = Connection.Table<IndiagramSql>().OrderBy(x => x.ParentId).ThenBy(x => x.Position).ToList(); // Load the collection Category collectionRoot = new Category { Id = IndiagramSql.ROOT_PARENT }; List<Category> categories = new List<Category> { collectionRoot }; for (int i = 0; i < categories.Count; ++i) { Category category = categories[i]; GetInterval(_databaseContent, category.Id).ForEach(x => { Indiagram indiagram = x.ToModel(); indiagram.Parent = category; category.Children.Add(indiagram); if (indiagram.IsCategory) { categories.Add(indiagram as Category); } }); } collectionRoot.Children.ForEach(x => { x.Parent = null; Collection.Add(x); }); _databaseContent = _databaseContent.OrderBy(x => x.Id).ToList(); IsInitialized = true; }
private void OnCategorySelected(Category category) { if (!Data.Model.Indiagram.AreSameIndiagram(CurrentIndiagram.Parent, category)) { CurrentIndiagram.Parent = category; RefreshBrothers(); } }
protected AbstractBrowserViewModel() { NextCommand = new DelegateCommand(NextAction); IndiagramSelectedCommand = new DelegateCommand<Indiagram>(IndiagramSelectedAction); // Load collection ObservableCollection<Indiagram> collection = CollectionStorageService.Collection; _rootCollection = new Category(collection) { Text = LocalizationService.GetString("Collection_RootCategoryName", "Text"), ImagePath = StorageService.ImageRootPath, }; }
protected void PushCategory(Category category, bool canBePopped = true) { if (_navigationStack.Any()) { _navigationStack.Peek().Children.CollectionChanged -= OnCollectionChanged; } _canCategoryBePopped = canBePopped; category.Children.CollectionChanged += OnCollectionChanged; _navigationStack.Push(category); RaisePropertyChanged("CurrentCategory"); RewindCategory(); RefreshDisplayList(); }
private void PushCategory(Category category) { _navigationStack.Push(category); CollectionOffset = 0; CurrentCategory = category; }
public UserViewModel() { Category rootCategory = new Category(CollectionStorageService.Collection) { Id = -1, Text = LocalizationService.GetString("Collection_RootCategoryName", "Text"), ImagePath = StorageService.ImageRootPath, }; _correctionCategory = new Category { Id = -2, Text = LocalizationService.GetString("Collection_CorrectionCategoryName", "Text"), ImagePath = StorageService.ImageCorrectionPath }; CollectionIndiagramSelectedCommand = new DelegateCommand<Indiagram>(CollectionIndiagramSelectedAction); CollectionIndiagramDragStartCommand = new DelegateCommand<Indiagram>(CollectionIndiagramDragStartAction); SentenceIndiagramSelectedCommand = new DelegateCommand<IndiagramUIModel>(SentenceIndiagramSelectedAction); EnterCorrectionModeCommand = new DelegateCommand(EnterCorrectionModeAction); CollectionNextCommand = new DelegateCommand(CollectionNextAction); ReadSentenceCommand = new DelegateCommand(ReadSentenceAction); PushCategory(rootCategory); TextToSpeechService.SpeakingCompleted += OnIndiagramReadCompleted; }
private void DeleteTree(Category category) { if (category == null) { return; } category.Children.ForEach(x => { IndiagramSql indiagram = SearchById(x.Id); if (x.IsCategory) { DeleteTree(x as Category); } _databaseContent.Remove(indiagram); try { Connection.Delete<IndiagramSql>(indiagram.Id); } catch (Exception) { //TODO : log error } }); }