Example #1
0
        private void btnDownloadSelected_Click(object sender, EventArgs e)
        {
            if (!DataGridOperations.AnyRowsSelected(grdDocuments))
            {
                return;
            }

            var selected =
                DataGridOperations.GetSelectedItems <Document>
                (
                    grdDocuments,
                    bsDocuments
                );

            // TODO: extract this to a ZipFactory;
            var source     = "document.pdf";
            var uniquename = Guid.NewGuid().ToString();
            var tempDir    = Path.GetTempPath();
            var basedir    = Path.Combine(tempDir, uniquename);

            Directory.CreateDirectory(basedir);

            foreach (var document in selected)
            {
                var destination = Path.Combine(basedir, document.Filename);
                File.Copy(source, destination);
            }

            var zipDest = Path.Combine(tempDir, String.Concat(uniquename, ".zip"));

            ZipFile.CreateFromDirectory(basedir, zipDest);

            Process.Start("explorer.exe", zipDest);
        }
Example #2
0
        private void dgvDocumentGroups_SelectionChanged(object sender, EventArgs e)
        {
            var grid = (DataGridView)sender;

            if (!DataGridOperations.AnyRowsSelected(grid))
            {
                return;
            }

            var selectedGroups =
                DataGridOperations.GetSelectedItems <DocumentGroup>
                (
                    grdDocumentGroups,
                    bsDocumentGroups
                );

            var documents =
                selectedGroups.
                SelectMany(n => n.Documents);

            bsDocuments.DataSource = documents;
            bsDocuments.ResetBindings(true);
        }