Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Логика взаимодействия для MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public int[] BinaryValue = new int[64];
- public MainWindow()
- {
- InitializeComponent();
- int indexLb = 0;
- int colIndexStkPnl = 0;
- for (int stpnl = 0; stpnl < 16; stpnl++)
- {
- BinPanel.Children.Add(new StackPanel {Orientation = Orientation.Horizontal, Margin = new Thickness(10,0,10,0)});
- }
- foreach (object anyContener in BinPanel.Children)
- {
- if(anyContener is StackPanel)
- {
- StackPanel stkPanel = (StackPanel)anyContener;
- if (indexLb < 32)
- {
- Grid.SetRow(stkPanel, 0);
- Grid.SetColumn(stkPanel, colIndexStkPnl);
- colIndexStkPnl++;
- }
- else if(indexLb > 31)
- {
- Grid.SetRow(stkPanel, 2);
- Grid.SetColumn(stkPanel, colIndexStkPnl % 8);
- colIndexStkPnl++;
- }
- for(int i = 0; i<4; i++)
- {
- stkPanel.Children.Add(new Label { Name = "Bin" + indexLb.ToString(), Content = 0, Padding = new Thickness(1) });
- indexLb++;
- }
- }
- }
- }
- private void BinaryPanel_MouseDown(object sender, MouseButtonEventArgs e)
- {
- Label ChildElem = (Label)e.Source;
- bool PinVal = Convert.ToBoolean(Convert.ToInt16(ChildElem.Content));
- ChildElem.Content = Convert.ToInt16(!PinVal);
- int indexChild = Convert.ToInt32(ChildElem.Name.Substring(3));
- BinaryValue[indexChild] = Convert.ToInt16(ChildElem.Content);
- string FullBinVal = string.Concat<int>(BinaryValue);
- Tablo.Text = Convert.ToString(Convert.ToInt64(FullBinVal, 2));
- }
- private void Numbers(object sender, RoutedEventArgs e)
- {
- Button Any_but = (Button)sender;
- switch (Any_but.Content)
- {
- case "0":
- if (Tablo.Text != "0")
- {
- Tablo.Text += "0";
- }
- break;
- default:
- if (Tablo.Text == "0")
- {
- Tablo.Text = Convert.ToString(Any_but.Content);
- }
- else
- {
- Tablo.Text += Any_but.Content;
- }
- break;
- }
- }
- private void Comma_Click(object sender, RoutedEventArgs e)
- {
- if (!Tablo.Text.Contains(","))
- {
- Tablo.Text += ",";
- }
- }
- private void Cancel_mode(object sender, RoutedEventArgs e)
- {
- Button cancel = (Button)sender;
- switch (cancel.Content)
- {
- case "CE":
- Tablo.Text = "0";
- break;
- case "C":
- Tablo.Text = "0";
- Func_calc.Text = "";
- break;
- default:
- if (Tablo.Text.Length != 1)
- {
- Tablo.Text = Tablo.Text.Substring(0, Tablo.Text.Length - 1);
- }
- else
- {
- Tablo.Text = "0";
- }
- break;
- }
- }
- private void MenuItem_Click(object sender, RoutedEventArgs e)
- {
- usles.IsChecked = false;
- stat.IsChecked = false;
- progr.IsChecked = false;
- ingen.IsChecked = false;
- MenuItem test = (MenuItem)sender;
- test.IsChecked = true;
- }
- private void Unchecked(object sender, RoutedEventArgs e)
- {
- MenuItem test = (MenuItem)sender;
- switch (test.Name)
- {
- case "usles":
- break;
- case "ingen":
- Application.Current.MainWindow.Width = Application.Current.MainWindow.Width / 2;
- EnginPanel.Visibility = Visibility.Collapsed;
- leftCol.Width = GridLength.Auto;
- break;
- case "progr":
- Application.Current.MainWindow.Width = Application.Current.MainWindow.Width / 2;
- Application.Current.MainWindow.Height = Application.Current.MainWindow.Height - BinPanel.Height;
- BinPanel.Visibility = Visibility.Collapsed;
- ProgrPanel.Visibility = Visibility.Collapsed;
- leftCol.Width = GridLength.Auto;
- break;
- case "stat":
- break;
- }
- }
- private void Cheched(object sender, RoutedEventArgs e)
- {
- MenuItem test = (MenuItem)sender;
- switch (test.Name)
- {
- case "usles":
- break;
- case "ingen":
- Application.Current.MainWindow.Width = Application.Current.MainWindow.Width * 2;
- EnginPanel.Visibility = Visibility.Visible;
- leftCol.Width = new GridLength(1, GridUnitType.Star);
- break;
- case "progr":
- Application.Current.MainWindow.Width = Application.Current.MainWindow.Width * 2;
- Application.Current.MainWindow.Height = Application.Current.MainWindow.Height + BinPanel.Height;
- BinPanel.Visibility = Visibility.Visible;
- ProgrPanel.Visibility = Visibility.Visible;
- leftCol.Width = new GridLength(1, GridUnitType.Star);
- break;
- case "stat":
- break;
- }
- }
- private void Window_TextInput(object sender, TextCompositionEventArgs e)
- {
- char KeyPress;
- Char.TryParse(e.Text, out KeyPress);
- switch (Convert.ToInt32(KeyPress))
- {
- case 8:
- Cancel_mode(BackSP, new RoutedEventArgs());
- break;
- default:
- if (Convert.ToInt32(KeyPress) <= 57 && Convert.ToInt32(KeyPress) >= 48)
- {
- if (Tablo.Text != "0")
- {
- Tablo.Text += KeyPress;
- }
- else
- {
- Tablo.Text = Convert.ToString(KeyPress);
- }
- }
- break;
- }
- }
- private void Tablo_TextChanged(object sender, TextChangedEventArgs e)
- {
- string binValue = Convert.ToString(Convert.ToInt64(Tablo.Text), 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment