コード例 #1
0
        /// <summary>
        /// The ButtonDownload_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonDownload_Click(object sender, EventArgs args)
        {
            if (lvLogs.SelectedItems.Count == 0)
            {
                return;
            }

            var log      = (Log)lvLogs.SelectedItems[0].Tag;
            var endpoint = log.LogEndpoint;

            // Open a save file dialog for the user to select a filename for the
            // log download.
            saveFileDialog.FileName = "Log-" + log.Id + ".zip";
            var result = saveFileDialog.ShowDialog();

            saveFileDialog.Dispose();

            if (result != DialogResult.OK)
            {
                return;
            }

            using (var downloadForm = new DownloadProgressForm(new Uri(endpoint), saveFileDialog.FileName, 0))
            {
                downloadForm.StartDownload();
                downloadForm.ShowDialog();
            }
        }
コード例 #2
0
        /// <summary>
        /// The ButtonDownload_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonDownload_Click(object sender, EventArgs args)
        {
            if (lvExportManager.CheckedItems.Count == 0)
            {
                return;
            }

            // Get the associated Export object from the selected item.
            var export = (Export)lvExportManager.CheckedItems[0].Tag;

            // Open a save file dialog for the user to select a filename for the
            // export download.
            saveFileDialog.FileName = export.Name;
            var result = saveFileDialog.ShowDialog();

            saveFileDialog.Dispose();

            if (result != DialogResult.OK)
            {
                return;
            }

            using (var downloadForm = new DownloadProgressForm(new Uri(export.DataUri), saveFileDialog.FileName, export.FileSizeKb))
            {
                downloadForm.StartDownload();
                downloadForm.ShowDialog();
            }
        }
コード例 #3
0
        /// <summary>
        /// The ButtonDownload_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonDownload_Click(object sender, EventArgs args)
        {
            if (lvReports.SelectedItems.Count == 0 || !(lvReports.SelectedItems[0].Tag is Report report) || string.IsNullOrEmpty(report.ReportEndpoint))
            {
                return;
            }

            var reportFilename = $"{report.Name}.{report.Format}";
            var invalidChars   = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());

            reportFilename = invalidChars.Aggregate(reportFilename, (current, invalidChar) => current.Replace(invalidChar.ToString(), "_"));

            // Open a save file dialog for the user to select a filename for the report download.
            using (var saveFileDialog = new SaveFileDialog {
                FileName = reportFilename
            })
            {
                if (saveFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                using (var downloadForm = new DownloadProgressForm(new Uri(report.ReportEndpoint), saveFileDialog.FileName, 0))
                {
                    downloadForm.StartDownload();
                    downloadForm.ShowDialog();
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// The ButtonDownload_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonDownload_Click(object sender, EventArgs args)
        {
            if (lvFileManager.CheckedItems.Count == 0)
            {
                return;
            }

            // Get the associated File object from the selected item.
            var file = (VxFile)lvFileManager.CheckedItems[0].Tag;

            // Open a save file dialog for the user to select a filename for the
            // file download.
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.FileName = file.Filename;
            var result = saveFileDialog.ShowDialog();

            saveFileDialog.Dispose();

            if (result != DialogResult.OK)
            {
                return;
            }

            using (var downloadForm = new DownloadProgressForm(new Uri(file.FileEndpoint), saveFileDialog.FileName, 0))
            {
                downloadForm.StartDownload();
                downloadForm.ShowDialog();
            }
        }