Example #1
0
        private void WaterfallListView_Holding(object sender, HoldingRoutedEventArgs e)
        {
            ListView listView = (ListView)sender;

            tapped = ((FrameworkElement)e.OriginalSource).DataContext as ViewModels.WaterfallItemViewModel;
            if (tapped == null)
            {
                return;
            }
            quickStar.Text = (tapped.IsBookmarked) ?
                             OverAll.GetResourceString("DeleteBookmarkPlain") :
                             OverAll.GetResourceString("QuickBookmarkPlain");
            quickStar.IsEnabled = tapped.Title != null;
            quickActions.ShowAt(listView, e.GetPosition(listView));
        }
Example #2
0
        private async void NavControl_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
        {
            if (OverAll.AppUri != null)
            {
                return;
            }
            if (_programmablechange)
            {
                _programmablechange = false;
                await HideNacPlaceHolder();

                return;
            }
            switch (sender.MenuItems.IndexOf(args.SelectedItem))
            {
            case 0:
                OverAll.RefreshRecommendList();
                ContentFrame.Navigate(typeof(WaterfallPage), WaterfallPage.ListContent.Recommend, App.FromRightTransitionInfo);
                await HideNacPlaceHolder();

                break;

            case 1:
                OverAll.RefreshBookmarkList();
                ContentFrame.Navigate(typeof(WaterfallPage), WaterfallPage.ListContent.Bookmark, App.FromRightTransitionInfo);
                await HideNacPlaceHolder();

                break;

            case 2:
                OverAll.RefreshFollowingList();
                ContentFrame.Navigate(typeof(WaterfallPage), WaterfallPage.ListContent.Following, App.FromRightTransitionInfo);
                await HideNacPlaceHolder();

                break;

            case 3:
                OverAll.RefreshRankingList();
                ContentFrame.Navigate(typeof(WaterfallPage), WaterfallPage.ListContent.Ranking, App.FromRightTransitionInfo);
                await HideNacPlaceHolder();

                break;
            }
        }
Example #3
0
        async Task loadContents()
        {
            var res = await new PixivAppAPI(Data.OverAll.GlobalBaseAPI)
                      .GetUserDetailAsync(userid.ToString());

            detail = Data.UserDetail.FromObject(res);
            string _getText(string input) => (input == "") ? OverAll.GetResourceString("PrivatePlain") : input;

            txtUsername.Text      = detail.Name;
            txtAuthor.Text        = detail.Name;
            txtAccount.Text       = "@" + detail.Account;
            txtAuthorAccount.Text = txtAccount.Text;
            txtWebPage.Text       = (detail.WebPage == "") ? OverAll.GetResourceString("PrivateOrNonePlain") : detail.WebPage;
            if (detail.Gender == "")
            {
                txtGender.Text = OverAll.GetResourceString("PrivatePlain");
            }
            else
            {
                txtGender.Text = (detail.Gender == "male") ? OverAll.GetResourceString("MalePlain") : OverAll.GetResourceString("FemalePlain");
            }
            txtBirthday.Text = _getText(detail.BirthDay);
            txtRegion.Text   = _getText(detail.Region);
            txtJob.Text      = _getText(detail.Job);
            string _getHW(string input) => (input == "") ? OverAll.GetResourceString("UnknownPlain") : input;

            txtPC.Text            = _getHW(detail.PC);
            txtMonitor.Text       = _getHW(detail.Monitor);
            txtTool.Text          = _getHW(detail.Tool);
            txtScanner.Text       = _getHW(detail.Scanner);
            txtTablet.Text        = _getHW(detail.Tablet);
            txtMouse.Text         = _getHW(detail.Mouse);
            txtPrinter.Text       = _getHW(detail.Printer);
            txtDesktop.Text       = _getHW(detail.Desktop);
            txtMusic.Text         = _getHW(detail.Music);
            txtDesk.Text          = _getHW(detail.Desk);
            txtChair.Text         = _getHW(detail.Chair);
            txtBtnFollow.Text     = detail.IsFollowed ? OverAll.GetResourceString("FollowingPlain") : OverAll.GetResourceString("NotFollowingPlain");
            btnFollow.IsChecked   = detail.IsFollowed;
            imgAvatar.ImageSource = await Data.OverAll.LoadImageAsync(detail.AvatarUrl);

            imgAuthor.ImageSource = imgAvatar.ImageSource;
        }
Example #4
0
        private async void btnSetWallpaper_Click(object sender, RoutedEventArgs e)
        {
            if (UserProfilePersonalizationSettings.IsSupported())
            {
                var img  = mainImg.Source as WriteableBitmap;
                var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("wallpaper.png", CreationCollisionOption.ReplaceExisting);

                if (file is null)
                {
                    return;
                }
                using (var fs = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, fs);

                    encoder.SetPixelData(BitmapPixelFormat.Bgra8,
                                         BitmapAlphaMode.Premultiplied,
                                         (uint)img.PixelWidth,
                                         (uint)img.PixelHeight,
                                         96.0,
                                         96.0,
                                         await Data.OverAll.ImageToBytes(img));
                    await encoder.FlushAsync();

                    await fs.FlushAsync();
                }
                if (await UserProfilePersonalizationSettings.Current.TrySetWallpaperImageAsync(file))
                {
                    await ShowTip(OverAll.GetResourceString("SetWallpaper_Done"));
                }
                else
                {
                    await new MessageDialog(OverAll.GetResourceString("SetWallpaper_Failed")).ShowAsync();
                }
            }
            else
            {
                await new MessageDialog(OverAll.GetResourceString("SetWallpaper_NoSupported")).ShowAsync();
            }
        }
        private async void TxtWord_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            if (string.IsNullOrWhiteSpace(txtWord.Text))
            {
                return;
            }
            if (txtWord.Text.Trim() != lastWord || cbSearchTarget.SelectedIndex != lastSearchTarget ||
                cbSort.SelectedIndex != lastSort || cbDuration.SelectedIndex != lastDuration)
            {
                if (resultFrame.Content != null)
                {
                    (resultFrame.Content as WaterfallPage).ItemsSource.CollectionChanged -= ItemsSource_CollectionChanged;
                }
                var param = new OverAll.SearchParam()
                {
                    Word = txtWord.Text.Trim()
                };
                switch (cbSearchTarget.SelectedIndex)
                {
                case 0:
                    param.SearchTarget = "partial_match_for_tags";
                    break;

                case 1:
                    param.SearchTarget = "exact_match_for_tags";
                    break;

                case 2:
                    param.SearchTarget = "title_and_caption";
                    break;
                }
                switch (cbSort.SelectedIndex)
                {
                case 0:
                    param.Sort = "date_desc";
                    break;

                case 1:
                    param.Sort = "date_asc";
                    break;
                }
                switch (cbDuration.SelectedIndex)
                {
                case 0:
                    param.Duration = null;
                    break;

                case 1:
                    param.Duration = "within_last_day";
                    break;

                case 2:
                    param.Duration = "within_last_week";
                    break;

                case 3:
                    param.Duration = "within_last_month";
                    break;
                }
                OverAll.RefreshSearchResultList(param);
                resultFrame.Navigate(typeof(WaterfallPage), WaterfallPage.ListContent.SearchResult, App.FromRightTransitionInfo);
                (resultFrame.Content as WaterfallPage).ItemsSource.CollectionChanged += ItemsSource_CollectionChanged;
            }
            storyFade.Begin();
            await Task.Delay(200);

            grdSearchPanel.Visibility = Visibility.Collapsed;
            if (txtWord.Text.Trim() != lastWord || cbSearchTarget.SelectedIndex != lastSearchTarget ||
                cbSort.SelectedIndex != lastSort || cbDuration.SelectedIndex != lastDuration)
            {
                lastWord                      = txtWord.Text.Trim();
                lastSearchTarget              = cbSearchTarget.SelectedIndex;
                lastSort                      = cbSort.SelectedIndex;
                lastDuration                  = cbDuration.SelectedIndex;
                searchProgressRing.IsActive   = true;
                searchProgressRing.Visibility = Visibility.Visible;
            }
        }
Example #6
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     OverAll.TheMainPage.SelectNavPlaceholder(OverAll.GetResourceString("DownloadsPlain"));
     NavControl.SelectedItem = NavControl.MenuItems[1];
 }
Example #7
0
        private async void QuickStar_Click(object sender, RoutedEventArgs e)
        {
            if (tapped == null)
            {
                return;
            }
            var i     = tapped;
            var title = i.Title;

            try
            {
                //用Title作标识,表明任务是否在执行
                i.Title = null;
                if (i.IsBookmarked)
                {
                    bool res;
                    try
                    {
                        await new PixivAppAPI(Data.OverAll.GlobalBaseAPI)
                        .PostIllustBookmarkDeleteAsync(i.ItemId.ToString());
                        res = true;
                    }
                    catch
                    {
                        res = false;
                    }
                    i.Title = title;
                    if (res)
                    {
                        i.IsBookmarked = false;
                        i.Stars--;
                        i.NotifyChange("StarsString");
                        i.NotifyChange("IsBookmarked");
                        await OverAll.TheMainPage?.ShowTip(string.Format(OverAll.GetResourceString("DeletedBookmarkPlain"), title));
                    }
                    else
                    {
                        await OverAll.TheMainPage?.ShowTip(string.Format(OverAll.GetResourceString("BookmarkDeleteFailedPlain"), title));
                    }
                }
                else
                {
                    bool res;
                    try
                    {
                        await new PixivAppAPI(Data.OverAll.GlobalBaseAPI)
                        .PostIllustBookmarkAddAsync(i.ItemId.ToString());
                        res = true;
                    }
                    catch
                    {
                        res = false;
                    }
                    i.Title = title;
                    if (res)
                    {
                        i.IsBookmarked = true;
                        i.Stars++;
                        i.NotifyChange("StarsString");
                        i.NotifyChange("IsBookmarked");
                        await OverAll.TheMainPage?.ShowTip(string.Format(OverAll.GetResourceString("WorkBookmarkedPlain"), title));
                    }
                    else
                    {
                        await OverAll.TheMainPage?.ShowTip(string.Format(OverAll.GetResourceString("WorkBookmarkFailedPlain"), title));
                    }
                }
            }
            finally
            {
                //确保出错时数据不被破坏
                i.Title = title;
            }
        }
Example #8
0
        private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
        {
            var request = args.Request;

            request.Data.SetText(string.Format("{0}\n{1}\n" +
                                               "{2}:https://www.pixiv.net/member.php?id={3}\n" +
                                               "PixivFSUWP:pixiv://user?id={3}", OverAll.GetResourceString("PixivUserPlain"), detail.Name, OverAll.GetResourceString("LinkPlain"), detail.ID));
            request.Data.Properties.Title       = string.Format("{0}:{1}", OverAll.GetResourceString("ArtistPlain"), detail.Name);
            request.Data.Properties.Description = OverAll.GetResourceString("UserShareTipPlain");
        }
Example #9
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     ((Frame.Parent as Grid)?.Parent as MainPage)?.SelectNavPlaceholder(OverAll.GetResourceString("DownloadedCaption\\Content"));
 }