Exemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // 获取 ProtocolForResultsActivatedEventArgs 对象(从 App.xaml.cs 传来的)
            _protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs;

            // 显示协议的详细信息
            if (_protocolForResultsArgs != null)
            {
                _protocolForResultsOperation = _protocolForResultsArgs.ProtocolForResultsOperation;

                grid.Background   = new SolidColorBrush(Colors.Blue);
                lblMsg.Foreground = new SolidColorBrush(Colors.White);

                lblMsg.Text  = "激活程序的自定义协议为: " + _protocolForResultsArgs.Uri.AbsoluteUri;
                lblMsg.Text += Environment.NewLine;

                if (_protocolForResultsArgs.Data.ContainsKey("InputData"))
                {
                    string inputData = _protocolForResultsArgs.Data["InputData"] as string;

                    lblMsg.Text += $"收到了数据:{inputData}";
                    lblMsg.Text += Environment.NewLine;
                }

                btnOpenProtocol.Visibility = Visibility.Collapsed;
            }
            else
            {
                btnBack.Visibility = Visibility.Collapsed;
            }
        }
 public ProtocolForResultsPayload(string path, IDictionary <string, object> data, QueryString parameters, ProtocolForResultsOperation operation)
 {
     Path           = path;
     Data           = data != null ? new ReadOnlyDictionary <string, object>(data) : null;
     Parameters     = parameters;
     this.operation = operation;
 }
Exemplo n.º 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ProtocolForResultsOperation ro = ((App)App.Current).mem["ResultsOperation"] as ProtocolForResultsOperation;

            // wait for user input oder simply return a value
            var resultData = new ValueSet();

            resultData.Add("Result", "Hello from Result Target");
            ro.ReportCompleted(resultData);
        }
Exemplo n.º 4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs;

            operation = protocolForResultsArgs.ProtocolForResultsOperation;
            var callerpfn = protocolForResultsArgs.CallerPackageFamilyName;

            if (protocolForResultsArgs.Data.Keys.Count == 1 && protocolForResultsArgs.Data.ContainsKey("Items"))
            {
                selectedgoods = JSONHelper.JsonDeserialize <ObservableCollection <Goods> >(protocolForResultsArgs.Data["Items"].ToString());
            }
            totalAmount   = selectedgoods.Select(i => i.Price).Sum().ToString();
            txtTotal.Text = string.Format("Total:{0}", totalAmount);
        }
Exemplo n.º 5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs;

            if (protocolForResultsArgs != null)
            {
                _operation = protocolForResultsArgs.ProtocolForResultsOperation;

                if (protocolForResultsArgs.Data.ContainsKey("Question"))
                {
                    string dataFromCaller = protocolForResultsArgs.Data["Question"] as string;
                    txtRequest.Text = dataFromCaller;
                }
            }
        }
Exemplo n.º 6
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is ProtocolForResultsActivatedEventArgs protocolForResultsArgs)
            {
                // Set the ProtocolForResultsOperation field.
                operation = protocolForResultsArgs.ProtocolForResultsOperation;

                if (protocolForResultsArgs.Data.ContainsKey("TestData"))
                {
                    string dataFromCaller = protocolForResultsArgs.Data["TestData"] as string;
                    //response to the calling app
                    var result = new ValueSet();
                    result["ReturnedData"] = "The returned result";
                    operation.ReportCompleted(result);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs;

            this.operation = protocolForResultsArgs.ProtocolForResultsOperation;
            var callerPfn = protocolForResultsArgs.CallerPackageFamilyName;

            // We only want certain, approved apps to use our checkout functionality so check the caller is one
            // This is, of course, optional. You don't have to do this.
            if (this.validCallers.Any(c => c.Item1.Equals(callerPfn)))
            {
                if (protocolForResultsArgs.Data.Keys.Count == 2 &&
                    protocolForResultsArgs.Data.ContainsKey("Transaction") &&
                    protocolForResultsArgs.Data.ContainsKey("Items"))
                {
                    // This is a bit hacky - you could put this into a view model if you wanted
                    this.transaction = protocolForResultsArgs.Data["Transaction"] as string;
                    var items = protocolForResultsArgs.Data["Items"] as string;

                    var allItems = JsonConvert.DeserializeObject <List <Item> >(items);

                    this.ItemsInOrder.ItemsSource = allItems;

                    this.totalAmount      = allItems.Select(i => i.UnitPrice * i.Quantity).Sum().ToString();
                    this.TotalAmount.Text = this.totalAmount;
                }
                else
                {
                    var result = new ValueSet();
                    result["Success"] = false;
                    result["Reason"]  = "Invalid payload";

                    operation.ReportCompleted(result);
                }
            }
            else
            {
                var result = new ValueSet();
                result["Success"] = false;
                result["Reason"]  = "Application not approved";

                operation.ReportCompleted(result);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs;
            this.operation = protocolForResultsArgs.ProtocolForResultsOperation;
            var callerPfn = protocolForResultsArgs.CallerPackageFamilyName;

            // We only want certain, approved apps to use our checkout functionality so check the caller is one
            // This is, of course, optional. You don't have to do this.
            if (this.validCallers.Any(c => c.Item1.Equals(callerPfn)))
            {
                if (protocolForResultsArgs.Data.Keys.Count == 2
                    && protocolForResultsArgs.Data.ContainsKey("Transaction")
                    && protocolForResultsArgs.Data.ContainsKey("Items"))
                {
                    // This is a bit hacky - you could put this into a view model if you wanted
                    this.transaction = protocolForResultsArgs.Data["Transaction"] as string;
                    var items = protocolForResultsArgs.Data["Items"] as string;

                    var allItems = JsonConvert.DeserializeObject<List<Item>>(items);

                    this.ItemsInOrder.ItemsSource = allItems;

                    this.totalAmount = allItems.Select(i => i.UnitPrice * i.Quantity).Sum().ToString();
                    this.TotalAmount.Text = this.totalAmount;
                }
                else
                {
                    var result = new ValueSet();
                    result["Success"] = false;
                    result["Reason"] = "Invalid payload";

                    operation.ReportCompleted(result);
                }
            }
            else
            {
                var result = new ValueSet();
                result["Success"] = false;
                result["Reason"] = "Application not approved";

                operation.ReportCompleted(result);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs;
            this.operation = protocolForResultsArgs.ProtocolForResultsOperation;
			productName = protocolForResultsArgs.Data["ProductName"] as string;
			this.Item.Text = productName;
            this.Amount.Text = "$" + protocolForResultsArgs.Data["Amount"] as string;

            if (protocolForResultsArgs.Data.ContainsKey("ImageFileToken"))
            {
                string imageFileToken = protocolForResultsArgs.Data["ImageFileToken"] as string;

                StorageFile imageFile = await SharedStorageAccessManager.RedeemTokenForFileAsync(imageFileToken);
                BitmapImage bitmap = new BitmapImage();
                bitmap.SetSource(await imageFile.OpenReadAsync());
                ProductImage.Source = bitmap;
                ProductImage.Height = 200;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs;

            this.operation   = protocolForResultsArgs.ProtocolForResultsOperation;
            productName      = protocolForResultsArgs.Data["ProductName"] as string;
            this.Item.Text   = productName;
            this.Amount.Text = "$" + protocolForResultsArgs.Data["Amount"] as string;

            if (protocolForResultsArgs.Data.ContainsKey("ImageFileToken"))
            {
                string imageFileToken = protocolForResultsArgs.Data["ImageFileToken"] as string;

                StorageFile imageFile = await SharedStorageAccessManager.RedeemTokenForFileAsync(imageFileToken);

                BitmapImage bitmap = new BitmapImage();
                bitmap.SetSource(await imageFile.OpenReadAsync());
                ProductImage.Source = bitmap;
                ProductImage.Height = 200;
            }
        }
Exemplo n.º 11
0
 public void SetArgsAndGetResults(string args, ValueSet data, ProtocolForResultsOperation op)
 {
     _op = op;
     SetArgs(args, data);
 }