public MainWindow() { InitializeComponent(); //This sets Console output to the textbox in the MainWindow rather than the debug console Console.SetOut(new ControlWriter(textbox1)); string databaseName = "Shapes.db"; //Instantiate database handler object and connect to db DBHandler dBHandler = new DBHandler(); dBHandler.connectToDB(databaseName); //run a query to get all of the info we need. List <queryRow> shapeQuery = dBHandler.selectStatement("SELECT * FROM shapes;"); //display the number of shapes in the database numberOfShapesLabel.Content = "Total Number of Shapes in Database: " + shapeQuery.Count.ToString(); //shape handler turns the query into a list of shape objects such that circle, square, and triangle inherit properties from the shape class ShapeHandler shapeHandler = new ShapeHandler(shapeQuery); //sort the shapes using z-order List <Shape> sortedShapes = shapeHandler.sortShapes(); //display the shorted shapes using the shape display object ShapeDisplay SDisplay = new ShapeDisplay(sortedShapes); SDisplay.displayAll(); }
static void Main(string[] args) { IShapeFactory shapeFactory = new ShapesFactory(); List <IShape> shapes = shapeFactory.CreateShapes(); IShapeRepository shapeRepository = new ShapeRepository(shapes); IShapeSorter shapeSorter = new ShapeSorter(shapes); IShapeStrategy shapePrinter = new ShapePrinter(); ShapeHandler shapeHandler = new ShapeHandler(shapeRepository, shapeSorter, shapePrinter); shapeHandler.SortShapes(); shapeHandler.SaveOnDisk(); shapeHandler.GetShapesInMemory(); }