private static void DoSelection(RadHeatMap heatMap, HeatMapCellDataPoint hoveredDataPoint)
        {
            if (clickedDataPoint == null || hoveredDataPoint == null)
            {
                return;
            }

            int startRowIndex = Math.Min(clickedDataPoint.RowIndex, hoveredDataPoint.RowIndex);
            int endRowIndex = Math.Max(clickedDataPoint.RowIndex, hoveredDataPoint.RowIndex);
            int startColumnIndex = Math.Min(clickedDataPoint.ColumnIndex, hoveredDataPoint.ColumnIndex);
            int endColumnIndex = Math.Max(clickedDataPoint.ColumnIndex, hoveredDataPoint.ColumnIndex);

            var cDefinition = heatMap.Definition as CategoricalDefinition;
            if (cDefinition != null)
            {
                DoSelection(cDefinition, startRowIndex, endRowIndex, startColumnIndex, endColumnIndex);
            }
            var hDefinition = heatMap.Definition as HorizontalDefinition;
            if (hDefinition != null)
            {
                DoSelection(hDefinition, startRowIndex, endRowIndex);
            }
            var vDefinition = heatMap.Definition as VerticalDefinition;
            if (vDefinition != null)
            {
                DoSelection(vDefinition, startColumnIndex, endColumnIndex);
            }
        }
        private static void Heatmap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (currentHeatmap != sender)
            {
                return;
            }

            if (clickedDataPoint == null || currentHeatmap.HoveredCellDataPoint == null)
            {
                return;
            }

            lastHoveredDataPoint = currentHeatmap.HoveredCellDataPoint;
            var pos = e.GetPosition(currentHeatmap);

            Rect r;

            if (currentHeatmap.Definition is CategoricalDefinition)
            {
                r = new Rect(new Point(clickedX, clickedY), pos);
            }
            else if (currentHeatmap.Definition is HorizontalDefinition)
            {
                r = new Rect(new Point(0, clickedY), new Point(currentHeatmap.ActualWidth, pos.Y));
            }
            else
            {
                r = new Rect(new Point(clickedX, 0), new Point(pos.X, currentHeatmap.ActualHeight));
            }

            Canvas.SetLeft(selectionRectangle, r.Left);
            Canvas.SetTop(selectionRectangle, r.Top);
            selectionRectangle.Width  = r.Width;
            selectionRectangle.Height = r.Height;
        }
        private static void DoSelection(HeatMapCellDataPoint hoveredDataPoint)
        {
            if (clickedDataPoint == null || hoveredDataPoint == null)
            {
                return;
            }

            int startRowIndex    = Math.Min(clickedDataPoint.RowIndex, hoveredDataPoint.RowIndex);
            int endRowIndex      = Math.Max(clickedDataPoint.RowIndex, hoveredDataPoint.RowIndex);
            int startColumnIndex = Math.Min(clickedDataPoint.ColumnIndex, hoveredDataPoint.ColumnIndex);
            int endColumnIndex   = Math.Max(clickedDataPoint.ColumnIndex, hoveredDataPoint.ColumnIndex);

            var cDefinition = currentHeatmap.Definition as CategoricalDefinition;

            if (cDefinition != null)
            {
                DoSelection(cDefinition, startRowIndex, endRowIndex, startColumnIndex, endColumnIndex);
            }
            var hDefinition = currentHeatmap.Definition as HorizontalDefinition;

            if (hDefinition != null)
            {
                DoSelection(hDefinition, startRowIndex, endRowIndex);
            }
            var vDefinition = currentHeatmap.Definition as VerticalDefinition;

            if (vDefinition != null)
            {
                DoSelection(vDefinition, startColumnIndex, endColumnIndex);
            }
        }
 private static void Heatmap_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     DoSelection(lastHoveredDataPoint);
     selectionRectangle.Visibility = Visibility.Collapsed;
     clickedDataPoint     = null;
     lastHoveredDataPoint = null;
     currentHeatmap       = null;
 }
        private static void Heatmap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            currentHeatmap = (RadHeatMap)sender;
            if (currentHeatmap.HoveredCellDataPoint == null)
            {
                return;
            }

            EnsureSelectionRectangleVisualParent();
            selectionRectangle.Visibility = Visibility.Visible;
            selectionRectangle.Width = 0;
            selectionRectangle.Height = 0;

            var pos = e.GetPosition(currentHeatmap);
            clickedX = pos.X;
            clickedY = pos.Y;
            clickedDataPoint = currentHeatmap.HoveredCellDataPoint;
            lastHoveredDataPoint = clickedDataPoint;
        }
        private static void Heatmap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            currentHeatmap = (RadHeatMap)sender;
            if (currentHeatmap.HoveredCellDataPoint == null)
            {
                return;
            }

            EnsureSelectionRectangleVisualParent();
            selectionRectangle.Visibility = Visibility.Visible;
            selectionRectangle.Width      = 0;
            selectionRectangle.Height     = 0;

            var pos = e.GetPosition(currentHeatmap);

            clickedX             = pos.X;
            clickedY             = pos.Y;
            clickedDataPoint     = currentHeatmap.HoveredCellDataPoint;
            lastHoveredDataPoint = clickedDataPoint;
        }
        private static void Heatmap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            var heatmap = (RadHeatMap)sender;
            if (clickedDataPoint == null || heatmap.HoveredCellDataPoint == null)
            {
                return;
            }

            lastHoveredDataPoint = heatmap.HoveredCellDataPoint;
            var pos = e.GetPosition(heatmap);

            Rect r;
            if (heatmap.Definition is CategoricalDefinition)
            {
                r = new Rect(new Point(clickedX, clickedY), pos);
            }
            else if (heatmap.Definition is HorizontalDefinition)
            {
                r = new Rect(new Point(0, clickedY), new Point(heatmap.ActualWidth, pos.Y));
            }
            else
            {
                r = new Rect(new Point(clickedX, 0), new Point(pos.X, heatmap.ActualHeight));
            }

            Canvas.SetLeft(selectionRectangle, r.Left);
            Canvas.SetTop(selectionRectangle, r.Top);
            selectionRectangle.Width = r.Width;
            selectionRectangle.Height = r.Height;
        }
 private static void Heatmap_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     var heatmap = (RadHeatMap)sender;
     DoSelection(heatmap, lastHoveredDataPoint);
     selectionRectangle.Visibility = Visibility.Collapsed;
     clickedDataPoint = null;
     lastHoveredDataPoint = null;
 }