12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- 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.Shapes;
- namespace GraphDrawer
- {
- /// <summary>
- /// Interaction logic for GraphByMatrix.xaml
- /// </summary>
- public partial class GraphByMatrix : Window
- {
- T[,] ResizeArray<T>(T[,] original, int rows, int cols)
- {
- var newArray = new T[rows, cols];
- int minRows = Math.Min(rows, original.GetLength(0));
- int minCols = Math.Min(cols, original.GetLength(1));
- for (int i = 0; i < minRows; i++)
- for (int j = 0; j < minCols; j++)
- newArray[i, j] = original[i, j];
- return newArray;
- }
- public GraphByMatrix()
- {
- InitializeComponent();
- }
- private void submitBtn_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- var row = MatrixTextBox.GetLineText(0);
- row = row.Replace(" ", "");
- var elements = row.Split(',');
- int rows = elements.Length;
- int cols = 0;
- while (true)
- {
- var String = MatrixTextBox.GetLineText(cols);
- if (!(String.Length > 0))
- cols++;
- else
- break;
- }
- int[,] matrix = new int[rows, cols];
- for(int i = 0; i < rows; i++)
- {
- row = MatrixTextBox.GetLineText(i);
- row = row.Replace(" ", "");
- var rowArray = row.Split(',');
- for(int j = 0; j < cols; j++)
- {
- matrix[i, j] = int.Parse(rowArray[j]);
- }
- }
- GraphByClick graphByClick = new GraphByClick(matrix, true);
- }
- catch(Exception ex)
- {
- MessageBox.Show("Разделитель - запятая\nПопробуйте еще раз", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
- MessageBox.Show(ex.Message);
- }
- }
- private void backBtn_Click(object sender, RoutedEventArgs e)
- {
- ChoiseRegime choice = new ChoiseRegime();
- choice.Show();
- Close();
- }
- }
- }
|