Exemplo n.º 1
0
        private void Draw()
        {
            _dataGrid.CollectionChanged -= dataGrid_CollectionChanged;
            _dataGrid.Clear();

            // get colour scheme values from combobox selections
            ComboBoxItem nDataClassesSelection = numDataClassesComboBox.SelectedItem as ComboBoxItem;
            int          nDataClasses          = int.Parse(nDataClassesSelection.Content.ToString());

            byte[][] defaultColourScheme = _colourScheme.GetRGBColours(colourSchemeComboBox.SelectedItem.ToString(), nDataClasses);

            for (int i = 0; i < _datasetModel.Dataset.Count; i++)
            {
                string[]     row     = _datasetModel.Dataset[i];
                ListViewItem item    = BuildRowStructure(_cellWidth, row[_idIndex]);
                Grid         rowGrid = item.Content as Grid;

                for (int j = 0; j < this.Columns.Length; j++)
                {
                    int    currentColumn = _columnIndexes[j];
                    string columnTitle   = _datasetModel.ColumnHeadings[currentColumn];

                    // get max and min for the column
                    double[] minMax = _datasetModel.GetAxisMinMaxValues(columnTitle);
                    double   min    = minMax[0];
                    double   max    = minMax[1];

                    double cellValue       = double.Parse(row[currentColumn]);
                    double linearTransform = (cellValue - min) / (max - min) * (nDataClasses - 1);
                    int    colourIndex     = (int)Math.Truncate(linearTransform);
                    byte[] colourRGB       = defaultColourScheme[colourIndex];

                    Rectangle cell = new Rectangle();
                    cell.Stroke          = new SolidColorBrush(Colors.LightGray);
                    cell.StrokeThickness = 1;
                    cell.Fill            = new SolidColorBrush(Color.FromArgb(255, colourRGB[0], colourRGB[1], colourRGB[2]));

                    ToolTip tt = new ToolTip();
                    tt.Content   = row[currentColumn];
                    tt.Placement = Windows.UI.Xaml.Controls.Primitives.PlacementMode.Mouse;
                    ToolTipService.SetToolTip(cell, tt);

                    rowGrid.Children.Add(cell);
                    // add to column + 1 to account for the row title
                    Grid.SetColumn(cell, j + 1);
                }
                _dataGrid.Add(item);
            }

            _dataGrid.CollectionChanged += dataGrid_CollectionChanged;
            dataListView.ItemsSource     = _dataGrid;

            // check for filtered items
            if (_filteredItems.Count > 0)
            {
                Filter();
            }
        }
        private void AddRangeSliders()
        {
            _rangeSliders.Clear();

            for (int i = 0; i < this.Axes.Length; i++)
            {
                RangeSlider rangeSlider = new RangeSlider();
                rangeSlider.Height = _canvasHeight;
                rangeSlider.Width  = RANGE_SLIDER_WIDTH;
                Canvas.SetTop(rangeSlider, 0.0);

                // Centralise positions
                if (i == 0)
                {
                    Canvas.SetLeft(rangeSlider, 0.0);
                }
                else if (i == this.Axes.Length - 1)
                {
                    Canvas.SetLeft(rangeSlider, (i * _xSeparation) - rangeSlider.Width);
                }
                else
                {
                    Canvas.SetLeft(rangeSlider, (i * _xSeparation) - (rangeSlider.Width / 2));
                }

                int      index    = _axesIndexes[i];
                string   axisName = _datasetModel.ColumnHeadings[index];
                double[] minMax   = _datasetModel.GetAxisMinMaxValues(axisName);

                rangeSlider.Max = minMax[1];
                rangeSlider.Min = minMax[0];

                rangeSlider.UpperValueChangedEvent += rangeSlider_UpperValueChangedEvent;
                rangeSlider.LowerValueChangedEvent += rangeSlider_LowerValueChangedEvent;

                _rangeSliders.Add(rangeSlider);
                canvas.Children.Add(rangeSlider);
            }
        }