private void Button_Calculate_Click(object sender, RoutedEventArgs e) { Drowing.Children.Clear(); try { boxHight = Convert.ToInt32(MainHight.Text); boxWidth = Convert.ToInt32(MainWidth.Text); rectanglePacker = new RectanglePacker(boxHight, boxWidth); bool result; //result = rectanglePacker.PackRectangleWithNFDH(rectangles); result = rectanglePacker.PackRectangleWithFFDH(rectangles); if (!result) { MassageBox.Text = "Cant fit"; } if (result) { MassageBox.Text = "successfully fited"; int h = rectanglePacker.Hight; int w = rectanglePacker.Width; RectangleGeometry rectangle = new RectangleGeometry(new Rect(0, 0, w, h)); Path myPath = new Path(); myPath.HorizontalAlignment = HorizontalAlignment.Left; myPath.VerticalAlignment = VerticalAlignment.Bottom; myPath.Stroke = Brushes.Black; myPath.StrokeThickness = 3; GeometryGroup geometryGroup = new GeometryGroup(); geometryGroup.Children.Add(rectangle); foreach (var item in rectanglePacker.PackedRectengles) { var cord = item.Key; var rect = item.Value; var rectangle2 = new RectangleGeometry(new Rect(cord.X, cord.Y, rect.Width, rect.Hight)); geometryGroup.Children.Add(rectangle2); } myPath.Data = geometryGroup; Drowing.Children.Add(myPath); } } catch (Exception ex) { MassageBox.Text = ex.Message; } }