示例#1
0
        //다른이름저장
        protected void SaveAsFile()
        {
            if (opencount != 0)
            {
                tss_State.Text = "다른이름저장";
                TextForm tf = new TextForm();
                tf = (TextForm)this.ActiveMdiChild;

                saveFileDialog1.Title            = "저장";
                saveFileDialog1.InitialDirectory = @"C:\";
                saveFileDialog1.Filter           = "텍스트 파일(*.txt)|*.txt|모든 파일(*.*)|*.*";
                saveFileDialog1.FilterIndex      = 1;
                saveFileDialog1.RestoreDirectory = true;
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    TextBox tb = new TextBox();
                    tb = (TextBox)this.ActiveMdiChild.ActiveControl;
                    StreamWriter sw = new StreamWriter(saveFileDialog1.FileName, false, Encoding.Default);
                    sw.Write(tb.Text);
                    sw.Close();
                    tf.save = true;
                    tf.Text = Path.GetFileNameWithoutExtension(saveFileDialog1.FileName);
                }
                else
                {
                    tss_State.Text = "다른이름저장취소";
                }
            }
            else
            {
                tss_State.Text = "열린 파일이 없습니다.";
            }
        }
示例#2
0
        private void 저장SToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TextForm tf = new TextForm();

            tf = (TextForm)this.ActiveMdiChild;
            SaveFile(tf);
        }
示例#3
0
        private void tlb_Save_Click(object sender, EventArgs e)
        {
            TextForm tf = new TextForm();

            tf = (TextForm)this.ActiveMdiChild;
            SaveFile(tf);
        }
示例#4
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            TextForm tf = new TextForm();

            tf = (TextForm)this.ActiveMdiChild;
            Font f = new Font("바탕", 10);

            e.Graphics.DrawString(tf.textBox1.Text, f, Brushes.Black, e.MarginBounds.Left + 10, e.MarginBounds.Top + 10);
        }
示例#5
0
        protected void ReadFile(string s, string name, string sp)
        {
            TextForm newfile = new TextForm();

            newfile.TopLevel  = false;
            newfile.MdiParent = this;
            newfile.BringToFront();
            newfile.Text          = name;
            newfile.textBox1.Text = s;
            newfile.save          = true;
            newfile.savePoin      = sp;
            newfile.Show();
        }
示例#6
0
 private void 닫기ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (opencount != 0)
     {
         TextForm tf = new TextForm();
         tf = (TextForm)this.ActiveMdiChild;
         tf.Close();
     }
     else
     {
         tss_State.Text = "열린 파일이 없습니다.";
     }
 }
示例#7
0
 //붙여넣기
 protected void ControlPaste()
 {
     if (opencount != 0)
     {
         TextForm tf = new TextForm();
         tf = (TextForm)this.ActiveMdiChild;
         tf.textBox1.Paste();
         tss_State.Text = "붙여넣기";
     }
     else
     {
         tss_State.Text = "열린 파일이 없습니다.";
     }
 }
示例#8
0
        //파일새로만들기
        protected void NewFile()
        {
            tss_State.Text = "파일새로만들기";
            TextForm newfile = new TextForm();

            newfile.TopLevel  = false;
            newfile.MdiParent = this;
            newfile.BringToFront();
            count++;
            newfile.Text = "제목 없음(" + count + ")";
            opencount++;
            newfile.save = true;
            newfile.Show();
        }
示例#9
0
 //미리보기
 protected void FilePrintPreview()
 {
     if (opencount != 0)
     {
         tss_State.Text = "미리보기";
         TextForm tf = new TextForm();
         tf = (TextForm)this.ActiveMdiChild;
         this.printPreviewDialog1.Document = this.printDocument1;
         this.printPreviewDialog1.ShowDialog();
     }
     else
     {
         tss_State.Text = "열린 파일이 없습니다.";
     }
 }
示例#10
0
        //닫기

        public void FileClose(TextForm tf)
        {
            if (opencount != 0)
            {
                if (tf.save == false)
                {
                    switch (MessageBox.Show("변경된 내용을 " + tf.Text + "에 저장하겠습니까?", "메모장", MessageBoxButtons.YesNoCancel))
                    {
                    case DialogResult.Yes:
                    {
                        SaveFile(tf);
                        opencount--;
                        tf.exit        = true;
                        tss_State.Text = "닫기";
                        break;
                    }

                    case DialogResult.No:
                    {
                        opencount--;
                        tf.exit        = true;
                        tss_State.Text = "닫기";
                        break;
                    }

                    case DialogResult.Cancel:
                    {
                        tf.exit        = false;
                        tss_State.Text = "닫기취소";
                        break;
                    }
                    }
                }
                else
                {
                    opencount--;
                    tf.exit        = true;
                    tss_State.Text = "닫기";
                }
            }
            else
            {
                tss_State.Text = "열린 파일이 없습니다.";
            }
        }
示例#11
0
 //프린트
 protected void FilePrint()
 {
     if (opencount != 0)
     {
         tss_State.Text = "프린트";
         if (printDialog1.ShowDialog() == DialogResult.OK)
         {
             TextForm tf = new TextForm();
             tf = (TextForm)this.ActiveMdiChild;
             this.printDialog1.Document = this.printDocument1;
             printDialog1.Document.Print();
         }
     }
     else
     {
         tss_State.Text = "열린 파일이 없습니다.";
     }
 }
示例#12
0
        //저장
        public void SaveFile(TextForm tf)
        {
            if (opencount != 0)
            {
                tss_State.Text                   = "저장";
                saveFileDialog1.Title            = "저장";
                saveFileDialog1.InitialDirectory = @"C:\";
                saveFileDialog1.Filter           = "텍스트 파일(*.txt)|*.txt|모든 파일(*.*)|*.*";
                saveFileDialog1.FilterIndex      = 1;
                saveFileDialog1.RestoreDirectory = true;

                if (tf.save == false)
                {
                    if (tf.Text.Contains("제목 없음") == true)
                    {
                        if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            StreamWriter sw = new StreamWriter(saveFileDialog1.FileName, false, Encoding.Default);
                            sw.Write(tf.textBox1.Text);
                            sw.Close();
                            tf.save     = true;
                            tf.savePoin = saveFileDialog1.FileName;
                            tf.Text     = Path.GetFileNameWithoutExtension(saveFileDialog1.FileName);
                        }
                        else
                        {
                            tss_State.Text = "저장취소";
                        }
                    }
                    else
                    {
                        StreamWriter sw = new StreamWriter(tf.savePoin, false, Encoding.Default);
                        sw.Write(tf.textBox1.Text);
                        sw.Close();
                        tf.save = true;
                    }
                }
            }
            else
            {
                tss_State.Text = "열린 파일이 없습니다.";
            }
        }
示例#13
0
 //배경색
 private void 배경색ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (opencount != 0)
     {
         if (colorDialog1.ShowDialog() == DialogResult.OK)
         {
             TextForm tf = new TextForm();
             tf = (TextForm)this.ActiveMdiChild;
             tf.textBox1.BackColor = colorDialog1.Color;
             tss_State.Text        = "배경색을 교체";
         }
         else
         {
             tss_State.Text = "배경색을 교체취소";
         }
     }
     else
     {
         tss_State.Text = "열린 파일이 없습니다.";
     }
 }
示例#14
0
 //폰트
 private void 폰트ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (opencount != 0)
     {
         fontDialog1.ShowColor = true;
         if (fontDialog1.ShowDialog() == DialogResult.OK)
         {
             TextForm tf = new TextForm();
             tf = (TextForm)this.ActiveMdiChild;
             tf.textBox1.Font      = fontDialog1.Font;
             tf.textBox1.ForeColor = fontDialog1.Color;
             tss_State.Text        = "폰트변경";
         }
         else
         {
             tss_State.Text = "폰트변경취소";
         }
     }
     else
     {
         tss_State.Text = "열린 파일이 없습니다.";
     }
 }