Esempio n. 1
0
        private void dgvObjectExplorer_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            try
            {
                ExplorerItem item = explorerList[e.RowIndex];
                if (e.ColumnIndex == 1)
                {
                    e.Value = item.title;
                }
                else
                {
                    switch (item.type)
                    {
                    case ExplorerItemType.DisabledProperty:
                        e.Value = Resources.disabled_property;
                        return;

                    case ExplorerItemType.Class:
                        e.Value = Resources.class_libraries;
                        return;

                    case ExplorerItemType.Method:
                        e.Value = Resources.box;
                        return;

                    case ExplorerItemType.Event:
                        e.Value = Resources.lightning;
                        return;

                    case ExplorerItemType.Property:
                        e.Value = Resources.property;
                        return;
                    }
                }
            }
            catch {; }
        }
Esempio n. 2
0
        private void ReBuildObjectExplorer(string text)
        {
            try
            {
                List <ExplorerItem> list = new List <ExplorerItem>();
                //int lastClassIndex = -1;
                //find classes, methods and properties
                Regex regex = new Regex(@"^(?<range>[\w\s]+\b(class|struct|enum|interface)\s+[\w<>,\s]+)|^\s*(#define|//\s*#define|public|private|internal|protected)[^\n]+(\n?\s*{|;)?", RegexOptions.Multiline);
                foreach (Match r in regex.Matches(text))
                {
                    try
                    {
                        var item = new ExplorerItem {
                            title = r.Value.Trim(), position = r.Index
                        };

                        if (item.title.Contains("#define"))
                        {
                            //TODO: Fix Startwith
                            if (item.title.StartsWith(@"#define"))
                            {
                                item.title = item.title.Replace(@"#define", "").Trim();

                                if (item.title.Contains(@"//"))
                                {
                                    item.title = item.title.Substring(0,
                                                                      item.title.IndexOf(@"//", StringComparison.Ordinal));
                                }
                                item.type = ExplorerItemType.Property;
                            }

                            //TODO: Fix Startwith
                            if (item.title.StartsWith(@"//"))
                            {
                                item.title = item.title.TrimStart('/').Trim();

                                item.title = item.title.Replace(@"#define", "").Trim();

                                item.type = ExplorerItemType.DisabledProperty;
                            }
                        }



                        list.Add(item);
                    }
                    catch
                    {
                        ;
                    }
                }


                explorerList.Clear();

                BeginInvoke(
                    new Action(() =>
                {
                    explorerList = list;
                    dgvObjectExplorer.RowCount = explorerList.Count;
                    dgvObjectExplorer.Invalidate();
                })
                    );
            }
            catch {; }
        }