private void initFreeList()
        {
            FreeLoddingTextBlock.Text = "处理中...";
            FreeLoddingProgressBar.Value = 0;
            for (int i = 0; i < kb.Length; i++)
            {
                if (kb[i] != "")
                {
                    JObject obj = JObject.Parse(kb[i]);
                    if (Int32.Parse(obj["status"].ToString()) == 200)
                    {
                        JArray ClassListArray = Utils.ReadJso(kb[i]);
                        for (int j = 0; j < ClassListArray.Count; j++)
                        {
                            ClassList classitem = new ClassList();
                            classitem.GetAttribute((JObject)ClassListArray[j]);
                            Debug.WriteLine(Array.IndexOf(classitem.Week, week));
                            if (Array.IndexOf(classitem.Week, week) != -1)
                            {
                                freeclasstime[classitem.Hash_day, classitem.Hash_lesson] = 1;
                            }
                        }
                    }
                }
                FreeLoddingProgressBar.Value = FreeLoddingProgressBar.Value + 100.0 / muIdList.Count;
                Debug.WriteLine(FreeLoddingProgressBar.Value);
            }
            FreeLoddingStackPanel.Visibility = Visibility.Collapsed;

            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    if (freeclasstime[i, j] == 0)
                    {
                        FreeList ft = new FreeList();
                        ft.vis = 1;
                        ft.weekday = i;
                        mFreeList.Add(ft);
                        break;
                    }
                }

                for (int j = 0; j < 6; j++)
                {
                    if (freeclasstime[i, j] == 0)
                    {
                        FreeList fc = new FreeList();
                        fc.vis = 0;
                        fc.time = j;
                        mFreeList.Add(fc);
                    }
                }
            }
        }
        /// <summary>
        /// 课程格子的填充
        /// </summary>
        /// <param name="item">ClassList类型的item</param>
        /// <param name="ClassColor">颜色数组,0~9</param>
        private void SetClass(ClassList item, int ClassColor)
        {

            Color[] colors = new Color[]{
                   //Color.FromArgb(255,132, 191, 19),
                   //Color.FromArgb(255,67, 182, 229),
                   //Color.FromArgb(255,253, 137, 1),
                   //Color.FromArgb(255,128, 79, 242),
                   //Color.FromArgb(255,240, 68, 189),
                   //Color.FromArgb(255,229, 28, 35),
                   //Color.FromArgb(255,156, 39, 176),
                   //Color.FromArgb(255,3, 169, 244),
                   //Color.FromArgb(255,255, 193, 7),
                   //Color.FromArgb(255,255, 152, 0),
                   //Color.FromArgb(255,96, 125, 139),
                   Color.FromArgb(255,255, 161, 16),
                   Color.FromArgb(255,56, 188, 242),
                   Color.FromArgb(255,159, 213, 27),
                };

            TextBlock ClassTextBlock = new TextBlock();

            ClassTextBlock.Text = item.Course + "\n" + item.Classroom + "\n" + item.Teacher;
            ClassTextBlock.Foreground = this.Foreground;
            ClassTextBlock.FontSize = 12;
            ClassTextBlock.TextWrapping = TextWrapping.WrapWholeWords;
            ClassTextBlock.VerticalAlignment = VerticalAlignment.Center;
            ClassTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            ClassTextBlock.Margin = new Thickness(3);
            ClassTextBlock.MaxLines = 6;

            Grid BackGrid = new Grid();
            BackGrid.Background = new SolidColorBrush(colors[ClassColor]);
            BackGrid.SetValue(Grid.RowProperty, System.Int32.Parse(item.Hash_lesson * 2 + ""));
            BackGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(item.Hash_day + ""));
            BackGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(item.Period + ""));

            BackGrid.Children.Add(ClassTextBlock);

            if (classtime[item.Hash_day, item.Hash_lesson] != null)
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri("ms-appx:///Assets/shape.png", UriKind.Absolute));
                img.VerticalAlignment = VerticalAlignment.Bottom;
                img.HorizontalAlignment = HorizontalAlignment.Right;
                img.Width = 10;
                BackGrid.Children.Add(img);

                string[] temp = classtime[item.Hash_day, item.Hash_lesson];
                string[] tempnew = new string[temp.Length + 1];
                for (int i = 0; i < temp.Length; i++)
                    tempnew[i] = temp[i];
                tempnew[temp.Length] = item._Id;
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }
            else
            {
                string[] tempnew = new string[1];
                tempnew[0] = item._Id;
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }

            BackGrid.Tapped += BackGrid_Tapped;
            kebiaoGrid.Children.Add(BackGrid);
        }
        /// <summary>
        /// 显示课表
        /// </summary>
        /// <param name="weekOrAll">1学期课表;2周课表</param>
        /// <param name="week">指定课表周次,默认0为本周</param>
        private void showKB(int weekOrAll = 1, int week = 0)
        {
            for (int i = 0; i < 7; i++)
                for (int j = 0; j < 6; j++)
                    classtime[i, j] = null;


            kebiaoGrid.Children.Clear();
            SetKebiaoGridBorder(week);
            classList.Clear();
            JArray ClassListArray = Utils.ReadJso(kb);
            int ColorI = 0;
            for (int i = 0; i < ClassListArray.Count; i++)
            {
                ClassList classitem = new ClassList();
                classitem.GetAttribute((JObject)ClassListArray[i]);
                classList.Add(classitem);
                int ClassColor = 0;
                if (!colorlist.ContainsKey(classitem.Course))
                {
                    colorlist[classitem.Course] = ColorI;
                    ClassColor = ColorI;
                    ColorI++;
                    if (ColorI > 2)
                        ColorI = 0;
                }
                else
                {
                    ClassColor = System.Int32.Parse(colorlist[classitem.Course].ToString());
                }
                if (weekOrAll == 1)
                {
                    SetClass(classitem, ClassColor);
                    HubSectionKBNum.Visibility = Visibility.Collapsed;
                }
                else
                {
                    HubSectionKBNum.Visibility = Visibility.Visible;
                    if (week == 0)
                    {
                        if (Array.IndexOf(classitem.Week, Int32.Parse(appSetting.Values["nowWeek"].ToString())) != -1)
                        {
                            SetClass(classitem, ClassColor);
                            HubSectionKBNum.Text = "第" + appSetting.Values["nowWeek"].ToString() + "周";
                        }
                    }
                    else
                    {
                        if (Array.IndexOf(classitem.Week, week) != -1)
                        {
                            SetClass(classitem, ClassColor);
                            HubSectionKBNum.Text = "第" + week.ToString() + "周";
                        }
                    }
                }
            }
            colorlist.Clear();

        }
Пример #4
0
        /// <summary>
        /// 周视图课程格子的填充
        /// </summary>
        /// <param name="item">ClassList类型的item</param>
        /// <param name="ClassColor">颜色数组,0~9</param>
        private void SetClassAll(ClassList item, int ClassColor)
        {
            //有事项的画个角- -
            //foreach (var transactionItem in transationList) {
            //    if (item.Week == transactionItem.week && item.Lesson == transactionItem.classToLesson)
            //    {

            //    }
            //}

            Color[] colors = new Color[]{
                   //Color.FromArgb(255,132, 191, 19),
                   //Color.FromArgb(255,67, 182, 229),
                   //Color.FromArgb(255,253, 137, 1),
                   //Color.FromArgb(255,128, 79, 242),
                   //Color.FromArgb(255,240, 68, 189),
                   //Color.FromArgb(255,229, 28, 35),
                   //Color.FromArgb(255,156, 39, 176),
                   //Color.FromArgb(255,3, 169, 244),
                   //Color.FromArgb(255,255, 193, 7),
                   //Color.FromArgb(255,255, 152, 0),
                   //Color.FromArgb(255,96, 125, 139),
                   Color.FromArgb(255,255, 161, 16),
                   Color.FromArgb(255,56, 188, 242),
                   Color.FromArgb(255,159, 213, 27),
                   Color.FromArgb(255,200, 200, 200), //灰色
                };

            //折叠角的颜色数组
            Color[] _color = new Color[] {
                Color.FromArgb(255,255,219,178),
                Color.FromArgb(255,162,229,255),
                Color.FromArgb(255,155,244,244),
            };

            TextBlock ClassTextBlock = new TextBlock();

            ClassTextBlock.Text = item.Course + "\n" + item.Classroom + "\n" + item.Teacher;
            ClassTextBlock.Foreground = new SolidColorBrush(Colors.White);
            ClassTextBlock.FontSize = 12;
            ClassTextBlock.TextWrapping = TextWrapping.WrapWholeWords;
            ClassTextBlock.VerticalAlignment = VerticalAlignment.Center;
            ClassTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            ClassTextBlock.Margin = new Thickness(3);
            ClassTextBlock.MaxLines = 6;

            Grid BackGrid = new Grid();
            BackGrid.Background = new SolidColorBrush(colors[ClassColor]);
            BackGrid.SetValue(Grid.RowProperty, System.Int32.Parse(item.Hash_lesson * 2 + ""));
            BackGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(item.Hash_day + ""));
            BackGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(item.Period + ""));
            BackGrid.Margin = new Thickness(0.5);
            BackGrid.Children.Add(ClassTextBlock);

            //TODO:新增 折叠三角
            if (classtime[item.Hash_day, item.Hash_lesson] != null)
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri("ms-appx:///Assets/shape.png", UriKind.Absolute));
                img.VerticalAlignment = VerticalAlignment.Bottom;
                img.HorizontalAlignment = HorizontalAlignment.Right;
                img.Width = 10;

                //他要折叠..我画一个三角好了..
                Grid _grid = new Grid();
                Polygon pl = new Polygon();
                PointCollection collection = new PointCollection();
                collection.Add(new Point(0, 0));
                collection.Add(new Point(10, 0));
                collection.Add(new Point(0, 10));
                pl.Points = collection;
                pl.Stroke = new SolidColorBrush(Colors.Black);
                pl.StrokeThickness = 0;
                _grid.Children.Add(pl);
                _grid.Background = new SolidColorBrush(_color[ClassColor]);
                _grid.Width = 10;
                _grid.Height = 10;
                _grid.VerticalAlignment = VerticalAlignment.Bottom;
                _grid.HorizontalAlignment = HorizontalAlignment.Right;
                BackGrid.Children.Add(_grid);

                BackGrid.Children.Add(img);

                string[] temp = classtime[item.Hash_day, item.Hash_lesson];
                string[] tempnew = new string[temp.Length + 1];
                for (int i = 0; i < temp.Length; i++)
                    tempnew[i] = temp[i];
                tempnew[temp.Length] = item._Id;
                Debug.WriteLine("if~id->" + item._Id);
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }
            else
            {
                string[] tempnew = new string[1];
                tempnew[0] = item._Id;
                Debug.WriteLine("else~id->" + item._Id);
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }

            BackGrid.Tapped += BackGrid_Tapped;
            kebiaoGrid.Children.Add(BackGrid);
        }
Пример #5
0
        /// <summary>
        /// 日视图课程格子的填充
        /// </summary>
        /// <param name="classitem"></param>
        private void SetClassDay(ClassList classitem)
        {
            Grid BackGrid = new Grid();
            BackGrid.Background = new SolidColorBrush(Color.FromArgb(255, 88, 179, 255));
            //BackGrid.Background = new SolidColorBrush(Colors.Wheat);
            BackGrid.SetValue(Grid.RowProperty, System.Int32.Parse(classitem.Hash_lesson * 2 + ""));
            BackGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(classitem.Hash_day + ""));
            BackGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(classitem.Period + ""));

            StackPanel BackStackPanel = new StackPanel();
            BackStackPanel.Margin = new Thickness(15);
            BackStackPanel.VerticalAlignment = VerticalAlignment.Center;

            TextBlock classNameTextBlock = new TextBlock();
            classNameTextBlock.Text = classitem.Course;
            classNameTextBlock.FontSize = 20;
            classNameTextBlock.Margin = new Thickness(0, 3, 0, 3);
            classNameTextBlock.Foreground = new SolidColorBrush(Colors.White);


            StackPanel classTeaStackPanel = new StackPanel();
            Image classTeaImage = new Image();
            TextBlock classTeaTextBlock = new TextBlock();
            classTeaImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/dialog_course_peo_white.png", UriKind.Absolute));
            classTeaImage.Width = 15;
            classTeaImage.Height = 15;
            classTeaTextBlock.Text = classitem.Teacher;
            classTeaTextBlock.FontSize = 15;
            classTeaTextBlock.Margin = new Thickness(10, 0, 0, 0);
            classTeaTextBlock.Foreground = new SolidColorBrush(Colors.White);
            classTeaStackPanel.Orientation = Orientation.Horizontal;
            classTeaStackPanel.Children.Add(classTeaImage);
            classTeaStackPanel.Children.Add(classTeaTextBlock);
            classTeaStackPanel.Margin = new Thickness(0, 3, 0, 3);


            StackPanel classAddStackPanel = new StackPanel();
            Image classAddImage = new Image();
            TextBlock classAddTextBlock = new TextBlock();
            classAddImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/dialog_course_add_white.png", UriKind.Absolute));
            classAddImage.Width = 15;
            classAddImage.Height = 15;
            classAddTextBlock.Text = classitem.Classroom;
            classAddTextBlock.FontSize = 15;
            classAddTextBlock.Margin = new Thickness(10, 0, 0, 0);
            classAddTextBlock.Foreground = new SolidColorBrush(Colors.White);
            classAddStackPanel.Orientation = Orientation.Horizontal;
            classAddStackPanel.Children.Add(classAddImage);
            classAddStackPanel.Children.Add(classAddTextBlock);
            classAddStackPanel.Margin = new Thickness(0, 3, 0, 3);

            StackPanel classTypeStackPanel = new StackPanel();
            Image classTypeImage = new Image();
            TextBlock classTypeTextBlock = new TextBlock();
            classTypeImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/dialog_course_type_white.png", UriKind.Absolute));
            classTypeImage.Width = 15;
            classTypeImage.Height = 15;
            classTypeTextBlock.Text = classitem.Type;
            classTypeTextBlock.FontSize = 15;
            classTypeTextBlock.Margin = new Thickness(10, 0, 0, 0);
            classTypeTextBlock.Foreground = new SolidColorBrush(Colors.White);
            classTypeStackPanel.Orientation = Orientation.Horizontal;
            classTypeStackPanel.Children.Add(classTypeImage);
            classTypeStackPanel.Children.Add(classTypeTextBlock);
            classTypeStackPanel.Margin = new Thickness(0, 3, 0, 3);

            BackStackPanel.Children.Add(classNameTextBlock);
            BackStackPanel.Children.Add(classTeaStackPanel);
            BackStackPanel.Children.Add(classAddStackPanel);
            BackStackPanel.Children.Add(classTypeStackPanel);

            BackGrid.Children.Add(BackStackPanel);

            KebiaoDayGrid.Children.Add(BackGrid);
        }
Пример #6
0
        private void showKB(int weekOrAll = 1, int week = 0, string transactioncontent = null)
        {
            for (int i = 0; i < 7; i++)
                for (int j = 0; j < 6; j++)
                    classtime[i, j] = null;

            for (int i = 0; i < 7; i++)
                for (int j = 0; j < 6; j++)
                    transactiontime[i, j] = null;

            var vault = new Windows.Security.Credentials.PasswordVault();
            var credentialList = vault.FindAllByResource(resourceName);
            credentialList[0].RetrievePassword();
            if (stuNum == credentialList[0].UserName)
                GetTransaction(transactioncontent);

            kebiaoGrid.Children.Clear();
            SetKebiaoGridBorder(week);
            classList.Clear();
            JArray ClassListArray = Utils.ReadJso(kb);
            int ColorI = 0;
            for (int i = 0; i < ClassListArray.Count; i++)
            {
                ClassList classitem = new ClassList();
                classitem.GetAttribute((JObject)ClassListArray[i]);
                classList.Add(classitem);
                int ClassColor = 0;
                if (!colorlist.ContainsKey(classitem.Course))
                {
                    colorlist[classitem.Course] = ColorI;
                    ClassColor = ColorI;
                    ColorI++;
                    if (ColorI > 2)
                        ColorI = 0;
                }
                else
                {
                    ClassColor = System.Int32.Parse(colorlist[classitem.Course].ToString());
                }
                if (weekOrAll == 1)
                {
                    //if (bool.Parse(appSetting.Values["AllKBGray"].ToString()))
                    //    if (Array.IndexOf(classitem.Week, Int32.Parse(appSetting.Values["nowWeek"].ToString())) != -1)
                    //        SetClassAll(classitem, ClassColor);
                    //    else
                    //        SetClassAll(classitem, 3);
                    //else
                    SetClassAll(classitem, ClassColor);
                    SetTransactionAll(transationList, classList);
                    HubSectionKBNum.Visibility = Visibility.Collapsed;
                }
                else
                {
                    HubSectionKBNum.Visibility = Visibility.Visible;
                    if (week == 0)
                    {
                        if (Array.IndexOf(classitem.Week, Int32.Parse(appSetting.Values["nowWeek"].ToString())) != -1)
                        {
                            SetClassAll(classitem, ClassColor);
                            if (transationList.Count != 0)
                                SetTransactionDay(transationList, classList);

                            HubSectionKBNum.Text = " | 第" + appSetting.Values["nowWeek"].ToString() + "周";
                        }
                    }
                    else
                    {
                        if (Array.IndexOf(classitem.Week, week) != -1)
                        {
                            SetClassAll(classitem, ClassColor);
                            HubSectionKBNum.Text = " | 第" + week.ToString() + "周";
                        }
                        SetTransactionDay(transationList, classList, week);
                    }
                }
            }

            KebiaoDayGrid.Children.Clear();
            //这特么在逗我
            //if (transationList.Count != 0)
            //   SetTransactionDay(transationList, classList);

            //当日课表显示
            for (int i = 0; i < ClassListArray.Count; i++)
            {
                ClassList classitem = new ClassList();
                classitem.GetAttribute((JObject)ClassListArray[i]);
                //#if DEBUG
                //                if (Array.IndexOf(classitem.Week, 5) != -1 && classitem.Hash_day == 2)
                //                {
                //                    SetClassDay(classitem);
                //                }
                //#else
                if (Array.IndexOf(classitem.Week, Int32.Parse(appSetting.Values["nowWeek"].ToString())) != -1 && classitem.Hash_day == (Int16.Parse(Utils.GetWeek()) + 6) % 7)
                {
                    SetClassDay(classitem);
                }
                //#endif
            }

            colorlist.Clear();
        }