private static List <Control> findPropagationPathUsingTest(IControlParent root, PropagationTest propagationTest) { var path = new List <Control>(); tryFindPropagationPathForAnyChild(root, propagationTest, path); return(path); }
public InstructorHomeControl(IControlParent controlParent, int id) { InitializeComponent(); instructorStore = StoreFactory.BuildInstructorStore(); instructor = instructorStore.GetInstructorById(id); ShowInstructorBasicInfo(); }
public LoginControl(IControlParent controlParent) { InitializeComponent(); // keep a reference to the parent form, which is how we request a new control be shown this.controlParent = controlParent; // create the login manager, which handles all the login requests this.loginManager = new LoginManager(); }
public NavigationController( IControlParent root, DependencyResolver dependencyResolver, IDictionary <Type, object> modelFactories, IDictionary <Type, object> viewFactories) { this.root = root; this.dependencyResolver = dependencyResolver; this.modelFactories = modelFactories; this.viewFactories = viewFactories; }
// notice that the parent (as an interface called icontrolparent) is passed into the constructor. // we'll use this later so that we can navigate to other controls. public StudentHomeControl(IControlParent controlParent, int id) { InitializeComponent(); // create the store (the place where we get student data from) studentStore = StoreFactory.BuildStudentStore(); // load data for the student whose id was passed into the constructor-- // we only want to do this once when the screen loads so that we don't // have to call the database many times student = studentStore.GetStudentByUserId(id); // show the student's basic info at the top of the screen-- // this really just takes the student info we've already loaded and updates the screen; // it's often easier to wrap simple code like this into methods because it makes the // code much easier to read--your intent is clear from how you named the method ShowStudentBasicInfo(); // load the student's current course enrollments GetCurrentCourseEnrollments(); }
// Never returns the root as part of the path. public static EventPropagationPath FindPropagationPath(IControlParent root, Control leaf) { var parent = leaf.Parent; var path = new List <Control> { leaf }; while (parent != root) { if (!(parent is Control parentAsControl)) { // Tried creating path between unconnected controls. return(EventPropagationPath.Empty); } path.Add(parentAsControl); parent = parentAsControl.Parent; } path.Reverse(); return(new EventPropagationPath(path.AsReadOnly())); }
public void SetParent(IControlParent control) { Parent = control; }
public static bool IsDescendantOf(this Control control, IControlParent parent) { return(control.Parent == parent || (control.Parent is Control parentControl && parentControl.IsDescendantOf(parent))); }
public static T?FirstChildOfType <T>(this IControlParent parent) where T : class { return(parent.Children.OfType <T>().FirstOrDefault()); }
private static bool tryFindPropagationPathForAnyChild( IControlParent parent, PropagationTest propagationTest, List <Control> path) => parent.Children.Reverse() .Any(child => findPropagationPathUsingTest(child, propagationTest, path));
// Never returns the root as part of the path. public static EventPropagationPath FindPropagationPath(IControlParent root, PropagationTest propagationTest) => new EventPropagationPath(findPropagationPathUsingTest(root, propagationTest).AsReadOnly());
public void SetParent(IControlParent control) { _content.SetParent(control); }