Esempio n. 1
0
        private void btnImportPP_Click(object sender, EventArgs e)
        {
            IEnumerable <string> paths = ShowOpenFileDialog("PP archive files|*.pp", true);

            if (!paths.Any())
            {
                return;
            }

            var progform = new formImporting();

            int counter = 0;

            IProgress <int> progress = new Progress <int>((x) =>
            {
                progform.SetProgress(100 * counter / paths.Count(), x);
            });

            Task t = Task.Factory.StartNew(() =>
            {
                foreach (string file in paths)
                {
                    counter++;
                    ImportPP(file, progress);
                }

                progform.DynamicInvoke(() =>
                                       progform.Close()
                                       );
            });

            trvFiles.BeginUpdate();
            progform.ShowDialog(this);
            trvFiles.EndUpdate();
        }
Esempio n. 2
0
        private void convertxggTowavToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CommonOpenFileDialog dialog = new CommonOpenFileDialog()
            {
                Multiselect = true
            };

            dialog.Filters.Add(new CommonFileDialogFilter("XGG audio file", "*.xgg"));

            var result = dialog.ShowDialog();

            if (result != CommonFileDialogResult.Ok)
            {
                return;
            }

            var progform = new formImporting();

            IProgress <int> progress = new Progress <int>((x) =>
            {
                progform.SetProgress(x, x);
            });

            Task t = Task.Factory.StartNew(() =>
            {
                foreach (string file in dialog.FileNames)
                {
                    FileSource f            = new FileSource(file);
                    PPeX.Xgg.XggSubfile xgg = new PPeX.Xgg.XggSubfile(f, "", "");

                    using (FileStream fs = new FileStream(file.Replace(".xgg", ".wav"), FileMode.Create))
                        xgg.WriteToStream(fs);
                }

                progform.DynamicInvoke(() =>
                                       progform.Close()
                                       );
            });

            progform.ShowDialog(this);
        }
Esempio n. 3
0
        private void btnImportPP_Click(object sender, EventArgs e)
        {
            CommonOpenFileDialog dialog = new CommonOpenFileDialog()
            {
                Multiselect = true
            };

            dialog.Filters.Add(new CommonFileDialogFilter("PP archive files", "*.pp"));

            var result = dialog.ShowDialog();

            if (result != CommonFileDialogResult.Ok)
            {
                return;
            }

            var progform = new formImporting();

            int counter = 0;

            IProgress <int> progress = new Progress <int>((x) =>
            {
                progform.SetProgress(100 * counter / dialog.FileNames.Count(), x);
            });

            Task t = Task.Factory.StartNew(() =>
            {
                foreach (string file in dialog.FileNames)
                {
                    counter++;
                    ImportPP(file, progress);
                }

                progform.DynamicInvoke(() =>
                                       progform.Close()
                                       );
            });

            progform.ShowDialog(this);
        }
Esempio n. 4
0
        private void trvFiles_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            trvFiles.BeginUpdate();

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

            foreach (string file in files)
            {
                IsModified = true;

                if (Directory.Exists(file)) //is directory
                {
                    ImportFolder(file);
                }
                else if (file.EndsWith(".pp"))
                {
                    PPs.Add(file);
                }
                else
                {
                    if (trvFiles.SelectedNode != null)
                    {
                        var parent = trvFiles.SelectedNode.Level == 0 ?
                                     trvFiles.SelectedNode :
                                     trvFiles.SelectedNode.Parent;


                        var node = parent.Nodes.Add(Path.GetFileName(file));

                        node.Tag = new SubfileHolder(new FileSource(file), Path.GetFileName(file));
                        SetAutoIcon(node);

                        if (!node.Parent.IsExpanded)
                        {
                            node.Parent.Expand();
                        }


                        //trvFiles.SelectedNode = node;

                        //node.edi
                    }
                }
            }
            if (PPs.Count > 0)
            {
                var progform = new formImporting();

                int counter = 0;

                IProgress <int> progress = new Progress <int>((x) =>
                {
                    progform.SetProgress(100 * counter / PPs.Count, x);
                });

                Task t = Task.Factory.StartNew(() =>
                {
                    foreach (string file in PPs)
                    {
                        counter++;
                        ImportPP(file, progress);
                    }

                    progform.DynamicInvoke(() =>
                                           progform.Close()
                                           );
                });

                progform.ShowDialog(this);
            }

            trvFiles.EndUpdate();
        }