private async void DeleteDownloads_OnClick(object sender, RoutedEventArgs e)
        {
            deleteDownloads.IsEnabled = false;

            var ctx = new RisDbContext();
            await ctx.DeleteDownloads();

            MessengerHelper.Notify(MessengerHelper.DownloadsDeleted);
        }
        private async void DeleteHistory_OnClick(object sender, RoutedEventArgs e)
        {
            deleteHistory.IsEnabled = false;

            var ctx = new RisDbContext();
            await ctx.DeleteSearchHistory();

            MessengerHelper.Notify(MessengerHelper.SearchHistoryDeleted);
        }
Ejemplo n.º 3
0
        protected override void SaveState(Dictionary <String, Object> pageState)
        {
            MessengerHelper.Unregister(this, MessengerHelper.SearchHistoryDeleted);
            MessengerHelper.Unregister(this, MessengerHelper.DownloadsDeleted);
            MessengerHelper.Unregister(this, MessengerHelper.DbLoadCompleted);

            var state = ViewModel.SaveState();

            state.SearchHistoryVerticalOffset = ScrollViewerHelpers.GetVerticalOffset(searchHistoryListView);
            state.DownloadsVerticalOffset     = ScrollViewerHelpers.GetVerticalOffset(downloadsListView);

            string serializedState = SerializationHelper.SerializeToString(state);

            pageState[Constants.MainPageState] = serializedState;

            // OnNavigatedFrom would be called *before* SaveState (unless we call base. first), that's why we destroy the references here
            DataContext = null;
            ViewModel   = null;
        }
Ejemplo n.º 4
0
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            MessengerHelper.Register(this, MessengerHelper.SearchHistoryDeleted, SearchHistoryDeleted);
            MessengerHelper.Register(this, MessengerHelper.DownloadsDeleted, DownloadsDeleted);
            MessengerHelper.Register(this, MessengerHelper.DbLoadCompleted, DbLoadCompleted);

            if (pageState != null && pageState.ContainsKey(Constants.MainPageState))
            {
                string serializedState = pageState[Constants.MainPageState].ToString();
                var    state           = SerializationHelper.DeserializeFromString <MainPageState>(serializedState);

                ViewModel.LoadState(state);

                _historyVerticalOffset   = state.SearchHistoryVerticalOffset;
                _downloadsVerticalOffset = state.DownloadsVerticalOffset;
            }

            ViewModel.LoadSearchHistoryAsync(); // intentionally no await
            ViewModel.LoadDownloadsAsync();     // intentionally no await
        }