예제 #1
0
        protected virtual bool ValidateRegionName(string[] lines, ref string regionName)
        {
            int keepHashMark = 0; // "#example" if value is -1 or "example" if value will be 0

            string region      = lines[0];
            int    regionIndex = region.IndexOf(RegionHelperStartPattern);

            if (regionIndex == 0)
            {
                isHelper   = true;
                regionName = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(region.Substring(regionIndex + RegionHelperStartPattern.Length + keepHashMark));
            }

            if (regionIndex < 0)
            {
                isHelper    = false;
                regionIndex = region.IndexOf(RegionStartPattern);
                if (regionIndex < 0)
                {
                    regionName = String.Empty;
                    return(false);
                }
                regionName = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(region.Substring(regionIndex + RegionStartPattern.Length + keepHashMark));
            }
            return(true);
        }
예제 #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;
            }
        }
예제 #3
0
        private void InitializeSyntaxHighlightForVBClass(object sender, EventArgs e)
        {
            SyntaxHightlightInitializeHelper syntaxHightlightInitializator = new SyntaxHightlightInitializeHelper();

            syntaxHightlightInitializator.Initialize(codeEditorVbClass, CodeExampleDemoUtils.GetCodeExampleFileExtension(ExampleLanguage.VB));

            DisableRichEditFeatures(codeEditorVbClass);
        }
예제 #4
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);
        }
예제 #5
0
        void ShowFirstExample()
        {
            projectLanguage = CodeExampleDemoUtils.DetectExampleLanguage("DXRichEditControlAPISample");
            if (projectLanguage == ExampleLanguage.Csharp)
            {
                this.tabControl.SelectedIndex = 0;
            }
            else
            {
                this.tabControl.SelectedIndex = 1;
            }

            treeList1.View.ExpandAllNodes();

            if (treeList1.View.Nodes.Count > 0)
            {
                treeList1.View.FocusedNode = treeList1.View.Nodes[0].Nodes.First();
            }
        }
예제 #6
0
        //CultureInfo defaultCulture = new CultureInfo("en-US");

        public MainWindow()
        {
            InitializeComponent();
            string examplePath = "CodeExamples";
            Dictionary <string, FileInfo> examplesCS = CodeExampleDemoUtils.GatherExamplesFromProject(examplePath, ExampleLanguage.Csharp);
            Dictionary <string, FileInfo> examplesVB = CodeExampleDemoUtils.GatherExamplesFromProject(examplePath, ExampleLanguage.VB);

            DisableTabs(examplesCS.Count, examplesVB.Count);
            List <CodeExampleGroup> examples = CodeExampleDemoUtils.FindExamples(examplePath, examplesCS, examplesVB);

            ShowExamplesInTreeList(treeList1, examples);

            richEditControlCS.Loaded += richEditControlCS_Loaded;
            richEditControlVB.Loaded += richEditControlVB_Loaded;

            this.evaluator = new RichEditExampleEvaluatorByTimer();

            this.evaluator.QueryEvaluate   += OnExampleEvaluatorQueryEvaluate;
            this.evaluator.OnBeforeCompile += evaluator_OnBeforeCompile;
            this.evaluator.OnAfterCompile  += evaluator_OnAfterCompile;
        }
예제 #7
0
 protected virtual string[] DeleteLeadingWhiteSpacesFromSourceCode(string[] lines)
 {
     return(CodeExampleDemoUtils.DeleteLeadingWhiteSpaces(lines, "        "));
 }
예제 #8
0
 protected override string[] DeleteLeadingWhiteSpacesFromSourceCode(string[] lines)
 {
     string[] result = base.DeleteLeadingWhiteSpacesFromSourceCode(lines);
     return(CodeExampleDemoUtils.DeleteLeadingWhiteSpaces(result, "\t\t"));
 }