Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp5
- {
- public partial class Form1 : Form
- {
- bool searchFor;
- public Form1()
- {
- InitializeComponent();
- textBox2.MaxLength = 1;
- splitterBox.MaxLength = 1;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string input = textBox1.Text;
- if (!searchFor)
- {
- char ill = Convert.ToChar(textBox2.Text);
- MessageBox.Show("An folgender Stelle kommt der illegale Charakter vor: " + input.IndexOf(ill));
- }
- else
- {
- string ill = textBox2.Text;
- MessageBox.Show("An folgender Stelle kommt der illegale Charakter vor: " + input.IndexOf(ill));
- }
- }
- private void checkChange(object sender, EventArgs e)
- {
- if (searchFor)
- {
- illegal.Text = "illegal char";
- textBox2.MaxLength = 1;
- textBox2.Text = "";
- searchFor = false;
- }
- else
- {
- illegal.Text = "illegal string";
- textBox2.MaxLength = 0;
- textBox2.Text = "";
- searchFor = true;
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- string splitterString = splitBox.Text;
- char splitter = Convert.ToChar(splitterBox.Text);
- string[] splittedStrings = splitterString.Split(splitter);
- for(int i = 0; i < splittedStrings.Length; i++)
- {
- richTextBox1.AppendText(splittedStrings[i]);
- richTextBox1.AppendText("\n");
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- string trimmerString = stringTrim.Text;
- char[] remove = new char[] { 'a', 'e', 'i', 'u' };
- trimmerString = trimmerString.Trim(remove);
- richTextBox2.AppendText(trimmerString.Trim(remove));
- }
- private void button4_Click(object sender, EventArgs e)
- {
- string p = precodeString.Text;
- int s = Convert.ToInt32(cipherShiftBox.Text);
- encodeStringBox.Text = encodeString(p, s);
- }
- private string encodeString(string s, int shift)
- {
- s = s.ToLower();
- string res = null;
- char[] code = s.ToCharArray();
- for(int i = 0; i < code.Length; i++)
- {
- int a = code[i];
- if(code[i] >= 'a' && code[i] <= 'z')
- {
- a += shift;
- if(a > 'z')
- {
- a -= 26;
- }
- if(a < 'a')
- {
- a += 26;
- }
- }
- code[i] = (char)a;
- res += code[i];
- }
- return res;
- }
- private string decodeString(string s, int shift)
- {
- s = s.ToLower();
- string res = null;
- char[] code = s.ToCharArray();
- for (int i = 0; i < code.Length; i++)
- {
- int a = code[i];
- if (code[i] >= 'a' && code[i] <= 'z')
- {
- a -= shift;
- if (a > 'z')
- {
- a -= 26;
- }
- if (a < 'a')
- {
- a += 26;
- }
- }
- code[i] = (char)a;
- res += code[i];
- }
- return res;
- }
- private void decodeButton_Click(object sender, EventArgs e)
- {
- string p = ripcodeString.Text;
- int s = Convert.ToInt32(decipherShiftBox.Text);
- decodedString.Text = decodeString(p, s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement