コード例 #1
0
ファイル: EventRouter.cs プロジェクト: beardgame/ui
        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
ファイル: NavigationController.cs プロジェクト: Mattias1/ui
 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
ファイル: EventRouter.cs プロジェクト: beardgame/ui
        // 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
ファイル: ControlBase.cs プロジェクト: sleepless1/GameSharp
 public void SetParent(IControlParent control)
 {
     Parent = control;
 }
コード例 #8
0
ファイル: Extensions.cs プロジェクト: beardgame/ui
 public static bool IsDescendantOf(this Control control, IControlParent parent)
 {
     return(control.Parent == parent ||
            (control.Parent is Control parentControl && parentControl.IsDescendantOf(parent)));
 }
コード例 #9
0
ファイル: Extensions.cs プロジェクト: beardgame/ui
 public static T?FirstChildOfType <T>(this IControlParent parent) where T : class
 {
     return(parent.Children.OfType <T>().FirstOrDefault());
 }
コード例 #10
0
ファイル: EventRouter.cs プロジェクト: beardgame/ui
 private static bool tryFindPropagationPathForAnyChild(
     IControlParent parent, PropagationTest propagationTest, List <Control> path) =>
 parent.Children.Reverse()
 .Any(child => findPropagationPathUsingTest(child, propagationTest, path));
コード例 #11
0
ファイル: EventRouter.cs プロジェクト: beardgame/ui
 // 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);
 }