Advertisement
Guest User

Texter

a guest
Dec 2nd, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10.  
  11. namespace Texter_0._2
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
  19.         }
  20.  
  21.         private void neuToolStripMenuItem_Click(object sender, EventArgs e)
  22.         {
  23.             if (tabControl1.SelectedIndex == 0)
  24.             {
  25.                 TextBox.Clear();
  26.                 Tab1.Text = "Neues Dokument 1";
  27.             }
  28.             else if (tabControl1.SelectedIndex == 1)
  29.             {
  30.                 TextBox2.Clear();
  31.                 Tab2.Text = "Neues Dokument 2";
  32.             }
  33.         }
  34.  
  35.         private void beendenToolStripMenuItem_Click(object sender, EventArgs e)
  36.         {
  37.             this.Close();
  38.         }
  39.  
  40.         private void öffnenToolStripMenuItem_Click(object sender, EventArgs e)
  41.         {
  42.             string open;
  43.  
  44.             openFileDialog1.Filter = "Alle (*.*) | *.*";
  45.             openFileDialog1.FileName = "";
  46.             if (openFileDialog1.ShowDialog(Owner) == DialogResult.OK)
  47.             {
  48.                 open = openFileDialog1.FileName;
  49.                 if (tabControl1.SelectedIndex == 0)
  50.                 {
  51.                     TextBox.Text = File.ReadAllText(open);
  52.                     Tab1.Text = open;
  53.                 }
  54.                 else if (tabControl1.SelectedIndex == 1)
  55.                 {
  56.                     TextBox2.Text = File.ReadAllText(open);
  57.                     Tab2.Text = open;
  58.                 }
  59.             }
  60.         }
  61.         private void ausschneidenToolStripMenuItem_Click(object sender, EventArgs e)
  62.         {
  63.             if (tabControl1.SelectedIndex == 0)
  64.             {
  65.                 TextBox.Cut();
  66.             }
  67.             else if (tabControl1.SelectedIndex == 1)
  68.             {
  69.                 TextBox2.Cut();
  70.             }
  71.         }
  72.  
  73.         private void kopierenToolStripMenuItem_Click(object sender, EventArgs e)
  74.         {
  75.             if (tabControl1.SelectedIndex == 0)
  76.             {
  77.                 TextBox.Copy();
  78.             }
  79.             else if (tabControl1.SelectedIndex == 1)
  80.             {
  81.                 TextBox2.Copy();
  82.             }
  83.         }
  84.  
  85.         private void einfügenToolStripMenuItem_Click(object sender, EventArgs e)
  86.         {
  87.             if (tabControl1.SelectedIndex == 0)
  88.             {
  89.                 TextBox.Paste();
  90.             }
  91.             else if (tabControl1.SelectedIndex == 1)
  92.             {
  93.                 TextBox2.Paste();
  94.             }
  95.         }
  96.  
  97.         private void speichernToolStripMenuItem_Click(object sender, EventArgs e)
  98.         {
  99.             string save, text, text2;
  100.             text = TextBox.Text;
  101.             text2 = TextBox2.Text;
  102.             saveFileDialog1.Filter = "Textdateien (*.txt)|*.txt|Alle (*.*) | *.*";
  103.             saveFileDialog1.FileName = "Neues Dokument";
  104.             if (saveFileDialog1.ShowDialog(Owner) == DialogResult.OK)
  105.             {
  106.                 save = saveFileDialog1.FileName;
  107.                 if (tabControl1.SelectedIndex == 0)
  108.                 {
  109.                     File.WriteAllText(save, text);
  110.                 }
  111.                 else if (tabControl1.SelectedIndex == 1)
  112.                 {
  113.                     File.WriteAllText(save, text2);
  114.                 }
  115.             }
  116.         }
  117.  
  118.         private void schriftToolStripMenuItem_Click(object sender, EventArgs e)
  119.         {
  120.             if (fontDialog1.ShowDialog(Owner) == DialogResult.OK)
  121.             {
  122.                 TextBox.SelectionFont = fontDialog1.Font;
  123.             }
  124.         }
  125.  
  126.         private void infosToolStripMenuItem_Click(object sender, EventArgs e)
  127.         {
  128.             MessageBox.Show("Programmierer: Alexander Rudel \nDatum: 2012\nVersion: Beta 0.3.1", "Informationen",
  129.             MessageBoxButtons.OK, MessageBoxIcon.Information);
  130.         }
  131.         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  132.         {
  133.             DialogResult result = MessageBox.Show("Wollen sie das Programm beenden?\nDenken sie an das speichern ihrer Dateien!", "Beenden", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  134.             if (result == DialogResult.Yes)
  135.             {
  136.                 e.Cancel = false;
  137.             }
  138.             else if (result == DialogResult.No)
  139.             {
  140.                 e.Cancel = true;
  141.             }
  142.         }
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement