Ejemplo n.º 1
0
        private async void LoadDataAsync(object sender, RoutedEventArgs e)
        {
            vm.LoadCourses(await AAOAPI.RequestInfomation("学生课程表"));

            BindingOperations.SetBinding(comboBox1, ComboBox.SelectedIndexProperty, new Binding()
            {
                Source = vm,
                Path   = new PropertyPath("Week"),
                Mode   = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });

            for (var cno = 1; cno <= 6; ++cno)
            {
                for (var weekday = 1; weekday <= 7; ++weekday)
                {
                    var text = new TextBlock()
                    {
                        Foreground          = new SolidColorBrush(Colors.White),
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center
                    };
                    Grid.SetColumn(text, weekday);
                    Grid.SetRow(text, cno);
                    CoursesContainer.Children.Add(text);
                    BindingOperations.SetBinding(text, TextBlock.TextProperty, new Binding()
                    {
                        Source = vm[weekday - 1][cno - 1],
                        Path   = new PropertyPath("Text"),
                        Mode   = BindingMode.OneWay,
                        UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                    });
                }
            }
        }
Ejemplo n.º 2
0
        public AAO()
        {
            this.InitializeComponent();

            login.Refresh += async(sender, e) => {
                return(await AAOAPI.CaptchaImage());
            };

            login.Submit += async(sender, e) => {
                var reason = await AAOAPI.Login(e.username, e.password, e.captcha);

                if (!String.IsNullOrEmpty(reason))
                {
                    await Dialogs.Popup("错误", reason);

                    return(false);
                }
                return(true);
            };
        }
        private async void LoadDataAsync(object sender, RoutedEventArgs e)
        {
            vm.LoadGrades(await AAOAPI.RequestInfomation("学生成绩查询"));

            int row = 1, col;

            vm.Grades.Select(grade => grade.Serialize()).ForEach((list) => {
                col = 0;
                list.ForEach((prop) => {
                    var block = new TextBlock()
                    {
                        Text                = prop,
                        Foreground          = new SolidColorBrush(Colors.White),
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center
                    };
                    Grid.SetColumn(block, col++);
                    Grid.SetRow(block, row);
                    gradesContainer.Children.Add(block);
                });
                ++row;
            });
        }
Ejemplo n.º 4
0
        private async void Logout(object sender, RoutedEventArgs e)
        {
            await AAOAPI.Logout(login.UserName, login.Password);

            await login.ClearState();
        }