Esempio n. 1
0
        /// <summary>
        /// 將自我介紹的資訊顯示到畫面上
        /// </summary>
        private void loadSaveIntroduction()
        {
            IntroductionOBJ introductionOBJ = FileHelper.processRead();

            nameTextBox.Text     = introductionOBJ.name;
            homeTownTextBox.Text = introductionOBJ.homeTown;

            birthdate_YearBox.Text  = introductionOBJ.birthDate.Year.ToString();
            birthdate_MonthBox.Text = introductionOBJ.birthDate.Month.ToString();
            birthdate_DayBox.Text   = introductionOBJ.birthDate.Day.ToString();

            if (introductionOBJ.photo != null)
            {
                photoBox.Image = PhotoHelper.bytesToImage(introductionOBJ.photo);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 自我介紹 JSON讀檔流程
        /// </summary>
        /// <returns></returns>
        public static IntroductionOBJ processRead()
        {
            IntroductionOBJ introductionOBJ;
            JObject         introductionJson;

            if (!prepareRead())
            {
                return(new IntroductionOBJ());
            }

            introductionJson = readFromJson();
            if (!checkJsonIsVailed(introductionJson))
            {
                return(new IntroductionOBJ());
            }

            introductionOBJ       = getIntroductionJsonStr(introductionJson);
            introductionOBJ.photo = PhotoHelper.readImageStreamFromFile(imagePath).ToArray();

            return(introductionOBJ);
        }
Esempio n. 3
0
        /// <summary>
        /// 從畫面上的所有欄位取得自我介紹資訊
        /// </summary>
        /// <returns></returns>
        private IntroductionOBJ getIntroductionFromView()
        {
            try
            {
                checkAllColumnIsNotEmpty();
                checkDateIsValidate();

                IntroductionOBJ introductionOBJ = new IntroductionOBJ();

                introductionOBJ.name      = nameTextBox.Text;
                introductionOBJ.homeTown  = homeTownTextBox.Text;
                introductionOBJ.birthDate = new DateTime(int.Parse(birthdate_YearBox.Text), int.Parse(birthdate_MonthBox.Text), int.Parse(birthdate_DayBox.Text));
                introductionOBJ.photo     = PhotoHelper.ImageToBytes(photoBox.Image);

                return(introductionOBJ);
            }
            catch (Exception error)
            {
                throw new Exception(error.Message);
            }
        }
Esempio n. 4
0
        private static void saveImageToFile(byte[] imageByte)
        {
            Image newImage = PhotoHelper.bytesToImage(imageByte);

            newImage.Save(imagePath, ImageFormat.Jpeg);
        }