Exemple #1
0
        private void ExtractFile(TreeIter iter, string filename)
        {
            waitWindow = new WaitWindow(this, "Extracting", filename);
            waitWindow.Show();

            ThreadNotify done = new ThreadNotify(new ReadyEvent(() =>
            {
                waitWindow.Destroy();
                waitWindow = null;
            }));

            ThreadNotify error = new ThreadNotify(new ReadyEvent(() =>
            {
                waitWindow.Destroy();
                waitWindow = null;

                CustomMessageDialog msg =
                    new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError);
                msg.Run();
                msg.Destroy();
            }));

            Packer.Item item = packStore.GetValue(iter, 0) as Packer.Item;
            new Thread(new ThreadStart(() =>
            {
                if (fileSystem.Extract(item, filename))
                {
                    done.WakeupMain();
                }
                else
                {
                    error.WakeupMain();
                }
            })).Start();
        }
Exemple #2
0
 private void AppendFiles(TreeIter destIter, string path)
 {
     try
     {
         Directory.EnumerateFiles(path, "*.*", SearchOption.TopDirectoryOnly).ToList()
         .ForEach(file => AppendFile(destIter, file));
     }
     catch (UnauthorizedAccessException)
     {
         CustomMessageDialog msg =
             new CustomMessageDialog(this, MessageType.Error, String.Format("Access denied to {0}", path));
         msg.Run();
         msg.Destroy();
     }
 }
Exemple #3
0
        private void AppendFile(TreeIter destIter, string filename)
        {
            Gtk.Application.Invoke((sender, e) => waitWindow.FileText = filename);

            Packer.Item fileItem = NewItem(destIter, filename);
            if (fileSystem.Add(fileItem))
            {
                AppendItem(destIter, fileItem);
            }
            else
            {
                CustomMessageDialog msg =
                    new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError);
                msg.Run();
                msg.Destroy();
            }
        }
Exemple #4
0
        private void AppendFolders(TreeIter destIter, string path)
        {
            try
            {
                Directory.EnumerateDirectories(path, "*", SearchOption.TopDirectoryOnly).ToList()
                .ForEach(folder =>
                {
                    Packer.Item folderItem = NewItem(destIter, folder);
                    TreeIter folderIter    = AppendItem(destIter, folderItem);
                    AppendFolders(folderIter, folder);
                });

                AppendFiles(destIter, path);
            }
            catch (UnauthorizedAccessException)
            {
                CustomMessageDialog msg =
                    new CustomMessageDialog(this, MessageType.Error, String.Format("Access denied to {0}", path));
                msg.Run();
                msg.Destroy();
            }
        }
Exemple #5
0
        private void OpenPack(string filename)
        {
            if (Packer.Create(System.IO.Path.GetExtension(filename), out fileSystem))
            {
                waitWindow = new WaitWindow(this, "Opening", filename);
                waitWindow.Show();

                ThreadNotify done = new ThreadNotify(new ReadyEvent(() =>
                {
                    waitWindow.Destroy();
                    waitWindow = null;
                }));

                ThreadNotify error = new ThreadNotify(new ReadyEvent(() =>
                {
                    waitWindow.Destroy();
                    waitWindow = null;

                    CustomMessageDialog msg =
                        new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError);
                    msg.Run();
                    msg.Destroy();
                }));

                new Thread(new ThreadStart(() =>
                {
                    if (fileSystem.Open(filename))
                    {
                        RebuildPackTree(fileSystem.ListFiles());
                        ChangePackActionSensitive(true);
                        done.WakeupMain();
                    }
                    else
                    {
                        error.WakeupMain();
                    }
                })).Start();
            }
        }
Exemple #6
0
        private void HandleSaveAction()
        {
            if (fileSystem == null)
            {
                return;
            }

            CustomFileChooserDialog dlg =
                new CustomFileChooserDialog(this, "Save pack", FileChooserAction.Save);

            dlg.FileChooser.SelectMultiple = false;

            using (Gtk.FileFilter filter = new Gtk.FileFilter())
            {
                filter.Name = fileSystem.Extension.ToUpper();
                filter.AddPattern("*." + fileSystem.Extension.ToLower());
                dlg.FileChooser.AddFilter(filter);
            }

            using (Gtk.FileFilter filter = new Gtk.FileFilter())
            {
                filter.Name = "All";
                filter.AddPattern("*.*");
                dlg.FileChooser.AddFilter(filter);
            }

            dlg.Ok += (sender, e) =>
            {
                string filename = dlg.FileChooser.Filename;

                waitWindow = new WaitWindow(this, "Saving", filename);
                waitWindow.Show();

                ThreadNotify done = new ThreadNotify(new ReadyEvent(() =>
                {
                    waitWindow.Destroy();
                    waitWindow = null;
                }));

                ThreadNotify error = new ThreadNotify(new ReadyEvent(() =>
                {
                    waitWindow.Destroy();
                    waitWindow = null;

                    CustomMessageDialog msg =
                        new CustomMessageDialog(this, MessageType.Error, fileSystem.LastError);
                    msg.Run();
                    msg.Destroy();
                }));

                new Thread(new ThreadStart(() =>
                {
                    if (fileSystem.Save(filename))
                    {
                        done.WakeupMain();
                    }
                    else
                    {
                        error.WakeupMain();
                    }
                })).Start();

                dlg.Destroy();
            };
            dlg.Cancel += (sender, e) => dlg.Destroy();
            dlg.Show();
        }