static List <CodeExample> MergeExamples(List <CodeExample> foundExamplesCS, List <CodeExample> foundExamplesVB)
        {
            List <CodeExample> result = new List <CodeExample>();

            int count = foundExamplesCS.Count;

            for (int i = 0; i < count; i++)
            {
                CodeExample itemCS = foundExamplesCS[i];

                CodeExample itemVB = foundExamplesVB[i];
                if (itemCS.HumanReadableGroupName == itemVB.HumanReadableGroupName &&
                    itemCS.RegionName == itemVB.RegionName)
                {
                    CodeExample merged = new CodeExample();
                    merged.RegionName             = itemCS.RegionName;
                    merged.HumanReadableGroupName = itemCS.HumanReadableGroupName;
                    merged.CodeCS = itemCS.CodeCS;
                    merged.CodeVB = itemVB.CodeVB;
                    result.Add(merged);
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }

            return(result);
        }
        public string ShowExample(CodeExample oldExample, CodeExample newExample)
        {
            InnerRichEditControl richEditControlCs = codeEditorCs.InnerControl;
            InnerRichEditControl richEditControlVb = codeEditorVb.InnerControl;

            if (oldExample != null)
            {
                oldExample.CodeCS = richEditControlCs.Text;
                oldExample.CodeVB = richEditControlVb.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;

                    richEditTextChanged = false;
                }
                finally
                {
                    richEditTextChanged = true;
                }
            }
            return(exampleCode);
        }
        internal void Merge(CodeExample n)
        {
            this.CodeCS += Environment.NewLine;
            this.CodeCS += n.CodeCS;

            this.CodeVB += Environment.NewLine;
            this.CodeVB += n.CodeVB;
        }
        protected CodeExample CreateSpreadsheetExample(string exampleGroup, string regionName, string exampleCode)
        {
            CodeExample result = new CodeExample();

            SetExampleCode(exampleCode, result);
            result.RegionName             = regionName;
            result.HumanReadableGroupName = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(exampleGroup);
            return(result);
        }
        void treeList_VirtualTreeGetCellValue(object sender, VirtualTreeGetCellValueInfo args)
        {
            CodeExampleGroup group = args.Node as CodeExampleGroup;

            if (group != null)
            {
                args.CellData = group.Name;
            }

            CodeExample example = args.Node as CodeExample;

            if (example != null)
            {
                args.CellData = example.RegionName;
            }
        }
        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, newExample.RegionName);
            evaluator.ForceCompile(args);
        }
 protected override void SetExampleCode(string code, CodeExample newExample)
 {
     newExample.CodeCS = code;
 }
 protected abstract void SetExampleCode(string exampleCode, CodeExample newExample);