コード例 #1
0
 private string GetFilename()
 {
     return(DesktopFile.GetFilename(platform));
 }
コード例 #2
0
        private void Pack()
        {
            if (!Directory.Exists(curPath))
            {
                MessageBox.Show("No valid folder selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (desktopFileOpt == DesktopFileOption.Ignore || desktopFileOpt == DesktopFileOption.LoadExisting)
            {
                DesktopFile desktopFileGCW0 = null;
                DesktopFile desktopFileA320 = null;

                if (textBoxExe.Text != "")
                {
                    desktopFileGCW0 = new DesktopFile();
                }

                if (textBoxExeA320.Text != "")
                {
                    desktopFileA320 = new DesktopFile();
                }

                if (desktopFileGCW0 == null && desktopFileA320 == null)
                {
                    MessageBox.Show("You must enter an executable for at least one platform.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (desktopFileGCW0 != null)
                {
                    desktopFileGCW0.Platform = "gcw0";

                    desktopFileGCW0.Name            = textBoxName.Text;
                    desktopFileGCW0.Exec            = textBoxExe.Text;
                    desktopFileGCW0.Icon            = textBoxIcon.Text;
                    desktopFileGCW0.Comment         = textBoxComment.Text;
                    desktopFileGCW0.Categories      = textBoxCategories.Text;
                    desktopFileGCW0.MimeTypes       = textBoxMimeTypes.Text;
                    desktopFileGCW0.Terminal        = checkBoxTerminal.Checked;
                    desktopFileGCW0.Manual          = textBoxManual.Text;
                    desktopFileGCW0.JoystickMode    = checkBoxJoystickMode.Checked;
                    desktopFileGCW0.GSensor         = checkBoxGSensor.Checked;
                    desktopFileGCW0.HardwareScaling = checkBoxHardwareScaling.Checked;
                }

                if (desktopFileA320 != null)
                {
                    desktopFileA320.Platform = "a320";

                    desktopFileA320.Name            = textBoxName.Text;
                    desktopFileA320.Exec            = textBoxExeA320.Text;
                    desktopFileA320.Icon            = textBoxIcon.Text;
                    desktopFileA320.Comment         = textBoxComment.Text;
                    desktopFileA320.Categories      = textBoxCategories.Text;
                    desktopFileA320.MimeTypes       = textBoxMimeTypes.Text;
                    desktopFileA320.Terminal        = checkBoxTerminal.Checked;
                    desktopFileA320.Manual          = textBoxManual.Text;
                    desktopFileA320.JoystickMode    = checkBoxJoystickMode.Checked;
                    desktopFileA320.GSensor         = checkBoxGSensor.Checked;
                    desktopFileA320.HardwareScaling = checkBoxHardwareScaling.Checked;
                }

                if (desktopFileGCW0 != null && !desktopFileGCW0.VerifyData())
                {
                    MessageBox.Show("Error: " + desktopFileGCW0.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (desktopFileA320 != null && !desktopFileA320.VerifyData())
                {
                    MessageBox.Show("Error: " + desktopFileA320.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (desktopFileGCW0 != null)
                {
                    string execPath  = Path.Combine(new string[] { curPath, desktopFileGCW0.Exec });
                    bool   exeExists = File.Exists(execPath);
                    if (!exeExists)
                    {
                        DialogResult exeResult = MessageBox.Show("Executable can not be found - Continue anyway?", "Executable not found", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (exeResult != System.Windows.Forms.DialogResult.Yes)
                        {
                            return;
                        }
                    }

                    desktopFileGCW0.WriteDesktopFile(curPath);

                    if (exeExists)
                    {
                        VerifyAndFixLineEndingsIfScript(execPath);
                    }
                }
                else
                {
                    string path = Path.Combine(curPath, DesktopFile.GetFilename("gcw0"));
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                }

                if (desktopFileA320 != null)
                {
                    string execPath  = Path.Combine(new string[] { curPath, desktopFileA320.Exec });
                    bool   exeExists = File.Exists(execPath);
                    if (!exeExists)
                    {
                        DialogResult exeResult = MessageBox.Show("Executable can not be found - Continue anyway?", "Executable not found", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (exeResult != System.Windows.Forms.DialogResult.Yes)
                        {
                            return;
                        }
                    }

                    desktopFileA320.WriteDesktopFile(curPath);

                    if (exeExists)
                    {
                        VerifyAndFixLineEndingsIfScript(execPath);
                    }
                }
                else
                {
                    string path = Path.Combine(curPath, DesktopFile.GetFilename("a320"));
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                }
            }

            if (textBoxManual.Text != "")
            {
                try
                {
                    VerifyAndFixLineEndings(Path.Combine(curPath, textBoxManual.Text));
                }
                catch (Exception)
                { }
            }

            saveFileDialogOpk.InitialDirectory = Directory.GetParent(curPath).FullName;

            DialogResult result = saveFileDialogOpk.ShowDialog();

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

            ExecutePacker(saveFileDialogOpk.FileName);
        }