Пример #1
0
        public TreeControl(Experimenter experimenter, Model model)
        {
            InitializeComponent();

            this.experimenter = experimenter;

            this.modelName = model.Name;

            this.DataContext = model;

            button.DataContext = player.DataContext = experimenter.GetSimulationState();

            InitShadowMaker();
        }
 private void Paint_Clear_Click(object sender, EventArgs e)
 {
     myGraphics.Clear(Color.White);
     Experimenter.Clear();
     Experimenter.Focus();
 }
        //실험자 정보 및 서명 저장
        private void Input_Click(object sender, EventArgs e)
        {
            //실험번호
            main.experiment_number++;
            main.Experimenter = "#S" + Experimenter.Text;
            Number            = "S" + Experimenter.Text;

            //이름 사인
            if (!String.Equals(NameSign.Text, ""))
            {
                isSignName = true;
            }
            else
            {
                isSignName = false;
            }

            //1번
            AnswerAge = AgeBox.SelectedItem.ToString();
            if (AgeBox.SelectedIndex != 0)
            {
                isAnswerAge = true;
            }
            else
            {
                isAnswerAge = false;
            }

            //2번
            AnswerHeight = HeightBox.SelectedItem.ToString();
            if (HeightBox.SelectedIndex != 0)
            {
                isAnswerHeight = true;
            }
            else
            {
                isAnswerHeight = false;
            }

            //3번
            AnswerWeight = WeightBox.SelectedItem.ToString();
            if (WeightBox.SelectedIndex != 0)
            {
                isAnswerWeight = true;
            }
            else
            {
                isAnswerWeight = false;
            }

            RadioButton_Check();

            //질문에 모두 대답을 하지 않은 경우 예외 처리
            if ((!isAnswerAge) || (!isAnswerHeight) || (!isAnswerWeight) || (!isSignName))
            {
                MessageBox.Show("Answer is not finished!, Please, Check your Answer!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                main.experiment_number--;
            }
            else
            {
                //각 실험자 폴더가 존재하지 않을 시 폴더 생성후 저장
                DirectoryInfo dir = new DirectoryInfo(@"C:\data\" + main.Experimenter);
                if (dir.Exists == false)
                {
                    dir.Create();
                }

                //실험자 정보 저장 및 서명 캡쳐 부분
                using (StreamWriter pi = new StreamWriter(@"C:\data\Experimenter.csv", true, Encoding.UTF8))
                {
                    if (main.experiment_number == 1)
                    {
                        pi.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", "번호", "이름", "나이", "키", "몸무게", "성별", "음주", "흡연", "커피", "스트레스");
                        pi.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", Number, NameSign.Text, AnswerAge, AnswerHeight, AnswerWeight, Answer2, Answer3, Answer4, Answer5, Answer6);
                    }
                    else
                    {
                        pi.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", Number, NameSign.Text, AnswerAge, AnswerHeight, AnswerWeight, Answer2, Answer3, Answer4, Answer5, Answer6);
                    }
                }
                Rectangle rect = new Rectangle(1470, 1300, 1070, 420);
                Bitmap    bmp  = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
                Graphics  g    = Graphics.FromImage(bmp);
                g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
                DirectoryInfo dir2 = new DirectoryInfo(@"C:\data\" + "Personal_Sign");
                //Personal_Sign폴더가 존재하지 않을 시 폴더 생성후 저장
                if (dir2.Exists == false)
                {
                    dir2.Create();
                }
                bmp.Save(@"C:\data\Personal_Sign\" + main.Experimenter + ".jpg", ImageFormat.Jpeg);

                MessageBox.Show("Data is completely saved!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                myGraphics.Clear(Color.White);
                NameSign.Clear();
                Experimenter.Clear();
                Experimenter.Focus();

                ShowNum.Text = main.experiment_number.ToString();
                All_Default_Set();
                All_Answer_Clear();
            }
        }