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 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_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { DoSelection(lastHoveredDataPoint); selectionRectangle.Visibility = Visibility.Collapsed; clickedDataPoint = null; lastHoveredDataPoint = null; currentHeatmap = null; }
private static void EnsureSelectionRectangleVisualParent(RadHeatMap heatmap) { var newParentGrid = Telerik.Windows.Controls.ChildrenOfTypeExtensions.ChildrenOfType <Grid>(heatmap).First(); var oldParentGrid = selectionRectangleHost.Parent as Grid; if (oldParentGrid != newParentGrid && oldParentGrid != null) { oldParentGrid.Children.Remove(selectionRectangleHost); } if (oldParentGrid != newParentGrid) { newParentGrid.Children.Add(selectionRectangleHost); } }
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 EnsureSelectionRectangleVisualParent(RadHeatMap heatmap) { var newParentGrid = Telerik.Windows.Controls.ChildrenOfTypeExtensions.ChildrenOfType<Grid>(heatmap).First(); var oldParentGrid = selectionRectangleHost.Parent as Grid; if (oldParentGrid != newParentGrid && oldParentGrid != null) { oldParentGrid.Children.Remove(selectionRectangleHost); } if (oldParentGrid != newParentGrid) { newParentGrid.Children.Add(selectionRectangleHost); } }
private static void Heatmap_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { DoSelection(lastHoveredDataPoint); selectionRectangle.Visibility = Visibility.Collapsed; clickedDataPoint = null; lastHoveredDataPoint = null; currentHeatmap = null; }