Exemple #1
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();
        }
Exemple #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();
        }
Exemple #3
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();
        }
        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();
        }
        private static async Task SaveAsync(UserActivity activity)
        {
            await activity.SaveAsync();

            // Dispose of any current UserActivitySession, and create a new one.
            _currentUserActivitySession?.Dispose();
            _currentUserActivitySession = activity.CreateSession();
        }
Exemple #6
0
        private static async Task SaveAsync(UserActivity activity)
        {
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal, async() =>
            {
                await activity.SaveAsync();

                // Dispose of any current UserActivitySession, and create a new one.
                _currentUserActivitySession?.Dispose();
                _currentUserActivitySession = activity.CreateSession();
            });
        }
        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();
        }
Exemple #8
0
        //internal static AdaptiveCard CreateAdaptiveCardForTimeline(string argArea, ModelBase argTheModel, string argBodyText)
        //{
        //    // _ModelUserActivity.VisualElements.BackgroundColor = ColorExtensions.ToPlatformColor(theModel.ModelItemGlyph.Symbol);

        // // Create an adaptive card specifically to reference this app in Windows 10 Timeline.
        // AdaptiveCard apodTimelineCard = new AdaptiveCard("1.0");

        // // Add a heading to the card, which allows the heading to wrap to the next line if
        // necessary. var apodHeading = new AdaptiveTextBlock { Text = argArea, Size =
        // AdaptiveTextSize.Large, Weight = AdaptiveTextWeight.Bolder, Wrap = true, MaxLines = 2 }; apodTimelineCard.Body.Add(apodHeading);

        // //// Add Column set //var apodColumnSet = new AdaptiveColumnSet();

        // //// Column 1 //var apodColumn1 = new AdaptiveColumn();

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

        // apodTimelineCard.Body.Add(apodDesc);

        // // Add column1 //apodColumn1.Items.Add(apodDesc); //apodColumnSet.Columns.Add(apodColumn1);

        // // Column 2

        // //// Add a background image to the card. //if (argTheModel.HLinkGlyph.IsImageType) //{ //
        // var apodColumn2 = new AdaptiveColumn();

        // // var apodImage = new AdaptiveImage { Url = new //
        // Uri(argTheModel.HLinkGlyph.ConvertToHLinkMediaModel.DeRef.MediaStorageFilePath), };

        // // // Add column1 apodColumn2.Items.Add(apodImage);

        // // apodColumnSet.Columns.Add(apodColumn2); //}

        // //apodTimelineCard.Body.Add(apodColumnSet);

        //    return apodTimelineCard;
        //}

        /// <summary>
        /// Generates the activity asynchronous.
        /// </summary>
        /// <param name="argActivity">
        /// The argument activity.
        /// </param>
        /// <returns>
        /// </returns>
        internal static async Task <UserActivitySession> GenerateActivityAsync(UserActivity argActivity)
        {
            // TODO Finish this code

            // Get channel and create activity.
            //UserActivityChannel channel = UserActivityChannel.GetDefault();

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

            // Create a session, which indicates that the user is engaged in the activity.
            return(argActivity.CreateSession());
        }
Exemple #9
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();
        }
Exemple #10
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();
        }
Exemple #11
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();
    }
Exemple #12
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();
        }
        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();
        }
        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();
        }
        private async void RenderResult_OnAction(RenderedAdaptiveCard sender, AdaptiveActionEventArgs e)
        {
            if (e.Action.ActionType == ActionType.OpenUrl)
            {
                _userActivity.ActivationUri = new Uri("adaptivecards://openLastPost");
                _userActivity.VisualElements.DisplayText = "Windows AppConsult blog";
                _userActivity.VisualElements.Content     = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(json);

                await _userActivity.SaveAsync();

                _userActivitySession?.Dispose();
                _userActivitySession = _userActivity.CreateSession();

                var action = e.Action as AdaptiveOpenUrlAction;
                await Launcher.LaunchUriAsync(action.Url);
            }
        }
Exemple #17
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);
        }
Exemple #18
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);
    }
Exemple #19
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();
        }
Exemple #20
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();
        }
Exemple #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());
        }
Exemple #22
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();
        }
        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();
        }
Exemple #24
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();
        }
Exemple #25
0
        public async Task LogOrUpdateActivityAsync(IFile file)
        {
            using (await TimelineMutex.LockAsync())
            {
                // Load the template, if needed
                if (_Template is null)
                {
                    StorageFile templateFile = await StorageFile.GetFileFromApplicationUriAsync(TemplateUri);

                    _Template = await FileIO.ReadTextAsync(templateFile);
                }

                // Get a unique id for the file
                uint numericId = (uint)HashCode <char> .Combine(file.Path.AsSpan());

                string
                    textId     = numericId.ToString(),
                    preview    = await CodeLibraryEntry.LoadCodePreviewAsync(file),
                    background = BackgroundImages[(int)(numericId % BackgroundImages.Count)];

                // Create the model to represent the current activity
                AdaptiveCard model = new AdaptiveCard(file.DisplayName, preview, background);

                // Render the adaptive card
                string adaptiveCard = await StaticStubbleRenderer.Instance.RenderAsync(_Template, model);

                // Get the default channel and create the activity
                UserActivity activity = await UserActivityChannel.GetDefault().GetOrCreateUserActivityAsync(textId);

                // Set the deep-link and the title
                activity.ActivationUri = new Uri($"brainf-ck:///file?path={file.Path}");
                activity.VisualElements.DisplayText = file.DisplayName;
                activity.VisualElements.Content     = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(adaptiveCard);
                activity.IsRoamable = false;

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

                // Update the activity currently in use
                _Session?.Dispose();
                _Session = activity.CreateSession();
            }
        }
Exemple #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 = "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?");
        }
        private async void RenderResult_OnAction(RenderedAdaptiveCard sender, AdaptiveActionEventArgs e)
        {
            if (e.Action.Type == "Action.OpenUrl")
            {
                if (_desktopBridgeHelpers.IsRunningAsUwp())
                {
                    _userActivity.ActivationUri = new Uri("adaptivecards://openLastPost");
                    _userActivity.VisualElements.DisplayText = "Windows AppConsult blog";
                    _userActivity.VisualElements.Content     = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(json);

                    await _userActivity.SaveAsync();

                    _userActivitySession?.Dispose();
                    _userActivitySession = _userActivity.CreateSession();
                }

                var action = e.Action as AdaptiveOpenUrlAction;
                Process.Start(action.Url.ToString());
            }
        }
Exemple #28
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");
        }
        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);
        }
Exemple #30
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);
            }
        }