예제 #1
0
        private void LoadCategorySample(string category, SourceGrid.Cells.Controllers.Button linkEvents, Type[] assemblyTypes, SourceGrid.Cells.Views.IView categoryView, SourceGrid.Cells.Views.IView headerView)
        {
            int row;

            //Create Category Row
            row = grid1.RowsCount;
            grid1.Rows.Insert(row);
            grid1[row, 0]            = new SourceGrid.Cells.Cell(category);
            grid1[row, 0].View       = categoryView;
            grid1[row, 0].ColumnSpan = grid1.ColumnsCount;

            //Create Headers
            row = grid1.RowsCount;
            grid1.Rows.Insert(row);

            SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader("Sample N?");
            header1.View = headerView;
            header1.AutomaticSortEnabled = false;
            grid1[row, 0] = header1;

            SourceGrid.Cells.ColumnHeader header2 = new SourceGrid.Cells.ColumnHeader("Description");
            header2.View = headerView;
            header2.AutomaticSortEnabled = false;
            grid1[row, 1] = header2;

            //Create Data Cells
            for (int i = 0; i < assemblyTypes.Length; i++)
            {
                object[] attributes = assemblyTypes[i].GetCustomAttributes(typeof(SampleAttribute), true);
                if (attributes != null && attributes.Length > 0)
                {
                    SampleAttribute sampleAttribute = (SampleAttribute)attributes[0];

                    if (sampleAttribute.Category == category)
                    {
                        row = grid1.RowsCount;
                        grid1.Rows.Insert(row);
                        grid1[row, 0]      = new SourceGrid.Cells.Cell(sampleAttribute.SampleNumber);
                        grid1[row, 0].View = new SourceGrid.Cells.Views.Cell();
                        grid1[row, 0].View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

                        //Create a cell with a link
                        grid1[row, 1]     = new SourceGrid.Cells.Link(sampleAttribute.Description);
                        grid1[row, 1].Tag = assemblyTypes[i];
                        grid1[row, 1].Controller.AddController(linkEvents);
                    }
                }
            }

            //Enable sorting of the category range
            SourceGrid.RangeLoader headerRange = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row, 0, header1.Range.Start.Row, 1));
            SourceGrid.RangeLoader rangeToSort = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row + 1, 0, row, 1));
            SourceGrid.Cells.Controllers.SortableHeader sortableController = new SourceGrid.Cells.Controllers.SortableHeader(rangeToSort, headerRange);

            header1.AddController(sortableController);
            header1.Sort(true);
            header2.AddController(sortableController);
        }
예제 #2
0
        private void LoadCategorySample(string category, SourceGrid.Cells.Controllers.Button linkEvents, Type[] assemblyTypes, SourceGrid.Cells.Views.IView categoryView, SourceGrid.Cells.Views.IView headerView)
        {
            int row;

            //Create Category Row
            row = grid1.RowsCount;
            grid1.Rows.Insert(row);
            grid1[row, 0] = new SourceGrid.Cells.Cell(category);
            grid1[row, 0].View = categoryView;
            grid1[row, 0].ColumnSpan = grid1.ColumnsCount;

            //Create Headers
            row = grid1.RowsCount;
            grid1.Rows.Insert(row);

            SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader("Sample N°");
            header1.View = headerView;
            header1.AutomaticSortEnabled = false;
            grid1[row, 0] = header1;

            SourceGrid.Cells.ColumnHeader header2 = new SourceGrid.Cells.ColumnHeader("Description");
            header2.View = headerView;
            header2.AutomaticSortEnabled = false;
            grid1[row, 1] = header2;

            //Create Data Cells
            for (int i = 0; i < assemblyTypes.Length; i++)
            {
                object[] attributes = assemblyTypes[i].GetCustomAttributes(typeof(SampleAttribute), true);
                if (attributes != null && attributes.Length > 0)
                {
                    SampleAttribute sampleAttribute = (SampleAttribute)attributes[0];

                    if (sampleAttribute.Category == category)
                    {
                        row = grid1.RowsCount;
                        grid1.Rows.Insert(row);
                        grid1[row, 0] = new SourceGrid.Cells.Cell( sampleAttribute.SampleNumber );
                        grid1[row, 0].View = new SourceGrid.Cells.Views.Cell();
                        grid1[row, 0].View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

                        //Create a cell with a link
                        grid1[row, 1] = new SourceGrid.Cells.Link( sampleAttribute.Description );
                        grid1[row, 1].Tag = assemblyTypes[i];
                        grid1[row, 1].Controller.AddController(linkEvents);
                    }
                }
            }

            //Enable sorting of the category range
            SourceGrid.RangeLoader headerRange = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row, 0, header1.Range.Start.Row, 1));
            SourceGrid.RangeLoader rangeToSort = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row+1, 0, row, 1));
            SourceGrid.Cells.Controllers.SortableHeader sortableController = new SourceGrid.Cells.Controllers.SortableHeader(rangeToSort, headerRange);

            header1.AddController(sortableController);
            header1.Sort(true);
            header2.AddController(sortableController);
        }