public CardControl(UiCard uiCard) { _uiCard = uiCard; _uiCard.Channels.CollectionChanged += (sender, args) => HookUpChannels(args); _uiCard.Channels.ForEach(c => c.PropertyChanged += ChannelPropChanged); _rects = new List <Rectangle>();//[_uiCard.Channels.Count]; Loaded += OnLoaded; }
private void RefreshSelectedCard() { if (SelectedCard == null) { return; } var ca = Cards.CastTo <ObservableCollection <UiCard> >().FirstOrDefault(u => u.Name.Equals(SelectedCard.Name)); if (ca != null) { SelectedCard = ca; } }
private void ManageSelected(UiCard oldValue, UiCard newValue) { try { if (oldValue == newValue || newValue == null) { return; } if (oldValue == null) { for (var i = 0; i < RowDefinitions.Count; i++) { RowDefinitions[i].Height = new GridLength(25); } } else { var cardControl = _cardControls.FirstOrDefault(c => c.Card.Name.Equals(oldValue.Name)); if (cardControl == null) { return; } var cardCanvas = Children.Cast <UIElement>().Where(c => c is CustomCanvas).Cast <CustomCanvas>().FirstOrDefault(canvas => canvas.Children.Cast <CardControl>().Any(cc => cc.Card.Name.Equals(cardControl.Card.Name))); if (cardCanvas != null) { var row = GetRow(cardCanvas); RowDefinitions[row].Height = new GridLength(25); } } if (_cardControls.Count == 0) { return; } var cardcontrol = _cardControls.FirstOrDefault(c => c.Card.Name.Equals(newValue.Name)); if (cardcontrol == null) { return; } var cCanvas = Children.Cast <UIElement>().Where(c => c is CustomCanvas).Cast <CustomCanvas>().FirstOrDefault(canvas => canvas.Children.Cast <CardControl>().Any(cc => cc.Card.Name.Equals(cardcontrol.Card.Name))); if (cCanvas != null) { var row = GetRow(cCanvas); RowDefinitions[row].Height = new GridLength(50); } } catch { } }
private void Watch() { InternalCards.CollectionChanged += (sender, args) => { SelectedCard = null; RefreshUi(null, null); InternalCards.ForEach(c => c.PropertyChanged -= RefreshUi); InternalCards.ForEach(c => c.PropertyChanged += RefreshUi); }; InternalCards.ForEach(c => c.PropertyChanged -= RefreshUi); InternalCards.ForEach(c => c.PropertyChanged += RefreshUi); }