Exemple #1
0
        public void AutoCheckSyntaxBackground()
        {
            if (PtrScriptFrame == IntPtr.Zero || TB.IsDisposed || !TB.IsHandleCreated || !IsHandleCreated) return;
            if (CheckSyntaxIsBusy) { CheckSyntaxAgain = true; return; }
            CheckSyntaxIsBusy = true;
            t = new Timer(TimeoutCheckSyntax, null, 3000, Timeout.Infinite);
            object objScriptName   = new BStrWrapper(ScriptLanguage);
            object objScriptText   = new BStrWrapper(TB.Text);
            object objErrorMessage = new BStrWrapper("");
            var th = new Thread(() =>
            {
                try {
                    int nErrorLine = 0;
                    int nErrorChar = 0;
                    int nResult    = 0;
                    IHmsScriptFrame scriptFrame1 = (IHmsScriptFrame)System.Runtime.Remoting.Services.EnterpriseServicesHelper.WrapIUnknownWithComObject(PtrScriptFrame);
                    scriptFrame1.CompileScript(ref objScriptName, ref objScriptText, ref objErrorMessage, ref nErrorLine, ref nErrorChar, ref nResult);
                    CheckSyntaxArgs args = new CheckSyntaxArgs();
                    if (nResult == 0) {
                        args.ErrorChar    = Math.Max(0, nErrorChar - 1);
                        args.ErrorLine    = Math.Max(0, nErrorLine - 1);
                        args.ErrorMessage = objErrorMessage.ToString();
                    }
                    TB.Invoke((MethodInvoker)delegate {
                        t?.Dispose();
                        if (args.ErrorMessage.Length > 0)
                            TB.SetErrorLines(args.ErrorChar, args.ErrorLine, args.ErrorMessage);
                        else
                            TB.ClearErrorLines();
                        CheckSyntaxIsBusy = false;
                        if (CheckSyntaxAgain) {
                            CheckSyntaxAgain = false;
                            AutoCheckSyntaxBackground();
                        }
                    });

                } catch /*(Exception e)*/ {
                    TB.ClearErrorLines();
                    //HMS.LogError(e.ToString());
                }
            }, 10);
            th.Start();
        }
Exemple #2
0
        private static BStrWrapper[] ObjectArrayToBStrWrapperArray(object[] SwObjects)
        {
            int arraySize;
            arraySize = SwObjects.GetUpperBound(0);
            BStrWrapper[] dispwrap = new BStrWrapper[arraySize + 1];
            int arrayIndex;

            for (arrayIndex = 0; arrayIndex < arraySize + 1; arrayIndex++)
            {
                dispwrap[arrayIndex] = new BStrWrapper((string)(SwObjects[arrayIndex]));
            }

            return dispwrap;
        }