Пример #1
0
        public async Task <UserActivity> UpdateActivityAsync(ISource <BaseTrack> source, BaseTrack track, IEnumerable <BaseTrack> playlist, string token)
        {
            // We do not support these items
            if (track.ServiceType == ServiceType.ITunesPodcast ||
                track.ServiceType == ServiceType.Local ||
                track.ServiceType == ServiceType.Unknown)
            {
                return(null);
            }

            var activity = await _channel.GetOrCreateUserActivityAsync("SoundByte.Playback");

            activity.FallbackUri = new Uri("https://soundbytemedia.com/pages/remote-subsystem");

            var continueText = $"Continue listening to {track.Title} by {track.User.Username}";

            activity.VisualElements.DisplayText = "Now Playing";
            activity.VisualElements.Description = continueText;

            activity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson("{\"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",\"type\":\"AdaptiveCard\",\"backgroundImage\":\"" + track.ArtworkUrl + "\",\"version\": \"1.0\",\"body\":[{\"type\":\"Container\",\"items\":[{\"type\":\"TextBlock\",\"text\":\"Now Playing\",\"weight\":\"bolder\",\"size\":\"large\",\"wrap\":true,\"maxLines\":3},{\"type\":\"TextBlock\",\"text\":\"" + continueText + ".\",\"size\": \"default\",\"wrap\": true,\"maxLines\": 3}]}]}");

            // Set the activation url using shorthand protocol
            activity.ActivationUri = new Uri($"sb://rs?d={EncodeActivityParameters(source, track, playlist, token)}");

            await activity.SaveAsync();

            return(activity);
        }
Пример #2
0
        public async void GenerateActivityAsync(string websitePage, string title, string content, string backgroundPath)
        {
            // Get the default UserActivityChannel and query it for our UserActivity. If the activity doesn't exist, one is created.
            UserActivityChannel channel      = UserActivityChannel.GetDefault();
            UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync("MainPage");

            var uri = new Uri("moepicture://" + title + "?action=view");

            // Populate required properties
            userActivity.VisualElements.DisplayText = "MoePicture";
            userActivity.ActivationUri = uri;

            var    folder       = Package.Current.InstalledLocation;
            var    file         = await(await folder.GetFolderAsync("JskyUwpLibs")).GetFileAsync("Activities.json");
            string cardJsonText = await FileIO.ReadTextAsync(file);

            dynamic card = JObject.Parse(cardJsonText);

            card.backgroundImage       = backgroundPath;
            card.body[0].items[0].text = title;
            card.body[0].items[1].text = content;
            cardJsonText = JsonConvert.SerializeObject(card);
            // where jsonCardText is a JSON string that represents the card
            userActivity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(cardJsonText);

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

            // Dispose of any current UserActivitySession, and create a new one.
            currentActivity?.Dispose();
            currentActivity = userActivity.CreateSession();
        }
Пример #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var selectedCase = e.Parameter as Case;

            Case = selectedCase;
            Bindings.Update();

            if (App.IsDeepLink)
            {
                return;
            }

            _userActivityChannel = UserActivityChannel.GetDefault();
            _userActivity        = await _userActivityChannel.GetOrCreateUserActivityAsync("Case");

            await Task.Delay(500);

            MessagePanel.Visibility = Visibility.Visible;
            MessageText.Text        = "Saving case to Windows Timeline...";
            await CreateAdaptiveCardForTimelineAsync();

            await Task.Delay(3000);

            MessageText.Text = "Done and you are good to go!";
            await Task.Delay(2000);

            MessagePanel.Visibility = Visibility.Collapsed;
        }
Пример #4
0
        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();
        }
Пример #5
0
        private async Task CreateUserActivityAsync()
        {
            // Get channel and create activity.
            UserActivityChannel channel  = UserActivityChannel.GetDefault();
            UserActivity        activity = await channel.GetOrCreateUserActivityAsync("Scenario2_AdvancedUserActivity");

            // Set deep-link and properties.
            activity.ActivationUri = new Uri("sdkUserActivitySample:page?Scenario2_AdvancedUserActivity");
            activity.VisualElements.DisplayText = "README.md";

            // Add advanced properties.
            activity.ContentUri  = new Uri("https://raw.githubusercontent.com/Microsoft/Windows-universal-samples/master/README.md");
            activity.FallbackUri = new Uri("http://go.microsoft.com/fwlink/p/?LinkId=873257");

            activity.VisualElements.Attribution = new UserActivityAttribution()
            {
                IconUri       = new Uri("https://raw.githubusercontent.com/Microsoft/Windows-universal-samples/master/SharedContent/media/storelogo-sdk.png"),
                AlternateText = "Windows SDK Samples",
                AddImageQuery = false
            };

            activity.VisualElements.BackgroundColor = Color.FromArgb(0xFF, 0x00, 0xb2, 0xf0);
            activity.VisualElements.Description     = "https://raw.githubusercontent.com/Microsoft/Windows-universal-samples/master/README.md";

            // Save to activity feed.
            await activity.SaveAsync();

            // Create a session, which indicates that the user is engaged
            // in the activity.
            _currentSession = activity.CreateSession();
        }
Пример #6
0
        public async Task UpdateActivityAsync(ISource source, Media media, IEnumerable <Media> queue, string token, TimeSpan?timeSpan, bool isShuffled)
        {
            if (media.MediaType != MediaType.Track)
            {
                return;
            }
            var track = (Track)media;

            var activity = await _channel.GetOrCreateUserActivityAsync("last-playback");

            activity.FallbackUri = new Uri("https://soundbytemedia.com/pages/remote-subsystem");

            var continueText = @"Continue listening to " + track.Title.Replace('"', ' ') + " and " + queue.Count() + " other songs.";

            activity.VisualElements.DisplayText = track.Title.Replace('"', ' ');
            activity.VisualElements.Description = continueText;

            var json = @"{""$schema"":""http://adaptivecards.io/schemas/adaptive-card.json"",""type"":""AdaptiveCard"",""backgroundImage"":""" + track.ArtworkUrl + @""",""version"": ""1.0"",""body"":[{""type"":""Container"",""items"":[{""type"":""TextBlock"",""text"":""" + track.Title.Replace('"', ' ') + @""",""weight"":""bolder"",""size"":""large"",""wrap"":true,""maxLines"":3},{""type"":""TextBlock"",""text"":""" + continueText + @""",""size"":""default"",""wrap"":true,""maxLines"":3}]}]}";

            activity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(json);

            activity.ActivationUri = new Uri("https://soundbytemedia.com/pages/remote-subsystem");

            await activity.SaveAsync();

            // Session
            await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
            {
                _currentUserActivitySession?.Dispose();
                _currentUserActivitySession = null;

                _currentUserActivitySession = activity.CreateSession();
            });
        }
Пример #7
0
        private async Task AddTimelineItem(T newItem)
        {
            UserActivityChannel _userActivityChannel = UserActivityChannel.GetDefault();
            UserActivity        _userActivity        = await _userActivityChannel.GetOrCreateUserActivityAsync("TDN");

            // Fetch the adaptive card JSON
            var adaptiveCard = AdaptiveCards.AdaptiveHeaderDescription;

            // Replace the content.
            adaptiveCard = adaptiveCard.Replace("{backgroundImage}", "");
            adaptiveCard = adaptiveCard.Replace("{name}", newItem.Name);
            adaptiveCard = adaptiveCard.Replace("{description}", newItem.Description);

            // Create the protocol, so when the clicks the Adaptive Card on the Timeline, it will directly launch to the correct image.
            //_userActivity.ActivationUri = new Uri($"my-timeline://details?{_galleryItem.ImageSource.Replace("ms-appx:///Assets/Images/", "")}");

            // Set the display text to the User Activity(e.g. Pike Place market.)
            _userActivity.VisualElements.DisplayText = newItem.Name;

            // Assign the Adaptive Card to the user activity.
            _userActivity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(adaptiveCard);

            // Save the details user activity.
            await _userActivity.SaveAsync();

            // Dispose of the session and create a new one ready for the next user activity.
            _userActivitySession?.Dispose();
            _userActivitySession = _userActivity.CreateSession();
        }
Пример #8
0
    private async Task <string> Create(string title, string body, Color background)
    {
        string       id       = random.Next(1, 100000000).ToString();
        UserActivity activity = await _channel.GetOrCreateUserActivityAsync(id);

        activity.VisualElements.DisplayText = title;
        activity.ActivationUri = new Uri(timeline_uri);
        activity.FallbackUri   = new Uri(timeline_uri);
        activity.VisualElements.BackgroundColor = background;
        activity.VisualElements.Description     = body;
        await activity.SaveAsync();

        UserActivitySession session = activity.CreateSession();

        session?.Dispose();
        return(id);
    }
Пример #9
0
 private async void OnWindowLoaded(object sender, RoutedEventArgs e)
 {
     if (_desktopBridgeHelpers.IsRunningAsUwp())
     {
         _userActivityChannel = UserActivityChannel.GetDefault();
         _userActivity        = await _userActivityChannel.GetOrCreateUserActivityAsync("NewBlogPost");
     }
 }
Пример #10
0
        public async Task InitializeUserSessionAsync()
        {
            UserActivityChannel channel = UserActivityChannel.GetDefault();

            _activity = await channel.GetOrCreateUserActivityAsync(_sessionId);

            _activity.ActivationUri = new Uri($"quadrant-app:resume?{_sessionId}");
            _activity.VisualElements.DisplayText = AppUtilities.GetString("AppName");
            await _activity.SaveAsync();

            _session = _activity.CreateSession();
        }
Пример #11
0
        //时间线支持
        public static async Task GenerateActivityAsync(string DisplayText, AdaptiveCard Card, Uri ActivationUri, string ActivityID)
        {
            UserActivityChannel channel      = UserActivityChannel.GetDefault();
            UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync(ActivityID);

            userActivity.VisualElements.DisplayText = DisplayText;
            userActivity.VisualElements.Content     = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(Card.ToJson());
            userActivity.ActivationUri = ActivationUri;
            await userActivity.SaveAsync();

            _currentActivity?.Dispose();
            _currentActivity = userActivity.CreateSession();
        }
Пример #12
0
        private async Task GenerateTimelineActivityAsync(MyTextItem item)
        {
            UserActivityChannel channel      = UserActivityChannel.GetDefault();
            UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync(item.Id.ToString());

            userActivity.VisualElements.DisplayText = item.Content;
            userActivity.VisualElements.Description = $"Last saved: {item.LastModified}";
            userActivity.ActivationUri = new Uri($"mytext://editor?id={item.Id}");

            await userActivity.SaveAsync();

            this.currentActivity?.Dispose();
            this.currentActivity = userActivity.CreateSession();
        }
Пример #13
0
        public async Task AddCardToTimeline(FileViewModel card)
        {
            UserActivityChannel channel      = UserActivityChannel.GetDefault();
            UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync(Guid.NewGuid().ToString());

            userActivity.VisualElements.DisplayText            = "Card error: " + card.Name;
            userActivity.VisualElements.AttributionDisplayText = card.Name;
            userActivity.ActivationUri = new Uri("https://github.com/Microsoft/AdaptiveCards/blob/master/samples/" + card.Name + ".json");

            userActivity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(card.Contents);

            await userActivity.SaveAsync();

            _currentSession?.Dispose();
            _currentSession = userActivity.CreateSession();
        }
Пример #14
0
    public async void Create(string json, string text)
    {
        string       id       = random.Next(1, 100000000).ToString();
        UserActivity activity = await channel.GetOrCreateUserActivityAsync(id);

        activity.VisualElements.DisplayText = text;
        activity.VisualElements.Content     =
            AdaptiveCardBuilder.CreateAdaptiveCardFromJson(json);
        activity.ActivationUri = new Uri(uri);
        activity.FallbackUri   = new Uri(uri);
        await activity.SaveAsync();

        UserActivitySession session = activity.CreateSession();

        session?.Dispose();
    }
Пример #15
0
        public static async Task <UserActivitySession> AddToTimeLine(string area, ModelBase theModel, string bodyText)
        {
            UserActivitySession returnedFromUIThread = await MainThread.InvokeOnMainThreadAsync(async() =>
            {
                UserActivitySession activitySession = null;

                try
                {
                    // Record in the TimeLine
                    UserActivityChannel channel = UserActivityChannel.GetDefault();

                    UserActivity _ModelUserActivity = await channel.GetOrCreateUserActivityAsync(theModel.HLinkKey.Value);

                    if (theModel.Valid)
                    {
                        _ModelUserActivity.VisualElements.DisplayText     = area.ToUpper();
                        _ModelUserActivity.VisualElements.Description     = bodyText;
                        _ModelUserActivity.VisualElements.BackgroundColor = ColorExtensions.ToPlatformColor(theModel.ModelItemGlyph.SymbolColour);

                        // _ModelUserActivity.VisualElements.Content =
                        // AdaptiveCardBuilder.CreateAdaptiveCardFromJson(CreateAdaptiveCardForTimeline(area,
                        // theModel, bodyText).ToJson());

                        _ModelUserActivity.ActivationUri = new Uri("gramps://" + area + @"/handle/" + theModel.HLinkKey);

                        //Save
                        await _ModelUserActivity.SaveAsync();

                        if (_ModelUserActivity != null)
                        {
                            activitySession = _ModelUserActivity.CreateSession();
                        }
                    }
                }
                catch (Exception ex)
                {
                    DataStore.Instance.CN.NotifyException("Timeline Add", ex);

                    throw;
                }

                return(activitySession);
            }).ConfigureAwait(false);

            return(returnedFromUIThread);
        }
Пример #16
0
        async Task CreateUserActivityAsync()
        {
            // Get channel and create activity.
            UserActivityChannel channel  = UserActivityChannel.GetDefault();
            UserActivity        activity = await channel.GetOrCreateUserActivityAsync("Scenario1_BasicUserActivity");

            // Set deep-link and properties.
            activity.ActivationUri = new Uri("useractivitysdkcs:page?Scenario1_BasicUserActivity");
            activity.VisualElements.DisplayText = "User Activity Sample Scenario 1";

            // Save to activity feed.
            await activity.SaveAsync();

            // Create a session, which indicates that the user is engaged
            // in the activity.
            _currentSession = activity.CreateSession();
        }
        public async Task AddToTimeline(Expense expense)
        {
            _userActivityChannel = UserActivityChannel.GetDefault();
            _userActivity        = await _userActivityChannel.GetOrCreateUserActivityAsync($"Expense-{expense.ExpenseId}");

            _userActivity.ActivationUri = new Uri($"contosoexpenses://expense/{expense.ExpenseId}");
            _userActivity.VisualElements.DisplayText = "Contoso Expenses";

            string json = BuildAdaptiveCard(expense);

            _userActivity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(json);

            await _userActivity.SaveAsync();

            _userActivitySession?.Dispose();
            _userActivitySession = _userActivity.CreateSession();
        }
Пример #18
0
        async Task CreateUserActivityAsync()
        {
            // Get channel and create activity.
            UserActivityChannel channel  = UserActivityChannel.GetDefault();
            UserActivity        activity = await channel.GetOrCreateUserActivityAsync("Coupon Reader");

            // Set deep-link and properties.
            activity.VisualElements.DisplayText = "DevIntersection Demo - Coupon Scanned!";
            activity.ActivationUri = new Uri("DevIntersectionDemo://page?MainPage");

            // Save to activity feed.
            await activity.SaveAsync();

            // Dispose prevsion session, Create a new session which indicates that the user is engaged in the activity.
            _currentSession?.Dispose();
            _currentSession = activity.CreateSession();
        }
        async Task CreateUserActivityAsync()
        {
            // Get channel and create activity.
            UserActivityChannel channel  = UserActivityChannel.GetDefault();
            UserActivity        activity = await channel.GetOrCreateUserActivityAsync("SentEmail");

            // Set deep-link and properties.
            activity.VisualElements.DisplayText = "Graph Demo - Email Sent!";
            activity.ActivationUri = new Uri("ignitedemo://page?MainPage");

            // Save to activity feed.
            await activity.SaveAsync();

            // Create a session, which indicates that the user is engaged in the activity.
            _currentSession?.Dispose();
            _currentSession = activity.CreateSession();
        }
Пример #20
0
        private async void GenerateActivityAsync()
        {
            // Get the default UserActivityChannel and query it for our UserActivity. If the activity doesn't exist, one is created.
            UserActivityChannel channel      = UserActivityChannel.GetDefault();
            UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync("ShowMerchants");

            // Populate required properties
            userActivity.VisualElements.DisplayText = "Handelaars";
            userActivity.VisualElements.Description = "Bekijk de handelaars";
            userActivity.ActivationUri = new Uri("stapp://ShowMerchants");

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

            // Dispose of any current UserActivitySession, and create a new one.
            _currentActivity?.Dispose();
            _currentActivity = userActivity.CreateSession();
        }
Пример #21
0
        public async Task GenerateCharActivityAsync(CharHolder Char)
        {
            if (!Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.ApplicationModel.UserActivities.UserActivityChannel"))
            {
                return;
            }
            UserActivityChannel channel = UserActivityChannel.GetDefault();
            var          name           = Char.MakeName(false);
            UserActivity userActivity   = await channel.GetOrCreateUserActivityAsync(name);

            userActivity.VisualElements.DisplayText = AppResources.PlayedWith + " " + name.Remove(name.Length - Constants.DATEIENDUNG_CHAR.Length);
            userActivity.ActivationUri = new Uri(Constants.PROTOCOL_CHAR + Char.FileInfo?.FullName);

            await userActivity.SaveAsync();

            CurrentCharActivity?.Dispose();
            ShadowRunHelper.Helper.PlatformHelper.ExecuteOnUIThreadAsync(() => CurrentCharActivity = userActivity.CreateSession());
        }
Пример #22
0
        private async Task GenerateActivityAsync()
        {
            // Get the default UserActivityChannel and query it for our UserActivity. If the activity doesn't exist, one is created.
            UserActivityChannel channel      = UserActivityChannel.GetDefault();
            UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync("MainPage");

            // Populate required properties
            userActivity.VisualElements.DisplayText = "ProjectCityAppUWP Activity";
            userActivity.VisualElements.Description = "You downloaded a discount PDF!";
            userActivity.ActivationUri = new Uri("my-app://MainPage?action=edit");

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

            // Dispose of any current UserActivitySession, and create a new one.
            _currentActivity?.Dispose();
            _currentActivity = userActivity.CreateSession();
        }
Пример #23
0
        private async Task GenerateActivityAsync()
        {
            // Get the default UserActivityChannel and query it for our UserActivity. If the activity doesn't exist, one is created.
            UserActivityChannel channel      = UserActivityChannel.GetDefault();
            UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync("MainPage");

            // Populate required properties
            userActivity.VisualElements.DisplayText = "First Activity";
            userActivity.ActivationUri = new Uri("JCSample:navigate?page=MainPage");

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

            // Dispose of any current UserActivitySession, and create a new one.
            _currentActivity?.Dispose();
            _currentActivity = userActivity.CreateSession();

            Debug.WriteLine("activity generated?");
        }
Пример #24
0
        public async static void AddToTimeLine(Activity data)
        {
            UserActivityChannel Channel  = UserActivityChannel.GetDefault();
            UserActivity        Activity = await Channel.GetOrCreateUserActivityAsync(data.url);

            Activity.ActivationUri = new Uri("tencentvideo:video?url=" + data.url);
            Activity.VisualElements.DisplayText = "腾讯视频";
            StorageFile CardFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Data/activity.json"));

            string CardText = await FileIO.ReadTextAsync(CardFile);

            CardText = TransferTemplate(CardText);
            string ActivityContent = string.Format(CardText, data.image, data.title, data.description);

            Activity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(ActivityContent);
            await Activity.SaveAsync();

            CurrentSession = Activity.CreateSession();
        }
Пример #25
0
        private async Task GenerateActivityAsync()
        {
            // Get the default UserActivityChannel and query it for our UserActivity. If the activity doesn't exist, one is created.
            UserActivityChannel channel      = UserActivityChannel.GetDefault();
            UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync(AppName);

            // Populate required properties
            userActivity.VisualElements.DisplayText            = AppName;
            userActivity.VisualElements.AttributionDisplayText = AppName;
            userActivity.VisualElements.Description            = AppInfo.Length > 3 ? AppInfo : AppReview;
            userActivity.ActivationUri = new Uri("coolapk://" + AppLink);

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

            // Dispose of any current UserActivitySession, and create a new one.
            _currentActivity?.Dispose();
            _currentActivity = userActivity.CreateSession();
        }
Пример #26
0
        private async Task GenerateActivityAsync()
        {
            // Get the default UserActivityChannel and query it for our UserActivity. If the activity doesn't exist, one is created.
            UserActivityChannel channel      = UserActivityChannel.GetDefault();
            UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync("MainPage");

            // Populate required properties
            userActivity.VisualElements.DisplayText = "Symbol Icon Finder";
            userActivity.ActivationUri = new Uri("symboliconfinder://");
            userActivity.VisualElements.Description = "View and search Segoe MDL2 icons";

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

            // Dispose of any current UserActivitySession, and create a new one.
            _currentActivity?.Dispose();
            _currentActivity = userActivity.CreateSession();

            Debug.WriteLine("Created user session");
        }
Пример #27
0
        public static async Task <UserActivitySession> AddToTimeLine(string area, ModelBase theModel, string bodyText)
        {
            UserActivitySession returnedFromUIThread = await MainThread.InvokeOnMainThreadAsync(async() =>
            {
                // Record in the TimeLine
                UserActivityChannel channel     = UserActivityChannel.GetDefault();
                UserActivity _ModelUserActivity = await channel.GetOrCreateUserActivityAsync(theModel.HLinkKey);
                Uri _Uri;
                UserActivitySession activitySession = null;

                if (theModel.Valid)
                {
                    // Set deep-link and properties.
                    _Uri = new Uri("gramps://" + area + @"/handle/" + theModel.HLinkKey);

                    //// TODO Add Adapative card visuals once the API has settled down StorageFile // cardFile
                    // = await StorageFile.GetFileFromApplicationUriAsync(new //
                    // Uri("ms-appx:///Assets/Misc/UserActivityCard.json")); string cardText = await
                    // // FileIO.ReadTextAsync(cardFile); // theModel.ModelUserActivity.VisualElements.Content

                    // = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(cardText);
                    // theModel.ModelUserActivity.VisualElements.DisplayText = headerText;

                    _ModelUserActivity.VisualElements.DisplayText = area;
                    _ModelUserActivity.VisualElements.Description = bodyText;
                    _ModelUserActivity.ActivationUri = new Uri("gramps://" + area + @"/handle/" + theModel.HLinkKey);

                    //Save
                    await _ModelUserActivity.SaveAsync(); //save the new metadata

                    if (_ModelUserActivity != null)
                    {
                        activitySession = _ModelUserActivity.CreateSession();
                    }
                }

                return(activitySession);
            }).ConfigureAwait(false);

            return(returnedFromUIThread);
        }
Пример #28
0
        private async void OnCreateActivity(object sender, RoutedEventArgs e)
        {
            string cardText = @"{
                ""type"": ""AdaptiveCard"",
                ""version"": ""1.0"",
                ""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"",
                ""body"": [{
                    ""type"": ""TextBlock"",
                    ""horizontalAlignment"": ""Center"",
                    ""size"": ""Large"",
                    ""text"": ""Hello BASTA!""
                },
                {
                    ""type"": ""TextBlock"",
                    ""horizontalAlignment"": ""Left"",
                    ""size"": ""Small"",
                    ""text"": ""This is a sample for BASTA! 2019in Frankfurt"",
                    ""maxLines"": 3,
                    ""wrap"": true
                }]
            }";

            try
            {
                UserActivityChannel channel  = UserActivityChannel.GetDefault();
                UserActivity        activity = await channel.GetOrCreateUserActivityAsync("MainPage5");

                activity.VisualElements.DisplayText = "BASTA! Sample";
                activity.ActivationUri = new Uri("basta://MainPage/1");
                var card = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(cardText);
                activity.VisualElements.Content = card;
                await activity.SaveAsync();

                _session?.Dispose();
                _session = activity.CreateSession();
            }
            catch (Exception ex)
            {
                new MessageDialog(ex.Message);
            }
        }
        private async Task GenerateActivityAsync()
        {
            //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("APOD-UWP");

            //Populate required properties: DisplayText and ActivationUri are required.
            userActivity.VisualElements.DisplayText = "APOD-UWP TIMELINE ACTIVITIES";
            userActivity.ActivationUri = new Uri("proto://");
            //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();
        }
Пример #30
0
        private async Task GenerateActivityAsync()
        {
            if (ApiInformation.IsTypePresent("Windows.ApplicationModel.UserActivities.UserActivityChannel"))
            {
                UserActivitySession currentActivity = null;
                // Get the default UserActivityChannel and query it for our UserActivity. If the activity doesn't exist, one is created.
                UserActivityChannel channel      = UserActivityChannel.GetDefault();
                UserActivity        userActivity = await channel.GetOrCreateUserActivityAsync(DateTime.Today.ToString("yyyyMMdd"));

                // Populate required properties
                userActivity.VisualElements.DisplayText = _keyword;
                userActivity.VisualElements.Description = (this.resultFlipView.Items.First() as GroupedDictItem).First().Definition;
                userActivity.ActivationUri = new Uri($"jpdict://result?keyword={_keyword}");

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

                // Dispose of any current UserActivitySession, and create a new one.
                currentActivity?.Dispose();
                currentActivity = userActivity.CreateSession();
            }
        }