Ejemplo n.º 1
0
 private void vbCodeBox_TextChanged(object sender, EventArgs e)
 {
     _functions.Clear();
     string src = vbCodeBox.Text.Trim();
     src = Preprocessor.ReplaceStrings(src, "_" + Environment.NewLine, "");
     src = Preprocessor.ReplaceStrings(src, "  ", " ");
     string[] lines = src.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
     foreach (string line in lines)
     {
         FuncDesc func = new FuncDesc(line);
         if (func.Valid)
         {
             statBox.Items.Add(func.ToSingleLine());
             _functions.Add(func);
         }
     }
 }
Ejemplo n.º 2
0
        private void StartConvertation()
        {
            string src = vbCodeBox.Text.Trim();
            src = Preprocessor.ReplaceStrings(src, "_" + Environment.NewLine, "");
            src = Preprocessor.ReplaceStrings(src, "  ", " ");
            string[] lines = src.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            funcInfoBox.Items.Clear();
            if (lines.Length == 0) return;
            FuncDesc func = new FuncDesc(lines[0]);
            funcInfoBox.Items.Add(string.Format("Valid: '{0}'", func.Valid));
            funcInfoBox.Items.Add(string.Format("Name: '{0}'", func.Name));
            funcInfoBox.Items.Add(string.Format("Result type: '{0}'", func.ResultType));
            funcInfoBox.Items.Add(string.Format("Commented src: '{0}'", func.CommentedSrc));
            funcInfoBox.Items.Add(string.Format("Params: {0}", func.Parameters.Count));
            foreach (FuncDesc.Parameter par in func.Parameters)
            {
                if (par.Valid)
                    funcInfoBox.Items.Add(string.Format("\tName:'{0}', Type: '{1}', Default value: '{2}', Src: {3}", par.Name, par.Type, par.HasDefaultValue ? par.DefaultValue : "-", par.CommentedSrc));
                else
                    funcInfoBox.Items.Add(string.Format("Param is not Valid: {0}", par.CommentedSrc));
            }
            string codeConversionResult = DoConvertDataAccess(lines, func.Name, func.ResultType, forceDataSetBox.Checked, forceUseCmdBox.Checked, wfBox.Checked);

            StringBuilder sb = new StringBuilder();
            if (func.Valid)
            {
                sb.AppendLine(func.ToString());
                sb.AppendLine("{");
                sb.AppendLine("\t" + func.CommentedSrc);
            }
            sb.Append(codeConversionResult);
            if (func.Valid)
                sb.AppendLine("}");

            csCodeBox.Text = sb.ToString();

            Clipboard.SetText(sb.ToString());
        }