コード例 #1
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(filename))
     {
         saveAsToolStripMenuItem_Click(sender, e);
     }
     else
     {
         using (PaddingDialog dlg = new PaddingDialog(file.Padding))
         {
             if (dlg.ShowDialog(this) != DialogResult.OK)
             {
                 return;
             }
             file.Padding = (int)dlg.numericUpDown1.Value;
         }
         file.Save(filename);
         if (MessageBox.Show(this, "Generate ARL file?", "Generations Archive Editor", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             new Thread(() => {
                 Ar00File.GenerateArlFile(filename);
             }).Start();
         }
     }
 }
コード例 #2
0
 private void LoadFile(string filename, bool clear = true)
 {
     try
     {
         file = new Ar00File(filename);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message);
         return;
     }
     this.filename = filename;
     if (clear)
     {
         listView1.Items.Clear();
         imageList1.Images.Clear();
     }
     if (file.Files.Count == 0)
     {
         return;
     }
     listView1.BeginUpdate();
     foreach (Ar00File.File item in file.Files)
     {
         imageList1.Images.Add(GetIcon(item.Name));
         listView1.Items.Add(item.Name, imageList1.Images.Count - 1);
     }
     listView1.EndUpdate();
 }
コード例 #3
0
 private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (CommonSaveFileDialog a = new CommonSaveFileDialog {
         Filters = { arFiles, allFiles }
     })
     {
         if (a.ShowDialog() == CommonFileDialogResult.Ok)
         {
             using (PaddingDialog dlg = new PaddingDialog(file.Padding))
             {
                 if (dlg.ShowDialog(this) != DialogResult.OK)
                 {
                     return;
                 }
                 file.Padding = (int)dlg.numericUpDown1.Value;
             }
             file.Save(a.FileName);
             filename = a.FileName;
             if (MessageBox.Show(this,
                                 "Generate ARL file?",
                                 "Generations Archive Editor",
                                 MessageBoxButtons.YesNo) ==
                 DialogResult.Yes)
             {
                 string filename = a.FileName;
                 new Thread(() => {
                     Ar00File.GenerateArlFile(filename);
                 }).Start();
             }
         }
     }
 }
コード例 #4
0
 private void Form1_Load(object sender, EventArgs e)
 {
     string[] args = Environment.GetCommandLineArgs();
     if (args.Length == 1)
     {
         file = new Ar00File();
     }
     else
     {
         LoadFile(args[1]);
     }
 }
コード例 #5
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                args = new string[] { "/?" }
            }
            ;
            switch (args[0].ToLowerInvariant())
            {
            case "/t":
                Main(ParseCommandLine(File.ReadAllText(args[1])));
                break;

            case "/u":
                try
                {
                    Ar00File ar   = new Ar00File(args[1]);
                    string   dest = Environment.CurrentDirectory;
                    if (args.Length > 2)
                    {
                        dest = args[2];
                        Directory.CreateDirectory(dest);
                    }
                    foreach (Ar00File.File item in ar.Files)
                    {
                        File.WriteAllBytes(Path.Combine(dest, item.Name), item.Data);
                    }
                }
                catch (Exception ex) { Console.WriteLine(ex.ToString()); }
                break;

            case "/p":
                string fn  = args[args.Length - 1];
                int    f   = 1;
                int    pad = 0x40;
                if (args[1].Equals("/pad", StringComparison.OrdinalIgnoreCase))
                {
                    f  += 2;
                    pad = int.Parse(args[2], System.Globalization.NumberStyles.HexNumber);
                }
                try
                {
                    Ar00File ar = new Ar00File();
                    ar.Padding = pad;
                    for (int i = f; i < args.Length - 1; i++)
                    {
                        ar.Files.Add(new Ar00File.File(args[i]));
                    }
                    ar.Save(fn);
                }
                catch (Exception ex) { Console.WriteLine(ex.ToString()); }
                break;

            case "/l":
                try
                {
                    Ar00File.GenerateArlFile(args[1]);
                }
                catch (Exception ex) { Console.WriteLine(ex.ToString()); }
                break;

            case "/?":
            default:
                Console.WriteLine("Arguments:");
                Console.WriteLine();
                Console.WriteLine("/?\tShow this help.");
                Console.WriteLine();
                Console.WriteLine("/t filename\tReads text file filename as a commandline.");
                Console.WriteLine();
                Console.WriteLine("/u filename [destination]\tExtracts filename to destination, or the current directory.");
                Console.WriteLine();
                Console.WriteLine("/p [/pad num] filenames destination\tPacks files into the destination archive. /pad num pads the files to num bytes in hex.");
                Console.WriteLine();
                Console.WriteLine("/l filename\tGenerates a listing file for the archive.");
                Console.WriteLine();
                Console.WriteLine("filename\tOpens file in the visual editor.");
                Console.WriteLine();
                break;
            }
        }
コード例 #6
0
 static void Main(string[] args)
 {
     if (args.Length > 0)
     {
         if (args[0] == "/?")
         {
             AttachConsole(-1);
             Console.WriteLine("Arguments:");
             Console.WriteLine();
             Console.WriteLine("/?\tShow this help.");
             Console.WriteLine();
             Console.WriteLine("/t filename\tReads text file filename as a commandline.");
             Console.WriteLine();
             Console.WriteLine("/u filename [destination]\tExtracts filename to destination, or the current directory.");
             Console.WriteLine();
             Console.WriteLine("/p [/pad num] filenames destination\tPacks files into the destination archive. /pad num pads the files to num bytes in hex.");
             Console.WriteLine();
             Console.WriteLine("/l filename\tGenerates a listing file for the archive.");
             Console.WriteLine();
             Console.WriteLine("filename\tOpens file in the visual editor.");
             Console.WriteLine();
             FreeConsole();
             return;
         }
         if (args[0].Equals("/t", StringComparison.OrdinalIgnoreCase))
         {
             Main(ParseCommandLine(File.ReadAllText(args[1])));
             return;
         }
         if (args[0].Equals("/u", StringComparison.OrdinalIgnoreCase))
         {
             AttachConsole(-1);
             try
             {
                 Ar00File ar   = new Ar00File(args[1]);
                 string   dest = Environment.CurrentDirectory;
                 if (args.Length > 2)
                 {
                     dest = args[2];
                     Directory.CreateDirectory(dest);
                 }
                 foreach (Ar00File.File item in ar.Files)
                 {
                     File.WriteAllBytes(Path.Combine(dest, item.Name), item.Data);
                 }
             }
             catch (Exception ex) { Console.WriteLine(ex.ToString()); }
             FreeConsole();
             return;
         }
         if (args[0].Equals("/p", StringComparison.OrdinalIgnoreCase))
         {
             AttachConsole(-1);
             string fn  = args[args.Length - 1];
             int    f   = 1;
             int    pad = 0x40;
             if (args[1].Equals("/pad", StringComparison.OrdinalIgnoreCase))
             {
                 f  += 2;
                 pad = int.Parse(args[2], NumberStyles.HexNumber);
             }
             try
             {
                 Ar00File ar = new Ar00File();
                 for (int i = f; i < args.Length - 1; i++)
                 {
                     ar.Files.Add(new Ar00File.File(args[i]));
                 }
                 ar.Save(fn);
             }
             catch (Exception ex) { Console.WriteLine(ex.ToString()); }
             FreeConsole();
             return;
         }
         if (args[0].Equals("/l", StringComparison.OrdinalIgnoreCase))
         {
             AttachConsole(-1);
             try
             {
                 Ar00File.GenerateArlFile(args[1]);
             }
             catch (Exception ex) { Console.WriteLine(ex.ToString()); }
             FreeConsole();
             return;
         }
     }
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new MainForm());
 }