public Form1()
        {
            InitializeComponent();
            InitializeRichEditControl();

            string examplePath = CodeExampleDemoUtils.GetExamplePath("CodeExamples");

            Dictionary <string, FileInfo> examplesCS = CodeExampleDemoUtils.GatherExamplesFromProject(examplePath, ExampleLanguage.Csharp);
            Dictionary <string, FileInfo> examplesVB = CodeExampleDemoUtils.GatherExamplesFromProject(examplePath, ExampleLanguage.VB);

            DisableTabs(examplesCS.Count, examplesVB.Count);
            this.examples = CodeExampleDemoUtils.FindExamples(examplePath, examplesCS, examplesVB);
            ShowExamplesInTreeList(treeList1, examples);

            this.codeEditor        = new ExampleCodeEditor(richEditControlCS, richEditControlVB, richEditControlCSClass, richEditControlVBClass);
            CurrentExampleLanguage = CodeExampleDemoUtils.DetectExampleLanguage("RichEditAPISample");
            this.evaluator         = new RichEditExampleEvaluatorByTimer();

            this.evaluator.QueryEvaluate             += OnExampleEvaluatorQueryEvaluate;
            this.evaluator.OnBeforeCompile           += evaluator_OnBeforeCompile;
            this.evaluator.OnAfterCompile            += evaluator_OnAfterCompile;
            this.xtraTabControl1.SelectedPageChanged += xtraTabControl1_SelectedPageChanged;

            ShowFirstExample("Range");
            treeList1.CollapseAll();
        }
        public void OnCompileExampleTimerTick(object sender, EventArgs e)
        {
            ExampleEvaluatorByTimer module = (ExampleEvaluatorByTimer)weakControlRef.Target;

            if (module != null)
            {
                module.CompileExample(sender, e);
            }
        }
 public LeakSafeCompileEventRouter(ExampleEvaluatorByTimer module)
 {
     //Guard.ArgumentNotNull(module, "module");
     this.weakControlRef = new WeakReference(module);
 }