public bool ExcecuteCodeAndGenerateDocument(CodeEvaluationEventArgs args)
        {
            string theCode = String.Concat(CodeStart, args.Code, MainMethodEnd, args.CustomActionHandler, args.AdditionalModules, CodeEnd);

            string[] linesOfCode = new string[] { theCode };
            return(CompileAndRun(linesOfCode, args.EvaluationParameter, args.AdditionalParameter));
        }
Exemple #2
0
        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));
        }
        void OnNewExampleSelected(object sender, FocusedNodeChangedEventArgs e)
        {
            CodeExample newExample = (sender as TreeList).GetDataRecordByNode(e.Node) as CodeExample;
            CodeExample oldExample = (sender as TreeList).GetDataRecordByNode(e.OldNode) as CodeExample;

            if (newExample == null)
            {
                return;
            }

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

            codeExampleNameLbl.Text = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(newExample.RegionName) + " example";
            CodeEvaluationEventArgs args = new CodeEvaluationEventArgs();

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

            if (newExample.HumanReadableGroupName == "Comments")
            {
                this.richEditControl.Options.Comments.Visibility = RichEditCommentVisibility.Visible;
                this.displayResultControl1.DockPanel.Show();
            }
            else
            {
                this.richEditControl.Options.Comments.Visibility = RichEditCommentVisibility.Hidden;
                this.displayResultControl1.DockPanel.Hide();
            }
        }
 void InitializeCodeEvaluationEventArgs(CodeEvaluationEventArgs e)
 {
     e.Result              = true;
     e.Code                = codeEditor.CurrentCodeEditor.Text;
     e.CodeClasses         = codeEditor.CurrentCodeClassEditor.Text;
     e.Language            = CurrentExampleLanguage;
     e.EvaluationParameter = richEditControl.Document;
 }
        public void ForceCompile(CodeEvaluationEventArgs args)
        {
            compileComplete = false;
            if (!String.IsNullOrEmpty(args.Code))
            {
                CompileExampleAndShowPrintPreview(args);
            }

            compileComplete = true;
        }
 //public event CodeEvaluationEventHandler QueryEvaluateEvent {
 //    add { onQeuryEvaluate += value; }
 //    remove { onQeuryEvaluate -= value; }
 //}
 protected internal virtual CodeEvaluationEventArgs RaiseQueryEvaluate()
 {
     if (QueryEvaluate != null)
     {
         CodeEvaluationEventArgs args = new CodeEvaluationEventArgs();
         QueryEvaluate(this, args);
         return(args);
     }
     return(null);
 }
        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);
        }
        void OnExampleEvaluatorQueryEvaluate(object sender, CodeEvaluationEventArgs e)
        {
            e.Result = false;
            if (codeEditor.RichEditTextChanged)
            {// && compileComplete) {
                TimeSpan span = DateTime.Now - codeEditor.LastExampleCodeModifiedTime;

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

            return(richeditExampleCodeEvaluator.ExcecuteCodeAndGenerateDocument(args));
        }