Esempio n. 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Shape      shape = null;
            StackPanel sp    = new StackPanel();
            Random     rand  = new Random();
            var        maxX  = canvas.Height;
            var        maxY  = canvas.Width;

            if (triangl.IsChecked == true)
            {
                if (a.Text != "" & b.Text != "" & c.Text != "")
                {
                    _Triangl t = new _Triangl();
                    t.a   = int.Parse(a.Text);
                    t.b   = int.Parse(b.Text);
                    t.c   = int.Parse(c.Text);
                    t.loc = new Point(x, y);
                    shape = t.Drawing();
                }
            }
            if (circle.IsChecked == true)
            {
                if (a.Text != "")
                {
                    _Circle c = new _Circle();
                    c.r   = int.Parse(a.Text);
                    c.loc = new Point(x, y);
                    shape = c.Drawing();
                }
            }
            if (ellipse.IsChecked == true)
            {
                if (a.Text != "" & b.Text != "")
                {
                    _Ellipse el = new _Ellipse();
                    el.r   = int.Parse(a.Text);
                    el.r2  = int.Parse(b.Text);
                    el.loc = new Point(x, y);
                    shape  = el.Drawing();
                }
            }
            if (square.IsChecked == true)
            {
                if (a.Text != "")
                {
                    _Square s = new _Square();
                    s.a   = int.Parse(a.Text);
                    s.loc = new Point(x, y);
                    shape = s.Drawing();
                }
            }
            if (rectangle.IsChecked == true)
            {
                if (a.Text != "" & b.Text != "")
                {
                    _Rectangle r = new _Rectangle();
                    r.a   = int.Parse(a.Text);
                    r.b   = int.Parse(b.Text);
                    r.loc = new Point(x, y);
                    shape = r.Drawing();
                }
            }
            if (shape != null)
            {
                canvas.Children.Add((UIElement)shape);
                x += 10;
                if (x >= maxX)
                {
                    x  = 0;
                    y += 50;
                }
                if (y >= maxY)
                {
                    y = 0;
                }
            }
        }
Esempio n. 2
0
 public static string GetPath(_Square key)
 {
     return(GetPath(key.ToString()));
 }
Esempio n. 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            #region SRP

            Employee emp = new Employee();
            emp.FirstName = "Ali";
            emp.AddToDB(emp);

            _Employee emp1 = new _Employee();
            emp1.FirstName = "Deneme";

            EmployeeManager manager = new EmployeeManager(emp1);
            manager.Insert();

            EmployeeManager manager2 = new EmployeeManager(new MessageService(), emp1);
            manager2.SendMessage("Test");

            #endregion

            #region OCP

            OCPClient manager1 = new OCPClient(new NormalTicket());
            manager1.Sale(100);

            OCPClient manager3 = new OCPClient(new StudentTicket());
            manager3.Sale(100);

            #endregion

            #region LSP

            #region BadPractice

            Shape  s  = new Square(5, 10);
            double d1 = s.GetArea();

            Shape  s1 = new Rect(3, 5);
            double d2 = s1.GetArea();


            #endregion

            #region BestPractice


            AbstractShape s3 = new _Square(3);
            s3.GetArea();

            AbstractShape s4 = new _Rect(3, 5);
            s4.GetArea();

            AbstractShape s5 = new _Circle(5);

            MessageBox.Show(s5.Diagonal.ToString());


            #endregion

            #endregion

            //Interface Segregation Principle
            #region ISP

            #region BadPractice

            JuniorDeveloper j = new JuniorDeveloper();
            j.UseSolid();

            SeniorDeveloper ss = new SeniorDeveloper();
            ss.UseSolid();

            #endregion

            #region BestPractice

            JDeveloper j1 = new JDeveloper();
            j1.UseOOP();


            SDeveloper s3 = new SDeveloper();
            s3.UseOOP();
            s3.UseSolid();


            #endregion

            #endregion

            #region DIP

            #region BadPractice

            IOService service = new IOService(new DBIO());
            service.Write("asdasda", "asddsa");

            #endregion

            //read işlemleri için

            _IOService _service = new _IOService(new _ExcelIO());
            _service.Read("asdsad", "ssadasd");
            _service.Write("adsdas", "asdasd");

            _IOService _service2 = new _IOService(new _TextIO());
            _service2.Read("asdasd", "asdasd");
            _service2.Write("asdasd", "asdsad");

            _IOService _service3 = new _IOService(new _DBIO());
            _service3.Read("sadasd", "asdasd");



            #endregion
        }