/// <summary>Loads the file into the given project.</summary>
        /// <param name="path">Full pathname of the file.</param>
        /// <param name="project">[in,out] The project.</param>
        private static void LoadProjectFromPath(string path, ref ReClassNetProject project)
        {
            Contract.Requires(path != null);
            Contract.Requires(project != null);
            Contract.Ensures(Contract.ValueAtReturn(out project) != null);

            IReClassImport import;

            switch (Path.GetExtension(path)?.ToLower())
            {
            case ReClassNetFile.FileExtension:
                import = new ReClassNetFile(project);
                break;

            case ReClassQtFile.FileExtension:
                import = new ReClassQtFile(project);
                break;

            case ReClassFile.FileExtension:
                import = new ReClassFile(project);
                break;

            default:
                Program.Logger.Log(LogLevel.Error, $"The file '{path}' has an unknown type.");
                return;
            }
            import.Load(path, Program.Logger);
        }
Beispiel #2
0
        /// <summary>Loads the file into the given project.</summary>
        /// <param name="filePath">Full pathname of the file.</param>
        /// <param name="project">[in,out] The project.</param>
        private void LoadFileFromPath(string filePath, ref ReClassNetProject project)
        {
            Contract.Requires(filePath != null);
            Contract.Requires(project != null);
            Contract.Ensures(Contract.ValueAtReturn(out project) != null);

            IReClassImport import = null;

            switch (Path.GetExtension(filePath))
            {
            case ReClassNetFile.FileExtension:
                import = new ReClassNetFile(project);
                break;

            case ReClassQtFile.FileExtension:
                import = new ReClassQtFile(project);
                break;

            case ReClassFile.FileExtension:
                import = new ReClassFile(project);
                break;

            case ReClass2007File.FileExtension:
                import = new ReClass2007File(project);
                break;

            default:
                Program.Logger.Log(LogLevel.Error, $"The file '{filePath}' has an unknown type.");
                break;
            }
            import?.Load(filePath, Program.Logger);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var commandLineArgs = new CommandLineArgs(args);

            // Register the files with the launcher.
            if (commandLineArgs[Constants.CommandLineOptions.FileExtRegister] != null)
            {
                NativeMethods.RegisterExtension(ReClassNetFile.FileExtension, ReClassNetFile.FileExtensionId, PathUtil.ExecutablePath, Constants.ApplicationName);

                return;
            }
            if (commandLineArgs[Constants.CommandLineOptions.FileExtUnregister] != null)
            {
                NativeMethods.UnregisterExtension(ReClassNetFile.FileExtension, ReClassNetFile.FileExtensionId);

                return;
            }

            is64Bit = IntPtr.Size == 8;

            // If there is a file in the commandline, read the platform.
            if (commandLineArgs.FileName != null)
            {
                try
                {
                    is64Bit = ReClassNetFile.ReadPlatform(commandLineArgs.FileName) == "x64";
                }
                catch (Exception)
                {
                }
            }

            // And finally start the real ReClass.NET.
            var applicationPath = Path.Combine(PathUtil.ExecutableFolderPath, is64Bit ? "x64" : "x86", Constants.ApplicationExecutableName);

            try
            {
                var processStartInfo = new ProcessStartInfo
                {
                    FileName        = applicationPath,
                    UseShellExecute = true,
                    WindowStyle     = ProcessWindowStyle.Normal
                };
                var arguments = GetCommandLineWithoutExecutablePath();
                if (arguments != null)
                {
                    processStartInfo.Arguments = arguments;
                }

                Process.Start(processStartInfo);
            }
            catch (Exception)
            {
                MessageBox.Show($"Could not start '{applicationPath}'.", Constants.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!currentProject.Classes.Any())
            {
                return;
            }

            if (string.IsNullOrEmpty(currentProject.Path))
            {
                saveAsToolStripMenuItem_Click(sender, e);

                return;
            }

            var file = new ReClassNetFile(currentProject);

            file.Save(currentProject.Path, Program.Logger);
        }