public bool ExecuteCodeAndGenerateDocument(CodeEvaluationEventArgs args)
        {
            string theCode = String.Concat(CodeStart, args.Code, CodeBeforeClasses, args.CodeClasses, CodeEnd);

            string[] linesOfCode = new string[] { theCode };
            return(CompileAndRun(linesOfCode, args.EvaluationParameter));
        }
Exemple #2
0
        private void OnNewExampleSelected(object sender, CurrentItemChangedEventArgs e)
        {
            CodeExample newExample = e.NewItem as CodeExample;
            CodeExample oldExample = e.OldItem as CodeExample;

            if (newExample == null)
            {
                return;
            }

            if (codeEditor == null)
            {
                return;
            }

            string exampleCode = codeEditor.ShowExample(oldExample, newExample);

            codeExampleNameLbl.Content = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(newExample.RegionName) + " example";

            CodeEvaluationEventArgs args = new CodeEvaluationEventArgs();

            InitializeCodeEvaluationEventArgs(args);
            evaluator.ForceCompile(args);

            if (newExample.HumanReadableGroupName == "Comments Actions")
            {
                this.richEditControl.Options.Comments.Visibility = DevExpress.XtraRichEdit.RichEditCommentVisibility.Visible;
            }
            else
            {
                this.richEditControl.Options.Comments.Visibility = DevExpress.XtraRichEdit.RichEditCommentVisibility.Hidden;
            }
        }
        public void ForceCompile(CodeEvaluationEventArgs args)
        {
            compileComplete = false;
            if (!String.IsNullOrEmpty(args.Code))
            {
                CompileExampleAndShowPrintPreview(args);
            }

            compileComplete = true;
        }
 protected internal virtual CodeEvaluationEventArgs RaiseQueryEvaluate()
 {
     if (QueryEvaluate != null)
     {
         CodeEvaluationEventArgs args = new CodeEvaluationEventArgs();
         QueryEvaluate(this, args);
         return(args);
     }
     return(null);
 }
Exemple #5
0
        void InitializeCodeEvaluationEventArgs(CodeEvaluationEventArgs e)
        {
            e.Result = true;
            if (codeEditor == null)
            {
                return;
            }

            e.Code                = codeEditor.CurrentCodeEditor.Text;
            e.CodeClasses         = codeEditor.CurrentCodeClassEditor.Text;
            e.Language            = CurrentExampleLanguage;
            e.EvaluationParameter = richEditControl.Document;
        }
        void CompileExampleAndShowPrintPreview(CodeEvaluationEventArgs args)
        {
            bool evaluationSucceed = false;

            try
            {
                RaiseOnBeforeCompile();

                evaluationSucceed = Evaluate(args);
            }
            finally
            {
                RaiseOnAfterCompile(evaluationSucceed);
            }
        }
        public void CompileExample(object sender, EventArgs e)
        {
            if (!compileComplete)
            {
                return;
            }
            CodeEvaluationEventArgs args = RaiseQueryEvaluate();

            if (!args.Result)
            {
                return;
            }

            ForceCompile(args);
        }
Exemple #8
0
        void OnExampleEvaluatorQueryEvaluate(object sender, CodeEvaluationEventArgs e)
        {
            e.Result = false;
            if ((codeEditor != null) && codeEditor.RichEditTextChanged)
            {
                TimeSpan span = DateTime.Now - codeEditor.LastExampleCodeModifiedTime;

                if (span < TimeSpan.FromMilliseconds(1000))
                {
                    codeEditor.ResetLastExampleModifiedTime();
                    return;
                }
                InitializeCodeEvaluationEventArgs(e);
            }
        }
        public bool Evaluate(CodeEvaluationEventArgs args)
        {
            ExampleCodeEvaluator richeditExampleCodeEvaluator = GetExampleCodeEvaluator(args.Language);

            return(richeditExampleCodeEvaluator.ExecuteCodeAndGenerateDocument(args));
        }