예제 #1
0
        public static ArchiveState Create(IAcDomain acDomain, ArchiveBase archive)
        {
            if (archive == null)
            {
                throw new ArgumentNullException("archive");
            }
            var data = new ArchiveState(archive.Id)
            {
                AcDomain     = acDomain,
                ArchiveOn    = archive.ArchiveOn,
                CreateBy     = archive.CreateBy,
                CreateOn     = archive.CreateOn,
                CreateUserId = archive.CreateUserId,
                DataSource   = archive.DataSource,
                FilePath     = archive.FilePath,
                NumberId     = archive.NumberId,
                OntologyId   = archive.OntologyId,
                Password     = archive.Password,
                RdbmsType    = archive.RdbmsType,
                Title        = archive.Title,
                UserId       = archive.UserId
            };

            return(data);
        }
예제 #2
0
        /// <summary>
        /// Should be called only once
        /// </summary>
        public static void Init()
        {
            Memory.Log.WriteLine($"{nameof(Fields)} :: {nameof(Initializer)} :: {nameof(Init)}");
            ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_FIELD);

            // ReSharper disable once StringLiteralTypo
            ArchiveBase mapData = aw.GetArchive("mapdata.fs");

            if (mapData == null)
            {
                return;
            }
            // ReSharper disable once StringLiteralTypo
            const string map = "maplist";

            byte[] bytes = mapData.GetBinaryFile(map);
            if (bytes == null)
            {
                return;
            }
            string[] mapList = System.Text.Encoding.UTF8.GetString(bytes)
                               .Replace("\r", "")
                               .Split('\n');

            //Memory.FieldHolder.FieldMemory = new int[1024];
            Memory.FieldHolder.fields = mapList;
            FieldId.FieldId_          = mapList;
        }
예제 #3
0
        public void SimpleWorkerTest()
        {
            string[] fileNames = new[]
            {
                "music0.obj",
                "music1.obj",
                "music2.obj",
                "music3.obj",
                "music4.obj",
                "music5.obj",
                "rail.obj",
                "texl.obj",
                "wmset.obj",
                "wmsetXX.obj",
                "wmx.obj",
                "chara.one"
            };

            Memory.Init(null, null, null, null);

            ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_WORLD);

            //Console.WriteLine(aw.archive);
            string[] wmxPath = aw.GetListOfFiles();
            Console.WriteLine("Files in Archive (" + Memory.Archives.A_WORLD + ")");
            for (int i = 0; i < wmxPath.Length; i++)
            {
                string filePath = wmxPath[i];
                Console.WriteLine(i + 1 + ".) " + filePath);
            }

            // From the wiki we know, that there are 12 files in the archive
            // http://wiki.ffrtt.ru/index.php/FF8#World_map_files
            Assert.AreEqual(wmxPath.Length, fileNames.Length);
        }
예제 #4
0
            // ReSharper disable once UnusedMember.Local
            private static void MergeArchiveToZzz(ArchiveBase aw)
            {
                if (aw == null)
                {
                    return;
                }

                void Merge(Archive a)
                {
                    Log.WriteLine($"{nameof(Archive)}::{nameof(Init)}::{nameof(Merge)}\n\t{a} to {ZZZ_MAIN}");
                    string      fs    = a.FS;
                    ArchiveBase child = ArchiveWorker.Load(a);
                    FI          fi    = aw.ArchiveMap.FindString(ref fs, out int _);

                    aw.ArchiveMap.MergeMaps(child.ArchiveMap, fi.Offset);
                }

                Merge(A_BATTLE);
                Merge(A_FIELD);
                Merge(A_MAGIC);
                Merge(A_MAIN);
                Merge(A_MENU);
                Merge(A_WORLD);
                aw.GetListOfFiles(true);
                ArchiveBase.PurgeCache();
                A_BATTLE = ZZZ_MAIN;
                A_FIELD  = ZZZ_MAIN;
                A_MAGIC  = ZZZ_MAIN;
                A_MAIN   = ZZZ_MAIN;
                A_MENU   = ZZZ_MAIN;
                A_WORLD  = ZZZ_MAIN;
            }
예제 #5
0
 public ArchiveUpdatedEvent(IAcSession acSession, ArchiveBase source)
     : base(acSession, source)
 {
     this.DataSource = source.DataSource;
     this.FilePath = source.FilePath;
     this.NumberId = source.NumberId;
     this.UserId = source.UserId;
     this.Password = source.Password;
 }
예제 #6
0
 public ArchiveUpdatedEvent(IAcSession acSession, ArchiveBase source)
     : base(acSession, source)
 {
     this.DataSource = source.DataSource;
     this.FilePath   = source.FilePath;
     this.NumberId   = source.NumberId;
     this.UserId     = source.UserId;
     this.Password   = source.Password;
 }
예제 #7
0
        private static void LoadWorld()
        {
            ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_WORLD);

            string wmPath = aw.GetListOfFiles().Where(x => x.ToLower().Contains($"wmset{Extended.GetLanguageShort(true)}.obj")).Select(x => x).First();

            using (World.Wmset wmset = new World.Wmset(aw.GetBinaryFile(wmPath)))
            {
                _worldEncounters     = wmset.Encounters.SelectMany(x => x.Select(y => y)).Distinct().ToHashSet();
                WorldEncountersLunar = wmset.EncountersLunar.SelectMany(x => x.Select(y => y)).Distinct().ToHashSet();
            }
            //rail = new rail(aw.GetBinaryFile(railFile));
        }
예제 #8
0
        public static Items_In_Menu Read()
        {
            ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_MENU);

            byte[] buffer = aw.GetBinaryFile("mitem.bin");
            if (buffer != null)
            {
                using (BinaryReader br = new BinaryReader(new MemoryStream(buffer)))
                {
                    return(Read(br));
                }
            }
            return(default);
예제 #9
0
        public static void Init(bool bForce = false)
        {
            if (bAlreadyInitialized && !bForce)
            {
                return;
            }

            List <MainFieldChara> mfc = new List <MainFieldChara>();

            ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_FIELD);

            string[] test = aw.GetListOfFiles();

            var CollectionEntry = test.Where(x => x.ToLower().Contains("main_chr"));

            if (!CollectionEntry.Any())
            {
                return;
            }
            string fieldArchiveName = CollectionEntry.First();
            var    fieldArchive     = aw.GetArchive(fieldArchiveName);

            string[] test_ = fieldArchive.GetListOfFiles();

            for (int i = 0; i < test_.Length; i++)
            {
                //if (test_[i].Contains("d008.mch"))
                //    continue;
                if (string.IsNullOrWhiteSpace(test_[i]))
                {
                    continue;
                }
                byte[] oneb = fieldArchive.GetBinaryFile(test_[i]);

                if (oneb.Length < 64) //Hello Kazuo Suzuki! I will skip your dummy files
                {
                    continue;
                }

                MainFieldChara currentLocalChara = ReadMainChara(oneb);
                int            localId           = int.Parse(Path.GetFileNameWithoutExtension(test_[i]).Substring(1, 3));
                currentLocalChara.id = localId;
                mfc.Add(currentLocalChara);
            }
            MainFieldCharacters = mfc.ToArray();
            bAlreadyInitialized = true;
        }
예제 #10
0
        /// <summary>
        /// Should be called only once
        /// </summary>
        public static void Init()
        {
            Memory.Log.WriteLine($"{nameof(Fields)} :: {nameof(Initializer)} :: {nameof(Init)}");
            ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_FIELD);

            ArchiveBase mapdata = aw.GetArchive("mapdata.fs");

            if (mapdata != null)
            {
                string   map      = mapdata.GetListOfFiles()[0];
                string[] maplistb = System.Text.Encoding.UTF8.GetString(mapdata.GetBinaryFile(map))
                                    .Replace("\r", "")
                                    .Split('\n');
                Memory.FieldHolder.fields = maplistb;
                FieldId.FieldId_          = maplistb;
            }
        }
예제 #11
0
파일: Stage.cs 프로젝트: hollow87/OpenVIII
        public static BinaryReader Open()
        {
            ArchiveBase aw       = ArchiveWorker.Load(Memory.Archives.A_BATTLE);
            string      filename = Memory.Encounters.Filename;

            Memory.Log.WriteLine($"{nameof(Battle)} :: Loading {nameof(Camera)} :: {filename}");
            byte[] stageBuffer = aw.GetBinaryFile(filename);

            BinaryReader br;
            MemoryStream ms;

            if (stageBuffer == null)
            {
                return(null);
            }
            return(br = new BinaryReader(ms = new MemoryStream(stageBuffer)));
        }
예제 #12
0
        private void openFile(string filePath, ArchiveBase archive)
        {
            // set defaults here
            setReadOnly(false);

            fileTreeView.Nodes.Clear();
            ActiveFile    = new FileInfo(filePath);
            ActiveArchive = archive;
            ActiveArchive.Load(ActiveFile.FullName);

            TreeNode node = createNode(ActiveArchive.RootFolder);

            foreach (TreeNode subnode in node.Nodes)
            {
                fileTreeView.Nodes.Add(subnode);
            }

            archiveToolStripMenuItem.Enabled = true;
        }
예제 #13
0
        public FieldCharaOne(int fieldId)
        {
            if (!FieldMainCharaOne.bAlreadyInitialized)
            {
                FieldMainCharaOne.Init();
            }
            ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_FIELD);

            string[] test = aw.GetListOfFiles();

            var CollectionEntry = test.Where(x => x.IndexOf(Memory.FieldHolder.fields[Memory.FieldHolder.FieldID], StringComparison.OrdinalIgnoreCase) >= 0);

            if (!CollectionEntry.Any())
            {
                return;
            }
            string fieldArchivename = CollectionEntry.First();
            var    fieldArchive     = aw.GetArchive(fieldArchivename);


            string[] test_ = fieldArchive.GetListOfFiles();


            string one;

            //string main_chr;
            try
            {
                one = test_.First(x => x.EndsWith(".one", StringComparison.OrdinalIgnoreCase));
            }
            catch
            {
                return;
            }

            byte[] oneb = fieldArchive.GetBinaryFile(one);
            if (oneb.Length == 0)
            {
                return;
            }
            ReadBuffer(oneb);
        }
예제 #14
0
        public Search(FF8String searchstring)
        {
            _s = searchstring;
            foreach (Memory.Archive a in ArchiveList)
            {
                ArchiveBase aw  = ArchiveWorker.Load(a);
                string[]    lof = aw.GetListOfFiles();
                foreach (string f in lof)
                {
                    string ext = Path.GetExtension(f);
                    if (_skipExtension.Any(x => ext != null && x.IndexOf(ext, StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        continue;
                    }
                    Debug.WriteLine($"Searching {f}, in {a} for {searchstring}");
                    //byte[] bf = aw.GetBinaryFile(f);
                    //SearchBin(bf, a.ToString(), f);
                    using (BinaryReader br = new BinaryReader(new MemoryStream(aw.GetBinaryFile(f))))
                    {
                        SearchBin(br, a.ToString(), f);
                    }
                }
            }
            foreach (string a in Files)
            {
                Debug.WriteLine($"Searching {a}, for {searchstring}");
                using (BinaryReader br = new BinaryReader(File.OpenRead(a))) //new FileStream(a, FileMode.Open, FileAccess.Read, FileShare.None, 65536)))//
                {
                    br.BaseStream.Seek(0, SeekOrigin.Begin);
                    //byte[] bf = br.ReadBytes((int)br.BaseStream.Length);

                    //SearchBin(bf, a, "");
                    SearchBin(br, a, "");
                }
            }
        }
예제 #15
0
        public static BMPInfo[] GetTextures(string filename)
        {
            List <BMPInfo> functionReturnValue = new List <BMPInfo>();
            bool           gvm     = false;
            ArchiveBase    pvmfile = null;

            byte[] pvmdata = File.ReadAllBytes(filename);
            if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
            {
                pvmdata = FraGag.Compression.Prs.Decompress(pvmdata);
            }
            pvmfile = new PvmArchive();
            if (!pvmfile.Is(pvmdata, filename))
            {
                pvmfile = new GvmArchive();
                gvm     = true;
            }
            VrSharp.VpPalette      pvp        = null;
            ArchiveEntryCollection pvmentries = pvmfile.Open(pvmdata).Entries;

            foreach (ArchiveEntry file in pvmentries)
            {
                VrTexture vrfile = gvm ? (VrTexture) new GvrTexture(file.Open()) : (VrTexture) new PvrTexture(file.Open());
                if (vrfile.NeedsExternalPalette)
                {
                    using (System.Windows.Forms.OpenFileDialog a = new System.Windows.Forms.OpenFileDialog
                    {
                        DefaultExt = gvm ? "gvp" : "pvp",
                        Filter = gvm ? "GVP Files|*.gvp" : "PVP Files|*.pvp",
                        InitialDirectory = System.IO.Path.GetDirectoryName(filename),
                        Title = "External palette file"
                    })
                    {
                        if (pvp == null)
                        {
                            if (a.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                pvp = gvm ? (VpPalette) new GvpPalette(a.FileName) : (VpPalette) new PvpPalette(a.FileName);
                            }
                            else
                            {
                                return(new BMPInfo[0]);
                            }
                        }
                    }
                    if (gvm)
                    {
                        ((GvrTexture)vrfile).SetPalette((GvpPalette)pvp);
                    }
                    else
                    {
                        ((PvrTexture)vrfile).SetPalette((PvpPalette)pvp);
                    }
                }
                try
                {
                    functionReturnValue.Add(new BMPInfo(Path.GetFileNameWithoutExtension(file.Name), vrfile.ToBitmap()));
                }
                catch
                {
                    functionReturnValue.Add(new BMPInfo(Path.GetFileNameWithoutExtension(file.Name), new Bitmap(1, 1)));
                }
            }
            return(functionReturnValue.ToArray());
        }
예제 #16
0
파일: Program.cs 프로젝트: Sewer56/sa_tools
        static void Main(string[] args)
        {
            Queue <string> files = new Queue <string>(args);

            if (files.Count == 0)
            {
                Console.Write("File: ");
                files.Enqueue(Console.ReadLine());
            }
            while (files.Count > 0)
            {
                string filename = files.Dequeue();
                string path     = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(filename)), Path.GetFileNameWithoutExtension(filename));
                Directory.CreateDirectory(path);
                byte[] filedata = File.ReadAllBytes(filename);
                using (TextWriter texList = File.CreateText(Path.Combine(path, "index.txt")))
                {
                    try
                    {
                        if (PvrTexture.Is(filedata))
                        {
                            if (!AddTexture(false, path, Path.GetFileName(filename), new MemoryStream(filedata), texList))
                            {
                                texList.Close();
                                Directory.Delete(path, true);
                            }
                            continue;
                        }
                        else if (GvrTexture.Is(filedata))
                        {
                            if (!AddTexture(true, path, Path.GetFileName(filename), new MemoryStream(filedata), texList))
                            {
                                texList.Close();
                                Directory.Delete(path, true);
                            }
                            continue;
                        }
                        bool        gvm     = false;
                        ArchiveBase pvmfile = null;
                        byte[]      pvmdata = File.ReadAllBytes(filename);
                        if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
                        {
                            pvmdata = FraGag.Compression.Prs.Decompress(pvmdata);
                        }
                        pvmfile = new PvmArchive();
                        if (!pvmfile.Is(pvmdata, filename))
                        {
                            pvmfile = new GvmArchive();
                            gvm     = true;
                        }
                        ArchiveEntryCollection pvmentries = pvmfile.Open(pvmdata).Entries;
                        bool fail = false;
                        foreach (ArchiveEntry file in pvmentries)
                        {
                            if (!AddTexture(gvm, path, file.Name, file.Open(), texList))
                            {
                                texList.Close();
                                Directory.Delete(path, true);
                                fail = true;
                                break;
                            }
                        }
                        if (fail)
                        {
                            continue;
                        }
                    }
                    catch
                    {
                        Console.WriteLine("Exception thrown. Canceling conversion.");
                        Directory.Delete(path, true);
                        throw;
                    }
                }
            }
        }
예제 #17
0
        /// <summary>
        /// Read binary data from into structures and arrays
        /// </summary>
        /// <see cref="http://forums.qhimm.com/index.php?topic=16923.msg240609#msg240609"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain"/>
        /// <seealso cref="https://github.com/alexfilth/doomtrain/wiki/Kernel.bin"/>
        public KernelBin()
        {
            Memory.Log.WriteLine($"{nameof(KernelBin)} :: new ");
            ArchiveBase aw = ArchiveWorker.Load(ArchiveString);

            byte[]     buffer       = aw.GetBinaryFile(Memory.Strings[Strings.FileID.KERNEL].GetFilenames()[0]);
            List <Loc> subPositions = Memory.Strings[Strings.FileID.KERNEL].GetFiles().subPositions;

            MemoryStream ms;

            if (buffer == null)
            {
                return;
            }
            using (BinaryReader br = new BinaryReader(ms = new MemoryStream(buffer)))
            {
                ms.Seek(subPositions[BattleCommand.ID], SeekOrigin.Begin);
                BattleCommands = BattleCommand.Read(br);
                ms.Seek(subPositions[Magic_Data.id], SeekOrigin.Begin);
                MagicData = Magic_Data.Read(br);
                ms.Seek(subPositions[Junctionable_GFs_Data.id], SeekOrigin.Begin);
                JunctionableGFsData = Junctionable_GFs_Data.Read(br);
                ms.Seek(subPositions[Enemy_Attacks_Data.id], SeekOrigin.Begin);
                EnemyAttacksData = Enemy_Attacks_Data.Read(br);
                ms.Seek(subPositions[Weapons_Data.id], SeekOrigin.Begin);
                WeaponsData = Weapons_Data.Read(br);
                ms.Seek(subPositions[Renzokuken_Finishers_Data.id], SeekOrigin.Begin);
                RenzokukenFinishersData = Renzokuken_Finishers_Data.Read(br);
                ms.Seek(subPositions[Character_Stats.id], SeekOrigin.Begin);
                CharacterStats = Character_Stats.Read(br);
                ms.Seek(subPositions[BattleItemData.ID], SeekOrigin.Begin);
                BattleItemsData    = BattleItemData.Read(br);
                NonBattleItemsData = Non_battle_Items_Data.Read();
                ms.Seek(subPositions[Non_Junctionable_GFs_Attacks_Data.id], SeekOrigin.Begin);
                NonJunctionableGFsAttacksData = Non_Junctionable_GFs_Attacks_Data.Read(br);
                ms.Seek(subPositions[Command_ability_data.id], SeekOrigin.Begin);
                CommandAbilityData = Command_ability_data.Read(br);
                ms.Seek(subPositions[Kernel.JunctionAbilities.ID], SeekOrigin.Begin);
                JunctionAbilities = Kernel.JunctionAbilities.Read(br);
                ms.Seek(subPositions[Kernel.CommandAbilities.ID], SeekOrigin.Begin);
                CommandAbilities = Kernel.CommandAbilities.Read(br);
                ms.Seek(subPositions[StatPercentageAbilities.ID], SeekOrigin.Begin);
                StatPercentAbilities = StatPercentageAbilities.Read(br);
                ms.Seek(subPositions[Kernel.CharacterAbilities.ID], SeekOrigin.Begin);
                CharacterAbilities = Kernel.CharacterAbilities.Read(br);
                ms.Seek(subPositions[Kernel.PartyAbilities.ID], SeekOrigin.Begin);
                PartyAbilities = Kernel.PartyAbilities.Read(br);
                ms.Seek(subPositions[Kernel.GFAbilities.ID], SeekOrigin.Begin);
                GFAbilities = Kernel.GFAbilities.Read(br);
                ms.Seek(subPositions[Kernel.MenuAbilities.ID], SeekOrigin.Begin);
                MenuAbilities = Kernel.MenuAbilities.Read(br);
                ms.Seek(subPositions[Temporary_character_limit_breaks.id], SeekOrigin.Begin);
                TemporaryCharacterLimitBreaks = Temporary_character_limit_breaks.Read(br);
                ms.Seek(subPositions[Blue_Magic_Quistis_limit_break.id], SeekOrigin.Begin);
                BlueMagicQuistisLimitBreak = Blue_Magic_Quistis_limit_break.Read(br);
                //ms.Seek(subPositions[Quistis_limit_break_parameters.BattleID], SeekOrigin.Begin);
                //QuistisLimitBreakParameters = Quistis_limit_break_parameters.Read(br);
                ms.Seek(subPositions[Shot_Irvine_limit_break.id], SeekOrigin.Begin);
                ShotIrvineLimitBreak = Shot_Irvine_limit_break.Read(br);
                ms.Seek(subPositions[Duel_Zell_limit_break.id], SeekOrigin.Begin);
                DuelZellLimitBreak = Duel_Zell_limit_break.Read(br);
                ms.Seek(subPositions[Zell_limit_break_parameters.id], SeekOrigin.Begin);
                ZellLimitBreakParameters = Zell_limit_break_parameters.Read(br);
                ms.Seek(subPositions[Rinoa_limit_breaks_part_1.id], SeekOrigin.Begin);
                RinoaLimitBreaksPart1 = Rinoa_limit_breaks_part_1.Read(br);
                ms.Seek(subPositions[Rinoa_limit_breaks_part_2.id], SeekOrigin.Begin);
                RinoaLimitBreaksPart2 = Rinoa_limit_breaks_part_2.Read(br);
                ms.Seek(subPositions[Slot_array.id], SeekOrigin.Begin);
                SlotArray = Slot_array.Read(br);
                ms.Seek(subPositions[Selphie_limit_break_sets.id], SeekOrigin.Begin);
                SelphieLimitBreakSets = Selphie_limit_break_sets.Read(br);
                ms.Seek(subPositions[Kernel.Devour.id], SeekOrigin.Begin);
                List <Devour> tmp = Kernel.Devour.Read(br);
                tmp.Add(new Devour {
                    Description = Memory.Strings.Read(Strings.FileID.KERNEL, 30, 112)
                });
                Devour = tmp;
                ms.Seek(subPositions[Misc_section.id], SeekOrigin.Begin);
                MiscSection      = Misc_section.Read(br);
                MiscTextPointers = Misc_text_pointers.Read();

                Dictionary <Abilities, Ability> allAbilities = new Dictionary <Abilities, Ability>(Kernel.MenuAbilities.Count + Kernel.JunctionAbilities.Count + Kernel.CommandAbilities.Count + StatPercentageAbilities.Count + Kernel.CharacterAbilities.Count + Kernel.PartyAbilities.Count + Kernel.GFAbilities.Count);
                foreach (Abilities ability in (Abilities[])(Enum.GetValues(typeof(Abilities))))
                {
                    combine(MenuAbilities);
                    combine(StatPercentAbilities);
                    combine(JunctionAbilities);
                    combine(CommandAbilities);
                    combine(CharacterAbilities);
                    combine(PartyAbilities);
                    combine(GFAbilities);
                    void combine <T>(IReadOnlyDictionary <Abilities, T> dict)
                        where T : Ability
                    {
                        if (!dict.TryGetValue(ability, out T a))
                        {
                            return;
                        }
                        allAbilities.Add(ability, a);
                    }
                }

                AllAbilities = allAbilities;
                Dictionary <Abilities, EquippableAbility> equippableAbilities = new Dictionary <Abilities, EquippableAbility>(
                    StatPercentageAbilities.Count +
                    Kernel.CharacterAbilities.Count +
                    Kernel.PartyAbilities.Count +
                    Kernel.GFAbilities.Count);
                foreach (Abilities ability in (Abilities[])(Enum.GetValues(typeof(Abilities))))
                {
                    if (StatPercentAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = StatPercentAbilities[ability];
                    }
                    else if (CharacterAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = CharacterAbilities[ability];
                    }
                    else if (PartyAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = PartyAbilities[ability];
                    }
                    else if (CharacterAbilities.ContainsKey(ability))
                    {
                        equippableAbilities[ability] = CharacterAbilities[ability];
                    }
                }
                EquippableAbilities = equippableAbilities;
            }
        }
예제 #18
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Error - please specify a texture list (.txt), or a PRS/PVM/GVM archive.");
                Console.WriteLine("Press ENTER to exit.");
                Console.ReadLine();
                return;
            }
            string filePath = args[0];
            bool   IsPRS    = false;

            if (args.Length > 1 && args[1] == "-prs")
            {
                IsPRS = true;
            }
            string directoryName = Path.GetDirectoryName(filePath);
            string extension     = Path.GetExtension(filePath).ToLowerInvariant();

            switch (extension)
            {
            case ".txt":
                string archiveName = Path.GetFileNameWithoutExtension(filePath);
                if (File.Exists(filePath))
                {
                    List <string> textureNames = new List <string>(File.ReadAllLines(filePath).Where(a => !string.IsNullOrEmpty(a)));
                    ArchiveBase   pvmArchive;
                    string        ext = Path.GetExtension(textureNames[0]).ToLowerInvariant();
                    if (textureNames.Any(a => !Path.GetExtension(a).Equals(ext, StringComparison.OrdinalIgnoreCase)))
                    {
                        Console.WriteLine("Cannot create archive from mixed file types.");
                        return;
                    }
                    switch (ext)
                    {
                    case ".pvr":
                        pvmArchive = new PvmArchive();
                        break;

                    case ".gvr":
                        pvmArchive = new GvmArchive();
                        break;

                    default:
                        Console.WriteLine("Unknown file type \"{0}\".", ext);
                        return;
                    }
                    using (Stream pvmStream = File.Open(Path.ChangeExtension(filePath, ".pvm"), FileMode.Create))
                    {
                        ArchiveWriter pvmWriter = pvmArchive.Create(pvmStream);
                        // Reading in textures
                        foreach (string tex in textureNames)
                        {
                            pvmWriter.CreateEntryFromFile(Path.Combine(directoryName, Path.ChangeExtension(tex, ".pvr")));
                        }
                        pvmWriter.Flush();
                    }
                    if (IsPRS == true)
                    {
                        byte[] pvmdata = File.ReadAllBytes(Path.ChangeExtension(filePath, ".pvm"));
                        pvmdata = FraGag.Compression.Prs.Compress(pvmdata);
                        File.WriteAllBytes(Path.ChangeExtension(filePath, ".prs"), pvmdata);
                        File.Delete(Path.ChangeExtension(filePath, ".pvm"));
                    }
                    Console.WriteLine("Archive was compiled successfully!");
                }
                else                         // error, supplied path is invalid
                {
                    Console.WriteLine("Supplied archive/texture list does not exist!");
                    Console.WriteLine("Press ENTER to exit.");
                    Console.ReadLine();
                }
                break;

            case ".prs":
            case ".pvm":
            case ".gvm":
                string path = Path.Combine(directoryName, Path.GetFileNameWithoutExtension(filePath));
                Directory.CreateDirectory(path);
                byte[] filedata = File.ReadAllBytes(filePath);
                using (TextWriter texList = File.CreateText(Path.Combine(path, Path.ChangeExtension(filePath, ".txt"))))
                {
                    try
                    {
                        ArchiveBase pvmfile = null;
                        byte[]      pvmdata = File.ReadAllBytes(filePath);
                        if (extension == ".prs")
                        {
                            pvmdata = FraGag.Compression.Prs.Decompress(pvmdata);
                        }
                        pvmfile = new PvmArchive();
                        if (!pvmfile.Is(pvmdata, filePath))
                        {
                            pvmfile = new GvmArchive();
                        }
                        ArchiveReader pvmReader = pvmfile.Open(pvmdata);
                        foreach (ArchiveEntry file in pvmReader.Entries)
                        {
                            texList.WriteLine(file.Name);
                            pvmReader.ExtractToFile(file, Path.Combine(path, file.Name));
                        }
                        Console.WriteLine("Archive extracted!");
                    }
                    catch
                    {
                        Console.WriteLine("Exception thrown. Canceling conversion.");
                        Directory.Delete(path, true);
                        throw;
                    }
                }
                break;

            default:
                Console.WriteLine("Unknown extension \"{0}\".", extension);
                break;
            }
        }
예제 #19
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("ArchiveTool is a command line tool to manipulate PVM, GVM and PRS archives.\n");
                Console.WriteLine("Usage:\n");
                Console.WriteLine("Extracting a PVM/GVM/PRS archive:\nArchiveTool file.pvm\nIf the archive is PRS compressed, it will be decompressed first.\nIf the archive contains textures, the program will produce a folder with all PVR/GVR textures and a texture list.\nThe texture list is a text file with each line containing a texture file name.\n");
                Console.WriteLine("Creating a PVM/GVM:\nArchiveTool texturelist.txt\nThe program will produce a PVM or GVM archive from a texture list.\nThe textures must be in the same folder as the texture list.\n");
                Console.WriteLine("Creating a PRS compressed PVM/GVM:\nArchiveTool texturelist.txt -prs\nSame as the previous option but the PVM/GVM file will be PRS compressed.\n");
                Console.WriteLine("Creating a PRS compressed binary:\nArchiveTool file.bin\nA PRS archive will be created from the file.\nFile extension must be .BIN for this option to work.\n");
                Console.WriteLine("Press ENTER to exit.");
                Console.ReadLine();
                return;
            }
            string filePath = args[0];
            bool   IsPRS    = false;
            bool   IsGVM    = false;
            bool   IsBIN    = false;

            if (args.Length > 1 && args[1] == "-prs")
            {
                IsPRS = true;
            }
            string directoryName = Path.GetDirectoryName(filePath);
            string extension     = Path.GetExtension(filePath).ToLowerInvariant();

            if (!File.Exists(filePath))
            {
                Console.WriteLine("Supplied archive/texture list does not exist!");
                Console.WriteLine("Press ENTER to exit.");
                Console.ReadLine();
                return;
            }
            switch (extension)
            {
            case ".bin":
                byte[] bindata = File.ReadAllBytes(Path.ChangeExtension(filePath, ".bin"));
                bindata = FraGag.Compression.Prs.Compress(bindata);
                File.WriteAllBytes(Path.ChangeExtension(filePath, ".prs"), bindata);
                Console.WriteLine("PRS archive was compiled successfully!");
                break;

            case ".txt":
                string        archiveName  = Path.GetFileNameWithoutExtension(filePath);
                List <string> textureNames = new List <string>(File.ReadAllLines(filePath).Where(a => !string.IsNullOrEmpty(a)));
                ArchiveBase   pvmArchive;
                string        ext = Path.GetExtension(textureNames[0]).ToLowerInvariant();
                if (textureNames.Any(a => !Path.GetExtension(a).Equals(ext, StringComparison.OrdinalIgnoreCase)))
                {
                    Console.WriteLine("Cannot create archive from mixed file types.");
                    Console.WriteLine("Press ENTER to exit.");
                    Console.ReadLine();
                    return;
                }
                switch (ext)
                {
                case ".pvr":
                    pvmArchive = new PvmArchive();
                    break;

                case ".gvr":
                    pvmArchive = new GvmArchive();
                    IsGVM      = true;
                    break;

                default:
                    Console.WriteLine("Unknown file type \"{0}\".", ext);
                    Console.WriteLine("Press ENTER to exit.");
                    Console.ReadLine();
                    return;
                }
                if (!IsGVM)
                {
                    ext = ".pvm";
                }
                else
                {
                    ext = ".gvm";
                }
                using (Stream pvmStream = File.Open(Path.ChangeExtension(filePath, ext), FileMode.Create))
                {
                    ArchiveWriter pvmWriter = pvmArchive.Create(pvmStream);
                    // Reading in textures
                    foreach (string tex in textureNames)
                    {
                        if (!IsGVM)
                        {
                            pvmWriter.CreateEntryFromFile(Path.Combine(directoryName, Path.ChangeExtension(tex, ".pvr")));
                        }
                        else
                        {
                            pvmWriter.CreateEntryFromFile(Path.Combine(directoryName, Path.ChangeExtension(tex, ".gvr")));
                        }
                    }
                    pvmWriter.Flush();
                }
                if (IsPRS)
                {
                    byte[] pvmdata = File.ReadAllBytes(Path.ChangeExtension(filePath, ext));
                    pvmdata = FraGag.Compression.Prs.Compress(pvmdata);
                    File.WriteAllBytes(Path.ChangeExtension(filePath, ".prs"), pvmdata);
                    File.Delete(Path.ChangeExtension(filePath, ext));
                }
                Console.WriteLine("Archive was compiled successfully!");
                break;

            case ".prs":
            case ".pvm":
            case ".gvm":
                string path = Path.Combine(directoryName, Path.GetFileNameWithoutExtension(filePath));
                Directory.CreateDirectory(path);
                byte[] filedata = File.ReadAllBytes(filePath);
                using (TextWriter texList = File.CreateText(Path.Combine(path, Path.ChangeExtension(filePath, ".txt"))))
                {
                    try
                    {
                        ArchiveBase pvmfile = null;
                        byte[]      pvmdata = File.ReadAllBytes(filePath);
                        if (extension == ".prs")
                        {
                            pvmdata = FraGag.Compression.Prs.Decompress(pvmdata);
                        }
                        pvmfile = new PvmArchive();
                        MemoryStream stream = new MemoryStream(pvmdata);
                        if (!PvmArchive.Identify(stream))
                        {
                            pvmfile = new GvmArchive();
                            if (!GvmArchive.Identify(stream))
                            {
                                File.WriteAllBytes(Path.ChangeExtension(filePath, ".bin"), pvmdata);
                                IsBIN = true;
                                Console.WriteLine("PRS archive extracted!");
                            }
                        }
                        if (!IsBIN)
                        {
                            ArchiveReader pvmReader = pvmfile.Open(pvmdata);
                            foreach (ArchiveEntry file in pvmReader.Entries)
                            {
                                texList.WriteLine(file.Name);
                                pvmReader.ExtractToFile(file, Path.Combine(path, file.Name));
                            }
                            Console.WriteLine("Archive extracted!");
                        }
                    }
                    catch
                    {
                        Console.WriteLine("Exception thrown. Canceling conversion.");
                        Console.WriteLine("Press ENTER to exit.");
                        Console.ReadLine();
                        Directory.Delete(path, true);
                        throw;
                    }
                }
                if (IsBIN)
                {
                    File.Delete(Path.Combine(path, Path.ChangeExtension(filePath, ".txt")));
                    Directory.Delete(path, true);
                }
                break;

            default:
                Console.WriteLine("Unknown extension \"{0}\".", extension);
                Console.WriteLine("Press ENTER to exit.");
                Console.ReadLine();
                break;
            }
        }
예제 #20
0
        public void saveFun()
        {
            if (File.Exists("printtemp\\xpsShow.xps"))
            {
                File.Delete("printtemp\\xpsShow.xps");
            }

            foreach (string strFile in Directory.GetFiles("printTemp"))
            {
                File.Delete(strFile);
            }

            if (!Directory.Exists(@"D:\汇出打印文件\" + date))
            {
                //foreach (string strFile in Directory.GetFiles(@"D:\汇出打印文件"))
                //{
                //    File.Delete(strFile);
                //}
                Directory.CreateDirectory(@"D:\汇出打印文件\" + date);
            }
            //else Directory.CreateDirectory(@"D:\汇出打印文件");

            RecordsBaseInfoBLL archive_baseinfo = new RecordsBaseInfoBLL();

            count        = 0;
            IsHaveReport = false;
            IGetReport igp;

            string[] SelectName = PrintType.Split(';');
            int      no         = 1;

            // 取得资料笔数
            DataTable dtData = archive_baseinfo.GetList(PrintWhere, "").Tables[0];
            DataTable dt     = dtData.DefaultView.ToTable("IDCardNo", true, "IDCardNo");

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i += 10)
                {
                    CardID = "";

                    for (int j = i; j < i + 10; j++)
                    {
                        if (j < dt.Rows.Count)
                        {
                            CardID += dt.Rows[j]["IDCardNo"].ToString() + ";";
                        }
                        else
                        {
                            break;
                        }
                    }

                    IDCard.Add(CardID);

                    #region 生成文件

                    string[] idCardsStrings = CardID.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string idCardNo in idCardsStrings)
                    {
                        foreach (string name in SelectName)
                        {
                            switch (name)
                            {
                            case "封面":
                                if (area == "淄博")
                                {
                                    igp = new HealthReport();
                                }
                                else
                                {
                                    igp = new ArchiveCover();
                                }

                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "基本信息":
                                igp = new ArchiveBase();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "健康体检表":
                                igp = new ArchivePhysical();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "高血压随访":
                                igp = new Hypertension_Followup();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "糖尿病随访":
                                igp = new Diabetes_Followup();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "精神病信息补充":
                                igp = new Mentaldisease_Baseinfo();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "精神病随访":
                                igp = new Mentaldisease_Followup();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "居民健康档案卡":
                                igp = new ArchiveCard();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "老年人中医健康":
                                igp = new Old_Medicine_CN();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "新生儿家庭访视":
                                igp = new Child_With_NEW();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "1岁内儿童健康检查":
                                igp = new Child_With_ONE();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "1-2岁内儿童健康检查":
                                igp = new Child_With_TWO();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "3-6岁内儿童健康检查":
                                igp = new Child_With_THREE();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "第1次产前随访":
                                igp = new GRAVIDA_FRIST();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "第2-5次产前随访":
                                igp = new GRAVIDA_TWO();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "产后访视记录":
                                igp = new GRAVIDA_Postpartum();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "产后42天健康检查":
                                igp = new GRAVIDA_Postpartum42();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "脑卒中随访记录":
                                igp = new Stroke_Followup();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "冠心病随访记录":
                                igp = new CHD_Follow();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "6-18月龄儿童中医健康":
                                igp = new Child_CN_ONE();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "24-36月龄儿童中医健康":
                                igp = new Child_CN_TWO();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "3-6岁内儿童中医健康":
                                igp = new Child_CN_THREE();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "第1次肺结核随访":
                                igp = new LungerFirstVisit();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "肺结核随访":
                                igp = new ChronicLungerVisit();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "健康教育":
                                igp = new HealthEducation();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "接诊记录":
                                igp = new Medical_Receive();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "会诊记录":
                                igp = new Medical_Consulation();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "双向转诊":
                                igp = new Medical_Refferral();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "健康体检反馈单":
                                igp = new HealthFeedback();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "老年人自理能力":
                                igp = new Physical_OldSelfCare();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "65岁以上老年人健康体检反馈单":
                                if (area.Equals("淄博"))
                                {
                                    igp = new OldHealthFeedback();
                                }
                                else if (community.Equals("日照街道社区"))
                                {
                                    igp = new OldHealthFeedbackRiZhao();
                                }
                                else
                                {
                                    igp = new OldHealthFeedbackYuCheng();
                                }

                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "档案封面":
                                igp = new HealthCoverCard();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "血生化、血常规、尿液数据":
                                igp = new Blood_Urine();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            case "心电":
                                string ecgType = DrawItems.GetECGConfig();

                                if (ecgType == "2")
                                {
                                    igp        = new ElectroCardioGramcs();
                                    igp.CardID = idCardNo;
                                    if (!igp.hasData())
                                    {
                                        igp = null;
                                    }
                                    else
                                    {
                                        this.saveInvoke(igp, idCardNo, no.ToString());
                                    }
                                }
                                break;

                            case "B超":
                                igp        = new TypeBchao();
                                igp.CardID = idCardNo;
                                if (!igp.hasData())
                                {
                                    igp = null;
                                }
                                else
                                {
                                    this.saveInvoke(igp, idCardNo, no.ToString());
                                }
                                break;

                            case "体检报告":
                                igp = new PhyicalReport();
                                this.saveInvoke(igp, idCardNo, no.ToString());
                                break;

                            default:
                                igp = null;
                                break;
                            }
                        }

                        no++;

                        if (no % 10 == 0)
                        {
                            Thread.Sleep(1000);
                        }
                    }

                    #endregion
                }

                Thread.Sleep(1000);

                if (!IsHaveReport)
                {
                    System.Windows.Forms.MessageBox.Show("无可汇出资料!", "提示",
                                                         System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk,
                                                         System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);

                    CloseWin("none");

                    return;
                }

                this.setMsg("开始生成合并文档");
                this.MergeInvoke();
                this.CloseWin("test");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("无可汇出资料!", "提示",
                                                     System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk,
                                                     System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);

                CloseWin("none");

                return;
            }
        }
예제 #21
0
        public void saveFun()
        {
            //if (File.Exists("printtemp\\xpsShow.xps"))
            //{
            //    File.Delete("printtemp\\xpsShow.xps");
            //}

            //foreach (string strFile in Directory.GetFiles("printTemp"))
            //{
            //    File.Delete(strFile);
            //}

            string[] idCardsStrings = CardID.Split(';');

            count        = 0;
            IsHaveReport = false;

            IGetReport igp;

            //int i = 0;
            //int n = 0;

            foreach (string idCardNo in idCardsStrings)
            {
                //n ++;

                //if (n != idCardsStrings.Length)
                //{
                //    if (PrintType == "btnOLDMEDICINECN")
                //    {
                //        RecordsCustomerBaseInfoModel modelc = new RecordsCustomerBaseInfoDAL().GetMaxModel(idCardNo);
                //        if (modelc == null )
                //        {
                //            continue;
                //        }
                //        RecordsMediPhysDistModel modelMdist = new RecordsMediPhysDistDAL().GetModelByOutKey(modelc.ID);
                //        if (modelMdist != null)
                //        {
                //            RecordsMedicineCnModel model2 = new RecordsMedicineCnBLL().GetModel(modelMdist.MedicineID);

                //            if (model2 == null || model2.FollowUpDoctor == "")
                //            {
                //                continue;
                //            }
                //        }
                //    }
                //}
                //else
                //{
                //    if (i != 0)
                //    {
                //        if (PrintType == "btnOLDMEDICINECN")
                //        {
                //            RecordsCustomerBaseInfoModel modelc = new RecordsCustomerBaseInfoDAL().GetMaxModel(idCardNo);
                //            if (modelc == null)
                //            {
                //                continue;
                //            }
                //            RecordsMediPhysDistModel modelMdist = new RecordsMediPhysDistDAL().GetModelByOutKey(modelc.ID);
                //            if (modelMdist != null)
                //            {
                //                RecordsMedicineCnModel model2 = new RecordsMedicineCnBLL().GetModel(modelMdist.MedicineID);

                //                if (model2 == null || model2.FollowUpDoctor == "")
                //                {
                //                    continue;
                //                }
                //            }
                //        }
                //    }
                //}

                //i++;

                switch (PrintType)
                {
                case "btnFengmian":
                    if (area == "淄博")
                    {
                        igp = new HealthReport();
                        saveInvoke(igp, idCardNo);
                    }
                    else
                    {
                        igp = new ArchiveCover();
                        saveInvoke(igp, idCardNo);
                    }
                    break;

                case "btnBaseInfo":
                    igp = new ArchiveBase();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnHyper":
                    igp = new Hypertension_Followup();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnDiabetes":
                    igp = new Diabetes_Followup();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnMentaldisease_Baseinfo":
                    igp = new Mentaldisease_Baseinfo();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnMentalFollow":
                    igp = new Mentaldisease_Followup();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnPhysical":
                    igp = new ArchivePhysical();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnArchiveCard":
                    igp = new ArchiveCard();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnChildInOne":
                    igp = new Child_With_ONE();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnChildNEW":
                    igp = new Child_With_NEW();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnChildTWO":
                    igp = new Child_With_TWO();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnChildTHREE":
                    igp = new Child_With_THREE();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnGRAVIDA_FRIST":
                    igp = new GRAVIDA_FRIST();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnGRAVIDA_TWO":
                    igp = new GRAVIDA_TWO();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnGRAVIDA_POST":
                    igp = new GRAVIDA_Postpartum();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnGRAVIDA_POST42":
                    igp = new GRAVIDA_Postpartum42();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnOLDMEDICINECN":

                    igp = new Old_Medicine_CN();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnChildCNOne":
                    igp = new Child_CN_ONE();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnChildCNOne2Three":
                    igp = new Child_CN_TWO();
                    saveInvoke(igp, idCardNo);
                    break;

                //case "btnChildCNThree2Six":
                //    igp = new Child_CN_THREE();
                //    saveInvoke(igp, idCardNo);
                //    break;
                case "btnChd":
                    igp = new CHD_Follow();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btStroke":
                    igp = new Stroke_Followup();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnOnePTBVisit":
                    igp = new LungerFirstVisit();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnPTBVisit":
                    igp = new ChronicLungerVisit();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnHealth":
                    igp = new HealthEducation();
                    //igp = new HealthExamination();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnHealthFeedback":
                    igp = new HealthFeedback();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnMReceiveTreat":
                    igp = new Medical_Receive();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnMConsulation":
                    igp = new Medical_Consulation();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnMReferral":
                    igp = new Medical_Refferral();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnPhyOLDSelf":
                    igp = new Physical_OldSelfCare();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnOldHealthFeedback":
                    if (area.Equals("淄博"))
                    {
                        igp = new OldHealthFeedback();
                    }
                    else if (community.Equals("日照街道社区"))
                    {
                        igp = new OldHealthFeedbackRiZhao();
                    }
                    else
                    {
                        igp = new OldHealthFeedbackYuCheng();
                    }
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnCoverCard":
                    igp = new HealthCoverCard();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnBloodUrine":
                    igp = new Blood_Urine();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnCoverCard_2":
                    igp = new HealthCoverCard_Colour();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnECG":
                    string ecgType = DrawItems.GetECGConfig();

                    if (ecgType == "2")
                    {
                        igp        = new ElectroCardioGramcs();
                        igp.CardID = idCardNo;
                        if (!igp.hasData())
                        {
                            igp = null;
                        }
                        else
                        {
                            this.saveInvoke(igp, idCardNo);
                        }
                    }
                    break;

                case "btnTypeBUI":
                    igp        = new TypeBchao();
                    igp.CardID = idCardNo;
                    if (!igp.hasData())
                    {
                        igp = null;
                    }
                    else
                    {
                        this.saveInvoke(igp, idCardNo);
                    }
                    break;

                case "btnPhyicalRe":
                    igp = new PhyicalReport();
                    saveInvoke(igp, idCardNo);
                    break;

                case "btnOldCover":
                    igp = new OldHealthReport();
                    saveInvoke(igp, idCardNo);
                    break;

                default:
                    igp = null;
                    break;
                }
            }

            Thread.Sleep(1000);

            if (!IsHaveReport)
            {
                System.Windows.Forms.MessageBox.Show("无打印资料!", "提示",
                                                     System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk,
                                                     System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);

                CloseWin("test");

                return;
            }

            setMsg("开始生成合并文档");
            MergeInvoke();
            CloseWin("test");
        }
예제 #22
0
 public ArchivedEvent(IAcSession acSession, ArchiveBase source)
     : base(acSession, source)
 {
 }
예제 #23
0
        public static BMPInfo[] GetTextures(string filename)
        {
            if (!File.Exists(filename))
            {
                return(null);
            }
            string ext = Path.GetExtension(filename).ToLowerInvariant();

            switch (ext)
            {
            case ".pak":
                PAKFile        pak         = new PAKFile(filename);
                string         filenoext   = Path.GetFileNameWithoutExtension(filename).ToLowerInvariant();
                byte[]         inf         = pak.Files.Single((file) => file.Name.Equals(filenoext + '\\' + filenoext + ".inf", StringComparison.OrdinalIgnoreCase)).Data;
                List <BMPInfo> newtextures = new List <BMPInfo>(inf.Length / 0x3C);
                for (int i = 0; i < inf.Length; i += 0x3C)
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder(0x1C);
                    for (int j = 0; j < 0x1C; j++)
                    {
                        if (inf[i + j] != 0)
                        {
                            sb.Append((char)inf[i + j]);
                        }
                        else
                        {
                            break;
                        }
                    }
                    byte[] dds = pak.Files.First((file) => file.Name.Equals(filenoext + '\\' + sb.ToString() + ".dds", StringComparison.OrdinalIgnoreCase)).Data;
                    using (MemoryStream str = new MemoryStream(dds))
                    {
                        uint check = BitConverter.ToUInt32(dds, 0);
                        if (check == 0x20534444)     // DDS header
                        {
                            PixelFormat pxformat;
                            var         image = Pfim.Pfim.FromStream(str, new Pfim.PfimConfig());
                            switch (image.Format)
                            {
                            case Pfim.ImageFormat.Rgba32:
                                pxformat = PixelFormat.Format32bppArgb;
                                break;

                            default:
                                System.Windows.Forms.MessageBox.Show("Unsupported image format.");
                                throw new NotImplementedException();
                            }
                            var        bitmap  = new Bitmap(image.Width, image.Height, pxformat);
                            BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, pxformat);
                            System.Runtime.InteropServices.Marshal.Copy(image.Data, 0, bmpData.Scan0, image.DataLen);
                            bitmap.UnlockBits(bmpData);
                            newtextures.Add(new BMPInfo(sb.ToString(), bitmap));
                        }
                        else
                        {
                            newtextures.Add(new BMPInfo(sb.ToString(), new Bitmap(str)));
                        }
                    }
                }
                return(newtextures.ToArray());

            case ".pvmx":
                PVMXFile       pvmx     = new PVMXFile(File.ReadAllBytes(filename));
                List <BMPInfo> textures = new List <BMPInfo>();
                for (int i = 0; i < pvmx.GetCount(); i++)
                {
                    var bmp = new Bitmap(new MemoryStream(pvmx.GetFile(i)));
                    textures.Add(new BMPInfo(pvmx.GetNameWithoutExtension(i), bmp));
                }
                return(textures.ToArray());

            case ".txt":
                string[]       files = File.ReadAllLines(filename);
                List <BMPInfo> txts  = new List <BMPInfo>();
                for (int s = 0; s < files.Length; s++)
                {
                    string[] entry = files[s].Split(',');
                    txts.Add(new BMPInfo(entry[1], new System.Drawing.Bitmap(Path.Combine(Path.GetDirectoryName(filename), entry[1]))));
                }
                return(txts.ToArray());

            case ".pb":
                PBFile         pbdata = new PBFile(File.ReadAllBytes(filename));
                List <BMPInfo> txtsp  = new List <BMPInfo>();
                for (int i = 0; i < pbdata.GetCount(); i++)
                {
                    PvrTexture pvr = new PvrTexture(pbdata.GetPVR(i));
                    txtsp.Add(new BMPInfo(i.ToString("D3"), pvr.ToBitmap()));
                }
                return(txtsp.ToArray());

            case ".pvm":
            case ".gvm":
            default:
                List <BMPInfo> functionReturnValue = new List <BMPInfo>();
                bool           gvm     = false;
                ArchiveBase    pvmfile = null;
                byte[]         pvmdata = File.ReadAllBytes(filename);
                if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
                {
                    pvmdata = FraGag.Compression.Prs.Decompress(pvmdata);
                }
                pvmfile = new PvmArchive();
                MemoryStream stream = new MemoryStream(pvmdata);
                if (!PvmArchive.Identify(stream))
                {
                    pvmfile = new GvmArchive();
                    gvm     = true;
                }
                VrSharp.VpPalette      pvp        = null;
                ArchiveEntryCollection pvmentries = pvmfile.Open(pvmdata).Entries;
                foreach (ArchiveEntry file in pvmentries)
                {
                    VrTexture vrfile = gvm ? (VrTexture) new GvrTexture(file.Open()) : (VrTexture) new PvrTexture(file.Open());
                    if (vrfile.NeedsExternalPalette)
                    {
                        using (System.Windows.Forms.OpenFileDialog a = new System.Windows.Forms.OpenFileDialog
                        {
                            DefaultExt = gvm ? "gvp" : "pvp",
                            Filter = gvm ? "GVP Files|*.gvp" : "PVP Files|*.pvp",
                            InitialDirectory = System.IO.Path.GetDirectoryName(filename),
                            Title = "External palette file"
                        })
                        {
                            if (pvp == null)
                            {
                                if (a.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    pvp = gvm ? (VpPalette) new GvpPalette(a.FileName) : (VpPalette) new PvpPalette(a.FileName);
                                }
                                else
                                {
                                    return(new BMPInfo[0]);
                                }
                            }
                        }
                        if (gvm)
                        {
                            ((GvrTexture)vrfile).SetPalette((GvpPalette)pvp);
                        }
                        else
                        {
                            ((PvrTexture)vrfile).SetPalette((PvpPalette)pvp);
                        }
                    }
                    try
                    {
                        functionReturnValue.Add(new BMPInfo(Path.GetFileNameWithoutExtension(file.Name), vrfile.ToBitmap()));
                    }
                    catch
                    {
                        functionReturnValue.Add(new BMPInfo(Path.GetFileNameWithoutExtension(file.Name), new Bitmap(1, 1)));
                    }
                }
                return(functionReturnValue.ToArray());
            }
        }
예제 #24
0
        static void Main(string[] args)
        {
            ArchiveFromFolderMode folderMode;
            string        dir;
            string        filePath;
            string        directoryName;
            ArchiveBase   pvmArchive;
            ArchiveWriter pvmWriter;
            string        archiveName;
            string        path;

            byte[] filedata;
            bool   isPRS;
            bool   isBIN = false;
            string extension;

            // Usage
            if (args.Length == 0)
            {
                Console.WriteLine("ArchiveTool is a command line tool to extract and create PVM, GVM, PRS, DAT and PB archives.\nIt can also decompress SADX Gamecube 'SaCompGC' REL files.\n");
                Console.WriteLine("Usage:\n");
                Console.WriteLine("Extracting a PVM/GVM/PRS/PB/PVMX/DAT/REL file:\nArchiveTool <archivefile>\nIf the archive is PRS compressed, it will be decompressed first.\nIf the archive contains textures/sounds, the program will extract them and create a list of files named 'index.txt'.\n");
                Console.WriteLine("Extracting an NjUtil archive: ArchiveTool -nju <archivefile>\n");
                Console.WriteLine("Converting PVM/GVM to a folder texture pack: ArchiveTool -png <archivefile>\n");
                Console.WriteLine("Creating a PB archive from a folder with textures: ArchiveTool -pb <foldername>");
                Console.WriteLine("Creating a PVM/GVM/DAT/PVMX from a folder with textures/sounds: ArchiveTool <foldername> [-prs]\nThe program will create an archive from files listed in 'index.txt' in the folder.\nThe -prs option will make the program output a PRS compressed archive.\n");
                Console.WriteLine("Creating a PVM from PNG textures: ArchiveTool -pvm <folder> [-prs]\nThe texture list 'index.txt' must contain global indices listed before each texture filename for this option to work.\n");
                Console.WriteLine("Converting GVM to PVM (lossy): ArchiveTool -gvm2pvm <file.gvm> [-prs]\n");
                Console.WriteLine("Creating a PRS compressed binary: ArchiveTool <file.bin>\nFile extension must be .BIN for this option to work.\n");
                Console.WriteLine("Press ENTER to exit.");
                Console.ReadLine();
                return;
            }
            switch (args[0].ToLowerInvariant())
            {
            // GVM2PVM mode
            case "-gvm2pvm":
                filePath = args[1];
                isPRS    = false;
                if (args.Length > 2 && args[2] == "-prs")
                {
                    isPRS = true;
                }
                Console.WriteLine("Converting GVM to PVM: {0}", filePath);
                directoryName = Path.GetDirectoryName(filePath);
                extension     = Path.GetExtension(filePath).ToLowerInvariant();
                if (!File.Exists(filePath))
                {
                    Console.WriteLine("Supplied GVM archive does not exist!");
                    Console.WriteLine("Press ENTER to exit.");
                    Console.ReadLine();
                    return;
                }
                if (extension != ".gvm")
                {
                    Console.WriteLine("GVM2PVM mode can only be used with GVM files.");
                    Console.WriteLine("Press ENTER to exit.");
                    Console.ReadLine();
                    return;
                }
                path = Path.Combine(directoryName, Path.GetFileNameWithoutExtension(filePath));
                Directory.CreateDirectory(path);
                filedata = File.ReadAllBytes(filePath);
                using (TextWriter texList = File.CreateText(Path.Combine(path, Path.GetFileName(path) + ".txt")))
                {
                    try
                    {
                        ArchiveBase gvmfile = null;
                        byte[]      gvmdata = File.ReadAllBytes(filePath);
                        gvmfile = new GvmArchive();
                        ArchiveReader gvmReader = gvmfile.Open(gvmdata);
                        Stream        pvmStream = File.Open(Path.ChangeExtension(filePath, ".pvm"), FileMode.Create);
                        pvmArchive = new PvmArchive();
                        pvmWriter  = pvmArchive.Create(pvmStream);
                        foreach (ArchiveEntry file in gvmReader.Entries)
                        {
                            if (!File.Exists(Path.Combine(path, file.Name)))
                            {
                                gvmReader.ExtractToFile(file, Path.Combine(path, file.Name));
                            }
                            Stream    data        = File.Open(Path.Combine(path, file.Name), FileMode.Open);
                            VrTexture vrfile      = new GvrTexture(data);
                            Bitmap    tempTexture = vrfile.ToBitmap();
                            System.Drawing.Imaging.BitmapData bmpd = tempTexture.LockBits(new Rectangle(Point.Empty, tempTexture.Size), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                            int    stride = bmpd.Stride;
                            byte[] bits   = new byte[Math.Abs(stride) * bmpd.Height];
                            System.Runtime.InteropServices.Marshal.Copy(bmpd.Scan0, bits, 0, bits.Length);
                            tempTexture.UnlockBits(bmpd);
                            int tlevels = 0;
                            archiveName = Path.GetFileNameWithoutExtension(filePath);
                            for (int y = 0; y < tempTexture.Height; y++)
                            {
                                int srcaddr = y * Math.Abs(stride);
                                for (int x = 0; x < tempTexture.Width; x++)
                                {
                                    Color c = Color.FromArgb(BitConverter.ToInt32(bits, srcaddr + (x * 4)));
                                    if (c.A == 0)
                                    {
                                        tlevels = 1;
                                    }
                                    else if (c.A < 255)
                                    {
                                        tlevels = 2;
                                        break;
                                    }
                                }
                                if (tlevels == 2)
                                {
                                    break;
                                }
                            }
                            PvrPixelFormat ppf = PvrPixelFormat.Rgb565;
                            if (tlevels == 1)
                            {
                                ppf = PvrPixelFormat.Argb1555;
                            }
                            else if (tlevels == 2)
                            {
                                ppf = PvrPixelFormat.Argb4444;
                            }
                            PvrDataFormat pdf;
                            if (!vrfile.HasMipmaps)
                            {
                                if (tempTexture.Width == tempTexture.Height)
                                {
                                    pdf = PvrDataFormat.SquareTwiddled;
                                }
                                else
                                {
                                    pdf = PvrDataFormat.Rectangle;
                                }
                            }
                            else
                            {
                                if (tempTexture.Width == tempTexture.Height)
                                {
                                    pdf = PvrDataFormat.SquareTwiddledMipmaps;
                                }
                                else
                                {
                                    pdf = PvrDataFormat.RectangleTwiddled;
                                }
                            }
                            PvrTextureEncoder encoder = new PvrTextureEncoder(tempTexture, ppf, pdf);
                            encoder.GlobalIndex = vrfile.GlobalIndex;
                            string pvrPath = Path.ChangeExtension(Path.Combine(path, file.Name), ".pvr");
                            if (!File.Exists(pvrPath))
                            {
                                encoder.Save(pvrPath);
                            }
                            data.Close();
                            File.Delete(Path.Combine(path, file.Name));
                            pvmWriter.CreateEntryFromFile(pvrPath);
                            texList.WriteLine(Path.GetFileName(pvrPath));
                            Console.WriteLine("Adding texture {0}", pvrPath);
                        }
                        pvmWriter.Flush();
                        pvmStream.Flush();
                        pvmStream.Close();
                        if (isPRS)
                        {
                            Console.WriteLine("Compressing to PRS...");
                            byte[] pvmdata = File.ReadAllBytes(Path.ChangeExtension(filePath, ".pvm"));
                            pvmdata = FraGag.Compression.Prs.Compress(pvmdata);
                            File.WriteAllBytes(Path.ChangeExtension(filePath, ".PVM.PRS"), pvmdata);
                            File.Delete(Path.ChangeExtension(filePath, ".PVM"));
                        }
                        Console.WriteLine("Archive converted!");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Exception thrown: {0}", ex.ToString());
                        Console.WriteLine("Press ENTER to exit.");
                        Console.ReadLine();
                        return;
                    }
                }
                break;

            // CompilePVM mode
            case "-pvm":
                bool IsPRS = false;
                if (args[args.Length - 1] == "-prs")
                {
                    IsPRS = true;
                }
                filePath = args[1];
                string            FullLine;
                string            texturename;
                uint              GBIX             = 0;
                List <string>     textureNames     = new List <String>();
                List <PvrTexture> finalTextureList = new List <PvrTexture>();
                directoryName = Path.GetDirectoryName(filePath);
                archiveName   = Path.GetFileNameWithoutExtension(filePath);
                if (Directory.Exists(filePath))
                {
                    Console.WriteLine("Converting texture pack to PVM: {0}", filePath);
                    StreamReader texlistStream = File.OpenText(Path.Combine(filePath, "index.txt"));
                    while (!texlistStream.EndOfStream)
                    {
                        textureNames.Add(texlistStream.ReadLine());
                    }
                    pvmArchive = new PvmArchive();
                    Stream pvmStream = File.Open(Path.ChangeExtension(filePath, ".pvm"), FileMode.Create);
                    pvmWriter = (PvmArchiveWriter)pvmArchive.Create(pvmStream);
                    // Reading in textures
                    for (uint imgIndx = 0; imgIndx < textureNames.Count; imgIndx++)
                    {
                        FullLine = textureNames[(int)imgIndx];
                        if (string.IsNullOrEmpty(FullLine))
                        {
                            continue;
                        }
                        String[] substrings = FullLine.Split(',');
                        GBIX        = UInt32.Parse(substrings[0]);
                        texturename = substrings[1];
                        Bitmap tempTexture = new Bitmap(8, 8);
                        string texturePath = Path.Combine(filePath, Path.ChangeExtension(texturename, ".png"));
                        if (File.Exists(texturePath))
                        {
                            Console.WriteLine("Adding texture: " + (texturePath));
                            tempTexture = (Bitmap)Bitmap.FromFile(texturePath);
                            tempTexture = tempTexture.Clone(new Rectangle(Point.Empty, tempTexture.Size), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                        }
                        else
                        {
                            Console.WriteLine(String.Concat("Texture ", textureNames[(int)imgIndx], " not found. Generating a placeholder. Check your files."));
                        }

                        System.Drawing.Imaging.BitmapData bmpd = tempTexture.LockBits(new Rectangle(Point.Empty, tempTexture.Size), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                        int    stride = bmpd.Stride;
                        byte[] bits   = new byte[Math.Abs(stride) * bmpd.Height];
                        System.Runtime.InteropServices.Marshal.Copy(bmpd.Scan0, bits, 0, bits.Length);
                        tempTexture.UnlockBits(bmpd);
                        int tlevels = 0;
                        for (int y = 0; y < tempTexture.Height; y++)
                        {
                            int srcaddr = y * Math.Abs(stride);
                            for (int x = 0; x < tempTexture.Width; x++)
                            {
                                Color c = Color.FromArgb(BitConverter.ToInt32(bits, srcaddr + (x * 4)));
                                if (c.A == 0)
                                {
                                    tlevels = 1;
                                }
                                else if (c.A < 255)
                                {
                                    tlevels = 2;
                                    break;
                                }
                            }
                            if (tlevels == 2)
                            {
                                break;
                            }
                        }
                        PvrPixelFormat ppf = PvrPixelFormat.Rgb565;
                        if (tlevels == 1)
                        {
                            ppf = PvrPixelFormat.Argb1555;
                        }
                        else if (tlevels == 2)
                        {
                            ppf = PvrPixelFormat.Argb4444;
                        }
                        PvrDataFormat pdf = PvrDataFormat.Rectangle;
                        if (tempTexture.Width == tempTexture.Height)
                        {
                            pdf = PvrDataFormat.SquareTwiddled;
                        }
                        PvrTextureEncoder encoder = new PvrTextureEncoder(tempTexture, ppf, pdf);
                        encoder.GlobalIndex = GBIX;
                        string pvrPath = Path.ChangeExtension(texturePath, ".pvr");
                        encoder.Save(pvrPath);
                        pvmWriter.CreateEntryFromFile(pvrPath);
                    }
                    pvmWriter.Flush();
                    pvmStream.Close();
                    if (IsPRS)
                    {
                        Console.WriteLine("Compressing to PRS...");
                        byte[] pvmdata = File.ReadAllBytes(Path.ChangeExtension(filePath, ".pvm"));
                        pvmdata = FraGag.Compression.Prs.Compress(pvmdata);
                        File.WriteAllBytes(Path.ChangeExtension(filePath, ".prs"), pvmdata);
                        File.Delete(Path.ChangeExtension(filePath, ".pvm"));
                    }
                    Console.WriteLine("Archive was compiled successfully!");
                }
                else
                {
                    Console.WriteLine("Supplied texture list does not exist!");
                    Console.WriteLine("Press ENTER to continue...");
                    Console.ReadLine();
                    return;
                }
                break;

            // Create PB mode
            case "-pb":
                filePath = args[1];
                Console.WriteLine("Building PB from folder: {0}", filePath);
                if (Directory.Exists(filePath))
                {
                    string indexfilename = Path.Combine(filePath, "index.txt");
                    if (!File.Exists(indexfilename))
                    {
                        Console.WriteLine("Supplied path does not have an index file.");
                        Console.WriteLine("Press ENTER to exit.");
                        Console.ReadLine();
                        return;
                    }
                    List <string> filenames = new List <string>(File.ReadAllLines(indexfilename).Where(a => !string.IsNullOrEmpty(a)));
                    PBFile        pba       = new PBFile(filenames.Count);
                    int           l         = 0;
                    foreach (string tex in filenames)
                    {
                        byte[] texbytes = File.ReadAllBytes(Path.Combine(filePath, tex));
                        pba.AddPVR(texbytes, l);
                        l++;
                    }
                    path = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(filePath)), Path.GetFileNameWithoutExtension(filePath));
                    string filename_full = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(filePath)), Path.GetFileName(filePath) + ".pb");
                    Console.WriteLine("Output file: {0}", filename_full);
                    File.WriteAllBytes(filename_full, pba.GetBytes());
                }
                else
                {
                    Console.WriteLine("Supplied path does not exist.");
                    Console.WriteLine("Press ENTER to exit.");
                    Console.ReadLine();
                    return;
                }
                break;

            // Extract NjArchive mode
            case "-nju":
                filePath = args[1];
                filedata = File.ReadAllBytes(filePath);
                if (Path.GetExtension(filePath).Equals(".prs", StringComparison.OrdinalIgnoreCase))
                {
                    filedata = FraGag.Compression.Prs.Decompress(filedata);
                }
                NjArchive njarc = new NjArchive(filedata);
                Console.WriteLine("Extracting Ninja archive: {0}", filePath);
                dir = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
                Console.WriteLine("Output folder: {0}", dir);
                Directory.CreateDirectory(dir);
                for (int i = 0; i < njarc.Entries.Count; i++)
                {
                    byte[] data = njarc.Entries[i];
                    extension = ".bin";
                    string desc = "Unknown";
                    switch (System.Text.Encoding.ASCII.GetString(data, 0, 4))
                    {
                    case "NJIN":
                        desc      = "Ninja Information";
                        extension = ".nji";
                        break;

                    case "NJCM":
                        desc      = "Ninja Chunk model";
                        extension = ".nj";
                        break;

                    case "GJCM":
                        desc      = "Ninja Chunk model (GC)";
                        extension = ".gj";
                        break;

                    case "NJBM":
                        desc      = "Ninja Basic model";
                        extension = ".nj";
                        break;

                    case "NMDM":
                        desc      = "Ninja Motion";
                        extension = ".njm";
                        break;

                    case "NJLI":
                        desc      = "Ninja Light";
                        extension = ".njl";
                        break;

                    case "NLIM":
                        desc      = "Ninja Light Motion";
                        extension = ".njlm";
                        break;

                    case "NSSM":
                        desc      = "Ninja Simple Shape Motion";
                        extension = ".njsm";
                        break;

                    case "NCAM":
                        desc      = "Ninja Camera Motion";
                        extension = ".ncm";
                        break;

                    case "NJTL":
                        desc      = "Ninja Texlist";
                        extension = ".nj";
                        break;

                    case "GJTL":
                        desc      = "Ninja Texlist (GC)";
                        extension = ".gj";
                        break;

                    case "PVMH":
                        desc      = "PVM";
                        extension = ".pvm";
                        break;

                    case "GVMH":
                        desc      = "GVM";
                        extension = ".gvm";
                        break;
                    }
                    Console.WriteLine("Entry {0} is {1}", i, desc);
                    string outpath = Path.Combine(dir, i.ToString("D3") + extension);
                    File.WriteAllBytes(outpath, njarc.Entries[i]);
                }
                break;

            // PVM2TexPack mode
            case "-png":
                Queue <string> files = new Queue <string>();
                for (int u = 1; u < args.Length; u++)
                {
                    files.Enqueue(args[u]);
                }
                if (files.Count == 0)
                {
                    Console.Write("File: ");
                    files.Enqueue(Console.ReadLine());
                }
                while (files.Count > 0)
                {
                    string filename = files.Dequeue();
                    path = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(filename)), Path.GetFileNameWithoutExtension(filename));
                    string filename_full = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(filename)), Path.GetFileName(filename));
                    Console.WriteLine("Converting file to texture pack: {0}", filename_full);
                    Directory.CreateDirectory(path);
                    filedata = File.ReadAllBytes(filename_full);
                    using (TextWriter texList = File.CreateText(Path.Combine(path, "index.txt")))
                    {
                        try
                        {
                            if (PvrTexture.Is(filedata))
                            {
                                if (!AddTexture(false, path, Path.GetFileName(filename_full), new MemoryStream(filedata), texList))
                                {
                                    texList.Close();
                                    Directory.Delete(path, true);
                                }
                                continue;
                            }
                            else if (GvrTexture.Is(filedata))
                            {
                                if (!AddTexture(true, path, Path.GetFileName(filename_full), new MemoryStream(filedata), texList))
                                {
                                    texList.Close();
                                    Directory.Delete(path, true);
                                }
                                continue;
                            }
                            bool        gvm     = false;
                            ArchiveBase pvmfile = null;
                            byte[]      pvmdata = File.ReadAllBytes(filename_full);
                            if (Path.GetExtension(filename_full).Equals(".prs", StringComparison.OrdinalIgnoreCase))
                            {
                                pvmdata = FraGag.Compression.Prs.Decompress(pvmdata);
                            }
                            pvmfile = new PvmArchive();
                            MemoryStream stream = new MemoryStream(pvmdata);
                            if (!PvmArchive.Identify(stream))
                            {
                                pvmfile = new GvmArchive();
                                gvm     = true;
                            }
                            ArchiveEntryCollection pvmentries = pvmfile.Open(pvmdata).Entries;
                            bool fail = false;
                            foreach (ArchiveEntry file in pvmentries)
                            {
                                if (!AddTexture(gvm, path, file.Name, file.Open(), texList))
                                {
                                    texList.Close();
                                    Directory.Delete(path, true);
                                    fail = true;
                                    break;
                                }
                            }
                            if (fail)
                            {
                                continue;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Exception thrown: " + ex.ToString() + "\nCanceling conversion.");
                            return;
                        }
                        Console.WriteLine("Conversion complete!");
                    }
                }
                break;

            // Other modes
            default:
                filePath = args[0];
                IsPRS    = false;
                if (args.Length > 1 && args[1] == "-prs")
                {
                    IsPRS = true;
                }
                extension = Path.GetExtension(filePath).ToLowerInvariant();
                //Folder mode
                if (Directory.Exists(filePath))
                {
                    string        indexfilename = Path.Combine(filePath, "index.txt");
                    List <string> filenames     = new List <string>(File.ReadAllLines(indexfilename).Where(a => !string.IsNullOrEmpty(a)));
                    string        ext           = Path.GetExtension(filenames[0]).ToLowerInvariant();
                    pvmArchive = new PvmArchive();
                    switch (ext)
                    {
                    case ".pvr":
                        folderMode = ArchiveFromFolderMode.PVM;
                        break;

                    case ".gvr":
                        pvmArchive = new GvmArchive();
                        folderMode = ArchiveFromFolderMode.GVM;
                        break;

                    case ".wav":
                        folderMode = ArchiveFromFolderMode.DAT;
                        break;

                    case ".png":
                    case ".jpg":
                    case ".bmp":
                    case ".dds":
                    case ".gif":
                    default:
                        folderMode = ArchiveFromFolderMode.PVMX;
                        break;
                    }
                    Console.WriteLine("Creating {0} archive from folder: {1}", folderMode.ToString(), filePath);
                    switch (folderMode)
                    {
                    case ArchiveFromFolderMode.DAT:
                        // Load index
                        DATFile    dat  = new DATFile();
                        TextReader tr   = File.OpenText(Path.Combine(filePath, "index.txt"));
                        string     line = tr.ReadLine();
                        while (line != null)
                        {
                            Console.WriteLine("Adding file {0}", Path.Combine(filePath, line));
                            dat.AddFile(Path.Combine(filePath, line));
                            line = tr.ReadLine();
                        }
                        tr.Close();
                        // Save DAT archive
                        File.WriteAllBytes(filePath + ".DAT", dat.GetBytes());
                        if (IsPRS)
                        {
                            Console.WriteLine("Compressing to PRS...");
                            byte[] datdata = File.ReadAllBytes(filePath + ".DAT");
                            datdata = FraGag.Compression.Prs.Compress(datdata);
                            File.WriteAllBytes(filePath + ".PRS", datdata);
                            File.Delete(filePath + ".DAT");
                        }
                        Console.WriteLine("Archive compiled successfully!");
                        return;

                    case ArchiveFromFolderMode.PVM:
                    case ArchiveFromFolderMode.GVM:
                        if (filenames.Any(a => !Path.GetExtension(a).Equals(ext, StringComparison.OrdinalIgnoreCase)))
                        {
                            Console.WriteLine("Cannot create archive from mixed file types.");
                            Console.WriteLine("Press ENTER to exit.");
                            Console.ReadLine();
                            return;
                        }
                        ext = folderMode == ArchiveFromFolderMode.PVM ? ".pvm" : ".gvm";
                        using (Stream pvmStream = File.Open(Path.ChangeExtension(filePath, ext), FileMode.Create))
                        {
                            pvmWriter = pvmArchive.Create(pvmStream);
                            // Reading in textures
                            foreach (string tex in filenames)
                            {
                                if (folderMode == ArchiveFromFolderMode.PVM)
                                {
                                    pvmWriter.CreateEntryFromFile(Path.Combine(filePath, Path.ChangeExtension(tex, ".pvr")));
                                }
                                else
                                {
                                    pvmWriter.CreateEntryFromFile(Path.Combine(filePath, Path.ChangeExtension(tex, ".gvr")));
                                }
                                Console.WriteLine("Adding file: {0}", tex);
                            }
                            pvmWriter.Flush();
                        }
                        if (IsPRS)
                        {
                            Console.WriteLine("Compressing to PRS...");
                            byte[] pvmdata = File.ReadAllBytes(Path.ChangeExtension(filePath, ext));
                            pvmdata = FraGag.Compression.Prs.Compress(pvmdata);
                            File.WriteAllBytes(Path.ChangeExtension(filePath, ".prs"), pvmdata);
                            File.Delete(Path.ChangeExtension(filePath, ext));
                        }
                        Console.WriteLine("Archive was compiled successfully!");
                        return;

                    case ArchiveFromFolderMode.PVMX:
                        // Load index
                        PVMXFile   pvmx = new PVMXFile();
                        TextReader trp  = File.OpenText(Path.Combine(filePath, "index.txt"));
                        foreach (string str in filenames)
                        {
                            string[] split   = str.Split(',');
                            string   texfile = Path.Combine(Path.GetFullPath(filePath), split[1]);
                            Console.WriteLine("Adding file {0}", texfile);
                            if (split.Length > 2)
                            {
                                string[] dimensions = split[2].Split('x');
                                pvmx.AddFile(split[1], uint.Parse(split[0]), File.ReadAllBytes(texfile), int.Parse(dimensions[0]), int.Parse(dimensions[1]));
                            }
                            else
                            {
                                pvmx.AddFile(split[1], uint.Parse(split[0]), File.ReadAllBytes(texfile));
                            }
                        }
                        Console.WriteLine("Output file: {0}", Path.ChangeExtension(filePath, ".pvmx"));
                        File.WriteAllBytes(Path.ChangeExtension(filePath, ".pvmx"), pvmx.GetBytes());
                        Console.WriteLine("Archive was compiled successfully!");
                        return;
                    }
                }
                //Continue with file mode otherwise
                if (!File.Exists(filePath))
                {
                    Console.WriteLine("Supplied archive/texture list does not exist!");
                    Console.WriteLine("Press ENTER to exit.");
                    Console.ReadLine();
                    return;
                }
                switch (extension)
                {
                case ".rel":
                    Console.WriteLine("Decompressing REL file: {0}", filePath);
                    byte[] input  = File.ReadAllBytes(args[0]);
                    byte[] output = SA_Tools.HelperFunctions.DecompressREL(input);
                    File.WriteAllBytes(Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + "_dec.rel"), output);
                    return;

                case ".dat":
                    Console.WriteLine("Extracting DAT file: {0}", filePath);
                    DATFile dat = new DATFile(File.ReadAllBytes(filePath));
                    dir = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
                    if (Directory.Exists(dir))
                    {
                        Directory.Delete(dir, true);
                    }
                    Directory.CreateDirectory(dir);
                    using (StreamWriter sw = File.CreateText(Path.Combine(dir, "index.txt")))
                    {
                        dat.Entries.Sort((f1, f2) => StringComparer.OrdinalIgnoreCase.Compare(f1.name, f2.name));
                        for (int i = 0; i < dat.GetCount(); i++)
                        {
                            string fname = dat.Entries[i].name;
                            sw.WriteLine(fname);
                            if (dat.Steam)
                            {
                                fname = Path.GetFileNameWithoutExtension(fname) + ".adx";
                            }
                            Console.WriteLine("Extracting file: {0}", fname);
                            File.WriteAllBytes(Path.Combine(dir, fname), dat.GetFile(i));
                        }
                        sw.Flush();
                        sw.Close();
                    }
                    Console.WriteLine("Archive extracted!");
                    break;

                case ".pvmx":
                    Console.WriteLine("Extracting PVMX file: {0}", filePath);
                    byte[] pvmxdata = File.ReadAllBytes(filePath);
                    dir = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
                    Directory.CreateDirectory(dir);
                    PVMXFile pvmx = new PVMXFile(pvmxdata);
                    using (TextWriter texList = File.CreateText(Path.Combine(dir, "index.txt")))
                    {
                        for (int u = 0; u < pvmx.GetCount(); u++)
                        {
                            byte[] tdata   = pvmx.GetFile(u);
                            string outpath = Path.Combine(dir, pvmx.GetName(u));
                            File.WriteAllBytes(outpath, tdata);
                            string entry;
                            string dimensions = string.Join("x", pvmx.GetWidth(u).ToString(), pvmx.GetHeight(u).ToString());
                            if (pvmx.HasDimensions(u))
                            {
                                entry = string.Join(",", pvmx.GetGBIX(u).ToString(), pvmx.GetName(u), dimensions);
                            }
                            else
                            {
                                entry = string.Join(",", pvmx.GetGBIX(u).ToString(), pvmx.GetName(u));
                            }
                            texList.WriteLine(entry);
                        }
                        texList.Flush();
                        texList.Close();
                    }
                    Console.WriteLine("Archive extracted!");
                    break;

                case ".pb":
                    Console.WriteLine("Extracting PB file: {0}", filePath);
                    byte[] pbdata = File.ReadAllBytes(filePath);
                    dir = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
                    Directory.CreateDirectory(dir);
                    PBFile pba = new PBFile(pbdata);
                    using (TextWriter texList = File.CreateText(Path.Combine(dir, "index.txt")))
                    {
                        for (int u = 0; u < pba.GetCount(); u++)
                        {
                            byte[] pvrt    = pba.GetPVR(u);
                            string outpath = Path.Combine(dir, u.ToString("D3") + ".pvr");
                            File.WriteAllBytes(outpath, pvrt);
                            texList.WriteLine(u.ToString("D3") + ".pvr");
                        }
                        texList.Flush();
                        texList.Close();
                    }
                    Console.WriteLine("Archive extracted!");
                    break;

                case ".bin":
                    Console.WriteLine("Compressing BIN file: {0}", filePath);
                    byte[] bindata = File.ReadAllBytes(Path.ChangeExtension(filePath, ".bin"));
                    bindata = FraGag.Compression.Prs.Compress(bindata);
                    File.WriteAllBytes(Path.ChangeExtension(filePath, ".prs"), bindata);
                    Console.WriteLine("PRS archive was compiled successfully!");
                    return;

                case ".prs":
                case ".pvm":
                case ".gvm":
                    Console.WriteLine("Extracting archive: {0}", filePath);
                    path = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));
                    Directory.CreateDirectory(path);
                    filedata = File.ReadAllBytes(filePath);
                    using (TextWriter texList = File.CreateText(Path.Combine(path, "index.txt")))
                    {
                        try
                        {
                            ArchiveBase pvmfile = null;
                            byte[]      pvmdata = File.ReadAllBytes(filePath);
                            if (extension == ".prs")
                            {
                                pvmdata = FraGag.Compression.Prs.Decompress(pvmdata);
                            }
                            pvmfile = new PvmArchive();
                            MemoryStream stream = new MemoryStream(pvmdata);
                            if (!PvmArchive.Identify(stream))
                            {
                                pvmfile = new GvmArchive();
                                if (!GvmArchive.Identify(stream))
                                {
                                    File.WriteAllBytes(Path.ChangeExtension(filePath, ".bin"), pvmdata);
                                    isBIN = true;
                                    Console.WriteLine("PRS archive extracted!");
                                }
                            }
                            if (!isBIN)
                            {
                                ArchiveReader pvmReader = pvmfile.Open(pvmdata);
                                foreach (ArchiveEntry pvmentry in pvmReader.Entries)
                                {
                                    Console.WriteLine("Extracting file: {0}", pvmentry.Name);
                                    texList.WriteLine(pvmentry.Name);
                                    pvmReader.ExtractToFile(pvmentry, Path.Combine(path, pvmentry.Name));
                                }
                                Console.WriteLine("Archive extracted!");
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Exception thrown. Canceling conversion.");
                            Console.WriteLine("Press ENTER to exit.");
                            Console.ReadLine();
                            Directory.Delete(path, true);
                            throw;
                        }
                    }
                    if (isBIN)
                    {
                        Directory.Delete(path, true);
                    }
                    break;

                default:
                    Console.WriteLine("Unknown extension \"{0}\".", extension);
                    Console.WriteLine("Press ENTER to exit.");
                    Console.ReadLine();
                    break;
                }
                break;
            }
        }
예제 #25
0
        private void addTextureButton_Click(object sender, EventArgs e)
        {
            string defext = null;
            string filter = null;

            switch (format)
            {
            case TextureFormat.PVM:
                defext = "pvr";
                filter = "Texture Files|*.prs;*.pvm;*.pvr;*.png;*.jpg;*.jpeg;*.gif;*.bmp";
                break;

            case TextureFormat.GVM:
                defext = "gvr";
                filter = "Texture Files|*.prs;*.gvm;*.gvr;*.png;*.jpg;*.jpeg;*.gif;*.bmp";
                break;
            }
            using (OpenFileDialog dlg = new OpenFileDialog()
            {
                DefaultExt = defext, Filter = filter, Multiselect = true
            })
            {
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    uint gbix = textures.Count == 0 ? 0 : textures.Max((item) => item.GlobalIndex);
                    if (gbix != uint.MaxValue)
                    {
                        gbix++;
                    }
                    listBox1.BeginUpdate();
                    foreach (string file in dlg.FileNames)
                    {
                        switch (Path.GetExtension(file).ToLowerInvariant())
                        {
                        case ".prs":
                        case ".pvm":
                        case ".gvm":
                            byte[] pvmdata = File.ReadAllBytes(file);
                            if (Path.GetExtension(file).Equals(".prs", StringComparison.OrdinalIgnoreCase))
                            {
                                pvmdata = FraGag.Compression.Prs.Decompress(pvmdata);
                            }
                            ArchiveBase pvmfile = null;
                            switch (format)
                            {
                            case TextureFormat.PVM:
                                pvmfile = new PvmArchive();
                                break;

                            case TextureFormat.GVM:
                                pvmfile = new GvmArchive();
                                break;
                            }
                            if (!pvmfile.Is(pvmdata, file))
                            {
                                MessageBox.Show(this, "Could not open file \"" + file + "\".", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                continue;
                            }
                            ArchiveEntryCollection pvmentries  = pvmfile.Open(pvmdata).Entries;
                            List <PvrTextureInfo>  newtextures = new List <PvrTextureInfo>(pvmentries.Count);
                            switch (format)
                            {
                            case TextureFormat.PVM:
                                PvpPalette pvp = null;
                                foreach (ArchiveEntry entry in pvmentries)
                                {
                                    PvrTexture vrfile = new PvrTexture(entry.Open());
                                    if (vrfile.NeedsExternalPalette)
                                    {
                                        if (pvp == null)
                                        {
                                            using (OpenFileDialog a = new OpenFileDialog
                                            {
                                                DefaultExt = "pvp",
                                                Filter = "PVP Files|*.pvp",
                                                InitialDirectory = Path.GetDirectoryName(file),
                                                Title = "External palette file"
                                            })
                                                if (a.ShowDialog(this) == DialogResult.OK)
                                                {
                                                    pvp = new PvpPalette(a.FileName);
                                                }
                                                else
                                                {
                                                    MessageBox.Show(this, "Could not open file \"" + Program.Arguments[0] + "\".", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                    continue;
                                                }
                                        }
                                        vrfile.SetPalette(pvp);
                                    }
                                    string name = Path.GetFileNameWithoutExtension(entry.Name);
                                    textures.Add(new PvrTextureInfo(name, vrfile));
                                    listBox1.Items.Add(name);
                                }
                                break;

                            case TextureFormat.GVM:
                                GvpPalette gvp = null;
                                foreach (ArchiveEntry entry in pvmentries)
                                {
                                    GvrTexture vrfile = new GvrTexture(entry.Open());
                                    if (vrfile.NeedsExternalPalette)
                                    {
                                        if (gvp == null)
                                        {
                                            using (OpenFileDialog a = new OpenFileDialog
                                            {
                                                DefaultExt = "gvp",
                                                Filter = "GVP Files|*.gvp",
                                                InitialDirectory = Path.GetDirectoryName(file),
                                                Title = "External palette file"
                                            })
                                                if (a.ShowDialog(this) == DialogResult.OK)
                                                {
                                                    gvp = new GvpPalette(a.FileName);
                                                }
                                                else
                                                {
                                                    MessageBox.Show(this, "Could not open file \"" + Program.Arguments[0] + "\".", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                    continue;
                                                }
                                        }
                                        vrfile.SetPalette(gvp);
                                    }
                                    string name = Path.GetFileNameWithoutExtension(entry.Name);
                                    textures.Add(new GvrTextureInfo(name, vrfile));
                                    listBox1.Items.Add(name);
                                }
                                break;
                            }
                            break;

                        default:
                        {
                            string name = Path.GetFileNameWithoutExtension(file);
                            if (format == TextureFormat.PVM && PvrTexture.Is(file))
                            {
                                textures.Add(new PvrTextureInfo(name, new PvrTexture(file)));
                            }
                            else if (format == TextureFormat.GVM && GvrTexture.Is(file))
                            {
                                textures.Add(new GvrTextureInfo(name, new GvrTexture(file)));
                            }
                            else
                            {
                                switch (format)
                                {
                                case TextureFormat.PVM:
                                    textures.Add(new PvrTextureInfo(name, gbix, new Bitmap(dlg.FileName)));
                                    break;

                                case TextureFormat.GVM:
                                    textures.Add(new GvrTextureInfo(name, gbix, new Bitmap(dlg.FileName)));
                                    break;
                                }
                                if (gbix != uint.MaxValue)
                                {
                                    gbix++;
                                }
                            }
                            listBox1.Items.Add(name);
                        }
                        break;
                        }
                    }
                    listBox1.EndUpdate();
                    listBox1.SelectedIndex = textures.Count - 1;
                    UpdateTextureCount();
                }
            }
        }
예제 #26
0
        static void Main(string[] args)
        {
            Queue <string> files = new Queue <string>(args);

            if (files.Count == 0)
            {
                Console.Write("File: ");
                files.Enqueue(Console.ReadLine());
            }
            while (files.Count > 0)
            {
                string      filename  = files.Dequeue();
                PAKFile     pak       = new PAKFile();
                List <byte> inf       = new List <byte>();
                string      filenoext = Path.GetFileNameWithoutExtension(filename).ToLowerInvariant();
                string      longdir   = "..\\..\\..\\sonic2\\resource\\gd_pc\\prs\\" + filenoext;
                byte[]      filedata  = File.ReadAllBytes(filename);
                using (System.Windows.Forms.Panel panel1 = new System.Windows.Forms.Panel())
                    using (Device d3ddevice = new Device(0, DeviceType.Hardware, panel1, CreateFlags.SoftwareVertexProcessing, new PresentParameters[] { new PresentParameters()
                                                                                                                                                         {
                                                                                                                                                             Windowed = true, SwapEffect = SwapEffect.Discard, EnableAutoDepthStencil = true, AutoDepthStencilFormat = DepthFormat.D24X8
                                                                                                                                                         } }))
                    {
                        if (PvrTexture.Is(filedata))
                        {
                            if (!AddTexture(pak, filenoext, longdir, false, inf, d3ddevice, filename, new MemoryStream(filedata)))
                            {
                                continue;
                            }
                            goto end;
                        }
                        else if (GvrTexture.Is(filedata))
                        {
                            if (!AddTexture(pak, filenoext, longdir, true, inf, d3ddevice, filename, new MemoryStream(filedata)))
                            {
                                continue;
                            }
                            goto end;
                        }
                        bool        gvm     = false;
                        ArchiveBase pvmfile = null;
                        byte[]      pvmdata = File.ReadAllBytes(filename);
                        if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
                        {
                            pvmdata = FraGag.Compression.Prs.Decompress(pvmdata);
                        }
                        pvmfile = new PvmArchive();
                        if (!pvmfile.Is(pvmdata, filename))
                        {
                            pvmfile = new GvmArchive();
                            gvm     = true;
                            if (!pvmfile.Is(pvmdata, filename))
                            {
                                Console.WriteLine("{0} is not a valid file.", filename);
                                continue;
                            }
                        }
                        ArchiveEntryCollection pvmentries = pvmfile.Open(pvmdata).Entries;
                        bool fail = false;
                        foreach (ArchiveEntry file in pvmentries)
                        {
                            if (!AddTexture(pak, filenoext, longdir, gvm, inf, d3ddevice, file.Name, file.Open()))
                            {
                                fail = true;
                                break;
                            }
                        }
                        if (fail)
                        {
                            continue;
                        }
                    }
end:
                pak.Files.Insert(0, new PAKFile.File(filenoext + '\\' + filenoext + ".inf", longdir + '\\' + filenoext + ".inf", inf.ToArray()));
                pak.Save(Path.ChangeExtension(filename, "pak"));
            }
        }
예제 #27
0
        public bool Init(ushort?inputFieldID = null, Sections flags = Sections.ALL)
        {
            Flags = flags;
            Memory.SuppressDraw = true;
            ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_FIELD);

            string[] test = aw.GetListOfFiles();
            //TODO fix endless look on FieldID 50.
            ID = inputFieldID ?? Memory.FieldHolder.FieldID;
            int count = (Memory.FieldHolder.fields?.Length ?? 0);

            if (ID >= count ||
                ID < 0)
            {
                return(false);
            }
            FileName    = Memory.FieldHolder.GetString(ID);
            ArchiveName = test.FirstOrDefault(x => x.IndexOf(FileName, StringComparison.OrdinalIgnoreCase) >= 0);
            if (string.IsNullOrWhiteSpace(ArchiveName))
            {
                Debug.WriteLine($"FileNotFound :: {ID} - {FileName.ToUpper()}");
                Mod = Field_modes.DISABLED;
                return(false);
            }

            ArchiveBase fieldArchive = aw.GetArchive(ArchiveName);

            string[] filelist = fieldArchive.GetListOfFiles();
            string findstr(string s) =>
            filelist.FirstOrDefault(x => x.IndexOf(s, StringComparison.OrdinalIgnoreCase) >= 0);

            byte[] getfile(string s)
            {
                s = findstr(s);
                if (!string.IsNullOrWhiteSpace(s))
                {
                    return(fieldArchive.GetBinaryFile(s));
                }
                else
                {
                    return(null);
                }
            }

            if (!flags.HasFlag(Sections.MIM | Sections.MAP) || (Background = Background.Load(getfile(".mim"), getfile(".map"))) == null)
            {
                Mod = Field_modes.DISABLED;
            }
            if (flags.HasFlag(Sections.CA | Sections.ID))
            {
                Cameras  = Cameras.Load(getfile(".ca"));
                WalkMesh = WalkMesh.Load(getfile(".id"), Cameras);
            }

            //let's start with scripts
            string s_jsm = findstr(".jsm");
            string s_sy  = findstr(".sy");

            if (flags.HasFlag(Sections.JSM | Sections.SYM) && !string.IsNullOrWhiteSpace(s_jsm) && (FileName != "test3"))
            {
                //try
                //{
                jsmObjects = Scripts.Jsm.File.Read(fieldArchive.GetBinaryFile(s_jsm));
                //}
                //catch (Exception e)
                //{
                //   Debug.WriteLine(e);
                //Mod = Field_modes.NOJSM;
                //}
                if (Mod != Field_modes.NOJSM)
                {
                    Sym.GameObjects symObjects;
                    if (!string.IsNullOrWhiteSpace(s_sy))
                    {
                        symObjects = Sym.Reader.FromBytes(fieldArchive.GetBinaryFile(s_sy));

                        services    = Initializer.GetServices();
                        EventEngine = ServiceId.Field[services].Engine;
                        EventEngine.Reset();
                        for (int objIndex = 0; objIndex < jsmObjects.Count; objIndex++)
                        {
                            Scripts.Jsm.GameObject obj         = jsmObjects[objIndex];
                            FieldObject            fieldObject = new FieldObject(obj.Id, symObjects.GetObjectOrDefault(objIndex).Name);

                            foreach (Scripts.Jsm.GameScript script in obj.Scripts)
                            {
                                fieldObject.Scripts.Add(script.ScriptId, script.Segment.GetExecuter());
                            }

                            EventEngine.RegisterObject(fieldObject);
                        }

                        Mod++;
                    }
                    else
                    {
                        Debug.WriteLine($"FileNotFound :: {FileName.ToUpper()}.sy");
                        //sy file might be optional.
                        //Mod = Field_modes.NOJSM;
                    }
                }
            }
            else
            {
                Mod = Field_modes.NOJSM;
                //goto end;
            }

            //if (flags.HasFlag(Sections.MCH))
            //{
            //    byte[] mchb = getfile(".mch");//Field character models
            //}

            //if (flags.HasFlag(Sections.ONE))
            //{
            //    byte[] oneb = getfile(".one");//Field character models container
            //}
            //if (flags.HasFlag(Sections.MSD))
            //{
            //    byte[] msdb = getfile(".msd");//dialogs
            //}
            if (flags.HasFlag(Sections.INF))
            {
                byte[] infb = getfile(".inf");//gateways
                if (infb != null && infb.Length > 0)
                {
                    inf = INF.Load(infb);
                }
            }

            if (flags.HasFlag(Sections.TDW))
            {
                byte[] tdwb = getfile(".tdw");//extra font
                if (tdwb != null && tdwb.Length > 0)
                {
                    tdw = new TDW(tdwb);
                }
            }

            if (flags.HasFlag(Sections.MSK))
            {
                byte[] mskb = getfile(".msk");//movie cam
                if (mskb != null && mskb.Length > 0)
                {
                    msk = new MSK(mskb);
                }
            }
            if (flags.HasFlag(Sections.RAT | Sections.MRT))
            {
                byte[] ratb = getfile(".rat"); //battle on field
                byte[] mrtb = getfile(".mrt"); //battle on field
                if (ratb != null && mrtb != null && ratb.Length > 0 && mrtb.Length > 0)
                {
                    MrtRat = new MrtRat(mrtb, ratb);
                }
            }
            //if (flags.HasFlag(Sections.PMD))
            //{
            //    byte[] pmdb = getfile(".pmd");//particle info
            //    if (pmdb != null && pmdb.Length > 4)
            //        using (FileStream fs = new FileStream(Path.Combine(Path.GetTempPath(),
            //            $"{Memory.FieldHolder.GetString()}.pmd"), FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
            //            fs.Write(pmdb, 0, pmdb.Length);
            //}
            if (flags.HasFlag(Sections.PMP))
            {
                byte[] pmpb = getfile(".pmp");//particle graphic?
                if (pmpb != null && pmpb.Length > 4)
                {
                    pmp = new PMP(pmpb);
                }
            }
            if (flags.HasFlag(Sections.SFX))
            {
                byte[] sfxb = getfile(".sfx");//sound effects
                if (sfxb != null && sfxb.Length > 0)
                {
                    sfx = new SFX(sfxb);
                }
            }

            if (Mod == Field_modes.NOJSM && Background == null)
            {
                Mod = Field_modes.DISABLED;
            }
            if (sfx == null &&
                pmp == null &&
                MrtRat == null &&
                msk == null &&
                tdw == null &&
                inf == null &&
                jsmObjects == null &&
                EventEngine == null &&
                Cameras == null &&
                WalkMesh == null &&
                Background == null &&
                services == null)
            {
                return(false);
            }
            return(true);
        }
예제 #28
0
        public static void Init()
        {
            Memory.Log.WriteLine($"{nameof(Music)} :: {nameof(Init)}");
            // PC 2000 version has an CD audio track for eyes on me. I don't think we can play that.
            const MusicId unkPrefix         = (MusicId)999;
            const MusicId altLoserPrefix    = (MusicId)512;
            const MusicId loserPrefix       = (MusicId)0;
            const MusicId eyesOnMePrefix    = (MusicId)513;
            const MusicId altEyesOnMePrefix = (MusicId)22;

            string[] ext = { ".ogg", ".sgt", ".wav", ".mp3" };
            //Roses and Wine V07 moves most of the sgt files to dmusic_backup
            //it leaves a few files behind. I think because RaW doesn't replace everything.
            //ogg files stored in:
            string RaW_ogg_pt = Extended.GetUnixFullPath(Path.Combine(Memory.FF8DIR, "RaW", "GLOBAL", "Music"));
            // From what I gather the OGG files and the sgt files have the same numerical prefix. I
            // might try to add the functionality to the debug screen monday.

            string dmusic_pt    = Extended.GetUnixFullPath(Path.Combine(Memory.FF8DIRdata, "Music", "dmusic_backup"));
            string music_pt     = Extended.GetUnixFullPath(Path.Combine(Memory.FF8DIRdata, "Music", "dmusic"));
            string music_wav_pt = Extended.GetUnixFullPath(Path.Combine(Memory.FF8DIRdata, "Music"));

            // goal of dicmusic is to be able to select a track by prefix. it adds an list of files
            // with the same prefix. so you can later on switch out which one you want.
            AddMusicPath(RaW_ogg_pt);
            AddMusicPath(music_wav_pt);
            AddMusicPath(dmusic_pt);
            AddMusicPath(music_pt);
            if (!Memory.dicMusic.ContainsKey(eyesOnMePrefix) && Memory.dicMusic.ContainsKey(altEyesOnMePrefix))
            {
                Memory.dicMusic.Add(eyesOnMePrefix, Memory.dicMusic[altEyesOnMePrefix]);
            }
            ArchiveBase a = ArchiveZzz.Load(Memory.Archives.ZZZ_OTHER);

            string[] list = a?.GetListOfFiles();
            if (list != null && list.Length > 0)
            {
                ZZZ = true;
                foreach (string m in list.Where(x => ext.Any(y => x.EndsWith(y, StringComparison.OrdinalIgnoreCase))))
                {
                    AddMusic(m);
                }
            }
            void AddMusicPath(string p)
            {
                if (!string.IsNullOrWhiteSpace(p) && Directory.Exists(p))
                {
                    foreach (string m in Directory.GetFiles(p).Where(x => ext.Any(y => x.EndsWith(y, StringComparison.OrdinalIgnoreCase))))
                    {
                        AddMusic(m);
                    }
                }
            }

            void AddMusic(string m)
            {
                if (ushort.TryParse(Path.GetFileName(m).Substring(0, 3), out ushort key))
                {
                    //mismatched prefix's go here
                    if ((MusicId)key == altLoserPrefix)
                    {
                        key = (ushort)loserPrefix; //loser.ogg and sgt don't match.
                    }
                }
                else if (m.IndexOf("eyes_on_me", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    key = (ushort)eyesOnMePrefix;
                }
                else
                {
                    key = (ushort)unkPrefix;
                }

                if (!Memory.dicMusic.ContainsKey((MusicId)key))
                {
                    Memory.dicMusic.Add((MusicId)key, new List <string> {
                        m
                    });
                }
                else
                {
                    Memory.dicMusic[(MusicId)key].Add(m);
                }
            }
        }
예제 #29
0
        public void saveFun()
        {
            File.Delete("printtemp\\xpsShow.xps");

            string[] files = Directory.GetFiles("printTemp");
            for (int i = 0; i < files.Length; i++)
            {
                string path = files[i];
                File.Delete(path);
            }

            frmSelectSave.count = 0;
            IGetReport igp;

            IsHaveReport = false;
            int no = 1;

            string[] idCardsStrings = CardID.Split(';');
            string[] SelectName     = PrintType.Split(';');

            foreach (string idCardNo in idCardsStrings)
            {
                foreach (string name in SelectName)
                {
                    try
                    {
                        switch (name)
                        {
                        case "封面":
                            if (area == "淄博")
                            {
                                igp = new HealthReport();
                            }
                            else
                            {
                                igp = new ArchiveCover();
                            }
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "基本信息":
                            igp = new ArchiveBase();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "健康体检表":
                            igp = new ArchivePhysical();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "高血压随访":
                            igp = new Hypertension_Followup();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "糖尿病随访":
                            igp = new Diabetes_Followup();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "精神病信息补充":
                            igp = new Mentaldisease_Baseinfo();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "精神病随访":
                            igp = new Mentaldisease_Followup();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "居民健康档案卡":
                            igp = new ArchiveCard();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "老年人中医健康(随访)":
                            igp = new Old_Medicine_CN();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "新生儿家庭访视":
                            igp = new Child_With_NEW();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "1岁内儿童健康检查":
                            igp = new Child_With_ONE();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "1-2岁内儿童健康检查":
                            igp = new Child_With_TWO();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "3-6岁内儿童健康检查":
                            igp = new Child_With_THREE();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "第1次产前随访":
                            igp = new GRAVIDA_FRIST();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "第2-5次产前随访":
                            igp = new GRAVIDA_TWO();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "产后访视记录":
                            igp = new GRAVIDA_Postpartum();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "产后42天健康检查":
                            igp = new GRAVIDA_Postpartum42();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "脑卒中随访记录":
                            igp = new Stroke_Followup();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "冠心病随访记录":
                            igp = new CHD_Follow();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "6-18月龄儿童中医健康":
                            igp = new Child_CN_ONE();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "24-36月龄儿童中医健康":
                            igp = new Child_CN_TWO();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "3-6岁内儿童中医健康":
                            igp = new Child_CN_THREE();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "第1次肺结核随访":
                            igp = new LungerFirstVisit();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "肺结核随访":
                            igp = new ChronicLungerVisit();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "健康教育":
                            igp = new HealthEducation();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "接诊记录":
                            igp = new Medical_Receive();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "会诊记录":
                            igp = new Medical_Consulation();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "双向转诊":
                            igp = new Medical_Refferral();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "健康体检反馈单":
                            igp = new HealthFeedback();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "老年人自理能力(体检)":
                            igp = new Physical_OldSelfCare();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "65岁以上老年人健康体检反馈单":
                            if (area.Equals("淄博"))
                            {
                                igp = new OldHealthFeedback();
                            }
                            else if (community.Equals("日照街道社区"))
                            {
                                igp = new OldHealthFeedbackRiZhao();
                            }
                            else
                            {
                                igp = new OldHealthFeedbackYuCheng();
                            }

                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "档案封面":
                            igp = new HealthCoverCard();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "血生化、血常规、尿液数据":
                            igp = new Blood_Urine();
                            this.saveInvoke(igp, idCardNo, no.ToString());
                            break;

                        case "心电打印":
                            string ecgType = DrawItems.GetECGConfig();

                            if (ecgType == "2")
                            {
                                igp        = new ElectroCardioGramcs();
                                igp.CardID = idCardNo;
                                if (!igp.hasData())
                                {
                                    igp = null;
                                }
                                else
                                {
                                    this.saveInvoke(igp, idCardNo, no.ToString());
                                }
                            }
                            break;

                        case "B超打印":
                            igp        = new TypeBchao();
                            igp.CardID = idCardNo;
                            if (!igp.hasData())
                            {
                                igp = null;
                            }
                            else
                            {
                                this.saveInvoke(igp, idCardNo, no.ToString());
                            }
                            break;

                        default:
                            igp = null;
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                no++;
            }

            Thread.Sleep(1000);

            if (!IsHaveReport)
            {
                System.Windows.Forms.MessageBox.Show("无打印资料!", "提示",
                                                     System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk,
                                                     System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);

                CloseWin("test");

                return;
            }

            this.setMsg("开始生成合并文档");
            this.MergeInvoke();
            this.CloseWin("test");
        }
예제 #30
0
 public ArchivedEvent(IAcSession acSession, ArchiveBase source)
     : base(acSession, source)
 {
 }
예제 #31
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Button     btnShow = (Button)sender;
            string     btnName = btnShow.Name;
            IGetReport igp;
            string     path = "printtemp\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + "\\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string[] idCardStrings = IDCard.Split(';');

            if (idCardStrings.Length > 1)
            {
                try
                {
                    frmShowBatch frm = new frmShowBatch();
                    frm.CardID    = IDCard;
                    frm.PrintType = btnName;
                    frm.Path      = path;
                    frm.ShowDialog();
                    if (!frm.IsHaveReport)
                    {
                        return;
                    }

                    frmPrint frmShow = new frmPrint();
                    frmShow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    frmShow.WindowState           = WindowState.Maximized;
                    frmShow.DocName = path + "xpsShow.xps";
                    frmShow.ShowDialog();
                }
                catch (Exception d)
                {
                    MessageBox.Show(d.ToString());
                }
            }
            else
            {
                switch (btnName)
                {
                case "btnFengmian":
                    if (area == "淄博")
                    {
                        igp = new HealthReport();
                    }
                    else
                    {
                        igp = new ArchiveCover();
                    }
                    break;

                case "btnBaseInfo":
                    igp = new ArchiveBase();
                    break;

                case "btnHyper":
                    igp = new Hypertension_Followup();
                    break;

                case "btnDiabetes":
                    igp = new Diabetes_Followup();
                    break;

                case "btnMentaldisease_Baseinfo":
                    igp = new Mentaldisease_Baseinfo();
                    break;

                case "btnMentalFollow":
                    igp = new Mentaldisease_Followup();
                    break;

                case "btnPhysical":
                    igp = new ArchivePhysical();
                    break;

                case "btnArchiveCard":
                    igp = new ArchiveCard();
                    break;

                case "btnChildInOne":
                    igp = new Child_With_ONE();
                    break;

                case "btnChildNEW":
                    igp = new Child_With_NEW();
                    break;

                case "btnChildTWO":
                    igp = new Child_With_TWO();
                    break;

                case "btnChildTHREE":
                    igp = new Child_With_THREE();
                    break;

                case "btnGRAVIDA_FRIST":
                    igp = new GRAVIDA_FRIST();
                    break;

                case "btnGRAVIDA_TWO":
                    igp = new GRAVIDA_TWO();
                    break;

                case "btnGRAVIDA_POST":
                    igp = new GRAVIDA_Postpartum();
                    break;

                case "btnGRAVIDA_POST42":
                    igp = new GRAVIDA_Postpartum42();
                    break;

                case "btnOLDMEDICINECN":
                    igp = new Old_Medicine_CN();
                    break;

                case "btnChildCNOne":
                    igp = new Child_CN_ONE();
                    break;

                case "btnChildCNOne2Three":
                    igp = new Child_CN_TWO();
                    break;

                //case "btnChildCNThree2Six":
                //    igp = new Child_CN_THREE();
                //    break;
                case "btnChd":
                    igp = new CHD_Follow();
                    break;

                case "btStroke":
                    igp = new Stroke_Followup();
                    break;

                case "btnOnePTBVisit":
                    igp = new LungerFirstVisit();
                    break;

                case "btnPTBVisit":
                    igp = new ChronicLungerVisit();
                    break;

                case "btnHealth":
                    igp = new HealthEducation();
                    //igp = new HealthExamination();
                    break;

                case "btnMReceiveTreat":
                    igp = new Medical_Receive();
                    break;

                case "btnMConsulation":
                    igp = new Medical_Consulation();
                    break;

                case "btnMReferral":
                    igp = new Medical_Refferral();
                    break;

                case "btnHealthFeedback":
                    igp = new HealthFeedback();
                    break;

                case "btnPhyOLDSelf":
                    igp = new Physical_OldSelfCare();
                    break;

                //case "btnPhyMedicine":
                //    igp = new Physical_MedicineCN();
                //    break;
                case "btnOldHealthFeedback":
                    if (area.Equals("淄博"))
                    {
                        igp = new OldHealthFeedback();
                    }
                    else if (community.Equals("日照街道社区"))
                    {
                        igp = new OldHealthFeedbackRiZhao();
                    }
                    else
                    {
                        igp = new OldHealthFeedbackYuCheng();
                    }
                    break;

                case "btnCoverCard":
                    igp = new HealthCoverCard();
                    break;

                case "btnBloodUrine":
                    igp = new Blood_Urine();
                    break;

                case "btnCoverCard_2":
                    igp = new HealthCoverCard_Colour();
                    break;

                case "btnECG":
                    string ecgType = DrawItems.GetECGConfig();

                    if (ecgType == "2")
                    {
                        igp        = new ElectroCardioGramcs();
                        igp.CardID = IDCard;

                        if (!igp.hasData())
                        {
                            igp = null;
                        }
                    }
                    else
                    {
                        igp = null;
                    }
                    break;

                case "btnTypeBUI":
                    igp        = new TypeBchao();
                    igp.CardID = IDCard;

                    if (!igp.hasData())
                    {
                        igp = null;
                    }
                    break;

                case "btnPhyicalRe":
                    igp = new PhyicalReport();
                    break;

                case "btnOldCover":
                    igp = new OldHealthReport();
                    break;

                default:
                    igp = null;
                    break;
                }

                if (igp == null)
                {
                    MessageBox.Show("无打印资料!");
                    return;
                }

                igp.CardID    = IDCard;
                igp.BaseModel = new RecordsBaseInfoBLL().GetModel(IDCard);

                if (igp.BaseModel == null)
                {
                    MessageBox.Show("无此人个人档案,身份证号:" + IDCard);
                    return;
                }

                try
                {
                    frmPrint frm = new frmPrint();
                    FixedDocumentSequence fsq = igp.getReport();

                    if (!DrawItems.SaveReport(path + igp.PrintName, fsq))
                    {
                        MessageBox.Show("打印文件正在被占用,请稍后重试");
                    }
                    else
                    {
                        frm.DocName = path + igp.PrintName;
                        frm.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        frm.WindowState           = WindowState.Maximized;
                        frm.ShowDialog();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }