コード例 #1
0
        static void attachmentsAnchor_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton source = sender as HyperlinkButton;

            if (source == null)
            {
                return;
            }
            StackPanel container = source.Tag as StackPanel;

            if (container == null)
            {
                return;
            }
            AttachmentFieldValue attachmentFieldValue = source.DataContext as AttachmentFieldValue;

            if (attachmentFieldValue == null)
            {
                return;
            }
            if (attachmentFieldValue.AttachmentsProvider == null)
            {
                return;
            }

            attachmentFieldValue.AttachmentsProvider.LoadAttachments(attachmentFieldValue.LinkUrl, (o, args) =>
            {
                container.Dispatcher.BeginInvoke((Action) delegate
                {
                    if (args == null)
                    {
                        return;
                    }
                    container.Children.Clear();
                    buildAttachmentsPanel(container, args.AttachmentInfo);
                });
            }, (o, args) =>
            {
                container.Dispatcher.BeginInvoke((Action) delegate
                {
                    if (args == null || args.Exception == null)
                    {
                        return;
                    }
                    container.Children.Add(new TextBlock()
                    {
                        Text = args.Exception.Message
                    });
                });
            }, null);
        }
コード例 #2
0
 private static void setupAttachments(AttachmentsPanel panel, AttachmentFieldValue attachmentFieldValue)
 {
     if (attachmentFieldValue != null && attachmentFieldValue.AttachmentsProvider != null)
     {
         if (attachmentFieldValue.AttachmentsProvider.HasAlreadyRetrievedAttachments())
         {
             MultipleAttachmentsInfo attachments = attachmentFieldValue.AttachmentsProvider.GetAttachments();
             panel.setAttachments(attachments);
         }
         else
         {
             attachmentFieldValue.AttachmentsProvider.LoadAttachments(attachmentFieldValue.LinkUrl, (o, args) =>
             {
                 panel.Dispatcher.BeginInvoke((Action) delegate
                 {
                     if (args == null)
                     {
                         return;
                     }
                     AttachmentsPanel pnl = args.UserState as AttachmentsPanel;
                     pnl.setAttachments(args.AttachmentInfo);
                 });
             }, (o, args) =>
             {
                 panel.Dispatcher.BeginInvoke((Action) delegate
                 {
                     if (args == null || args.Exception == null)
                     {
                         return;
                     }
                     AttachmentsPanel pnl = args.UserState as AttachmentsPanel;
                     pnl.Error            = args.Exception.Message;
                     pnl.ErrorVisibility  = Visibility.Visible;
                 });
             }, panel);
         }
     }
 }