Ejemplo n.º 1
0
        private async void buttonX3_Click(object sender, EventArgs e)
        {
            if (info == null)
            {
                return;
            }

            using (var sfd = new SaveFileDialog {
                Filter = "OpenIV Archive Files (*.oiv)|*.oiv|All files (*.*)|*.*"
            })
            {
                sfd.FileName = info.Name ?? "package.oiv";

                var result = sfd.ShowDialog();

                switch (result)
                {
                case DialogResult.Cancel: break;

                case DialogResult.OK:
                    Enabled = false;
                    using (var manager = new OIVPackageManager(sfd.FileName))
                    {
                        await manager.ExportPackage(info);

                        manager.Dispose();
                    }
                    Enabled = true;
                    MessageBox.Show(string.Format("Successfully exported to {0}.", sfd.FileName));
                    break;
                }

                sfd.Dispose();
            }
        }
Ejemplo n.º 2
0
        private async void buttonX2_Click(object sender, EventArgs e)
        {
            if (info == null)
            {
                return;
            }

            string filename = "";

            using (var ofd = new OpenFileDialog {
                Filter = "OpenIV Archive Files (*.oiv)|*.oiv|All files (*.*)|*.*"
            })
            {
                var result = ofd.ShowDialog();

                switch (result)
                {
                case DialogResult.Cancel: break;

                case DialogResult.OK:
                    filename = ofd.FileName;
                    break;
                }

                ofd.Dispose();
            }

            if (filename.Length <= 0)
            {
                return;
            }

            var oivpkg = new OIVPackageManager(filename);

            Enabled = false;

            info = await oivpkg.ReadPackage();

            propertyGrid1.SelectedObject = info;

            propertyGrid1.Refresh();

            listBox1.Items.Clear();

            foreach (var f in info.GenericFiles)
            {
                listBox1.Items.Add(string.Format("{0} -> {1}",
                                                 f.Source.Substring(f.Source.LastIndexOf('\\') + 1),
                                                 f.Destination));
            }

            foreach (var a in info.Archives)
            {
                foreach (var f in a.GetNestedFiles())
                {
                    listBox1.Items.Add(string.Format("{0} -> {1}",
                                                     f.Source.Substring(f.Source.LastIndexOf('\\') + 1),
                                                     f.FullPath).Replace("\\\\", "\\"));
                }
            }

            colorPickerButton1.SelectedColor = info.IconBackground;

            colorPickerButton2.SelectedColor = info.HeaderBackground;

            checkBoxX1.Checked = info.BlackTextEnabled;

            if (info.IconPath?.Length > 0)
            {
                var image = Image.FromFile(info.IconPath);

                pictureBox1.Image = image;
                pictureBox1.Refresh();
            }

            Enabled = true;
        }