private void menuBtn_exportSelfIntroduction_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "텍스트 파일|*.txt";
            saveFileDialog.Title  = "텍스트 파일로 내보내기";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                using (FileStream fs = File.OpenWrite(saveFileDialog.FileName))
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        StringBuilder sb = new StringBuilder();

                        Data.SelfIntroduction selfIntroduction = GetSelfIntroductionManager().GetSelfIntroduction(GetSelfIntroductionName());
                        foreach (Data.SelfIntroductionQuestion i in selfIntroduction.Questions)
                        {
                            sb.AppendLine("질문 : " + i.GetQuestion());
                            sb.AppendLine();
                            sb.AppendLine("답변 (글자수 : " + i.GetAnswer().Length + ") : ");
                            sb.AppendLine();
                            sb.AppendLine(i.GetAnswer());
                            sb.AppendLine();
                            sb.AppendLine("============================");
                        }

                        sw.Write(sb.ToString());
                    }
            }
        }
 private void menuBtn_addQuestion_Click(object sender, EventArgs e)
 {
     Data.SelfIntroduction selfIntroduction = GetSelfIntroductionManager().GetSelfIntroduction(GetSelfIntroductionName());
     selfIntroduction.Questions.Add(new Data.SelfIntroductionQuestion());
     GetSelfIntroductionManager().SaveSelfIntroduction(GetSelfIntroductionName(), selfIntroduction);
     loadIntroductions();
     tabControl1.SelectTab(tabControl1.TabCount - 1);
 }
        private void OnQuestionTextChanged(object sender, EventArgs e)
        {
            int questionIndex = (int)(sender as Control).Tag;

            Data.SelfIntroduction selfIntroduction = GetSelfIntroductionManager().GetSelfIntroduction(GetSelfIntroductionName());
            selfIntroduction.Questions[questionIndex].SetQuestion((sender as TextBox).Text);
            GetSelfIntroductionManager().SaveSelfIntroduction(GetSelfIntroductionName(), selfIntroduction);
        }
        private void OnAnswerTextChanged(object sender, EventArgs e)
        {
            int questionIndex = (int)(sender as Control).Tag;

            Data.SelfIntroduction selfIntroduction = GetSelfIntroductionManager().GetSelfIntroduction(GetSelfIntroductionName());
            selfIntroduction.Questions[questionIndex].SetAnswer((sender as TextBox).Text);
            (sender as Control).Parent.Controls["countLabel"].Text = "현재 글자수 : " + selfIntroduction.Questions[questionIndex].GetAnswer().Length;
            GetSelfIntroductionManager().SaveSelfIntroduction(GetSelfIntroductionName(), selfIntroduction);
        }
        private void menuBtn_cloneQuestion_Click(object sender, EventArgs e)
        {
            TabPage page          = tabControl1.SelectedTab;
            int     questionIndex = (int)page.Tag;

            Data.SelfIntroduction selfIntroduction = GetSelfIntroductionManager().GetSelfIntroduction(GetSelfIntroductionName());
            selfIntroduction.Questions.Add(new Data.SelfIntroductionQuestion(selfIntroduction.Questions[questionIndex]));
            GetSelfIntroductionManager().SaveSelfIntroduction(GetSelfIntroductionName(), selfIntroduction);
            loadIntroductions();
            tabControl1.SelectTab(tabControl1.TabCount - 1);
        }
 private void loadIntroductions()
 {
     Data.SelfIntroduction data = GetSelfIntroductionManager().GetSelfIntroduction(GetSelfIntroductionName());
     tabControl1.SuspendLayout();
     tabControl1.Controls.Clear();
     for (int i = 0; i < data.Questions.Count; i++)
     {
         createQuestionTabPage(i, data.Questions[i]);
     }
     tabControl1.ResumeLayout(false);
     tabControl1.PerformLayout();
 }
Пример #7
0
        public void SaveSelfIntroduction(string name, Data.SelfIntroduction data)
        {
            string filename = Path.Combine(directoryInfo.FullName, name + ".dat");

            if (data == null)
            {
                data = new Data.SelfIntroduction();
                data.Questions.Add(new Data.SelfIntroductionQuestion());
            }

            using (FileStream fs = File.OpenWrite(filename))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(fs, data);
            }
        }
        private void menuBtn_renameSelfIntroduction_Click(object sender, EventArgs e)
        {
            InputBoxDialog inputBox = new InputBoxDialog();

            inputBox.SetDescription("새로운 이름을 입력하세요.");
            if (inputBox.ShowDialog() == DialogResult.OK)
            {
                if (GetSelfIntroductionManager().GetSelfIntroductionNames().Contains(inputBox.GetResult()))
                {
                    MessageBox.Show("이미 존재하는 이름입니다.");
                    return;
                }
                Data.SelfIntroduction selfIntroduction = GetSelfIntroductionManager().GetSelfIntroduction(GetSelfIntroductionName());
                GetSelfIntroductionManager().DeleteSelfIntroduction(GetSelfIntroductionName());
                SetSelfIntroductionName(inputBox.GetResult());
                GetSelfIntroductionManager().SaveSelfIntroduction(GetSelfIntroductionName(), selfIntroduction);
                OnFileRenamedOrDeleted(this, new EventArgs());
                this.Text = "자기소개서 - " + this.GetSelfIntroductionName();
            }
        }
        private void menuBtn_deleteQuestion_Click(object sender, EventArgs e)
        {
            TabPage page             = tabControl1.SelectedTab;
            int     questionIndex    = (int)page.Tag;
            int     tabIndexToSelect = tabControl1.SelectedIndex - 1;

            if (tabIndexToSelect < 0)
            {
                tabIndexToSelect = 0;
            }
            if (MessageBox.Show("정말로 이 " + (questionIndex + 1) + "번 질문을 삭제하시겠습니까?", "확인", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Data.SelfIntroduction selfIntroduction = GetSelfIntroductionManager().GetSelfIntroduction(GetSelfIntroductionName());
                selfIntroduction.Questions.RemoveAt(questionIndex);
                if (selfIntroduction.Questions.Count == 0)
                {
                    selfIntroduction.Questions.Add(new Data.SelfIntroductionQuestion());
                }
                GetSelfIntroductionManager().SaveSelfIntroduction(GetSelfIntroductionName(), selfIntroduction);
                loadIntroductions();
                tabControl1.SelectTab(tabIndexToSelect);
            }
        }