示例#1
0
        /// <summary>
        /// Form used to Pick a face.
        /// </summary>
        public FaceForm()
        {
            InitializeComponent();
            if (Directory.Exists(sFaceDir))
            {
                mAllPhotoFiles = System.IO.Directory.GetFiles(sFaceDir, "*.jpg");
                mPhotoFiles    = mAllPhotoFiles;
                PopulatePhotosBoxes();
                UpdateScrollbarLargeChange();
                mPhotoScrollBar.ValueChanged += new EventHandler(mPhotoScrollBar_ValueChanged);
                StartingPictureIndex          = 0;
            }
            else
            {
                MessageBox.Show("Expected Folder '" + sFaceDir + "\\' to exist!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (!File.Exists(sCategoryFile))
            {
                String txf = StaticUtils.GetEmbeddedTextFile("FaceFormCategories.json");
                if (!Directory.Exists(".\\PlayerData\\"))
                {
                    Directory.CreateDirectory(".\\PlayerData\\");
                }
                Console.WriteLine("Couldn't fine 'FaceFormCategories.json', retrieving embedded file...");
                File.WriteAllText(sCategoryFile, txf);
            }
            if (File.Exists(sCategoryFile))
            {
                mCategories = GenericArrayArray.FromFile(sCategoryFile);
                PopulateCategories();
            }
        }
示例#2
0
        public static GenericArrayArray FromFile(string file)
        {
            GenericArrayArray retVal = null;

            using (System.IO.FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Open))
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(GenericArrayArray));
                retVal = (GenericArrayArray)ser.ReadObject(fs);
            }
            retVal.RemoveDups();
            return(retVal);
        }