private void drawSurface_MouseClickShowTemplateInfo(object sender, MouseEventArgs e) { System.Drawing.Point selectedPoint = drawer.AdjustPointToGridIntersection(drawer.drawSurface.PointToClient(Cursor.Position)); Logic.Domain.Point domainSeleectedPoint = drawer.pointConverter.DrawablePointIntoLogicPoint(selectedPoint); if (selectedBluePrint.GetOpenings().Any(x => x.GetPosition().Equals(domainSeleectedPoint))) { Opening selectedOpening = selectedBluePrint.GetOpenings().First(x => x.GetPosition().Equals(domainSeleectedPoint)); ShowTemplateInfo(selectedOpening.getTemplate()); } }
//Opening events private void drawSurface_MouseClickInsertOpening(object sender, MouseEventArgs e) { System.Drawing.Point point = drawer.AdjustPointToGridIntersection(drawer.drawSurface.PointToClient(Cursor.Position)); Logic.Domain.Point openingPoint = drawer.pointConverter.DrawablePointIntoLogicPoint(point); Template selectedTemplate = (Template)cmbTemplates.SelectedItem; if (selectedTemplate != null) { Opening newOpening = openingFactory.CreateFromTemplate(openingPoint, selectedTemplate.Name); InsertAndDrawOpening(newOpening); } }
private void InsertAndDrawColumn(System.Drawing.Point newColumnPoint) { Logic.Domain.Point logicColumnPoint = drawer.pointConverter.DrawablePointIntoLogicPoint(newColumnPoint); try { editor.InsertColumn(logicColumnPoint); } catch (Exception) { //error message } PaintColumns(); calulateCostsAndPrices(); }
//Erase events private void drawSurface_MouseClickErase(object sender, MouseEventArgs e) { System.Drawing.Point point = drawer.AdjustPointToGrid(drawer.drawSurface.PointToClient(Cursor.Position)); Logic.Domain.Point deletionPointPrecise = drawer.pointConverter.DrawablePointIntoLogicPoint(point); Logic.Domain.Point closestDeletionPointToGridIntersection = drawer.pointConverter.DrawablePointIntoLogicPoint(drawer.AdjustPointToGridIntersection(point)); try { bool existOpeningInPoint = selectedBluePrint.GetOpenings().Any(x => x.GetPosition().Equals(closestDeletionPointToGridIntersection)); bool existWallInPoint = selectedBluePrint.GetWalls().Any(x => x.DoesContainPoint(deletionPointPrecise)); bool existColumnInPoint = selectedBluePrint.GetColumns().Any(x => x.GetPosition().Equals(closestDeletionPointToGridIntersection)); if (existOpeningInPoint) { Opening openingToRemove = selectedBluePrint.GetOpenings().FirstOrDefault(x => x.GetPosition().Equals(closestDeletionPointToGridIntersection)); editor.RemoveOpening(openingToRemove); } else if (existWallInPoint && !existOpeningInPoint) { Wall wallToDelete = selectedBluePrint.GetWalls().First(x => x.DoesContainPoint(deletionPointPrecise)); editor.RemoveWall(wallToDelete.Beginning(), wallToDelete.End()); } else if (existColumnInPoint) { editor.RemoveColumn(closestDeletionPointToGridIntersection); } } catch (Exception) { //error message } PaintWalls(); PaintBeams(); PaintOpenings(); PaintColumns(); calulateCostsAndPrices(); }
private System.Drawing.Point LogicPointIntoDrawablePoint(Logic.Domain.Point point) { return(new System.Drawing.Point(Convert.ToInt32(point.CoordX * cellSizeInPixels), Convert.ToInt32(point.CoordY * cellSizeInPixels))); }
private void DrawCore(Point core, Color color) { var p = new Pen(color, 5); graphics.DrawRectangle(p, core.X, core.Y, 5, 5); }
private void DrawPoint(Point point, Color color) { var p = new Pen(color, 1); graphics.DrawRectangle(p, point.X, point.Y, 1, 1); }