Beispiel #1
0
        public void Parse()
        {
            while (Reader.BaseStream.Position < Reader.BaseStream.Length)
            {
                string sectionName   = Encoding.UTF8.GetString(Reader.ReadBytes(4));
                int    sectionLength = Reader.ReadInt32();
                byte[] sectionBytes  = Reader.ReadBytes(sectionLength);

                BinaryReader sectionReader = new BinaryReader(new MemoryStream(sectionBytes));

                switch (sectionName)
                {
                case "VERS":
                    // TODO: Implement parsing of VERS section
                    break;

                case "TEXT":
                    // TODO: Implement parsing of TEXT section
                    break;

                case "SMTL":
                    // TODO: Implement parsing of SMTL section
                    break;

                case "BONE":
                    Bones = BoneReader.ReadAllBones(sectionReader);
                    break;

                case "ANIM":
                    // TODO: Implement parsing of ANIM section
                    break;

                case "MESH":
                    Vertices = VertexReader.ReadAllVertices(sectionReader);
                    Polygons = PolygonReader.ReadAllPolygons(sectionReader);
                    break;

                case "FANM":
                    // TODO: Implement parsing of FANM section
                    break;

                case "FRAM":
                    // TODO: Implement parsing of FRAM section
                    break;

                case "MOTI":
                    Motions = MotionReader.ReadAllMotions(sectionReader);
                    break;

                case "COLL":
                    CollisionBoxes = CollisionBoxReader.ReadAllCollisionBoxes(sectionReader);
                    break;
                }

                sectionReader.Close();
            }
        }
Beispiel #2
0
        static void Main()
        {
            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                string strd = System.IO.Path.Combine(FDHelper.RunningDir(),
                                                     System.IO.Path.GetFileName(
                                                         FDHelper.RgGetUserProfilePath()));


                var isRunCheckDigestInfo = false;
                if (FDHelper.RgGetTechlinkAppDataPath() == string.Empty || FDHelper.RgGetUserProfilePath() == string.Empty || !System.IO.File.Exists(strd))
                {
                    isRunCheckDigestInfo = true;
                    Application.Run(new frmCheckDigestInfo());
                }
                else
                {
                    var bone   = BoneReader.GetBoneInfo(FDHelper.RgGetUserProfilePath());
                    var coccyx =
                        BoneReader.GetBoneInfo(strd);

                    if (bone.Length == 0)
                    {
                        isRunCheckDigestInfo = true;
                        Application.Run(new frmCheckDigestInfo());
                    }
                    else
                    {
                        var s   = XRayController.TranslateBoneInformation(bone);
                        var coc = XRayController.TranslateBoneInformation(coccyx);

                        string[] ss  = s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                        string[] sss = coc.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                        StringBuilder sb = new StringBuilder();

                        for (int i = 0; i < 6; i++)
                        {
                            sb.AppendLine(ss[i]);
                        }

                        // Set company name
                        if (ss[1] != null)
                        {
                            GlobalInfo.CompanyName = ss[1].ToString();
                        }

                        var xray  = XRayController.CreateFeatureOfHuman(sb.ToString());
                        var xray1 = XRayController.CreateFeatureOfHuman(xray);

                        var ts = FDHelper.RgGetTimeStamp().ToString();

                        if (sss.Length > 1 && ts == sss[1] && sss[0] == xray1)
                        {
                            Coccyx.IsAtTheEndOfCoccyx = true;
                        }
                    }
                }

                if (Coccyx.IsAtTheEndOfCoccyx)
                {
                    RegisterSuccess();
                }
                else
                {
                    //MessageBox.Show("Bạn chưa đăng ký sử dụng phần mềm!");
                    //Application.Exit();
                    if (!isRunCheckDigestInfo)
                    {
                        Application.Run(new frmCheckDigestInfo());
                    }
                    RegisterSuccess();
                }
                mutex.ReleaseMutex();
            }
            else
            {
                //If the application is started, show the message to warning and...
                MessageBox.Show("GS1 đã được khởi động. Bạn hãy kiểm tra lại cửa sổ đang mở!", "ECustom",
                                MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //Then post a message to show the opened windows
                NativeMethods.PostMessage(
                    (IntPtr)NativeMethods.HWND_BROADCAST,
                    NativeMethods.WM_SHOWME,
                    IntPtr.Zero,
                    IntPtr.Zero);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Parses the passed Stream into Puppet structures
        /// </summary>
        /// <param name="data">Stream containing the Puppet file data</param>
        /// <param name="catchExceptions">Flag allowing conditional exception catching</param>
        private void Parse(Stream data, bool catchExceptions = false)
        {
            using (BinaryReader reader = new BinaryReader(data))
            {
                while (reader.BaseStream.Position < reader.BaseStream.Length)
                {
                    string sectionName   = Encoding.UTF8.GetString(reader.ReadBytes(4));
                    int    sectionLength = reader.ReadInt32();
                    byte[] sectionBytes  = reader.ReadBytes(sectionLength);

                    using (BinaryReader sectionReader = new BinaryReader(new MemoryStream(sectionBytes)))
                    {
                        try
                        {
                            switch (sectionName)
                            {
                            case "VERS":
                                Version = VersionReader.ReadVersion(sectionReader);
                                break;

                            case "TEXT":
                                Textures = TextureReader.ReadAllTextures(sectionReader);
                                break;

                            case "SMTL":
                                SpecularMaterial = true;
                                break;

                            case "BONE":
                                Bones = BoneReader.ReadAllBones(sectionReader, Version);
                                break;

                            case "EXTR":
                                Extra = ExtraReader.ReadExtra(sectionReader);
                                break;

                            case "ANIM":
                                Animations = AnimationReader.ReadAllAnimations(sectionReader, Version);
                                break;

                            case "MESH":
                                Mesh = MeshReader.ReadMesh(sectionReader, Version);
                                break;

                            case "FANM":
                                // TODO: Implement parsing of FANM section
                                break;

                            case "FRAM":
                                Frames = FrameReader.ReadAllFrames(sectionReader);
                                break;

                            case "MOTI":
                                Motions = MotionReader.ReadAllMotions(sectionReader);
                                break;

                            case "COLL":
                                CollisionBoxes = CollisionBoxReader.ReadAllCollisionBoxes(sectionReader, Version);
                                break;

                            default:
                                Debug.WriteLine($"Unknown section '${sectionName}' with size of ${sectionLength.ToString()} bytes");
                                break;
                            }
                        }
                        catch (Exception e) when(catchExceptions)
                        {
                            Debug.WriteLine($"{e.Message}\n{e.StackTrace}");
                        }
                    }
                }
            }
        }