public void LoadModel(TwitterUser user) { buttonRegistry = new Dictionary<TwitterUser, TwitterUserControl>(); entityCanvas.Children.Clear(); // TODO: not sure if we want this here - the user model should already have dictated what data we retrieved. int depth = int.Parse(depthTextBox.Text); var startControl = new TwitterUserControl(user) {Title = user.Name}; var trans = new ScaleTransform {ScaleX = 1.3, ScaleY = 1.3}; startControl.RenderTransform = trans; startControl.Color = Colors.Blue; entityCanvas.Children.Add(startControl); Canvas.SetLeft(startControl, entityCanvas.ActualWidth / 2); Canvas.SetTop(startControl, entityCanvas.ActualHeight / 2); buttonRegistry.Add(user, startControl); ICollection<TwitterUser> ringEntities = user.Friends; for (int i = 1; i <= depth; i++) { ringEntities = LoadRing(ringEntities, i); } MakeFriends(); infoBlock.Text = "Node Count: " + buttonRegistry.Count; }
public TwitterUserControl(TwitterUser user) { InitializeComponent(); connectedControls = new List<TwitterUserControl>(); connectionLines = new List<Line>(); twitterUser = user; //highlightColor = Colors.Yellow; startColor = endStop.Color; MouseLeftButtonDown += EntityControl_MouseLeftButtonDown; }
public TwitterUserControl() { // for blend twitterUser = new TwitterUser {Name = "blend"}; }
public TwitterUserControlClickedEventArgs(TwitterUser user) { TwitterUser = user; }
void EvaluateFriend(TwitterUser entity, TwitterUser friend, IDictionary<int, int> exclusions) { int key = entity.GetHashCode() * friend.GetHashCode(); if (!exclusions.ContainsKey(key)) { if (buttonRegistry.ContainsKey(friend)) { DrawConnection(entity, friend); exclusions.Add(key, 0); } } }
void DrawConnection(TwitterUser user1, TwitterUser user2) { var button1 = buttonRegistry[user1]; var button2 = buttonRegistry[user2]; var line = new Line { StrokeThickness = 1, Stroke = new SolidColorBrush(Colors.Black), Opacity = .5, X1 = Canvas.GetLeft(button1) + button1.Width / 2, Y1 = Canvas.GetTop(button1) + button1.Height / 2, X2 = Canvas.GetLeft(button2) + button2.Width / 2, Y2 = Canvas.GetTop(button2) + button2.Height / 2 }; button1.ConnectedControls.Add(button2); button2.ConnectedControls.Add(button1); button1.ConnectionLines.Add(line); button2.ConnectionLines.Add(line); entityCanvas.Children.Insert(0, line); }