/// <summary> /// Add a window to a plan. /// </summary> /// <param name="window1">Window first point</param> /// <param name="window2">Window second point</param> /// <param name="wall1">Attached wall first point</param> /// <param name="wall2">Attached wall second point</param> /// <returns>Created HouseWindow object</returns> public HouseWindow AddWindow(Point window1, Point window2, Point wall1, Point wall2) { ScaleGeometrySave(ref window1); ScaleGeometrySave(ref window2); ScaleGeometrySave(ref wall1); ScaleGeometrySave(ref wall2); Segment wall = FindSegmentByCoords(wall1, wall2); if (wall != null) { HouseWindow houseWindow = new HouseWindow(new List <float>() { (float)window1.X, (float)window1.Y }, new List <float>() { (float)window2.X, (float)window2.Y }); wall.Window = houseWindow; return(houseWindow); } else { return(null); } }
public Segment(string name, List <float> start, List <float> stop, HouseWindow hw) { this.Name = name; this.Start = start; this.Stop = stop; this.Window = hw; }
/// <summary> /// Import plan content. Draw the plan content on the canvas. /// Loop throught each plan List (Door, Area, Wall) an entry point to create the plan /// </summary> /// <param name="receiver">Receiver object</param> /// <param name="invoker">Invoker object</param> public void ImportDraw(Receiver receiver, Invoker invoker) { ImportCamera(receiver, invoker); Area.ImportAreas(_areas, receiver, invoker, ScaleGeometryLoad); Segment.ImportSegments(_segments, receiver, invoker, ScaleGeometryLoad); HouseWindow.ImportWindows(ListWindows(), receiver, invoker, ScaleGeometryLoad); Door.ImportDoors(_doors, receiver, invoker, ScaleGeometryLoad); }
/// <summary> /// Remove a window from a plan /// </summary> /// <param name="w">HouseWindow object</param> public void RemoveWindow(HouseWindow w) { List <HouseWindow> hw = ListWindows(); int index = hw.IndexOf(w); if (index >= 0) { _segments[index].Window = new HouseWindow(); } }
/// <summary> /// Draw a window to the canvas /// </summary> /// <param name="p">Window point</param> public override void Draw(Point p) { _windowPoints.Push(p); //Count two point to create the rectangle area if (_windowPoints.Count == 2) { Point p2 = _windowPoints.Pop(); Point p1 = _windowPoints.Pop(); this._fillBrush = new SolidColorBrush(ImageUtil.RandomColor()); // Get the last shape on the canvas, this represents the preview rectangle Rect rect = new Rect(InkCanvas.GetLeft(_receiver.LastShape), InkCanvas.GetTop(_receiver.LastShape), _receiver.LastShape.Width, _receiver.LastShape.Height); // COnta foreach (Rect wall in _windowAvailableWalls) { Rect intersect = Rect.Intersect(rect, wall); // Compute the intersection between the wall and the window if (!intersect.IsEmpty) { // Check if the window is completly on the wall if ((intersect.X > wall.X && intersect.X + intersect.Width < wall.X + wall.Width) || (intersect.Y > wall.Y && intersect.Y + intersect.Height < wall.Y + wall.Height)) { Rectangle rectangle = new Rectangle { Fill = Application.Current.TryFindResource("PrimaryHueDarkBrush") as SolidColorBrush }; // Add the window to the canvas InkCanvas.SetLeft(rectangle, intersect.X - (COMPONENT_OFFSET / 2)); InkCanvas.SetTop(rectangle, intersect.Y - (COMPONENT_OFFSET / 2)); rectangle.Width = intersect.Width + COMPONENT_OFFSET; rectangle.Height = intersect.Height + COMPONENT_OFFSET; _receiver.ViewModel._mainWindow.canvas.Children.Add(rectangle); // Add the window to the plan HouseWindow houseWindow = _receiver.ViewModel._plan.AddWindow(new Point(intersect.X, intersect.Y), new Point(intersect.X + intersect.Width, intersect.Y + intersect.Height), new Point(wall.X, wall.Y), new Point(wall.X + wall.Width, wall.Y + wall.Height)); // Add the window to the history if (houseWindow != null) { MainWindow.main.History = "Window"; _receiver.ViewModel._stackHistory.Push(new Tuple <Object, Object, string>(rectangle, houseWindow, "Window")); _windowAvailableWalls.Remove(wall); break; // Allows not to draw 2 windows on parallel walls } } } } _receiver.ViewModel._mainWindow.canvas.Children.Remove(_receiver.LastShape); _receiver.LastShape = null; } }