public void populateMemoryCellsGrid(PRAMModel dataRows) { int rowCount = -1; foreach (KeyValuePair <string, List <dynamic> > kvp in dataRows) { memoryGrid.RowDefinitions.Add(new RowDefinition()); rowCount++; if (memoryGrid.ColumnDefinitions.Count < 1) { memoryGrid.ColumnDefinitions.Add(new ColumnDefinition()); } Viewbox viewBox = new Viewbox(); TextBlock rowName = new TextBlock(); rowName.Margin = new Thickness(7); rowName.Text = kvp.Key; viewBox.SetValue(Grid.ColumnProperty, 0); viewBox.SetValue(Grid.RowProperty, rowCount); viewBox.VerticalAlignment = VerticalAlignment.Center; viewBox.HorizontalAlignment = HorizontalAlignment.Center; viewBox.Child = rowName; memoryGrid.Children.Add(viewBox); memoryRows[kvp.Key] = new List <MemoryCellView>(); while (memoryGrid.ColumnDefinitions.Count < kvp.Value.Count + 1) { memoryGrid.ColumnDefinitions.Add(new ColumnDefinition()); } for (int i = 0; i < kvp.Value.Count; i++) { MemoryCellView memoryCellView = new MemoryCellView(); memoryCellView.Data = kvp.Value[i]; memoryCellView.SetValue(Grid.ColumnProperty, i + 1); memoryCellView.SetValue(Grid.RowProperty, rowCount); memoryGrid.Children.Add(memoryCellView); memoryRows[kvp.Key].Add(memoryCellView); } } }
private Point getMemoryCellLocation(MemoryCellView memoryCell) { var memoryCellLocation = memoryCell.TranslatePoint(new Point(0, 0), arrowPaintingArea); return(new Point(memoryCellLocation.X + memoryCell.ActualWidth / 2, memoryCellLocation.Y + memoryCell.ActualHeight / 2)); }