示例#1
0
        private static List <Control> findPropagationPathUsingTest(IControlParent root, PropagationTest propagationTest)
        {
            var path = new List <Control>();

            tryFindPropagationPathForAnyChild(root, propagationTest, path);
            return(path);
        }
示例#2
0
        public InstructorHomeControl(IControlParent controlParent, int id)
        {
            InitializeComponent();

            instructorStore = StoreFactory.BuildInstructorStore();
            instructor      = instructorStore.GetInstructorById(id);

            ShowInstructorBasicInfo();
        }
示例#3
0
        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();
        }
示例#4
0
 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;
 }
示例#5
0
        // 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();
        }
示例#6
0
        // 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()));
        }
示例#7
0
 public void SetParent(IControlParent control)
 {
     Parent = control;
 }
示例#8
0
 public static bool IsDescendantOf(this Control control, IControlParent parent)
 {
     return(control.Parent == parent ||
            (control.Parent is Control parentControl && parentControl.IsDescendantOf(parent)));
 }
示例#9
0
 public static T?FirstChildOfType <T>(this IControlParent parent) where T : class
 {
     return(parent.Children.OfType <T>().FirstOrDefault());
 }
示例#10
0
 private static bool tryFindPropagationPathForAnyChild(
     IControlParent parent, PropagationTest propagationTest, List <Control> path) =>
 parent.Children.Reverse()
 .Any(child => findPropagationPathUsingTest(child, propagationTest, path));
示例#11
0
 // Never returns the root as part of the path.
 public static EventPropagationPath FindPropagationPath(IControlParent root, PropagationTest propagationTest) =>
 new EventPropagationPath(findPropagationPathUsingTest(root, propagationTest).AsReadOnly());
示例#12
0
 public void SetParent(IControlParent control)
 {
     _content.SetParent(control);
 }