Esempio n. 1
0
        void importSingle(string filename, string title)
        {
            if (CurrentPackage == null)
            {
                fileNew();
            }

            if (new List <string>(asPkgExts).Contains(filename.Substring(filename.LastIndexOf('.'))))
            {
                ImportBatch  ib = new ImportBatch(new string[] { filename, }, ImportBatch.Mode.package);
                DialogResult dr = ib.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                importPackagesCommon(new string[] { filename, }, title, ib.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, ib.Compress, ib.UseNames);
            }
            else
            {
                ResourceDetails ir = new ResourceDetails(/*20120820 CurrentPackage.Find(x => x.ResourceType == 0x0166038C) != null/**/ true, true);
                ir.Filename = filename;
                DialogResult dr = ir.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                importFile(ir.Filename, ir, ir.UseName, ir.AllowRename, ir.Compress, ir.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, true);
            }
        }
Esempio n. 2
0
        private void resourceReplaceFrom()
        {
            var savedTitle = importPackagesDialog.Title;

            try
            {
                this.Enabled = false;
                importPackagesDialog.Title = "Replace Selected Resources from Package(s)";
                DialogResult dr = importPackagesDialog.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                ImportBatch ib = new ImportBatch(importPackagesDialog.FileNames, ImportBatch.Mode.replaceFrom);
                dr = ib.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                importPackagesCommon(ib.Batch, importPackagesDialog.Title, DuplicateHandling.replace, ib.Compress, selection: browserWidget1.SelectedResources);
            }
            finally { this.Enabled = true; importPackagesDialog.Title = savedTitle; }
        }
Esempio n. 3
0
        private void ResourceImportPackages()
        {
            try
            {
                this.Enabled = false;
                DialogResult dr = this.importPackagesDialog.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                ImportBatch ib = new ImportBatch(this.importPackagesDialog.FileNames, S4PIDemoFE.ImportBatch.Mode.package);
                dr = ib.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                this.ImportPackagesCommon(ib.Batch,
                                          this.importPackagesDialog.Title,
                                          ib.Replace ? DuplicateHandling.Replace : DuplicateHandling.Reject,
                                          ib.Compress,
                                          ib.UseNames,
                                          rename: ib.Rename);
            }
            finally
            {
                this.Enabled = true;
            }
        }
Esempio n. 4
0
        private void ImportBatch(IList <MyDataFormat> ldata)
        {
            ImportBatch  importBatch = new ImportBatch(ldata);
            DialogResult result      = importBatch.ShowDialog();

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

            List <MyDataFormat> output = new List <MyDataFormat>();

            foreach (string b in importBatch.Batch)
            {
                foreach (MyDataFormat data in ldata)
                {
                    if (data.tgin == b)
                    {
                        output.Add(data);
                        break;
                    }
                }
            }

            if (output.Count == 0)
            {
                return;
            }
            if (output.Count == 1)
            {
                this.ImportSingle(output[0]);
                return;
            }

            try
            {
                foreach (MyDataFormat data in output)
                {
                    this.ImportStream(data,
                                      importBatch.UseNames,
                                      importBatch.Rename,
                                      importBatch.Compress,
                                      importBatch.Replace ? DuplicateHandling.Replace : DuplicateHandling.Reject,
                                      false);
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                CopyableMessageBox.IssueException(ex, "Could not import all resources.\n", "Aborting import");
            }
        }
Esempio n. 5
0
        void importBatch(IList <myDataFormat> ldata)
        {
            ImportBatch  ib = new ImportBatch(ldata);
            DialogResult dr = ib.ShowDialog();

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

            List <myDataFormat> output = new List <myDataFormat>();

            foreach (string b in ib.Batch)
            {
                foreach (myDataFormat data in ldata)
                {
                    if (data.tgin == b)
                    {
                        output.Add(data); goto next;
                    }
                }
                next : { }
            }

            if (output.Count == 0)
            {
                return;
            }
            if (output.Count == 1)
            {
                importSingle(output[0]); return;
            }

            try
            {
                foreach (myDataFormat data in output)
                {
                    importStream(data, ib.UseNames, ib.Rename, ib.Compress, ib.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, false);
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                CopyableMessageBox.IssueException(ex, "Could not import all resources.\n", "Aborting import");
            }
        }
Esempio n. 6
0
        private void resourceImportPackages()
        {
            try
            {
                this.Enabled = false;
                DialogResult dr = importPackagesDialog.ShowDialog();
                if (dr != DialogResult.OK) return;

                ImportBatch ib = new ImportBatch(importPackagesDialog.FileNames, ImportBatch.Mode.package);
                dr = ib.ShowDialog();
                if (dr != DialogResult.OK) return;

                importPackagesCommon(ib.Batch, importPackagesDialog.Title, ib.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, ib.Compress, ib.UseNames,
                    rename: ib.Rename);
            }
            finally { this.Enabled = true; }
        }
Esempio n. 7
0
        private void resourceReplaceFrom()
        {
            var savedTitle = importPackagesDialog.Title;
            try
            {
                this.Enabled = false;
                importPackagesDialog.Title = "Replace Selected Resources from Package(s)";
                DialogResult dr = importPackagesDialog.ShowDialog();
                if (dr != DialogResult.OK) return;

                ImportBatch ib = new ImportBatch(importPackagesDialog.FileNames, ImportBatch.Mode.replaceFrom);
                dr = ib.ShowDialog();
                if (dr != DialogResult.OK) return;

                importPackagesCommon(ib.Batch, importPackagesDialog.Title, DuplicateHandling.replace, ib.Compress, selection: browserWidget1.SelectedResources);
            }
            finally { this.Enabled = true; importPackagesDialog.Title = savedTitle; }
        }
Esempio n. 8
0
        private void ImportSingle(string filename, string title)
        {
            if (this.CurrentPackage == null)
            {
                this.FileNew();
            }

            if (packageExtensions.Contains(filename.FileExtension()))
            {
                ImportBatch  ib = new ImportBatch(new[] { filename }, S4PIDemoFE.ImportBatch.Mode.package);
                DialogResult dr = ib.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                this.ImportPackagesCommon(new[] { filename },
                                          title,
                                          ib.Replace ? DuplicateHandling.Replace : DuplicateHandling.Reject,
                                          ib.Compress,
                                          ib.UseNames);
            }
            else
            {
                ResourceDetails ir = new ResourceDetails(true, true)
                {
                    Filename = filename
                };
                DialogResult dr = ir.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                this.ImportFile(ir.Filename,
                                ir,
                                ir.UseName,
                                ir.AllowRename,
                                ir.Compress,
                                ir.Replace ? DuplicateHandling.Replace : DuplicateHandling.Reject,
                                true);
            }
        }
Esempio n. 9
0
        void importBatch(string[] batch, string title)
        {
            if (CurrentPackage == null)
            {
                fileNew();
            }

            List <string> foo = new List <string>();

            foreach (string bar in batch)
            {
                if (Directory.Exists(bar))
                {
                    foo.AddRange(getFiles(bar));
                }
                else if (File.Exists(bar))
                {
                    foo.Add(bar);
                }
            }
            batch = foo.ToArray();

            ImportBatch ib = new ImportBatch(batch);

            ib.Text = title;
            DialogResult dr = ib.ShowDialog();

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

            List <string> resList = new List <string>();
            List <string> pkgList = new List <string>();
            List <string> folders = new List <string>();

            List <string> pkgExts = new List <string>(asPkgExts);

            foreach (string s in batch)
            {
                (pkgExts.Contains(s.Substring(s.LastIndexOf('.'))) ? pkgList : resList).Add(s);
            }

            try
            {
                if (pkgList.Count > 0)
                {
                    importPackagesCommon(pkgList.ToArray(), title, ib.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, ib.Compress, ib.UseNames);
                }

                bool nmOK = true;
                foreach (string filename in resList)
                {
                    nmOK = importFile(filename, filename, nmOK && ib.UseNames, ib.Rename, ib.Compress, ib.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, false);
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                CopyableMessageBox.IssueException(ex, "Could not import all resources - aborting.\n", title);
            }
        }
Esempio n. 10
0
        void importBatch(IList<myDataFormat> ldata)
        {
            ImportBatch ib = new ImportBatch(ldata);
            DialogResult dr = ib.ShowDialog();
            if (dr != DialogResult.OK) return;

            List<myDataFormat> output = new List<myDataFormat>();
            foreach (string b in ib.Batch)
            {
                foreach (myDataFormat data in ldata)
                    if (data.tgin == b) { output.Add(data); goto next; }
            next: { }
            }

            if (output.Count == 0) return;
            if (output.Count == 1) { importSingle(output[0]); return; }

            try
            {
                foreach (myDataFormat data in output)
                {
                    importStream(data, ib.UseNames, ib.Rename, ib.Compress, ib.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, false);
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                CopyableMessageBox.IssueException(ex, "Could not import all resources.\n", "Aborting import");
            }
        }
Esempio n. 11
0
        void importBatch(string[] batch, string title)
        {
            if (CurrentPackage == null)
                fileNew();

            List<string> foo = new List<string>();
            foreach (string bar in batch)
                if (Directory.Exists(bar)) foo.AddRange(getFiles(bar));
                else if (File.Exists(bar)) foo.Add(bar);
            batch = foo.ToArray();

            ImportBatch ib = new ImportBatch(batch);
            ib.Text = title;
            DialogResult dr = ib.ShowDialog();
            if (dr != DialogResult.OK) return;

            List<string> resList = new List<string>();
            List<string> pkgList = new List<string>();
            List<string> folders = new List<string>();

            List<string> pkgExts = new List<string>(asPkgExts);
            foreach (string s in batch)
                (pkgExts.Contains(s.Substring(s.LastIndexOf('.'))) ? pkgList : resList).Add(s);

            try
            {
                if (pkgList.Count > 0)
                    importPackagesCommon(pkgList.ToArray(), title, ib.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, ib.Compress, ib.UseNames);

                bool nmOK = true;
                foreach (string filename in resList)
                {
                    nmOK = importFile(filename, filename, nmOK && ib.UseNames, ib.Rename, ib.Compress, ib.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, false);
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                CopyableMessageBox.IssueException(ex, "Could not import all resources - aborting.\n", title);
            }
        }
Esempio n. 12
0
        void importSingle(string filename, string title)
        {
            if (CurrentPackage == null)
                fileNew();

            if (new List<string>(asPkgExts).Contains(filename.Substring(filename.LastIndexOf('.'))))
            {
                ImportBatch ib = new ImportBatch(new string[] { filename, }, ImportBatch.Mode.package);
                DialogResult dr = ib.ShowDialog();
                if (dr != DialogResult.OK) return;

                importPackagesCommon(new string[] { filename, }, title, ib.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, ib.Compress, ib.UseNames);
            }
            else
            {
                ResourceDetails ir = new ResourceDetails(/*20120820 CurrentPackage.Find(x => x.ResourceType == 0x0166038C) != null/**/true, true);
                ir.Filename = filename;
                DialogResult dr = ir.ShowDialog();
                if (dr != DialogResult.OK) return;

                importFile(ir.Filename, ir, ir.UseName, ir.AllowRename, ir.Compress, ir.Replace ? DuplicateHandling.replace : DuplicateHandling.reject, true);
            }
        }
Esempio n. 13
0
        private void ImportBatch(string[] batch, string title)
        {
            if (this.CurrentPackage == null)
            {
                this.FileNew();
            }

            List <string> allFiles = new List <string>();

            foreach (string path in batch)
            {
                if (Directory.Exists(path))
                {
                    allFiles.AddRange(this.GetFiles(path));
                }
                else if (File.Exists(path))
                {
                    allFiles.Add(path);
                }
            }
            batch = allFiles.ToArray();

            ImportBatch importBatch = new ImportBatch(batch)
            {
                Text = title
            };
            DialogResult result = importBatch.ShowDialog();

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

            List <string> resources = batch.Where(p => !packageExtensions.Contains(p.FileExtension())).ToList();
            List <string> packages  = batch.Where(p => packageExtensions.Contains(p.FileExtension())).ToList();

            try
            {
                if (packages.Count > 0)
                {
                    this.ImportPackagesCommon(packages.ToArray(),
                                              title,
                                              importBatch.Replace ? DuplicateHandling.Replace : DuplicateHandling.Reject,
                                              importBatch.Compress,
                                              importBatch.UseNames);
                }

                bool nmOK = true;
                foreach (string file in resources)
                {
                    nmOK = this.ImportFile(file,
                                           file,
                                           nmOK && importBatch.UseNames,
                                           importBatch.Rename,
                                           importBatch.Compress,
                                           importBatch.Replace ? DuplicateHandling.Replace : DuplicateHandling.Reject,
                                           false);
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                CopyableMessageBox.IssueException(ex, "Could not import all resources - aborting.\n", title);
            }
        }