コード例 #1
0
        public static IMEPackage OpenMEPackage(string pathToFile, WPFBase wpfWindow = null, WinFormsBase winForm = null)
        {
            IMEPackage package = null;
            if (!openPackages.ContainsKey(pathToFile))
            {
                ushort version;
                ushort licenseVersion;
                using (FileStream fs = new FileStream(pathToFile, FileMode.Open, FileAccess.Read))
                {
                    fs.Seek(4, SeekOrigin.Begin);
                    version = fs.ReadValueU16();
                    licenseVersion = fs.ReadValueU16();
                }

                if (version == 684 && licenseVersion == 194)
                {
                    package = ME3ConstructorDelegate(pathToFile);
                }
                else if (version == 512 && licenseVersion == 130)
                {
                    package = ME2ConstructorDelegate(pathToFile);
                }
                else if (version == 491 && licenseVersion == 1008)
                {
                    package = ME1ConstructorDelegate(pathToFile);
                }
                else
                {
                    throw new FormatException("Not an ME1, ME2, or ME3 package file.");
                }
                package.noLongerUsed += Package_noLongerUsed;
                openPackages.Add(pathToFile, package);
            }
            else
            {
                package = openPackages[pathToFile];
            }

            if (wpfWindow != null)
            {
                package.RegisterTool(new GenericWindow(wpfWindow, Path.GetFileName(pathToFile)));
                addToPackagesInTools(package);
            }
            else if (winForm != null)
            {
                package.RegisterTool(new GenericWindow(winForm, Path.GetFileName(pathToFile)));
                addToPackagesInTools(package);
            }
            else
            {
                package.RegisterUse();
            }
            return package;
        }
コード例 #2
0
        public static IMEPackage OpenMEPackage(string pathToFile, WPFBase wpfWindow = null, WinFormsBase winForm = null)
        {
            IMEPackage package = null;

            if (!openPackages.ContainsKey(pathToFile))
            {
                ushort version;
                ushort licenseVersion;

                using (FileStream fs = new FileStream(pathToFile, FileMode.Open, FileAccess.Read))
                {
                    fs.Seek(4, SeekOrigin.Begin);
                    version        = fs.ReadValueU16();
                    licenseVersion = fs.ReadValueU16();
                }


                if (version == 684 && licenseVersion == 194)
                {
                    package = ME3ConstructorDelegate(pathToFile);
                }
                else if (version == 512 && licenseVersion == 130)
                {
                    package = ME2ConstructorDelegate(pathToFile);
                }
                else if (version == 491 && licenseVersion == 1008)
                {
                    package = ME1ConstructorDelegate(pathToFile);
                }
                else if (version == 868 && licenseVersion == 0)
                {
                    //UDK
                    package = UDKConstructorDelegate(pathToFile);
                }
                else
                {
                    throw new FormatException("Not an ME1, ME2, ME3, or UDK package file.");
                }
                package.noLongerUsed += Package_noLongerUsed;
                openPackages.TryAdd(pathToFile, package);
            }
            else
            {
                package = openPackages[pathToFile];
            }

            if (wpfWindow != null)
            {
                package.RegisterTool(new GenericWindow(wpfWindow, Path.GetFileName(pathToFile)));
                addToPackagesInTools(package);
            }
            else if (winForm != null)
            {
                package.RegisterTool(new GenericWindow(winForm, Path.GetFileName(pathToFile)));
                addToPackagesInTools(package);
            }
            else
            {
                package.RegisterUse();
            }
            return(package);
        }
コード例 #3
0
        public static ME1Package OpenME1Package(string pathToFile, WPFBase wpfWindow = null, WinFormsBase winForm = null)
        {
            IMEPackage pck = OpenMEPackage(pathToFile, wpfWindow, winForm);
            ME1Package pcc = pck as ME1Package;

            if (pcc == null)
            {
                pck.Release(wpfWindow, winForm);
                throw new FormatException("Not an ME1 package file.");
            }
            return(pcc);
        }
コード例 #4
0
        public static IMEPackage OpenMEPackage(string pathToFile, WPFBase wpfWindow = null, WinFormsBase winForm = null, bool forceLoadFromDisk = false)
        {
            IMEPackage package;

            pathToFile = Path.GetFullPath(pathToFile); //STANDARDIZE INPUT
            if (forceLoadFromDisk || !openPackages.ContainsKey(pathToFile))
            {
                ushort version;
                ushort licenseVersion;

                using (FileStream fs = new FileStream(pathToFile, FileMode.Open, FileAccess.Read))
                {
                    fs.Seek(4, SeekOrigin.Begin);
                    version        = fs.ReadUInt16();
                    licenseVersion = fs.ReadUInt16();
                }


                if (version == MEPackage.ME3UnrealVersion && licenseVersion == MEPackage.ME3LicenseeVersion ||
                    version == MEPackage.ME2UnrealVersion && licenseVersion == MEPackage.ME2LicenseeVersion ||
                    version == MEPackage.ME1UnrealVersion && licenseVersion == MEPackage.ME1LicenseeVersion)
                {
                    package = MEConstructorDelegate(pathToFile, MEGame.Unknown);
                }
                else if (version == 868 && licenseVersion == 0)
                {
                    //UDK
                    package = UDKConstructorDelegate(pathToFile, false);
                }
                else
                {
                    throw new FormatException("Not an ME1, ME2, ME3, or UDK package file.");
                }

                if (!forceLoadFromDisk)
                {
                    package.noLongerUsed += Package_noLongerUsed;
                    openPackages.TryAdd(pathToFile, package);
                }
            }
            else
            {
                package = openPackages[pathToFile];
            }

            if (wpfWindow != null)
            {
                package.RegisterTool(new GenericWindow(wpfWindow, Path.GetFileName(pathToFile)));
                addToPackagesInTools(package);
            }
            else if (winForm != null)
            {
                package.RegisterTool(new GenericWindow(winForm, Path.GetFileName(pathToFile)));
                addToPackagesInTools(package);
            }
            else
            {
                package.RegisterUse();
            }
            return(package);
        }
コード例 #5
0
        public static IMEPackage OpenME1Package(string pathToFile, WPFBase wpfWindow = null, WinFormsBase winForm = null, bool forceLoadFromDisk = false)
        {
            IMEPackage pck = OpenMEPackage(pathToFile, wpfWindow, winForm, forceLoadFromDisk);

            if (pck.Game == MEGame.ME1)
            {
                return(pck);
            }

            pck.Release(wpfWindow, winForm);
            throw new FormatException("Not an ME1 package file.");
        }
コード例 #6
0
 public static ME1Package OpenME1Package(string pathToFile, WPFBase wpfWindow = null, WinFormsBase winForm = null)
 {
     IMEPackage pck = OpenMEPackage(pathToFile, wpfWindow, winForm);
     ME1Package pcc = pck as ME1Package;
     if (pcc == null)
     {
         pck.Release(wpfWindow, winForm);
         throw new FormatException("Not an ME1 package file.");
     }
     return pcc;
 }