/// <summary> /// /// </summary> /// <param name="demoModule"></param> public void RemoveDemoModule(DemoModule demoModule) { DepPropertyHelper.UnsubscribeFromChanged(demoModule.Bar, RibbonPage.IsSelectedProperty, demoModule.BarIsSelectedChanged); var demoModulesList = _demoModules[((ClassicShowType)demoModule.ShowMethodType).Category]; demoModulesList.Remove(demoModule); if (demoModulesList.Count == 0) { _demoModules.Remove(((ClassicShowType)demoModule.ShowMethodType).Category); UpdateNavBar(); } RemoveDemoModuleBar(demoModule); }
/// <summary> /// Adds an application module depended on the category /// </summary> /// <param name="demoModule">The demo module.</param> public void AddDemoModule(DemoModule demoModule) { PrepareDemoModuleBar(demoModule); PrepareDemoModuleRoot(demoModule); DepPropertyHelper.SubscribeToChanged(demoModule.Bar, RibbonPage.IsSelectedProperty, demoModule.BarIsSelectedChanged); AddDemoModuleBar(demoModule); List <DemoModule> demoModulesList; if (!_demoModules.TryGetValue(((ClassicShowType)demoModule.ShowMethodType).Category, out demoModulesList)) { demoModulesList = new List <DemoModule>(); _demoModules.Add(((ClassicShowType)demoModule.ShowMethodType).Category, demoModulesList); UpdateNavBar(); } demoModulesList.Add(demoModule); }
public void DependencyPropertyHelper_SubscribeToChanged() { bool eventRaised = false; TheDependencyObject theDependencyObject = new TheDependencyObject(); EventHandler changed = delegate(object sender, EventArgs e) { eventRaised = true; }; DepPropertyHelper.SubscribeToChanged(theDependencyObject, TheDependencyObject.IntValueProperty, changed); theDependencyObject.IntValue = 1; Assert.IsTrue(eventRaised); DepPropertyHelper.UnsubscribeFromChanged(theDependencyObject, TheDependencyObject.IntValueProperty, changed); eventRaised = false; theDependencyObject.IntValue = 2; Assert.IsFalse(eventRaised); }
void SetActiveBarItem(BarItem sharedBarItem, BarItem activeBarItem) { sharedBarItem.Tag = activeBarItem; BarCheckItem sharedBarCheckItem = sharedBarItem as BarCheckItem; BarEditItem sharedBarEditItem = sharedBarItem as BarEditItem; if (activeBarItem == null) { sharedBarItem.IsEnabled = false; sharedBarItem.Content = sharedBarItem.Content; sharedBarItem.Glyph = sharedBarItem.Glyph; sharedBarItem.LargeGlyph = sharedBarItem.LargeGlyph; sharedBarItem.Hint = sharedBarItem.Hint; sharedBarItem.GlyphAlignment = sharedBarItem.GlyphAlignment; if (sharedBarEditItem != null) { object editValue = sharedBarEditItem.EditValue; BindingOperations.ClearBinding(sharedBarEditItem, BarEditItem.EditValueProperty); sharedBarEditItem.EditValue = editValue; } if (sharedBarCheckItem != null) { DepPropertyHelper.UnbindHard(sharedBarCheckItem, BarCheckItem.IsCheckedProperty); } } else { sharedBarItem.SetBinding(BarItem.IsEnabledProperty, new Binding("IsEnabled") { Source = activeBarItem, Mode = BindingMode.OneWay }); sharedBarItem.SetBinding(BarItem.ContentProperty, new Binding("Content") { Source = activeBarItem, Mode = BindingMode.OneWay }); sharedBarItem.SetBinding(BarItem.GlyphProperty, new Binding("Glyph") { Source = activeBarItem, Mode = BindingMode.OneWay }); sharedBarItem.SetBinding(BarItem.LargeGlyphProperty, new Binding("LargeGlyph") { Source = activeBarItem, Mode = BindingMode.OneWay }); sharedBarItem.SetBinding(BarItem.HintProperty, new Binding("Hint") { Source = activeBarItem, Mode = BindingMode.OneWay }); sharedBarItem.SetBinding(BarItem.GlyphAlignmentProperty, new Binding("GlyphAlignment") { Source = activeBarItem, Mode = BindingMode.OneWay }); if (sharedBarItem is BarEditItem) { sharedBarItem.SetBinding(BarEditItem.EditValueProperty, new Binding("EditValue") { Source = activeBarItem, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); } if (sharedBarCheckItem != null) { DepPropertyHelper.BindHard(sharedBarCheckItem, BarCheckItem.IsCheckedProperty, activeBarItem, BarCheckItem.IsCheckedProperty); } } }