private void MenuItemLoad_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog(this) == true) { try { ReadFromFile(ofd.FileName); filename = ofd.FileName; } catch { MessageBox.Show("Неправильный формат файла!"); } text_box_dim.Text = R.Dim.ToString(); CreateUserInterface(); placing = new Placing(rects, region); placing.Find(); Visualize(); } }
private void TextBoxRect_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) { if (0 <= geometry_index && geometry_index < rects.Length) { int j = (int)(sender as TextBox).Tag; try { double size = double.Parse((sender as TextBox).Text); if (size > 0) { rects[geometry_index].Size(j, size); placing = new Placing(rects, region); placing.Find(); Visualize(); } } catch { MessageBox.Show("Введены неправильные данные!"); } } } }
public MainWindow() { InitializeComponent(); R.Dim = 0; rects = new Rect[0]; region = new Region(); CreateUserInterface(); placing = new Placing(rects, region); placing.Find(); dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10); #region Создание трёхмерного объекта размещения. mesh_geometry_3d_rect = new MeshGeometry3D(); #region Вершины единичного куба. mesh_geometry_3d_rect.Positions.Add(new Point3D(0, 0, 0)); // 0 mesh_geometry_3d_rect.Positions.Add(new Point3D(1, 0, 0)); // 1 mesh_geometry_3d_rect.Positions.Add(new Point3D(0, 1, 0)); // 2 mesh_geometry_3d_rect.Positions.Add(new Point3D(1, 1, 0)); // 3 mesh_geometry_3d_rect.Positions.Add(new Point3D(0, 0, 1)); // 4 mesh_geometry_3d_rect.Positions.Add(new Point3D(1, 0, 1)); // 5 mesh_geometry_3d_rect.Positions.Add(new Point3D(0, 1, 1)); // 6 mesh_geometry_3d_rect.Positions.Add(new Point3D(1, 1, 1)); // 7 #endregion #region Грани единичного куба. mesh_geometry_3d_rect.TriangleIndices.Add(0); mesh_geometry_3d_rect.TriangleIndices.Add(2); mesh_geometry_3d_rect.TriangleIndices.Add(1); mesh_geometry_3d_rect.TriangleIndices.Add(1); mesh_geometry_3d_rect.TriangleIndices.Add(2); mesh_geometry_3d_rect.TriangleIndices.Add(3); mesh_geometry_3d_rect.TriangleIndices.Add(0); mesh_geometry_3d_rect.TriangleIndices.Add(4); mesh_geometry_3d_rect.TriangleIndices.Add(2); mesh_geometry_3d_rect.TriangleIndices.Add(2); mesh_geometry_3d_rect.TriangleIndices.Add(4); mesh_geometry_3d_rect.TriangleIndices.Add(6); mesh_geometry_3d_rect.TriangleIndices.Add(0); mesh_geometry_3d_rect.TriangleIndices.Add(1); mesh_geometry_3d_rect.TriangleIndices.Add(4); mesh_geometry_3d_rect.TriangleIndices.Add(1); mesh_geometry_3d_rect.TriangleIndices.Add(5); mesh_geometry_3d_rect.TriangleIndices.Add(4); mesh_geometry_3d_rect.TriangleIndices.Add(1); mesh_geometry_3d_rect.TriangleIndices.Add(7); mesh_geometry_3d_rect.TriangleIndices.Add(5); mesh_geometry_3d_rect.TriangleIndices.Add(1); mesh_geometry_3d_rect.TriangleIndices.Add(3); mesh_geometry_3d_rect.TriangleIndices.Add(7); mesh_geometry_3d_rect.TriangleIndices.Add(4); mesh_geometry_3d_rect.TriangleIndices.Add(5); mesh_geometry_3d_rect.TriangleIndices.Add(6); mesh_geometry_3d_rect.TriangleIndices.Add(7); mesh_geometry_3d_rect.TriangleIndices.Add(6); mesh_geometry_3d_rect.TriangleIndices.Add(5); mesh_geometry_3d_rect.TriangleIndices.Add(2); mesh_geometry_3d_rect.TriangleIndices.Add(6); mesh_geometry_3d_rect.TriangleIndices.Add(3); mesh_geometry_3d_rect.TriangleIndices.Add(3); mesh_geometry_3d_rect.TriangleIndices.Add(6); mesh_geometry_3d_rect.TriangleIndices.Add(7); #endregion #endregion #region Создание трёхмерной области размещения. mesh_geometry_3d_region = new MeshGeometry3D(); #region Вершины единичного куба. mesh_geometry_3d_region.Positions.Add(new Point3D(0, 0, 0)); // 0 mesh_geometry_3d_region.Positions.Add(new Point3D(1, 0, 0)); // 1 mesh_geometry_3d_region.Positions.Add(new Point3D(0, 1, 0)); // 2 mesh_geometry_3d_region.Positions.Add(new Point3D(1, 1, 0)); // 3 mesh_geometry_3d_region.Positions.Add(new Point3D(0, 0, 1)); // 4 mesh_geometry_3d_region.Positions.Add(new Point3D(1, 0, 1)); // 5 mesh_geometry_3d_region.Positions.Add(new Point3D(0, 1, 1)); // 6 mesh_geometry_3d_region.Positions.Add(new Point3D(1, 1, 1)); // 7 #endregion #region Грани единичного куба. mesh_geometry_3d_region.TriangleIndices.Add(1); mesh_geometry_3d_region.TriangleIndices.Add(2); mesh_geometry_3d_region.TriangleIndices.Add(0); mesh_geometry_3d_region.TriangleIndices.Add(3); mesh_geometry_3d_region.TriangleIndices.Add(2); mesh_geometry_3d_region.TriangleIndices.Add(1); mesh_geometry_3d_region.TriangleIndices.Add(2); mesh_geometry_3d_region.TriangleIndices.Add(4); mesh_geometry_3d_region.TriangleIndices.Add(0); mesh_geometry_3d_region.TriangleIndices.Add(6); mesh_geometry_3d_region.TriangleIndices.Add(4); mesh_geometry_3d_region.TriangleIndices.Add(2); mesh_geometry_3d_region.TriangleIndices.Add(4); mesh_geometry_3d_region.TriangleIndices.Add(1); mesh_geometry_3d_region.TriangleIndices.Add(0); mesh_geometry_3d_region.TriangleIndices.Add(4); mesh_geometry_3d_region.TriangleIndices.Add(5); mesh_geometry_3d_region.TriangleIndices.Add(1); mesh_geometry_3d_region.TriangleIndices.Add(5); mesh_geometry_3d_region.TriangleIndices.Add(7); mesh_geometry_3d_region.TriangleIndices.Add(1); mesh_geometry_3d_region.TriangleIndices.Add(7); mesh_geometry_3d_region.TriangleIndices.Add(3); mesh_geometry_3d_region.TriangleIndices.Add(1); mesh_geometry_3d_region.TriangleIndices.Add(6); mesh_geometry_3d_region.TriangleIndices.Add(5); mesh_geometry_3d_region.TriangleIndices.Add(4); mesh_geometry_3d_region.TriangleIndices.Add(5); mesh_geometry_3d_region.TriangleIndices.Add(6); mesh_geometry_3d_region.TriangleIndices.Add(7); mesh_geometry_3d_region.TriangleIndices.Add(3); mesh_geometry_3d_region.TriangleIndices.Add(6); mesh_geometry_3d_region.TriangleIndices.Add(2); mesh_geometry_3d_region.TriangleIndices.Add(7); mesh_geometry_3d_region.TriangleIndices.Add(6); mesh_geometry_3d_region.TriangleIndices.Add(3); #endregion #endregion text_box_dim.Text = R.Dim.ToString(); Visualize(); }
private void TextBoxRegion_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) { int i = (int)(sender as TextBox).Tag; try { double size=double.Parse((sender as TextBox).Text); if (size < 0) { region.Freez(i, false); region.Size(i, 0); } else { region.Freez(i, false); region.Size(i, size); region.Freez(i, true); } CreateUserInterface(); placing = new Placing(rects, region); placing.Find(); Visualize(); } catch { MessageBox.Show("Введены неправильные данные!"); } } }