For example i have simple WPF application.Just window and nothing more.And i see that there are seven threads in application.What do this threads does?In Console Application 4 threads.I don't understand this also.I using Task manager to determine this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication2
{
static class swticher
{
}
static class moves
{
public static double devide(double a, double b)
{
return a / b;
}
public static double plus(double a, double b)
{
return a + b;
}
public static double multiply(double a, double b)
{
return a * b;
}
public static double minus(double a, double b)
{
return a - b;
}
public static double sinus(double a)
{
return Math.Sin(a);
}
}
public partial class MainWindow :Window
{
string Leftoperand = "";
string Rightoperand = "";
char Operator = ' ';
int isok=0;
bool b=false;
public MainWindow()
{
}
public void Somemethod(object e,EventArgs args)
{
}
public void Buttonmove(object sender, RoutedEventArgs e)
{
string s = (string)((Button)e.OriginalSource).Name;
if (s == "Buttonshift")
b = !b;
if (b == false)
swither1(s);
else
swither3(s);
}
private void Window1_KeyDown_1(object sender, KeyEventArgs e)
{
swither2(e);
}
public void swither1(string s)
{
switch (s)
{
case "Button0": Screen.Text += "0"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "0"; else Rightoperand += "0"; break;
case "Button1": Screen.Text += "1"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "1"; else Rightoperand += "1"; break;
case "Button2": Screen.Text += "2"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "2"; else Rightoperand += "2"; break;
case "Button3": Screen.Text += "3"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "3"; else Rightoperand += "3"; break;
case "Button4": Screen.Text += "4"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "4"; else Rightoperand += "4"; break;
case "Button5": Screen.Text += "5"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "5"; else Rightoperand += "5"; break;
case "Button6": Screen.Text += "6"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "6"; else Rightoperand += "6"; break;
case "Button7": Screen.Text += "7"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "7"; else Rightoperand += "7"; break;
case "Button8": Screen.Text += "5"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "8"; else Rightoperand += "8"; break;
case "Button9": Screen.Text += "6"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "9"; else Rightoperand += "9"; break;
case "Buttonsin": if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10)
{ Leftoperand = Convert.ToString(moves.sinus(Convert.ToDouble(Leftoperand))); Screen.Text = Leftoperand; }
else { Rightoperand = Convert.ToString(moves.sinus(Convert.ToDouble(Rightoperand))); Screen.Text = Rightoperand; } break;
case "ButtonDEL": if (isok == 0 && Leftoperand.Length > 0) { Leftoperand = Leftoperand.Remove(Leftoperand.Length - 1); Screen.Text = Leftoperand; } else { if (Rightoperand.Length > 0) { Rightoperand = Rightoperand.Remove(Rightoperand.Length - 1); Screen.Text = Rightoperand; } } break;
case "Buttonpoint": Screen.Text += ","; if (isok == 0 && Leftoperand.Length <= 10) Leftoperand += ","; else Rightoperand = ","; break;
case "Buttonx": Screen.Text = ""; isok = 1; Operator = 'x'; break;
case "Buttonplus": Screen.Text = ""; isok = 1; Operator = '+'; break;
case "Buttonminus": Screen.Text = ""; isok = 1; Operator = '-'; break;
case "Buttondevide": Screen.Text = ""; isok = 1; Operator = '/'; break;
case "ButtonClear": Screen.Text = ""; isok = 0; Operator = ' '; Leftoperand = ""; Rightoperand = ""; break;
case "ButtonEqual": if (isok == 1)
{
Screen.Text = "";
switch (Operator)
{
case 'x': Leftoperand = Convert.ToString(moves.multiply(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
case '/': Leftoperand = Convert.ToString(moves.devide(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
case '-': Leftoperand = Convert.ToString(moves.minus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
case '+': Leftoperand = Convert.ToString(moves.plus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
}
} break;
}
}
public void swither2(KeyEventArgs e)
{
switch (e.Key)
{
case Key.D0: Screen.Text += "0"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "0"; else Rightoperand += "0"; break;
case Key.D1: Screen.Text += "1"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "1"; else Rightoperand += "1"; break;
case Key.D2: Screen.Text += "2"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "2"; else Rightoperand += "2"; break;
case Key.D3: Screen.Text += "3"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "3"; else Rightoperand += "3"; break;
case Key.D4: Screen.Text += "4"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "4"; else Rightoperand += "4"; break;
case Key.D5: Screen.Text += "5"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "5"; else Rightoperand += "5"; break;
case Key.D6: Screen.Text += "6"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "6"; else Rightoperand += "6"; break;
case Key.D7: Screen.Text += "7"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "7"; else Rightoperand += "7"; break;
case Key.D8: Screen.Text += "8"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "8"; else Rightoperand += "8"; break;
case Key.D9: Screen.Text += "9"; if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10) Leftoperand += "9"; else Rightoperand += "9"; break;
case Key.Back:if (isok == 0 && Leftoperand.Length > 0) { Leftoperand = Leftoperand.Remove(Leftoperand.Length - 1); Screen.Text = Leftoperand; } else { if (Rightoperand.Length > 0) { Rightoperand = Rightoperand.Remove(Rightoperand.Length - 1); Screen.Text = Rightoperand; } } break;
case Key.OemComma: Screen.Text += ","; if (isok == 0 && Leftoperand.Length <= 10) Leftoperand += ","; else Rightoperand += ","; break;
case Key.S: if (isok == 0 && Leftoperand.Length <= 10 && Rightoperand.Length <= 10)
{ Leftoperand = Convert.ToString(moves.sinus(Convert.ToDouble(Leftoperand))); Screen.Text = Leftoperand; }
else { Rightoperand = Convert.ToString(moves.sinus(Convert.ToDouble(Rightoperand))); Screen.Text = Rightoperand; } break;
case Key.Multiply: Screen.Text = ""; isok = 1; Operator = 'x'; break;
case Key.OemPlus: Screen.Text = ""; isok = 1; Operator = '+'; break;
case Key.OemMinus: Screen.Text = ""; isok = 1; Operator = '-'; break;
case Key.Divide: Screen.Text = ""; isok = 1; Operator = '/'; break;
case Key.Escape: Screen.Text = ""; isok = 0; Operator = ' '; Leftoperand = ""; Rightoperand = ""; break;
case Key.LeftCtrl: if (isok == 1)
{
Screen.Text = "";
switch (Operator)
{
case 'x': Leftoperand = Convert.ToString(moves.multiply(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
case '/': Leftoperand = Convert.ToString(moves.devide(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
case '-': Leftoperand = Convert.ToString(moves.minus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
case '+': Leftoperand = Convert.ToString(moves.plus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
}
Rightoperand = "";
} break;
}
}
public void swither3(string s)
{
switch (s)
{
case "ButtonEqual": if (isok == 1)
{
Screen.Text = "";
switch (Operator)
{
case 'x': Leftoperand = Convert.ToString(moves.multiply(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
case '/': Leftoperand = Convert.ToString(moves.devide(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
case '-': Leftoperand = Convert.ToString(moves.minus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
case '+': Leftoperand = Convert.ToString(moves.plus(Convert.ToDouble(Leftoperand), Convert.ToDouble(Rightoperand))); Screen.Text = Leftoperand; break;
}
} break;
}
}
}
}
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Title="My program" x:Class="WpfApplication2.MainWindow" x:Name="Window1" Height="500" Width="500" ResizeMode="NoResize" KeyDown="Window1_KeyDown_1">
<Window.Background>
<ImageBrush ImageSource="pack://application:,,,/Resources/Somecalculator.jpg"/>
</Window.Background>
<Grid>
<TextBlock Margin="126,76,126,330" removed="White" x:Name="Screen" FontSize="40"/>
<Button Opacity="0" Margin="116,314,324,130" x:Name="Button7" Click="Buttonmove" />
<Button Opacity="0" Margin="116,350,324,99" x:Name="Button4" Click="Buttonmove"/>
<Button Opacity="0" Margin="116,381,324,68" x:Name="Button1" Click="Buttonmove"/>
<Button Opacity="0" Margin="116,412,324,37" x:Name="Button0" Click="Buttonmove"/>
<Button Opacity="0" Margin="170,319,274,135" x:Name="Button8" Click="Buttonmove"/>
<Button Opacity="0" Margin="170,352,274,102" x:Name="Button5" Click="Buttonmove"/>
<Button Opacity="0" Margin="170,383,274,71" x:Name="Button2" Click="Buttonmove"/>
<Button Opacity="0" Margin="170,416,274,38" x:Name="Buttonpoint" Click="Buttonmove"/>
<Button Opacity="0" Margin="222,319,222,135" x:Name="Button9" Click="Buttonmove"/>
<Button Opacity="0" Margin="222,351,222,103" x:Name="Button6" Click="Buttonmove"/>
<Button Opacity="0" Margin="222,383,222,71" x:Name="Button3" Click="Buttonmove"/>
<Button Opacity="0" Margin="275,351,169,103" x:Name="Buttonx" Click="Buttonmove"/>
<Button Opacity="0" Margin="275,383,169,71" x:Name="Buttonplus" Click="Buttonmove"/>
<Button Opacity="0" Margin="328,350,116,104" x:Name="Buttondevide" Click="Buttonmove"/>
<Button Opacity="0" Margin="330,381,114,71" x:Name="Buttonminus" Click="Buttonmove"/>
<Button Opacity="0" Margin="328,412,116,38" x:Name="ButtonEqual" Click="Buttonmove"/>
<Button Opacity="0" Margin="328,315,116,135" x:Name="ButtonClear" Click="Buttonmove"/>
<Button Opacity="0" Margin="275,317,169,133" x:Name="ButtonDEL" Click="Buttonmove"/>
<Button Opacity="0" Margin="249,263,204,194" x:Name="Buttonsin" Click="Buttonmove"/>
<Button Opacity="0" Margin="114,170,339,281" x:Name="Buttonshift" Click="Buttonmove"/>
</Grid>
</Window>