public ShellViewModel( INavigationService navigationService, IStorageService storageService, IAccountService authService, IApiHttpHelper httpHelper, Context context) { this.navigationService = navigationService; this.storageService = storageService; this.authService = authService; this.httpHelper = httpHelper; this.Context = context; var list = new List <MenuItem> { //new MenuItem //{ // Title = Constants.TextHome, // Icon = Constants.IconHome, // Type = typeof(HomePage) //}, new MenuItem { Title = Constants.TextFind, Icon = Constants.IconCategory, Type = typeof(CategoriesPage) }, new MenuItem { Title = Constants.TextSearch, Icon = Constants.IconFind, Type = typeof(FindPage) }, new MenuItem { Title = Constants.TextMine, Icon = Constants.IconMine, Type = typeof(MinePage) }, new MenuItem { Title = Constants.TextDownload, Icon = Constants.IconDownload, Type = typeof(DownloadPage) }, new MenuItem { Title = Constants.TextSetting, Icon = Constants.IconSetting, Type = typeof(SettingPage) }, }; Menu = new ObservableCollection <MenuItem>(list); this.Context.ShowMessageHandler += msg => { PopupMessage.ShowMessage(msg); }; }
public ImageViewerViewModel(IApiHttpHelper httpHelper, IThemeService themeService, IAccountService accountService, Context context) { this.httpHelper = httpHelper; this.themeService = themeService; this.Context = context; }
public PickPinPaneViewModel(IApiHttpHelper httpHelper, IThemeService themeService, IAccountService accountService, Context context) { this.httpHelper = httpHelper; this.themeService = themeService; this.accountService = accountService; this.Context = context; BoardList = new IncrementalLoadingList <Board>(GetMyBoards); }
public MineViewModel(LoginViewModel loginViewModel, IApiHttpHelper httpHelper, Context context) : base(context) { this.LoginViewModel = loginViewModel; this.httpHelper = httpHelper; this.ViewModel = context.User == null ? LoginViewModel : GetCurrentUserViewModel(); this.Context.PropertyChanged += (sender, e) => { if (e.PropertyName == "User") { ViewModel = context.User == null ? LoginViewModel : GetCurrentUserViewModel(); } }; }
public CategoriesViewModel(IApiHttpHelper httpHelper, Context context) : base(context) { this.HttpHelper = httpHelper; this.CategoryVisibility = Visibility.Collapsed; this.CategoryHeaderVisibility = Visibility.Visible; this.DataTypes = new ObservableCollection <DataType>() { new DataType { Title = "采集", BaseUrl = "", DataLoaderAsync = LoaderAsync <PinCollection, Pin>, UrlAction = GetCategoryUrl, }, new DataType { Title = "画板", BaseUrl = Constants.ApiBoardsName, DataLoaderAsync = LoaderAsync <BoardCollection, Board>, UrlAction = GetCategoryUrl, }, new DataType { Title = "用户", BaseUrl = "users", DataLoaderAsync = LoaderAsync <FavoriteUserCollection, PUser>, UrlAction = GetCategoryUrl, ScaleSize = "4:5", }, }; this.DataType = DataTypes[0]; this.Categories = new IncrementalLoadingList <Category>(GetCategoriesAsync); this.Categories.Add(Constants.CategoryAll); this.Categories.Add(Constants.CategoryHot); this.SelectedCategory = Constants.CategoryAll; this.Data = new IncrementalLoadingList <IModel>(GetPinsAsync) { AfterAddItems = o => { if (ExtendedGridView != null) { ExtendedGridView.Width = double.NaN; } } }; }
public ListViewModel( Context context, DataType dataType, IApiHttpHelper httpHelper, Func <string, IEnumerable <T> > converter, Func <T, string> feedKeyfunc = null, ListViewModelType type = ListViewModelType.Max) { this.Context = context; this.DataType = dataType; this.HttpHelper = httpHelper; this.Converter = converter; this.feedKeyfunc = feedKeyfunc; this.Type = type; this.Data = new IncrementalLoadingList <T>(GetData); }
public FindViewModel(IApiHttpHelper httpHelper, Context context) : base(context) { this.HttpHelper = httpHelper; this.DataTypes = new ObservableCollection <DataType>() { new DataType { Title = "采集", BaseUrl = "search", DataLoaderAsync = LoaderAsync <PinCollection, Pin>, UrlAction = GetSearchUrl, }, new DataType { Title = "画板", BaseUrl = "search/boards", DataLoaderAsync = LoaderAsync <BoardCollection, Board>, UrlAction = GetSearchUrl, }, new DataType { Title = "用户", BaseUrl = "search/users", DataLoaderAsync = LoaderAsync <UserCollection, User>, UrlAction = GetSearchUrl, ScaleSize = "4:5", }, }; this.DataType = this.DataTypes[0]; this.Data = new IncrementalLoadingList <IModel>(GetPinsAsync) { AfterAddItems = _ => { if (ExtendedGridView != null) { ExtendedGridView.Width = double.NaN; } } }; }
public Service(IApiHttpHelper httpHelper) { this.HttpHelper = httpHelper; }
public UserViewModel(User user, IApiHttpHelper httpHelper, Context context) { this.User = user; this.httpHelper = httpHelper; string urlname = !string.IsNullOrEmpty(this.User.urlname) ? this.User.urlname : this.User.user_id; urlname = urlname + "/"; ListTypes = new List <ViewModelBase> { new ListViewModel <Pin> ( context: context, dataType: new DataType { Title = "采集", Badge = user.pin_count, BaseUrl = urlname + "pins/" }, httpHelper: httpHelper, converter: o => JsonConvert.DeserializeObject <PinCollection>(o).Data, feedKeyfunc: o => o.pin_id.ToString() ), new ListViewModel <Board> ( context: context, dataType: new DataType { Title = "画板", Badge = user.board_count, BaseUrl = urlname + "boards/" }, httpHelper: httpHelper, converter: o => JsonConvert.DeserializeObject <BoardCollection>(o).Data ), new ListViewModel <Pin> ( context: context, dataType: new DataType { Title = "喜欢", Badge = user.like_count, BaseUrl = urlname + "likes/" }, httpHelper: httpHelper, converter: o => JsonConvert.DeserializeObject <PinCollection>(o).Data, feedKeyfunc: o => o.seq.ToString() ), new ListViewModel <User> ( context: context, dataType: new DataType { Title = "粉丝", Badge = user.follower_count, BaseUrl = urlname + "followers/", ScaleSize = "4:5", }, httpHelper: httpHelper, converter: o => JsonConvert.DeserializeObject <UserCollection>(o).Data, feedKeyfunc: o => o.seq.ToString() ), new ListViewModel <User> ( context: context, dataType: new DataType { Title = "关注用户", Badge = user.following_count, BaseUrl = urlname + "following", ScaleSize = "4:5", }, httpHelper: httpHelper, converter: o => JsonConvert.DeserializeObject <UserCollection>(o).Data, feedKeyfunc: o => o.seq.ToString() ), new ListViewModel <Board> ( context: context, dataType: new DataType { Title = "关注画板", Badge = user.muse_board_count, BaseUrl = urlname + "following/boards" }, httpHelper: httpHelper, converter: o => JsonConvert.DeserializeObject <BoardCollection>(o).Data, type: ListViewModelType.Page ) }; }