Esempio n. 1
0
        protected CodeExample CreateRichEditExample(string exampleGroup, string regionName, string exampleCode)
        {
            CodeExample result = new CodeExample();

            SetExampleCode(exampleCode, result);
            result.RegionName             = regionName;
            result.HumanReadableGroupName = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(exampleGroup);
            return(result);
        }
Esempio n. 2
0
 protected override void SetExampleCode(string code, CodeExample newExample)
 {
     if (isHelper)
     {
         newExample.CodeCsHelper = code;
     }
     else
     {
         newExample.CodeCS = code;
     }
 }
        public string ShowExample(CodeExample oldExample, CodeExample newExample)
        {
            InnerRichEditControl richEditControlCs      = codeEditorCs.InnerControl;
            InnerRichEditControl richEditControlVb      = codeEditorVb.InnerControl;
            InnerRichEditControl richEditControlCsClass = codeEditorCsClass.InnerControl;
            InnerRichEditControl richEditControlVbClass = codeEditorVbClass.InnerControl;

            if (oldExample != null)
            {
                //save edited example
                oldExample.CodeCS       = richEditControlCs.Text;
                oldExample.CodeVB       = richEditControlVb.Text;
                oldExample.CodeCsHelper = richEditControlCsClass.Text;
                oldExample.CodeVbHelper = richEditControlVbClass.Text;
            }
            string exampleCode = String.Empty;

            if (newExample != null)
            {
                try
                {
                    forceTextChangesCounter     = 2;
                    exampleCode                 = (CurrentExampleLanguage == ExampleLanguage.Csharp) ? newExample.CodeCS : newExample.CodeVB;
                    richEditControlCs.Text      = newExample.CodeCS;
                    richEditControlVb.Text      = newExample.CodeVB;
                    richEditControlCsClass.Text = newExample.CodeCsHelper;
                    richEditControlVbClass.Text = newExample.CodeVbHelper;

                    richEditTextChanged = false;
                }
                finally
                {
                    richEditTextChanged = true;
                }
            }
            return(exampleCode);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 protected abstract void SetExampleCode(string exampleCode, CodeExample newExample);