コード例 #1
0
ファイル: MainMenuForm.cs プロジェクト: hckhanh/PiGraph
        private static Input ConvertFromFunction(Function funct)
        {
            Input temp = null;

            switch (funct.FunctionType)
            {
            case LoaiHam.BacNhat:
            {
                temp = new P1();
                temp.update(new List <float>(funct.Values), Input.scale, funct.Color);

                break;
            }

            case LoaiHam.BacHai:
            {
                temp = new P2();
                temp.update(new List <float>(funct.Values), Input.scale, funct.Color);

                break;
            }

            case LoaiHam.BacBa:
            {
                temp = new P3();
                temp.update(new List <float>(funct.Values), Input.scale, funct.Color);

                break;
            }

            case LoaiHam.TrungPhuong:
            {
                temp = new P4();
                temp.update(new List <float>(funct.Values), Input.scale, funct.Color);

                break;
            }

            case LoaiHam.PhanThuc:
            {
                temp = new Frac();
                temp.update(new List <float>(funct.Values), Input.scale, funct.Color);

                break;
            }

            case LoaiHam.Sin:
            {
                temp = new Sin();
                temp.update(new List <float>(funct.Values), Input.scale, funct.Color);

                break;
            }

            case LoaiHam.Cos:
            {
                temp = new Cos();
                temp.update(new List <float>(funct.Values), Input.scale, funct.Color);

                break;
            }

            case LoaiHam.Log:
            {
                temp = new Logarit();
                temp.update(new List <float>(funct.Values), Input.scale, funct.Color);

                break;
            }

            case LoaiHam.CanThuc:
            {
                temp = new SQRT();
                temp.update(new List <float>(funct.Values), Input.scale, funct.Color);

                break;
            }

            case LoaiHam.Undefined:
            {
                throw new Exception("Can not determine the type of function.");
            }
            }
            temp.setType((int)funct.FunctionForm);

            return(temp);
        }