Exemplo n.º 1
0
        private void uploadSnapshot(ThumbnailInfo snapshotFile)
        {
            if (this.thumbnailListBox.Items.Count == 0)
            {
                this.uploadIcon();
                return;
            }

            this.uploadStatusTextBox.Text = "正在上传应用缩略图...";
            if (client != null)
            {
                client.Dispose();
                client = null;
            }
            client = new WebClient();
            client.Headers.Add("AddApp", "{A298CC02-CE4B-4B69-A1B5-94FF344C6B95}");
            client.UploadProgressChanged += ((s, e1) =>
            {
                this.uploadProgressBar.Value = e1.BytesSent * 100 / e1.TotalBytesToSend;
            });
            client.UploadFileCompleted += ((s, e1) =>
            {
                if (e1.Error != null)
                {
                    this.uploadProgressBar.Value = 0;
                    this.uploadStatusTextBox.Text = "上传应用失败:" + e1.Error.Message;
                    this.enableCtrls(true);
                }
                else if (e1.Cancelled)
                {
                    this.uploadProgressBar.Value = 0;
                    this.uploadStatusTextBox.Text = "上传应用过程被取消";
                    this.enableCtrls(true);
                }
                else
                {
                    this.uploadProgressBar.Value = 100;

                    this.snapshotUploadingIndex++;
                    this.Dispatcher.BeginInvoke(new ThreadStart(() =>
                    {
                        if (this.snapshotUploadingIndex < this.thumbnailListBox.Items.Count)
                        {
                            this.uploadSnapshot(this.thumbnailListBox.Items[this.snapshotUploadingIndex] as ThumbnailInfo);
                        }
                        else
                        {
                            this.uploadIcon();
                        }
                    }), DispatcherPriority.Background, null);
                }
            });
            snapshotFile.RemoteUrl = this.CreateAppUri("Apps/snapshots", snapshotFile.File);
            client.UploadFileAsync(new Uri(snapshotFile.RemoteUrl), snapshotFile.File);
        }
Exemplo n.º 2
0
        private string getSnapshot(int index)
        {
            if (index >= this.thumbnailListBox.Items.Count)
            {
                return(string.Empty);
            }

            ThumbnailInfo info = this.thumbnailListBox.Items[index] as ThumbnailInfo;

            return(info.RemoteUrl);
        }