private void SetChildColor(PluggableViewModel viewModel, Random rand, Dictionary<int, Color> parentMap, Dictionary<int, Color> childMap) { Color color; object brush; bool isBrushAvailable = viewModel.PluggableProperties.TryGetValue("Brush", out brush); if (brush == null) { if (!parentMap.TryGetValue(viewModel.ParentId, out color)) { color = GetColor(rand); } occupiedColors.Add(color); viewModel.PluggableProperties["Brush"] = new SolidColorBrush(color); } else { color = (viewModel.PluggableProperties["Brush"] as SolidColorBrush).Color; } childMap[viewModel.Id] = (viewModel.PluggableProperties["Brush"] as SolidColorBrush).Color; }
private void SetParentColor(PluggableViewModel viewModel, Random rand, Dictionary<int, Color> colorMap) { object brush; bool isBrushAvailable = viewModel.PluggableProperties.TryGetValue("Brush", out brush); if (brush == null) { var color = GetColor(rand); while (occupiedColors.Contains(color)) { color = GetColor(rand); } occupiedColors.Add(color); colorMap[viewModel.Id] = color; viewModel.PluggableProperties["Brush"] = new SolidColorBrush(color); } else { colorMap[viewModel.Id] = (viewModel.PluggableProperties["Brush"] as SolidColorBrush).Color; } }