コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: liudii337/Luo
        private async Task GenerateActivityAsync(VolItem volItem)
        {
            // Get the default UserActivityChannel and query it for our UserActivity. If the activity doesn't exist, one is created.
            UserActivityChannel channel = UserActivityChannel.GetDefault();

            // The text here should be treated as a title for this activity and should be unique to this app.
            UserActivity userActivity = await channel.GetOrCreateUserActivityAsync("LuoVol." + volItem.Vol.VolNum);

            // Populate required properties: DisplayText and ActivationUri are required.
            userActivity.VisualElements.DisplayText = "Luoo-UWP Timeline activities";

            // The name in the ActivationUri must match the name in the protocol setting in the manifest file (except for the "://" part).
            userActivity.ActivationUri = new Uri("luoo://?volnum=" + volItem.Vol.VolNum);

            // Build the adaptive card from a JSON string.
            userActivity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(apodTimelineCard.ToJson());

            // Set the mime type of the user activity, in this case, an application.
            userActivity.ContentType = "application/octet-stream";

            // Save the new metadata.
            await userActivity.SaveAsync();

            // Dispose of any current UserActivitySession, and create a new one.
            _currentActivity?.Dispose();
            _currentActivity = userActivity.CreateSession();
        }
コード例 #2
0
        private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            VolItem item = (VolItem)e.ClickedItem;
            await item.GetVolDetialAsync();

            MainVM.CurrentVol = item;
        }
コード例 #3
0
ファイル: MainViewModel.cs プロジェクト: liudii337/Luo
        private void CreateAdaptiveCardForTimeline(VolItem volItem)
        {
            // Create an adaptive card specifically to reference this app in Windows 10 Timeline.
            apodTimelineCard = new AdaptiveCard("1.0")
            {
                // Select a good background image.
                BackgroundImage = new Uri(volItem.Vol.Cover)
            };

            // Add a heading to the card, which allows the heading to wrap to the next line if necessary.
            var apodHeading = new AdaptiveTextBlock
            {
                Text     = "Vol." + volItem.Vol.VolNum + " " + volItem.Vol.Title,
                Size     = AdaptiveTextSize.Large,
                Weight   = AdaptiveTextWeight.Bolder,
                Wrap     = true,
                MaxLines = 2
            };

            apodTimelineCard.Body.Add(apodHeading);

            // Add a description to the card, and note that it can wrap for several lines.
            var apodDesc = new AdaptiveTextBlock
            {
                Text     = volItem.Vol.Description,
                Size     = AdaptiveTextSize.Default,
                Weight   = AdaptiveTextWeight.Lighter,
                Wrap     = true,
                MaxLines = 4,
            };

            apodTimelineCard.Body.Add(apodDesc);
        }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: liudii337/Luo
        private async void CreatVolPlayTimelineAsync(VolItem volItem)
        {
            // First create the adaptive card.
            CreateAdaptiveCardForTimeline(volItem);

            // Second record the user activity.
            await GenerateActivityAsync(volItem);
        }
コード例 #5
0
 public void RemoveVol(VolItem item)
 {
     if (IsHeartedVol(item))
     {
         HeartVols.Remove(item);
         ToastService.SendToast("已取消收藏");
     }
 }
コード例 #6
0
 public void AddVol(VolItem item)
 {
     if (!IsHeartedVol(item))
     {
         HeartVols.Add(item);
         ToastService.SendToast("期刊已收藏");
     }
 }
コード例 #7
0
ファイル: VolListPage.xaml.cs プロジェクト: liudii337/Luo
        private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            VolItem item = (VolItem)e.ClickedItem;

            if (!item.Vol.IsDetailGet)
            {
                item.GetVolDetialAsync();
            }

            MainVM.CurrentVol = item;
            MainNavigateToEvent(typeof(VolDetialPage));
        }
コード例 #8
0
ファイル: VolItemTemplate.xaml.cs プロジェクト: liudii337/Luo
        private void ToggleItemPointOverAnimation(FrameworkElement mask, FrameworkElement img, FrameworkElement btn, VolItem volItem, bool show)
        {
            var maskVisual = mask.GetVisual();
            var imgVisual  = img.GetVisual();
            var btnVisual  = btn.GetVisual();

            var fadeAnimation  = CreateFadeAnimation(show);
            var scaleAnimation = CreateScaleAnimation(show);

            if (imgVisual.CenterPoint.X == 0 && imgVisual.CenterPoint.Y == 0)
            {
                imgVisual.CenterPoint = new Vector3((float)mask.ActualWidth / 2, (float)mask.ActualHeight / 2, 0f);
            }

            if (!volItem.IsHeartVol)
            {
                btnVisual.StartAnimation("Opacity", fadeAnimation);
            }

            maskVisual.StartAnimation("Opacity", fadeAnimation);

            imgVisual.StartAnimation("Scale.x", scaleAnimation);
            imgVisual.StartAnimation("Scale.y", scaleAnimation);
        }
コード例 #9
0
#pragma warning restore
        public bool IsHeartedVol(VolItem item)
        {
            return(HeartVols.Any(p => p.TitleString == item.TitleString));
        }