/// <summary>Constructor.</summary> /// <param name="rootNode">The root list-item node.</param> public PackageController(PackageListItem rootNode) { // Store values. this.rootNode = rootNode; sidebarView = Common.Shell.Sidebar; events = Common.Events; // Wire up events. rootNode.SelectionChanged += OnSelectionChanged; rootNode.ChildSelectionChanged += OnChildSelectionChanged; }
/// <summary>Adds a test-package to the controller.</summary> /// <param name="testPackage">The test-package to add.</param> public void AddPackage(PackageInfo testPackage) { // Setup initial conditions. if (testPackage == null) return; // Create the list-item node and insert it within the tree. PackageListItem node = new PackageListItem(testPackage); listRoot.InsertChild(listRoot.ChildCount == 0 ? 0 : listRoot.ChildCount - 1, node); // Insert before last node. // Create the controller. PackageController controller = new PackageController(node); packageControllers.Add(controller); controller.Loaded += delegate { // When the controller loads, reveal it in the list. view.RootList.SelectedParent = controller.RootNode; }; }