void next_Click(object sender, System.EventArgs e) { bool userChangedFeatures = UserSelectedItems?.JoinBy(",") != InitialUserSelectedItems.JoinBy(","); if (userChangedFeatures) { string itemsToInstall = features.Where(x => x.IsViewChecked()) .Select(x => x.Name) .JoinBy(","); string itemsToRemove = features.Where(x => !x.IsViewChecked()) .Select(x => x.Name) .JoinBy(","); if (itemsToRemove.Any()) { Runtime.Session["REMOVE"] = itemsToRemove; } if (itemsToInstall.Any()) { Runtime.Session["ADDLOCAL"] = itemsToInstall; } } else { Runtime.Session["REMOVE"] = ""; Runtime.Session["ADDLOCAL"] = ""; } SaveUserSelection(); Shell.GoNext(); }
void BuildFeaturesHierarchy() { features = Runtime.Session.Features; //build the hierarchy tree var rootItems = features.Where(x => x.ParentName.IsEmpty()) .OrderBy(x => x.RawDisplay) .ToArray(); var itemsToProcess = new Queue <FeatureItem>(rootItems); //features to find the children for while (itemsToProcess.Any()) { var item = itemsToProcess.Dequeue(); //create the view of the feature var view = new ReadOnlyTreeNode { Text = item.Title, Tag = item, //link view to model IsReadOnly = item.DisallowAbsent, DefaultChecked = item.DefaultIsToBeInstalled(), Checked = item.DefaultIsToBeInstalled() }; item.View = view; if (item.Parent != null && item.Display != FeatureDisplay.hidden) { (item.Parent.View as TreeNode).Nodes.Add(view); //link child view to parent view } // even if the item is hidden process all its children so the correct hierarchy is established // find all children features.Where(x => x.ParentName == item.Name) .ForEach(c => { c.Parent = item; //link child model to parent model itemsToProcess.Enqueue(c); //schedule for further processing }); if (UserSelectedItems != null) { view.Checked = UserSelectedItems.Contains((view.Tag as FeatureItem).Name); } if (item.Display == FeatureDisplay.expand) { view.Expand(); } } //add views to the treeView control rootItems.Where(x => x.Display != FeatureDisplay.hidden) .Select(x => x.View) .Cast <TreeNode>() .ForEach(node => featuresTree.Nodes.Add(node)); InitialUserSelectedItems = features.Where(x => x.IsViewChecked()) .Select(x => x.Name) .OrderBy(x => x) .ToList(); isAutoCheckingActive = true; }