Source: How to Draw Home Design in C#
In this post I am going to put the code about how to design home architecture in C#. Using C#, you can do anything with simple codebase. Suppose you are an architecture or civil engineer and you need a software where you can put the size of each bedroom, drawing room, toilet, store room, kitchen, balcony, exit gate & entrance gate details and you will get a full architecture of your home. I have built a simple architecture using C#. All fields are dynamic that can be change anytime. You can also print those architecture image. The image will look like this:
I used a simple rectangle method to build these architecture.
- Create a database in ms-access.
- Store all information like width and length of bedroom, drawing room, toilet, store room, kitchen, balcony, exit gate & entrance gate.
- Get each room length and width and build a structure using C#
- Now draw some architecture:
if (flat_type=="1BHK")
{
DrawRectangle(50, 50, exg_w, exg_h, "Entrance Gate");
DrawRectangle(50, 50, dr_bdh, dr_len, "Drawing Room");
--
--
}
else if (flat_type == "2BHK")
{
DrawRectangle(50, 50, r1_bdh, r1_len, "Bedroom");
DrawRectangle(50 + r1_bdh - exg_h - 10, 50 + r1_len, exg_h, exg_w, "gate");
--
}
else if (flat_type == "3BHK")
{
DrawRectangle(50, 50, r1_bdh, r1_len, "Bedroom");
DrawRectangle(50 + r1_bdh - exg_h - 10, 50 + r1_len, exg_h, exg_w, "gate");
--
{
DrawRectangle(50, 50, exg_w, exg_h, "Entrance Gate");
DrawRectangle(50, 50, dr_bdh, dr_len, "Drawing Room");
--
--
}
else if (flat_type == "2BHK")
{
DrawRectangle(50, 50, r1_bdh, r1_len, "Bedroom");
DrawRectangle(50 + r1_bdh - exg_h - 10, 50 + r1_len, exg_h, exg_w, "gate");
--
}
else if (flat_type == "3BHK")
{
DrawRectangle(50, 50, r1_bdh, r1_len, "Bedroom");
DrawRectangle(50 + r1_bdh - exg_h - 10, 50 + r1_len, exg_h, exg_w, "gate");
--
}
For Printing we use this function:
private void PrintScreen()
{
Graphics mygraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
IntPtr dc1 = mygraphics.GetHdc();
IntPtr dc2 = memoryGraphics.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height-50, dc1, 0, 0, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
}
{
Graphics mygraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
IntPtr dc1 = mygraphics.GetHdc();
IntPtr dc2 = memoryGraphics.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height-50, dc1, 0, 0, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
}
Full code is available on request at esoftcode@gmail.com
Comments
Post a Comment