Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the session on a background thread
        /// and 
        /// </summary>
        /// <param name="callback"></param>
        public void InitializeAsync(Action callback)
        {
            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += (@s, e) =>
                {
                    Logging.D("Session.InitializeAsync(): Starting Session Initialization");

                    // Create the client
                    Client = new Danbooru2Client(Constants.SiteHostname, Credentials);

                    // Get User Profile
                    User = Client.GetUser(Credentials.Username);

                    // Load User Settings
                    if (!Database.Instance.HasUser(User))
                        Database.Instance.AddUser(User, "s", "new");
                    Database.UserConfig config = Database.Instance.GetUserConfig(User);
                    MaxRating = RatingEx.Parse(config.Rating);

                    Logging.D("Session.InitializeAsync(): Loading posts");

                    // Load Template generator
                    PostViewerTemplate = new PostViewerTemplate("Assets/template.html");

                    // Load first 3 pages
                    NewPosts = new PostTupleCollection();
                    //PostTuple[] tuples = GetMoreNewPosts(3);
                    Post[] newPosts = Client.GetPosts(1, 3, ResolveQueryString(""));
                    NewPosts.AddRange(newPosts);
                };
            bw.RunWorkerCompleted += (@s, e) => callback();
            bw.RunWorkerAsync();
        }
Ejemplo n.º 2
0
 public SearchViewModel(SearchView view)
     : base(view.Dispatcher)
 {
     //SearchResults = new ObservableCollection<PostTuple>();
     SearchResults = new PostTupleCollection();
 }
Ejemplo n.º 3
0
 public HomeViewModel(HomeView view)
     : base(view.Dispatcher)
 {
     PostTuple.SetViewCommand(ViewCommand);
     favorites = new PostTupleCollection();
 }