private bool isChildOf(IChangeNotifer ch, DO p) { if (ch is DO dch) { if (H.GetParent(dch) == p) { return(true); } child.MODIFIED -= reset; isTracking = false; return(false); } var chs = H.GetChildren(p); foreach (var c in chs) { if (c == ch) { return(true); } } child.MODIFIED -= reset; isTracking = false; return(false); }
private void bind(FE parent, int dl = 0) { if (parent == null || dl > searchDepth) { return; } var chs = H.GetChildren(parent); foreach (object ch in chs) { if (ch is UIReseter r && r != this) { throw new Exception($@"There's overlapping ""{nameof(UIReseter)}"" instance in the tree. Use single global instance of check ""{nameof(UIReseter.searchDepth)}"" levels."); } if (ch is IChangeNotifer sc) { trackObject(sc, parent); } else { bind(ch as FE, ++dl); } } }
public static IEnumerable <DependencyObject> GetLogicalChilds([CanBeNull] this DependencyObject obj) => obj is null ? Enumerable.Empty <DependencyObject>() : LogicalTreeHelper.GetChildren(obj).OfType <DependencyObject>();
public void CreateFriendsList() { var friend_list = MainWindow.api.Friends.Get(new FriendsGetParams { Order = FriendsOrder.Hints, Fields = ProfileFields.FirstName | ProfileFields.Photo50, Count = 6000, NameCase = NameCase.Nom, }); /*_ = Dispatcher.BeginInvoke(DispatcherPriority.Render, new ThreadStart(delegate * { * FullFriendList.Items.Add(MainWindow.api.Account.GetProfileInfo().FirstName + ' ' + MainWindow.api.Account.GetProfileInfo().LastName + " ID:" + MainWindow.api.UserId); * }));*/ int friendnum = 0; foreach (var friend in friend_list) { using (WebClient webClient = new WebClient()) { try { webClient.DownloadFile(friend.Photo50.AbsoluteUri, (Path.Combine(Environment.CurrentDirectory, "Friendava" + friendnum.ToString() + ".jpg"))); } catch { } } Dispatcher.BeginInvoke(new ThreadStart(delegate { ListBoxItem itemfriend = new ListBoxItem(); itemfriend.Name = "frienditem" + friendnum.ToString(); StackPanel itemstack = new StackPanel(); itemstack.Name = "friendstack" + friendnum.ToString(); Grid itemgrid = new Grid(); for (int i = 0; i < 8; i++) { itemgrid.ColumnDefinitions.Add(new ColumnDefinition()); } for (int i = 0; i < 3; i++) { itemgrid.RowDefinitions.Add(new RowDefinition()); } itemgrid.Name = "friendgrid" + friendnum.ToString(); itemstack.Children.Add(itemgrid); TextBlock friendinfo = new TextBlock(); friendinfo.Text = " " + friend.FirstName + " " + friend.LastName; friendinfo.FontSize = 15; Grid.SetColumn(friendinfo, 5); Grid.SetColumnSpan(friendinfo, 4); Grid.SetRow(friendinfo, 1); Grid.SetRowSpan(friendinfo, 2); itemgrid.Children.Add(friendinfo); itemfriend.Content = itemstack; itemfriend.Tag = friend.Id; FullFriendList.Items.Add(itemfriend); FullFriendList.UpdateLayout(); })); friendnum++; } _ = Dispatcher.BeginInvoke(new ThreadStart(delegate { int num = 0; System.Collections.IEnumerable nodes = LTH.GetChildren(FullFriendList); foreach (var node in nodes) { //MessageBox.Show(node.GetType().ToString()); if (node is string) { continue; } Visual listitem = (Visual)node; System.Collections.IEnumerable items = LTH.GetChildren(listitem); foreach (var item in items) { if (item is StackPanel) { Grid frgr = VTH.GetChild(item as DependencyObject, 0) as Grid; ImageBrush friendava = new ImageBrush(); BitmapImage friendbit = new BitmapImage(new Uri(Path.Combine(Environment.CurrentDirectory, "Friendava" + num.ToString() + ".jpg"))); friendava.ImageSource = friendbit; Ellipse ava = new Ellipse(); ava.Height = 50; ava.Width = 50; ava.Fill = friendava; Grid.SetColumn(ava, 0); Grid.SetColumnSpan(ava, 2); Grid.SetRow(ava, 0); Grid.SetRowSpan(ava, 3); frgr.Children.Add(ava); } } num++; } })); }