Example #1
0
        protected void CalculateTriangle(object sender, EventArgs e)
        {
            TypeOfTriangle.Text = "";
            Area.Text           = "";
            var         x           = Convert.ToInt32(FirstSide.Text);
            var         y           = Convert.ToInt32(SecondSide.Text);
            var         z           = Convert.ToInt32(ThirdSide.Text);
            Scalene     scalene     = new Scalene();
            Isosceles   isosceles   = new Isosceles();
            Equilateral equilateral = new Equilateral();

            var abs = System.Math.Abs(x - y);   // absolute value of substruction

            //third point's value must be with in the range of difference of the other sides to the total of the other sides,
            if (!(z > abs && z < x + y))
            {
                TypeOfTriangle.Text     = "These are not valid values to draw a triangle!";
                CalculateButton.Enabled = false;
            }
            else
            {
                TypeOfTriangle.Text     = "Triangle is valid.";
                CalculateButton.Enabled = true;
            }
        }
Example #2
0
        protected void DrawMultipleLines()
        {
            // scaling the triangle's sides to be able to draw
            var     x = Convert.ToInt32(FirstSide.Text.ToString()) * 10;
            var     y = Convert.ToInt32(SecondSide.Text.ToString()) * 10;
            var     z = Convert.ToInt32(ThirdSide.Text.ToString()) * 10;
            var     typeOfTriangle = "";
            Scalene triangle       = new Scalene();

            typeOfTriangle = triangle.DecideTypeOfTriangle(x, y, z);

            Graphics grap = Graphics.FromImage(bitm);

            grap.Clear(Color.Black);
            Pen   pen = new Pen(Color.White, 2);
            Point p1  = new Point(100, 100);       // start point on the bitmap.
            Point p2  = new Point((100 + x), 100); // taking the first side(AB line) as a straight line on the X-axis and declaring its A and B points.
            Point p7  = CalculateThirdPoint(Convert.ToDouble(x), Convert.ToDouble(z), Convert.ToDouble(y), p2);

            // Drawing lines between three points
            grap.DrawLine(pen, p1, p2);
            grap.DrawLine(pen, p2, p7);
            grap.DrawLine(pen, p7, p1);

            string path = Server.MapPath("~/Image/lines.jpg");

            bitm.Save(path, ImageFormat.Jpeg);
            Image.ImageUrl      = "~/Image/lines.jpg";
            TypeOfTriangle.Text = typeOfTriangle;
            grap.Dispose();
            bitm.Dispose();
        }
Example #3
0
        static void Main(string[] args)
        {
            string   outputPath = "c:\\temp\\temp.txt";
            IPrinter printer;
            IWriter  fileWriter = new FileWriter(outputPath);

            printer = new ConsolePrinter();
            IShapes circle = new Circle(printer)
            {
                Radius = 5
            };

            circle.CalculateArea();

            printer = new FilePrinter(fileWriter);
            Triangle triangle = new Scalene(printer)
            {
                Base = 6, Height = 4
            };

            triangle.GetAllSides();
        }
Example #4
0
        static void Main(string[] args)
        {
            Right right = new Right(1.3d, 2.4d)
            {
                Name = "Right Triangle"
            };

            UI.PrintProperties(right);

            Right right1 = Clone.GetShallowCopy(right, includeBaseTypes: true);

            right1.Name = $"Clone of {nameof(right)}";
            UI.PrintProperties(right1);

            Scalene scalene = new Scalene(1d, 2d)
            {
                Name = "Scalene Triangle"
            };

            UI.PrintProperties(scalene);

            Scalene scalene1 = Clone.GetShallowCopy(scalene, includeBaseTypes: true);

            scalene1.Name = $"Clone of {nameof(scalene)}";
            UI.PrintProperties(scalene1);

            /****************************************************************/

            //Country fr = new Country() { Name = "France" };
            //Country uk = new Country() { Name = "United Kingdom" };
            //Citizen citizen = new Citizen(Sex.Female) { Name = "Laetitia Casta", Address = "Paris" }.From(fr).From(uk);
            //UI.PrintProperties(citizen, false);

            //Citizen citizen1 = Clone.GetShallowCopy(citizen ,false, true);
            //UI.PrintProperties(citizen1);


            Console.ReadKey();
        }