private void OnDeleted(object item) { GrilleFilterTargetItemPanel panel = (GrilleFilterTargetItemPanel)item; if (panel.TargetItem != null) { if (this.Scope == null) { this.Scope = GetNewScope(); } panel.TargetItem.parent = this.Scope; this.Scope.RemoveTargetItem(panel.TargetItem); RemoveHandlers(panel); this.panel.Children.Remove(panel); if (this.ActiveItemPanel != null && this.ActiveItemPanel == panel) { this.ActiveItemPanel = (GrilleFilterTargetItemPanel)this.panel.Children[this.panel.Children.Count - 1]; } int index = 1; foreach (object pan in this.panel.Children) { ((GrilleFilterTargetItemPanel)pan).Index = index++; } OnChanged(); } }
private void RemoveHandlers(GrilleFilterTargetItemPanel itemPanel) { itemPanel.Added -= OnAdded; itemPanel.Updated -= OnUpdated; itemPanel.Deleted -= OnDeleted; itemPanel.Activated -= OnActivated; }
private void InitializeHandlers(GrilleFilterTargetItemPanel itemPanel) { itemPanel.Added += OnAdded; itemPanel.Updated += OnUpdated; itemPanel.Deleted += OnDeleted; itemPanel.Activated += OnActivated; }
private void OnUpdated(object item) { GrilleFilterTargetItemPanel panel = (GrilleFilterTargetItemPanel)item; if (this.Scope == null) { this.Scope = GetNewScope(); } this.Scope.UpdateTargetItem(panel.TargetItem); OnChanged(); }
/// <summary> /// /// </summary> /// <param name="scope"></param> public void DisplayScope(Target scope) { this.Scope = scope; this.panel.Children.Clear(); if (scope != null) { foreach (TargetItem item in scope.targetItemListChangeHandler.Items) { GrilleFilterTargetItemPanel itemPanel = new GrilleFilterTargetItemPanel(item); AddItemPanel(itemPanel); } } AddDefaultItem(); }
protected void AddItemPanel(GrilleFilterTargetItemPanel itemPanel) { InitializeHandlers(itemPanel); this.panel.Children.Add(itemPanel); }