/// <summary> /// Gets substruct (material block data) from file /// </summary> public void LoadSubstructData() { if ( !File.Exists( FilePath ) ) { MessageBox.Show( "Could not find input data file." , "Error" ); return; } // get canvas dimensions/properties double originX = OriginOffsetX , originY = OriginOffsetY , scale = Scale , yHeight = ActualHeight; Units units = Units; // get units dependent scaling factor double factor; switch ( units ) { case Units.Metres: factor = 0.0254; break; case Units.Millimetres: factor = 25.4; break; case Units.Feet: factor = 1.0 / 12.0; break; default: factor = 1.0; break; } // Load material blocks from source canvas substructs = new List<MaterialBlock>(); using ( TextReader tr = new StreamReader( FilePath ) ) { // advance to material block data while ( !tr.ReadLine().Contains( "MATERIAL BLOCK DATA" ) ) ; tr.ReadLine(); tr.ReadLine(); int numMaterialBlocks = int.Parse( tr.ReadLine().Split( '=' )[1] ); tr.ReadLine(); if ( numMaterialBlocks > 0 ) { MaterialBlock newMaterialBlock; MaterialType newMaterialType; Point[] materialBoundPoints; string materialName; int numMaterialBoundPoints , numLineConstraints , numLineLoads , numPointLoads; double xCoord , yCoord; string[] coords; for ( int i = 0 ; i < numMaterialBlocks ; i++ ) { tr.ReadLine(); tr.ReadLine(); numMaterialBoundPoints = int.Parse( tr.ReadLine().Split( '=' )[1] ); materialBoundPoints = new Point[numMaterialBoundPoints]; for ( int j = 0 ; j < numMaterialBoundPoints ; j++ ) { coords = tr.ReadLine().Split( new char[] { ',' , ' ' } , StringSplitOptions.RemoveEmptyEntries ); xCoord = double.Parse( coords[0] ); yCoord = double.Parse( coords[1] ); materialBoundPoints[j].X = xCoord / (factor * Scale) * dpiX + OriginOffsetX; materialBoundPoints[j].Y = ActualHeight - (yCoord / (factor * Scale) * dpiY + OriginOffsetY); } newMaterialBlock = new MaterialBlock( this , null , materialBoundPoints ); numLineConstraints = int.Parse( tr.ReadLine().Split( '=' )[1] ); for ( int j = 0 ; j < numLineConstraints ; j++ ) tr.ReadLine(); numLineLoads = int.Parse( tr.ReadLine().Split( '=' )[1] ); for ( int j = 0 ; j < numLineLoads ; j++ ) tr.ReadLine(); numPointLoads = int.Parse( tr.ReadLine().Split( '=' )[1] ); for ( int j = 0 ; j < numPointLoads ; j++ ) tr.ReadLine(); substructs.Add( newMaterialBlock ); tr.ReadLine(); } // advance to phase data while ( !tr.ReadLine().Contains( "ANALYSIS PHASES" ) ) ; int phaseNum = SelectedPhase.Number; string phaseHeader = string.Format( "Phase #{0}" , phaseNum ); while ( !tr.ReadLine().Contains( phaseHeader ) ) ; while ( !tr.ReadLine().Contains( "Material Block #" ) ) ; // get material type info string line; for ( int i = 0 ; i < numMaterialBlocks ; i++ ) { materialName = tr.ReadLine(); newMaterialType = materialTypes.Find( delegate( MaterialType mt ) { return mt.Name == materialName; } ); substructs[i].Material = newMaterialType; while ( (line = tr.ReadLine()) != null ) if ( line.Contains( "Material Block #" ) ) break; } } } }
public DrawingPoint( SlopeDefineCanvas canvas , MaterialBlock parent , Point pt ) { this.defineCanvas = canvas; this.parentBlocks = new List<MaterialBlock>() { parent }; this.point = pt; fixLines = new List<Polyline>(); Polyline newLine; for ( int i = 0 ; i < 4 ; i++ ) { newLine = new Polyline(); newLine.Visibility = Visibility.Hidden; newLine.Fill = Brushes.Blue; newLine.Opacity = 1.0; newLine.StrokeThickness = 1.5; newLine.Stroke = Brushes.Blue; fixLines.Add( newLine ); canvas.Children.Add( newLine ); newLine.MouseLeftButtonUp += new MouseButtonEventHandler( fixLines_MouseLeftButtonUp ); } fixLines[0].Points.Add( new Point( point.X - 7 , point.Y - 3.5 ) ); fixLines[0].Points.Add( new Point( point.X + 7 , point.Y - 3.5 ) ); fixLines[1].Points.Add( new Point( point.X - 7 , point.Y + 3.5 ) ); fixLines[1].Points.Add( new Point( point.X + 7 , point.Y + 3.5 ) ); fixLines[2].Points.Add( new Point( point.X - 3.5 , point.Y + 7 ) ); fixLines[2].Points.Add( new Point( point.X - 3.5 , point.Y - 7 ) ); fixLines[3].Points.Add( new Point( point.X + 3.5 , point.Y + 7 ) ); fixLines[3].Points.Add( new Point( point.X + 3.5 , point.Y - 7 ) ); dot = new Ellipse(); dot.HorizontalAlignment = HorizontalAlignment.Left; dot.VerticalAlignment = VerticalAlignment.Top; dot.Height = 7; dot.Width = 7; dot.Margin = new Thickness( point.X - 0.5 * dot.Width , point.Y - 0.5 * dot.Height , 0 , 0 ); dot.Stroke = Brushes.Black; dot.Fill = Brushes.Black; dot.Opacity = 0.7; dot.Visibility = Visibility.Hidden; dot.MouseLeftButtonDown += new MouseButtonEventHandler( MouseLeftButtonDown ); canvas.Children.Add( dot ); }