Class ModuleTreeViewModel
- Namespace
- Loehnert.Lisrt.Modules.ViewModels
- Assembly
- Loehnert.Lisrt.Modules.dll
Represents a view model for ILisrtModule tree.
[Export(typeof(IModuleTree))]
public class ModuleTreeViewModel : Tool, IViewAware, IChild, IModuleTree, ITool, ILayoutItem, IScreen, IHaveDisplayName, IActivate, IDeactivate, IGuardClose, IClose, INotifyPropertyChangedEx, INotifyPropertyChanged
- Inheritance
-
PropertyChangedBaseViewAwareScreenModuleTreeViewModel
- Implements
-
IViewAwareIChildIScreenIHaveDisplayNameIActivateIDeactivateIGuardCloseICloseINotifyPropertyChangedEx
- Inherited Members
-
Screen.OnInitialize()Screen.OnActivate()Screen.ParentScreen.IsActiveScreen.IsInitializedScreen.ActivatedScreen.AttemptingDeactivationScreen.DeactivatedViewAware.DefaultContextViewAware.ViewsViewAware.ViewAttachedPropertyChangedBase.Refresh()PropertyChangedBase.IsNotifyingPropertyChangedBase.PropertyChanged
- Extension Methods
Remarks
The root module must be exported with this contract:
[Export(ModulesService.RootModuleName, typeof(ILisrtModule))]
.
Constructors
ModuleTreeViewModel(IMenuBuilder, IModulesService, IEnumerable<Lazy<ILisrtModule, IRootModuleMetadata>>, IModuleTreeViewFilter)
Initializes a new instance of the ModuleTreeViewModel class.
[ImportingConstructor]
public ModuleTreeViewModel(IMenuBuilder menuBuilder, IModulesService modulesService, IEnumerable<Lazy<ILisrtModule, IRootModuleMetadata>> rootModules, IModuleTreeViewFilter moduleFilter)
Parameters
menuBuilder
IMenuBuilderMenu builder that builds the menu.
modulesService
IModulesServiceService for the modules.
rootModules
IEnumerable<Lazy<ILisrtModule, IRootModuleMetadata>>Root modules.
moduleFilter
IModuleTreeViewFilterFilter for filtering modules.
Exceptions
- ArgumentNullException
Thrown when
menuBuilder
ormodulesService
is null.
Properties
ContextMenuItems
Gets the menu items for the context menu in the Loehnert.Lisrt.Modules.Views.ModuleTreeView.
public IObservableCollection<MenuItemBase> ContextMenuItems { get; }
Property Value
- IObservableCollection<MenuItemBase>
DisplayName
Gets the display name.
public override string DisplayName { get; }
Property Value
FirstGeneration
Gets the root modules.
public ObservableCollection<ModuleTreeItemViewModel> FirstGeneration { get; }
Property Value
PreferredLocation
Gets the preferred PaneLocation for this Tool.
public override PaneLocation PreferredLocation { get; }
Property Value
RootModuleIsNull
Gets a value indicating whether no root module is defined.
public bool RootModuleIsNull { get; }
Property Value
SearchKey
Gets or sets the search key for filtering the modules and filters the FirstGeneration by setting.
public string SearchKey { get; set; }
Property Value
Methods
Fold(Func<int, ModuleTreeItemViewModel, bool?>)
Expands or folds the items of a module tree.
public void Fold(Func<int, ModuleTreeItemViewModel, bool?> shouldBeFolded)
Parameters
shouldBeFolded
Func<int, ModuleTreeItemViewModel, bool?>Function to determine whether ModuleTreeItemViewModel should be folded. The first argument is the generation (0 is the top level generation), the second argument is the module tree item view model. This function should return
true if the item should be folded
false if the item should be expanded
null if the IsExpanded value shouldn't be changed.
Examples
This example shows how fold all tree items, but not the top level items.
var moduleTree = (ModuleTreeViewModel)IoC.Get<IModuleTree>();
moduleTree.Fold((generation, vm) => generation >= 1);
This example shows how fold only the tree item named "Cavity1", all others are unchanged.
var moduleTree = (ModuleTreeViewModel)IoC.Get<IModuleTree>();
moduleTree.Fold((generation, vm) => vm.Module.Name == "Cavity1" ? (bool?)true : null);
Exceptions
- ArgumentNullException
Thrown when
shouldBeFolded
is null.
GetSelectedModule()
Gets the selected ILisrtModule.
public ILisrtModule GetSelectedModule()
Returns
- ILisrtModule
The selected ILisrtModule or null if no module is selected.