public void NotifyDisplaysChanged(SmartObservableCollection <DisplayInfo> displays) { if (SelectedMonitorInfo == null) { SelectedMonitorInfo = displays[0]; } SelectedMonitorInfo.Update(displays); if (string.IsNullOrWhiteSpace(_name)) { _name = "Conf 1"; } if (SelectedApps.Count == 0) { Initialize(LayoutType.Layout, _name); } else if (SelectedApps.Count != GridSize.CellCount) { UpdateApps(GridSize); } NotifyPropertyChanged(nameof(Name)); }
public static int FindApp(string title, SmartObservableCollection <AppInfo> apps) { int pos = title.IndexOf("["); int end = title.IndexOf("]"); if (pos < 0 || end < 0) { return(0); } string processInTitle = title.Substring(pos + 1, end - pos - 1); //search first by title for (int i = 1; i < apps.Count; i++) { if (title == apps[i].Title) { return(i); } } //then by process name for (int i = 1; i < apps.Count; i++) { string processName = apps[i].ProcessName; if (processInTitle == processName) { return(i); } } return(0); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { _feedLocator = new LocalFeedLocationService(); CacheDictionary = new Dictionary<Uri, KeyValuePair<DateTime, IList<FeedItemSummary>>>(); FeedTitles = new ObservableCollection<string>(); FeedItems = new SmartObservableCollection<FeedItemSummary>(); Feeds = _feedLocator.GetFeeds(); //Initialize the feeds collection CurrentFeedUri = Feeds[0]; //Initialize the CurrentFeedUri PopulateFeedTitles(); //Initialize the feed titles collection if (IsInDesignMode) { // Code runs in Blend --> create design time data. var designFeed = FeedSummarizer.SummarizeFeed(DesignTimeData.Feeds.First()); PopulateFeedItems(designFeed); } else { // Code runs "for real" _remoteQueryService = new FeedQueryService(new HttpFeedFactory()); LocateFeedUri = new RelayCommand<SelectionChangedEventArgs>(ResolveFeedUri); LoadLastOrDefaultFeed = new RelayCommand(() => ExecuteQuery(CurrentFeedUri, true)); NavigateToUri = new RelayCommand<string>(uri => Messenger.Default.Send<string>(uri, "NavigationRequest")); BeginLoading = new RelayCommand(() => DispatcherHelper.CheckBeginInvokeOnUI(() => { IsLoading = true; })); PopulateItemsList = new RelayCommand(() => { if (FeedIsInCache(CurrentFeedUri.FeedUri)) { UpdateBindings(CacheDictionary[CurrentFeedUri.FeedUri].Value); } else { ExecuteQuery(CurrentFeedUri, bind: true); } }); EndLoading = new RelayCommand(() => DispatcherHelper.CheckBeginInvokeOnUI(() => { if(FeedIsInCache(CurrentFeedUri.FeedUri)) IsLoading = false; })); BuildAllItems = new RelayCommand(() => { foreach(var feed in Feeds) { ExecuteQuery(feed); } }); } }
public new void ReloadData() { var exampleData = new List <SimpleItem>(); var random = new Random(DateTime.Now.Millisecond); var howMany = 60; TotalRecords = 120; for (int i = 0; i < howMany; i++) { exampleData.Add(new SimpleItem() { Title = Guid.NewGuid().ToString("N").Substring(0, 8) }); } var sorted = exampleData .OrderBy(item => item.Title) .GroupBy(item => item.Title[0].ToString()) .Select(itemGroup => new Grouping <string, SimpleItem>(itemGroup.Key, itemGroup, random.Next(1, 6))) .ToList(); sorted.Insert(0, new Grouping <string, SimpleItem>("-")); Items = new SmartObservableCollection <object>(sorted); }
public void Update(SmartObservableCollection <DisplayInfo> displays) { if (Index < 0 || Index >= displays.Count) { Index = 0; } this.screen = displays[Index].screen; }
public async void Init(MalMessageDetailsNavArgs args, bool force = false) { if (args.WorkMode == MessageDetailsWorkMode.Message) { var arg = args.Arg as MalMessageModel; if (arg == null) //compose new { _newMessage = true; MessageSet.Clear(); NewMessageFieldsVisibility = true; ViewModelLocator.GeneralMain.OffRefreshButtonVisibility = false; MessageTarget = args.NewMessageTarget; RaisePropertyChanged(() => MessageTarget); return; } NewMessageFieldsVisibility = false; _newMessage = false; if (!force && _prevMsg?.Id == arg.Id) { return; } _prevMsg = arg; MessageSet.Clear(); LoadingVisibility = true; if (!force && arg.ThreadId != null && MessageThreads.ContainsKey(arg.ThreadId)) { MessageSet.AddRange(MessageThreads[arg.ThreadId]); } else { var msgs = await new MalMessageDetailsQuery().GetMessagesInThread(arg); msgs.Reverse(); MessageSet.AddRange(msgs); } } else { NewMessageFieldsVisibility = false; var arg = args.Arg as MalComment; if (!force && arg.ComToCom == (_prevArgs?.Arg as MalComment)?.ComToCom) { return; } _prevMsg = null; LoadingVisibility = true; MessageSet.Clear(); MessageSet = new SmartObservableCollection <MalMessageModel>( (await ProfileCommentQueries.GetComToComMessages(arg.ComToCom))); RaisePropertyChanged(() => MessageSet); } _prevArgs = args; LoadingVisibility = false; }
public static void PlatformAddRange <T>(this SmartObservableCollection <T> collection, IEnumerable <T> items, PlatformType platformType) { if (platformType == PlatformType.UWP) { foreach (var item in items) { collection.Add(item); } } else { collection.AddRange(items); } }
public async void NavigatedTo(ListComparisonPageNavigationArgs args) { if (args.Equals(_navArgs)) { return; } CurrentItems = new SmartObservableCollection <ComparisonItemViewModel>(); RaisePropertyChanged(() => CurrentItems); _navArgs = args; Loading = true; MyData = await DataCache.RetrieveProfileData(Credentials.UserName); OtherData = await DataCache.RetrieveProfileData(args.CompareWith.Name); RaisePropertyChanged(() => MyData); RaisePropertyChanged(() => OtherData); try { var otherItems = _animeLibraryDataStorage.OthersAbstractions[_navArgs.CompareWith.Name].Item1; foreach (var myItem in _animeLibraryDataStorage.AllLoadedAuthAnimeItems) { var sharedItem = otherItems.FirstOrDefault(abstraction => abstraction.Id == myItem.Id); if (sharedItem != null) { _allSharedItems.Add(new ComparisonItemViewModel(myItem.ViewModel, sharedItem.ViewModel)); } else { _allMyItems.Add(new ComparisonItemViewModel(myItem.ViewModel, null)); } } var usedIds = _allSharedItems.Concat(_allMyItems).Select(model => model.MyEntry.Id); _allOtherItems = otherItems.Where(other => !usedIds.Any(i => i == other.Id)) .Select(abstraction => new ComparisonItemViewModel(null, abstraction.ViewModel)).ToList(); Loading = false; RefreshList(); } catch (Exception) { ResourceLocator.SnackbarProvider.ShowText("Error while retrieving aniem list."); } }
private async void LoadAllClubs() { if (_allClubs == null) { Loading = true; _allClubs = await MalClubQueries.GetClubs(MalClubQueries.QueryType.All, 0); Loading = false; if (_allClubs != null && _allClubs.Any()) { Clubs = new SmartObservableCollection <MalClubEntry>(_allClubs); EmptyNoticeVisibility = false; } else { Clubs = new SmartObservableCollection <MalClubEntry>(); EmptyNoticeVisibility = true; } } }
public void ReloadData() { var exampleData = new SmartObservableCollection <object>(); var howMany = 60; TotalRecords = 240; exampleData.BatchStart(); for (int i = 0; i < howMany; i++) { exampleData.Add(new SimpleItem() { Title = string.Format("Item nr {0}", i) }); } exampleData.BatchEnd(); Items = exampleData; }
void AnimeList_Initialized() { animeItems = ViewModelLocator.AnimeList.AnimeGridItems; }
public BooksViewModel(IBooksService booksService) { _booksService = booksService; Books = new SmartObservableCollection <BookCellViewModel>(); }
public HousesViewModel(IHousesService housesService) { _housesService = housesService; Houses = new SmartObservableCollection <HouseCellViewModel>(); }
public async void Init(MalMessageDetailsNavArgs args,bool force = false) { if (args.WorkMode == MessageDetailsWorkMode.Message) { var arg = args.Arg as MalMessageModel; if (arg == null) //compose new { _newMessage = true; MessageSet.Clear(); NewMessageFieldsVisibility = true; return; } NewMessageFieldsVisibility = false; _newMessage = false; if (!force &&_prevMsg?.Id == arg.Id) return; _prevMsg = arg; MessageSet.Clear(); LoadingVisibility = true; if (MessageThreads.ContainsKey(arg.ThreadId)) { MessageSet.AddRange(MessageThreads[arg.ThreadId]); } else { var msgs = await new MalMessageDetailsQuery().GetMessagesInThread(arg); msgs.Reverse(); MessageSet.AddRange(msgs); } } else { NewMessageFieldsVisibility = false; var arg = args.Arg as MalComment; if(!force && arg.ComToCom == (_prevArgs?.Arg as MalComment)?.ComToCom) return; _prevMsg = null; LoadingVisibility = true; MessageSet.Clear(); MessageSet = new SmartObservableCollection<MalMessageModel>( (await ProfileCommentQueries.GetComToComMessages(arg.ComToCom))); RaisePropertyChanged(() => MessageSet); } _prevArgs = args; LoadingVisibility = false; }
public ViewModel() { _tabItems = new ObservableCollection<TabItem>(); _functions = new SmartObservableCollection<NewFolding>(); }
/// <summary> /// This method is fully responsible for preparing the view. /// Depending on display mode it distributes items to right containers. /// </summary> private void UpdatePageSetup() { AnimeItems = new SmartObservableCollection<AnimeItemViewModel>(); _lastOffset = 0; RaisePropertyChanged(() => DisplayMode); var minItems = GetGridItemsToLoad(); if (CurrentIndexPosition == LastIndexPositionOnRefresh) CurrentIndexPosition = _animeItemsSet.Count + AnimeItems.Count - 1; minItems = minItems < 10 ? 10 : minItems; var minimumIndex = CurrentIndexPosition == -1 ? minItems : CurrentIndexPosition + 1 <= minItems ? minItems : CurrentIndexPosition + 1; switch (DisplayMode) { case AnimeListDisplayModes.IndefiniteCompactList: AnimeItems.AddRange(_animeItemsSet.Take(minimumIndex).Select(abstraction => abstraction.ViewModel)); _animeItemsSet = _animeItemsSet.Skip(minimumIndex).ToList(); break; case AnimeListDisplayModes.IndefiniteList: AnimeItems.AddRange(_animeItemsSet.Take(minimumIndex).Select(abstraction => abstraction.ViewModel)); _animeItemsSet = _animeItemsSet.Skip(minimumIndex).ToList(); break; case AnimeListDisplayModes.IndefiniteGrid: AnimeItems.AddRange(_animeItemsSet.Take(minimumIndex) .Select(abstraction => abstraction.ViewModel)); _animeItemsSet = _animeItemsSet.Skip(minimumIndex).ToList(); break; default: throw new ArgumentOutOfRangeException(); } RaisePropertyChanged(() => AnimeItems); AddScrollHandler(); if (CurrentIndexPosition != -1) { try { ScrollIntoViewRequested?.Invoke(AnimeItems[CurrentIndexPosition]); } catch (Exception) { //no index } CurrentIndexPosition = -1; } ViewModelLocator.GeneralMain.ScrollToTopButtonVisibility = CurrentIndexPosition > minItems ? true : false; Loading = false; _randomedIds = new List<int>(); }
public CharactersViewModel(ICharactersService charactersService) { _charactersService = charactersService; Characters = new SmartObservableCollection <CharacterCellViewModel>(); }
public void LogIn() { _animeItemsSet.Clear(); AnimeItems = new SmartObservableCollection<AnimeItemViewModel>(); RaisePropertyChanged(() => AnimeItems); AllLoadedAnimeItemAbstractions = new List<AnimeItemAbstraction>(); _allLoadedAuthAnimeItems = new List<AnimeItemAbstraction>(); AllLoadedMangaItemAbstractions = new List<AnimeItemAbstraction>(); _allLoadedAuthMangaItems = new List<AnimeItemAbstraction>(); _allLoadedSeasonalAnimeItems = new List<AnimeItemAbstraction>(); ListSource = Credentials.UserName; _prevListSource = ""; }
void AnimeList_Initialized() { animeItems = ViewModelLocator.AnimeList.AnimeGridItems; }
/// <summary> /// Constructs a new instance of SpyHelper. /// </summary> public SpyHelper() { _Packets = new SmartObservableCollection<UltimaPacket>(); _PacketsView = CollectionViewSource.GetDefaultView( _Packets ); }
public MainPageViewModel() { Lands = new SmartObservableCollection<LandModel>(); }
public RanksViewModel() { CommandsInit(); Ranks = new SmartObservableCollection<GroupModel>(); }
public Configuration() { Displays = new SmartObservableCollection <DisplayInfo>(Logic.GetDisplays()); }
public LandPageViewModel() { Organizations = new SmartObservableCollection<OrganizationModel>(); }
public async void Init(AnimeListPageNavigationArgs args) { //base _scrollHandlerAdded = false; Initializing = true; _manuallySelectedViewMode = null; //take out trash _animeItemsSet = new List<AnimeItemAbstraction>(); AnimeItems = new SmartObservableCollection<AnimeItemViewModel>(); RaisePropertyChanged(() => AnimeItems); _randomedIds = new List<int>(); _fetching = _fetchingSeasonal = false; CurrentPage = 1; if (args == null || args.ResetBackNav) ViewModelLocator.NavMgr.ResetMainBackNav(); if (!_queryHandler) { ViewModelLocator.GeneralMain.OnSearchDelayedQuerySubmitted += OnOnSearchDelayedQuerySubmitted; ViewModelLocator.GeneralMain.OnSearchQuerySubmitted += OnOnSearchDelayedQuerySubmitted; } _queryHandler = true; //give visual feedback Loading = true; LoadMoreFooterVisibility = false; await Task.Delay(10); //depending on args var gotArgs = false; if (args != null) //Save current mode { ResetedNavBack = args.ResetBackNav; WorkMode = args.WorkMode; if (WorkMode == AnimeListWorkModes.TopAnime) { TopAnimeWorkMode = args.TopWorkMode; ViewModelLocator.GeneralHamburger.SetActiveButton(args.TopWorkMode);//we have to have it } else if (WorkMode == AnimeListWorkModes.AnimeByGenre) { Genre = args.Genre; } else if(WorkMode == AnimeListWorkModes.AnimeByStudio) { Studio = args.Studio; } if (!string.IsNullOrEmpty(args.ListSource)) ListSource = args.ListSource; else ListSource = Credentials.UserName; if (args.NavArgs) // Use args if we have any { SortDescending = SortDescending = args.Descending; SetSortOrder(args.SortOption); //index SetDesiredStatus(args.Status); CurrentIndexPosition = args.SelectedItemIndex; CurrentSeason = args.CurrSeason; DisplayMode = args.DisplayMode; gotArgs = true; } } else //assume default AnimeList { WorkMode = AnimeListWorkModes.Anime; ListSource = Credentials.UserName; } ViewModelLocator.GeneralHamburger.UpdateAnimeFiltersSelectedIndex(); RaisePropertyChanged(() => CurrentlySelectedDisplayMode); switch (WorkMode) { case AnimeListWorkModes.Manga: case AnimeListWorkModes.Anime: if (!gotArgs) SetDefaults(args?.StatusIndex); AppBtnListSourceVisibility = true; AppbarBtnPinTileVisibility = false; AppBtnSortingVisibility = true; AnimeItemsDisplayContext = AnimeItemDisplayContext.AirDay; if (WorkMode == AnimeListWorkModes.Anime) { SortAirDayVisibility = true; Sort3Label = "Watched"; StatusAllLabel = "All"; Filter1Label = "Watching"; Filter5Label = "Plan to watch"; } else // manga { SortAirDayVisibility = false; Sort3Label = "Read"; StatusAllLabel = "All"; Filter1Label = "Reading"; Filter5Label = "Plan to read"; } //try to set list source - display notice on fail if (string.IsNullOrWhiteSpace(ListSource)) { if (!string.IsNullOrWhiteSpace(Credentials.UserName)) ListSource = Credentials.UserName; } if (string.IsNullOrWhiteSpace(ListSource)) { EmptyNoticeVisibility = true; EmptyNoticeContent = "We have come up empty...\nList source is not set.\nLog in or set it manually."; BtnSetSourceVisibility = true; Loading = false; } else await FetchData(); //we have source we can fetch break; case AnimeListWorkModes.SeasonalAnime: case AnimeListWorkModes.TopAnime: case AnimeListWorkModes.TopManga: case AnimeListWorkModes.AnimeByGenre: case AnimeListWorkModes.AnimeByStudio: Loading = true; EmptyNoticeVisibility = false; AppBtnListSourceVisibility = false; AppBtnGoBackToMyListVisibility = false; BtnSetSourceVisibility = false; ViewModelLocator.NavMgr.DeregisterBackNav(); ViewModelLocator.NavMgr.RegisterBackNav(PageIndex.PageAnimeList, null); if (!gotArgs) { SortDescending = false; SetSortOrder(SortOptions.SortWatched); //index SetDesiredStatus(null); CurrentSeason = null; SeasonSelection.Clear(); } //StatusAllLabel = WorkMode == AnimeListWorkModes.SeasonalAnime ? "Airing" : "All"; Sort3Label = "Index"; await FetchSeasonalData(); if (WorkMode == AnimeListWorkModes.TopAnime || WorkMode == AnimeListWorkModes.TopManga) { AppbarBtnPinTileVisibility = AppBtnSortingVisibility = false; if (CurrentPage <= 4) LoadMoreFooterVisibility = true; AnimeItemsDisplayContext = AnimeItemDisplayContext.Index; } else { if (CurrentPage <= 4) LoadMoreFooterVisibility = true; if (WorkMode == AnimeListWorkModes.AnimeByGenre || WorkMode == AnimeListWorkModes.AnimeByStudio) { AppbarBtnPinTileVisibility = false; AppBtnSortingVisibility = true; } else AppbarBtnPinTileVisibility = AppBtnSortingVisibility = true; AnimeItemsDisplayContext = AnimeItemDisplayContext.AirDay; } break; default: throw new ArgumentOutOfRangeException(); } RaisePropertyChanged(() => LoadAllDetailsButtonVisiblity); SortingSettingChanged?.Invoke(SortOption, SortDescending); Initializing = false; UpdateUpperStatus(); }