Exemple #1
0
        public void Activate(ShareTargetActivatedEventArgs args)
        {
            DefaultViewModel["Sharing"] = false;

            _ShareOperation = args.ShareOperation;
            DataPackagePropertySetView shareProperties = _ShareOperation.Data.Properties;

            DefaultViewModel["Link"] = new Link
            {
                Name = shareProperties.Title,
                Uri  = new Uri(shareProperties.Description)
            };

            Window.Current.Content = this;
            Window.Current.Activate();
        }
        private void ComposeMessage(string message)
        {
            DataPackagePropertySetView properties = this.ShareOperation.Data.Properties;
            string        title         = properties.Title;
            string        description   = properties.Description;
            StringBuilder stringBuilder = new StringBuilder();

            if (!string.IsNullOrEmpty(title))
            {
                stringBuilder.Append(title).Append("\n");
            }
            if (!string.IsNullOrEmpty(description))
            {
                stringBuilder.Append(description).Append("\n");
            }
            stringBuilder.Append(message);
            this.Message = stringBuilder.ToString();
        }
 internal DataPackagePropertySetViewAdapter( DataPackagePropertySetView propertySetView )
 {
     Contract.Requires( propertySetView != null );
     adapted = propertySetView;
 }
        /// <summary>
        /// Invoked when another application wants to share content through this application.
        /// </summary>
        /// <param name="args">Activation data used to coordinate the process with Windows.</param>
        public async void Activate(ShareTargetActivatedEventArgs args)
        {
            _shareOperation = args.ShareOperation;

            // Communicate metadata about the shared content through the view model
            DataPackagePropertySetView shareProperties = _shareOperation.Data.Properties;
            var thumbnailImage = new BitmapImage();

            DefaultViewModel["Title"]           = shareProperties.Title;
            DefaultViewModel["Description"]     = shareProperties.Description;
            DefaultViewModel["Image"]           = thumbnailImage;
            DefaultViewModel["Sharing"]         = false;
            DefaultViewModel["ShowImage"]       = false;
            DefaultViewModel["Comment"]         = String.Empty;
            DefaultViewModel["SupportsComment"] = true;
            Window.Current.Content = this;
            Window.Current.Activate();

            // Update the shared content's thumbnail image in the background
            if (shareProperties.Thumbnail != null)
            {
                var stream = await shareProperties.Thumbnail.OpenReadAsync();

                thumbnailImage.SetSource(stream);
                DefaultViewModel["ShowImage"] = true;
            }

            DefaultViewModel["ShowBlog"] = false;

            const string BLOG_POST = "http://schema.org/BlogPosting";

            if (!_shareOperation.Data.Contains(BLOG_POST))
            {
                return;
            }

            var data = await _shareOperation.Data.GetDataAsync(BLOG_POST);

            if (data == null)
            {
                return;
            }

            DefaultViewModel["ShowBlog"] = true;
            DefaultViewModel["BlogPost"] = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType((string)data,
                                                                                                new
            {
                type       = "http://shema.org/BlogPosting",
                properties = new
                {
                    description   = string.Empty,
                    image         = new Uri("http://schema.org/"),
                    name          = string.Empty,
                    url           = new Uri("http://schema.org/"),
                    audience      = "Windows 8 Developers",
                    datePublished = DateTime.Now,
                    headline      = string.Empty,
                    articleBody   = string.Empty
                }
            });
        }