Ejemplo n.º 1
0
        public void UpdateColorScheme()
        {
            var reportResults = (DataSource as BindingListSource)?.ReportResults as ClusteredReportResults;

            if (reportResults == null)
            {
                ReportColorScheme = null;
            }
            else
            {
                ReportColorScheme = ReportColorScheme.FromClusteredResults(CancellationToken.None, reportResults);
            }
        }
Ejemplo n.º 2
0
        private Tuple <Clusterer, ClusteredReportResults, ReportColorScheme> GetClusteredResultsBackground(ILongWaitBroker longWaitBroker)
        {
            var clusterer = Clusterer.CreateClusterer(longWaitBroker.CancellationToken, BindingListSource.ClusteringSpec ?? ClusteringSpec.DEFAULT,
                                                      BindingListSource.ReportResults);

            if (clusterer == null)
            {
                return(null);
            }

            var results     = clusterer.GetClusteredResults();
            var colorScheme = ReportColorScheme.FromClusteredResults(longWaitBroker.CancellationToken, results);

            return(Tuple.Create(clusterer, results, colorScheme));
        }
Ejemplo n.º 3
0
        protected override void OnCellFormatting(DataGridViewCellFormattingEventArgs e)
        {
            base.OnCellFormatting(e);
            if (ReportColorScheme == null)
            {
                return;
            }

            if (e.ColumnIndex < 0 || e.ColumnIndex >= ColumnCount)
            {
                return;
            }
            var reportResults = (DataSource as BindingListSource)?.ReportResults;

            if (reportResults == null)
            {
                return;
            }

            if (e.RowIndex < 0 || e.RowIndex >= reportResults.RowCount)
            {
                return;
            }

            var column = Columns[e.ColumnIndex];

            if (column == null)
            {
                return;
            }
            var propertyDescriptor = reportResults.ItemProperties.FindByName(Columns[e.ColumnIndex].DataPropertyName);

            if (propertyDescriptor == null)
            {
                return;
            }

            var color = ReportColorScheme.GetColor(propertyDescriptor, reportResults.RowItems[e.RowIndex]);

            if (color.HasValue)
            {
                e.CellStyle.BackColor = LightenColor(color.Value);
            }
        }
Ejemplo n.º 4
0
 public void SetData(Clusterer clusterer, ReportColorScheme colorScheme)
 {
     Clusterer   = clusterer;
     ColorScheme = colorScheme;
     UpdateControls();
 }
Ejemplo n.º 5
0
        public void UpdateColumnDendrograms(ClusteredProperties clusteredProperties, ReportColorScheme reportColorScheme, IList <DendrogramData> columnDendrogramDatas)
        {
            var pivotedProperties = clusteredProperties.PivotedProperties;

            if (columnDendrogramDatas == null || columnDendrogramDatas.All(data => null == data))
            {
                splitContainerHorizontal.Panel1Collapsed = true;
                return;
            }
            List <KeyValuePair <double, double> > columnLocations = new List <KeyValuePair <double, double> >();
            Dictionary <string, int> nameToIndex = new Dictionary <string, int>();
            double currentPosition = 0 - DataGridView.HorizontalScrollingOffset;

            if (DataGridView.RowHeadersVisible)
            {
                currentPosition += DataGridView.RowHeadersWidth;
            }
            foreach (var column in DataGridView.Columns.Cast <DataGridViewColumn>())
            {
                if (!string.IsNullOrEmpty(column.DataPropertyName))
                {
                    nameToIndex[column.DataPropertyName] = columnLocations.Count;
                }

                double width = column.Visible ? column.Width : 0;
                columnLocations.Add(new KeyValuePair <double, double>(currentPosition, currentPosition + width));
                currentPosition += width;
            }

            if (columnLocations.Count == 0)
            {
                return;
            }
            var datas = new List <DendrogramFormat>();

            for (int i = 0; i < columnDendrogramDatas.Count; i++)
            {
                var dendrogramData = columnDendrogramDatas[i];
                if (dendrogramData == null)
                {
                    continue;
                }

                var seriesGroup = pivotedProperties.SeriesGroups[i];
                if (seriesGroup == null)
                {
                    continue;
                }
                KeyValuePair <double, double>         lastLocation = columnLocations[0];
                List <KeyValuePair <double, double> > leafLocatons = new List <KeyValuePair <double, double> >(seriesGroup.PivotKeys.Count);
                List <List <Color> > leafColors = new List <List <Color> >();
                for (int iPivotKey = 0; iPivotKey < seriesGroup.PivotKeys.Count; iPivotKey++)
                {
                    var colors = new List <Color>();
                    var locs   = new List <KeyValuePair <double, double> >();
                    foreach (var series in seriesGroup.SeriesList)
                    {
                        var propertyDescriptor = series.PropertyDescriptors[iPivotKey];
                        int columnIndex;
                        if (nameToIndex.TryGetValue(propertyDescriptor.Name, out columnIndex))
                        {
                            locs.Add(columnLocations[columnIndex]);
                        }

                        if (reportColorScheme != null)
                        {
                            if (clusteredProperties.GetColumnRole(series) == ClusterRole.COLUMNHEADER)
                            {
                                colors.Add(reportColorScheme.GetColumnColor(propertyDescriptor) ?? Color.Transparent);
                            }
                        }
                    }

                    if (locs.Count != 0)
                    {
                        lastLocation = new KeyValuePair <double, double>(locs.Min(kvp => kvp.Key), locs.Max(kvp => kvp.Value));
                    }
                    leafLocatons.Add(lastLocation);
                    leafColors.Add(colors);
                }
                datas.Add(new DendrogramFormat(dendrogramData, ImmutableList.ValueOf(leafLocatons), leafColors));
            }
            columnDendrogram.SetDendrogramDatas(datas);
            splitContainerHorizontal.Panel1Collapsed = false;
        }