// Called by the form when the button is pressed private void MenuItemSave() { // Get the output file FloorLayoutInput fli = LoadFloorLayoutInputFromEdit(); // If we've previously saved something save to the same location if (DefaultFileToSaveTo != "") { // Save it to the where we saved it last time fli.GetProperties().Save(DefaultFileToSaveTo); return; } // Prompt on a location to save SaveFileDialog x = new SaveFileDialog(); x.DefaultExt = "XML | .xml"; bool?sts = x.ShowDialog(); if (sts == null || sts.Value == false) { return; } fli.GetProperties().Save(x.FileName); DefaultFileToSaveTo = x.FileName; }
public void LoadEditorsFromFloorLayoutInput(FloorLayoutInput fli) { oFWRInput = new Edit2DFloorLayoutInput(); oFWRInput.GridSize = GridSize; oFWRInput.OutlineAreas.GridSize = GridSize; oFWRInput.OpenAreas.GridSize = GridSize; oFWRInput.Walls.GridSize = GridSize; // Reset canvase oCanvas.Children.Clear(); // define parameters for editor oFWRInput.DrawPrimitives = oDrawPrimitives; oFWRInput.PictureBoxHeight = (int)oCanvas.Height; oFWRInput.PictureBoxWidth = (int)oCanvas.Width; oDrawPrimitives?.StartDrawing(true); LoadEdit2d(oFWRInput.OutlineAreas, fli.Outline); LoadEdit2d(oFWRInput.OpenAreas, fli.OpenArea); oFWRInput.Walls.DrawPrimitives = oDrawPrimitives; oFWRInput.Walls.PictureBoxHeight = (int)oCanvas.Height; oFWRInput.Walls.PictureBoxWidth = (int)oCanvas.Width; foreach (LineSegment ls in fli.WallSegmentArray) { oFWRInput.Walls.AddEdge(new PointF(ls.From.X, ls.From.Y), new PointF(ls.To.X, ls.To.Y), 3, 10); } oDrawPrimitives?.StartDrawing(true); oFWRInput.DrawShapes(); }
// Called by the form when the button is pressed private void MenuItemOpen() { string message = ""; OpenFileDialog o = new OpenFileDialog(); o.Multiselect = false; o.Filter = "XML | *.xml"; bool?b = o.ShowDialog(); if (b == null || b.Value == false) { return; } XElement xo = XElement.Load(o.FileName); FloorLayoutInput fli = new FloorLayoutInput(); fli.LoadProperties(xo, out message); LoadEditorsFromFloorLayoutInput(fli); // Save this as the default file to save to. DefaultFileToSaveTo = o.FileName; }
/// <summary> /// Load the drawing into floorlayout input template /// </summary> /// <returns></returns> public FloorLayoutInput LoadFloorLayoutInputFromEdit() { FloorLayoutInput oInput = new FloorLayoutInput(); oFWRInput.OpenAreas.InvertHolePoints(); oInput.OpenArea.oHoleGroup = oFWRInput.OpenAreas.HoleGroupList[0]; oInput.OpenArea.EllipseArray = oFWRInput.OpenAreas.BoundaryEllipseList.ToArray(); oInput.OpenArea.RectangleArray = oFWRInput.OpenAreas.BoundaryRectangleList.ToArray(); oInput.OpenArea.PolygonArray = oFWRInput.OpenAreas.BoundaryPolygonList.ToArray(); oFWRInput.OutlineAreas.InvertHolePoints(); oInput.Outline.oHoleGroup = oFWRInput.OutlineAreas.HoleGroupList[0]; oInput.Outline.EllipseArray = oFWRInput.OutlineAreas.BoundaryEllipseList.ToArray(); oInput.Outline.RectangleArray = oFWRInput.OutlineAreas.BoundaryRectangleList.ToArray(); oInput.Outline.PolygonArray = oFWRInput.OutlineAreas.BoundaryPolygonList.ToArray(); List <LineSegment> linelist = new List <LineSegment>(); Edit2DLib.Edit2DGraphLayer oLayer = oFWRInput.Walls.Edit2dGraphLayerList[0]; foreach (Edge oEdge in oLayer.EdgeList) { Vertex p1 = oLayer.VertexList[oEdge.p1]; Vertex p2 = oLayer.VertexList[oEdge.p2]; linelist.Add(new LineSegment() { From = new Point2D() { X = p1.X, Y = p1.Y }, To = new Point2D() { X = p2.X, Y = p2.Y } }); } oInput.WallSegmentArray = linelist.ToArray(); oFWRInput.OpenAreas.InvertHolePoints(); oFWRInput.OutlineAreas.InvertHolePoints(); /* * Re-invert the points in the drawing */ return(oInput); }
private void QuickStart() { MenuItemNew(); string message = ""; Uri uri = new Uri("/Samples/hello.xml", UriKind.Relative); StreamResourceInfo info = Application.GetContentStream(uri); XElement xo = XElement.Load(info.Stream); FloorLayoutInput fli = new FloorLayoutInput(); fli.LoadProperties(xo, out message); LoadEditorsFromFloorLayoutInput(fli); }
// Called by the form when the button is pressed private void MenuItemSaveAs() { FloorLayoutInput fli = LoadFloorLayoutInputFromEdit(); SaveFileDialog x = new SaveFileDialog(); bool?sts = x.ShowDialog(); x.DefaultExt = "XML | .xml"; if (sts == null && sts.Value == false) { return; } fli.GetProperties().Save(x.FileName); }
// Called by the form when the button is pressed private void Generate() { FloorLayoutInput oInput = LoadFloorLayoutInputFromEdit(); if (DefaultFileToGenerateTo == "") { // Prompt on a location to save SaveFileDialog x = new SaveFileDialog(); x.DefaultExt = "FBX|.fbx"; bool?sts = x.ShowDialog(); if (sts == null || sts.Value == false) { return; } DefaultFileToGenerateTo = x.FileName; } // Flip the 'y' before generating rooms oFWRInput.OpenAreas.InvertHolePoints(); oFWRInput.OutlineAreas.InvertHolePoints(); XElement xfl = GetFloorLayout(oInput.GetProperties()); oFWRInput.OpenAreas.InvertHolePoints(); oFWRInput.OutlineAreas.InvertHolePoints(); string message = ""; ShapeTemplateLib.Templates.User0.FloorLayout oFloorLayout = new ShapeTemplateLib.Templates.User0.FloorLayout(); oFloorLayout.LoadProperties(xfl, out message); oFloorLayout.RandomlySelectDoors(); XElement sl = oFloorLayout.Compile(5, 5); XElement scene = new XElement("scene", sl); File.Delete(DefaultFileToGenerateTo); GetMesh(DefaultFileToGenerateTo, scene); }