Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- private void doesContainMethod()
- {
- string myString = Display.Content.ToString();
- bool doesContain = myString.Contains("+");
- bool doesContain1 = myString.Contains("-");
- bool doesContain2 = myString.Contains("/");
- bool doesContain3 = myString.Contains("*");
- string[] stringArray;
- if (doesContain)
- {
- stringArray = myString.Split('+');
- Display.Content = stringArray[0];
- }
- else if (doesContain1)
- {
- stringArray = myString.Split('-');
- Display.Content = stringArray[0];
- }
- else if (doesContain2)
- {
- stringArray = myString.Split('/');
- Display.Content = stringArray[0];
- }
- else if (doesContain3)
- {
- stringArray = myString.Split('*');
- Display.Content = stringArray[0];
- }
- }
- public MainWindow()
- {
- InitializeComponent();
- }
- //Math operators
- private void gange_Click(object sender, RoutedEventArgs e)
- {
- //Converts Display.Content from string to chararray
- char[] myCharArray = Display.Content.ToString().ToCharArray();
- //Finds length of MyCharArray
- int LengthofArray = myCharArray.Length;
- //If last char is NOT a '*'
- if (myCharArray[LengthofArray - 1] != '*')
- {
- //Add '/' to Display.Content
- Display.Content += "*";
- }
- }
- private void minus_Click(object sender, RoutedEventArgs e)
- {
- //Converts Display.Content from string to chararray
- char[] myCharArray = Display.Content.ToString().ToCharArray();
- //Finds length of MyCharArray
- int LengthofArray = myCharArray.Length;
- //If last char is NOT a '-'
- if (myCharArray[LengthofArray - 1] != '-')
- {
- //Add '-' to Display.Content
- Display.Content += "-";
- }
- }
- private void plus_Click(object sender, RoutedEventArgs e)
- {
- //Converts Display.Content from string to chararray
- char[] myCharArray = Display.Content.ToString().ToCharArray();
- //Finds length of MyCharArray
- int LengthofArray = myCharArray.Length;
- //If last char is NOT a '+'
- if (myCharArray[LengthofArray - 1] != '+')
- {
- //Add '+' to Display.Content
- Display.Content += "+";
- }
- }
- private void dividere_Click(object sender, RoutedEventArgs e)
- {
- //Converts Display.Content from string to chararray
- char[] myCharArray = Display.Content.ToString().ToCharArray();
- //Finds length of MyCharArray
- int LengthofArray = myCharArray.Length;
- //If last char is NOT a '/'
- if (myCharArray[LengthofArray - 1] != '/')
- {
- //Add '/' to Display.Content
- Display.Content += "/";
- }
- }
- private void erligmed_Click(object sender, RoutedEventArgs e)
- {
- doesContainMethod();
- }
- private void Clear_Click(object sender, RoutedEventArgs e)
- {
- Display.Content = "0";
- }
- //Numbers
- private void tal1_Click(object sender, RoutedEventArgs e)
- {
- if (Display.Content.ToString() == "0")
- {
- Display.Content = 1;
- }
- else
- {
- Display.Content += "1";
- }
- }
- private void tal4_Click(object sender, RoutedEventArgs e)
- {
- if (Display.Content.ToString() == "0")
- {
- Display.Content = 4;
- }
- else
- {
- Display.Content += "4";
- }
- }
- private void tal7_Click(object sender, RoutedEventArgs e)
- {
- if (Display.Content.ToString() == "0")
- {
- Display.Content = 7;
- }
- else
- {
- Display.Content += "7";
- }
- }
- private void tal8_Click(object sender, RoutedEventArgs e)
- {
- if (Display.Content.ToString() == "0")
- {
- Display.Content = 8;
- }
- else
- {
- Display.Content += "8";
- }
- }
- private void tal5_Click(object sender, RoutedEventArgs e)
- {
- if (Display.Content.ToString() == "0")
- {
- Display.Content = 5;
- }
- else
- {
- Display.Content += "5";
- }
- }
- private void tal2_Click(object sender, RoutedEventArgs e)
- {
- if(Display.Content.ToString() == "0")
- {
- Display.Content = 2;
- }
- else
- {
- Display.Content += "2";
- }
- }
- private void tal3_Click(object sender, RoutedEventArgs e)
- {
- if (Display.Content.ToString() == "0")
- {
- Display.Content = 3;
- }
- else
- {
- Display.Content += "3";
- }
- }
- private void tal6_Click(object sender, RoutedEventArgs e)
- {
- if (Display.Content.ToString() == "0")
- {
- Display.Content = 6;
- }
- else
- {
- Display.Content += "6";
- }
- }
- private void tal9_Click(object sender, RoutedEventArgs e)
- {
- if (Display.Content.ToString() == "0")
- {
- Display.Content = 9;
- }
- else
- {
- Display.Content += "9";
- }
- }
- private void tal0_Click(object sender, RoutedEventArgs e)
- {
- if (Display.Content.ToString() == "0")
- {
- Display.Content = 0;
- }
- else
- {
- Display.Content += "0";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement