コード例 #1
0
ファイル: Function.cs プロジェクト: hebskjcc/OpenR8-1
        //20170117 leo: 今天討論後, Function 預設裡面不塞 Data ,但[parameters 的格子] 留著
        //暫時開一個接 Parameters 的結構。以後這個應該會從 json 接。
        //20170123 leo : 改成從 json 接
        public static List <Parameter> getFunctionParameters(string name)
        {
            List <Parameter> args = new List <Parameter>();

            /*
             * switch (name)
             * {
             *  case "OpenImage":
             *      args.Add(new Parameter("Image File Name", R8.getDataTypeByString("string"), true));
             *      args.Add(new Parameter("Image ", R8.getDataTypeByString("image"), false));
             *      break;
             *  case "SaveImage":
             *      //arg1: (input, mat) image
             *      //arg2: (input, string) imagePath
             *      args.Add(new Parameter("Image", R8.getDataTypeByString("image"), true));
             *      args.Add(new Parameter("Image File Name", R8.getDataTypeByString("string"), true));
             *      break;
             *  case "Binarize":
             *      //cv::threshold(image, thresholdedImage, gv, 255, type);
             *
             *      args.Add(new Parameter("Input Image", R8.getDataTypeByString("image"), true));
             *      args.Add(new Parameter("Threshold", R8.getDataTypeByString("int"), true));
             *      //args.Add(new Parameter("thresholdType", Data.VariableType.Int, true));//對應 cv::threshold 的 type 參數
             *      args.Add(new Parameter("Output Image", R8.getDataTypeByString("image"), false));
             *      break;
             * }*/
            //20170123 leo : 改從 json 接
            int           functionGroupNum = 0;
            int           functionNum      = 0;
            int           variableNum      = 0;
            StringBuilder str = new StringBuilder(R7.STRING_SIZE);

            functionGroupNum = R8.GetFunctionGroupNum();
            string tempNameString;

            for (int i = 0; i < functionGroupNum; i++)
            {
                functionNum = R8.GetFunctionNumInGroup(i);
                for (int j = 0; j < functionNum; j++)
                {
                    R8.GetFunctionName(str, R7.STRING_SIZE, i, j);
                    //addButton(str.ToString());
                    if (str.ToString().Equals(name))
                    {
                        variableNum = R8.GetVariableNumInFunction(i, j);
                        for (int k = 0; k < variableNum; k++)
                        {
                            R8.GetVariableNameInFunction(str, R7.STRING_SIZE, i, j, k);
                            tempNameString = str.ToString();
                            R8.GetVariableTypeInFunction(str, R7.STRING_SIZE, i, j, k);
                            Parameter parameter = new Parameter(tempNameString, R8.getVariableTypeByString(str.ToString()));
                            //20170214 加入 Direction
                            //20171024 Direction 變成 Option
                            //option
                            R8.GetVariableOptionInFunction(str, R7.STRING_SIZE, i, j, k);
                            parameter.option = str.ToString();
                            args.Add(parameter);

                            //GetVariableDirectionInFunction
                        }
                    }
                }
            }
            str.Clear();
            return(args);
        }