示例#1
0
 private static bool EqualsTime(Coursedata Course, DateTime SetTime)
 {
     if (Coursedata.是否在课程周数内(Course.NewCourseTime, SetTime) && Coursedata.是否在课程星期内(Course.NewCourseTime, SetTime) && Coursedata.是否在课程节数内(Course.NewCourseTime, SetTime))//判断周数符合//判断星期符合//判断节符合
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
        /// <summary>
        /// JSON房间信息处理
        /// </summary>
        static private List <RoomData> Serialize(string JsonRoomsData)
        {
            /*反序列化出ROOMS的数组*/
            JObject jObject = (JObject)JsonConvert.DeserializeObject(JsonRoomsData);
            JArray  jArray  = (JArray)jObject["rooms"];

            List <RoomData> rooms = new List <RoomData>();

            foreach (var item in jArray)
            {
                /*反序列化出course课程*/
                JObject jOcourse = (JObject)JsonConvert.DeserializeObject(item.ToString());
                JArray  jAcourse = (JArray)jOcourse["courses"];

                List <Coursedata> courselist = new List <Coursedata>();
                foreach (var Courseitem in jAcourse)
                {
                    Coursedata course = new Coursedata
                    {
                        TeacherName  = Courseitem["courseTeacher"].ToString(),
                        CourseName   = Courseitem["courseName"].ToString(),
                        CourseTime   = Courseitem["courseTime"].ToString(),
                        CourseNum    = Courseitem["courseNum"].ToString(),
                        CourseChange = Courseitem["courseChange"].ToString()
                    };
                    courselist.Add(course);
                }
                RoomData room = new RoomData
                {
                    RoomNum     = (((JObject)item)["number"]).ToString(),
                    Coursedates = courselist
                };
                rooms.Add(room);
            }
            return(rooms);
        }
示例#3
0
        private void CreateView(RoomData Room)
        {
            Week = TimeTools.计算当前周(((MainActivity)Context).conditions.Time);
            RelativeLayout day;
            int            CourseCount = 0;

            foreach (var Course in Room.Coursedates)
            {
                switch (Course.NewCourseTime.星期)
                {
                case DayOfWeek.Monday: day = (RelativeLayout)dialogView.FindViewById(Resource.Id.monday); break;

                case DayOfWeek.Tuesday: day = (RelativeLayout)dialogView.FindViewById(Resource.Id.tuesday); break;

                case DayOfWeek.Wednesday: day = (RelativeLayout)dialogView.FindViewById(Resource.Id.wednesday); break;

                case DayOfWeek.Thursday: day = (RelativeLayout)dialogView.FindViewById(Resource.Id.thursday); break;

                case DayOfWeek.Friday: day = (RelativeLayout)dialogView.FindViewById(Resource.Id.friday); break;

                case DayOfWeek.Saturday: day = (RelativeLayout)dialogView.FindViewById(Resource.Id.saturday); break;

                case DayOfWeek.Sunday: day = (RelativeLayout)dialogView.FindViewById(Resource.Id.weekday); break;

                default: day = (RelativeLayout)dialogView.FindViewById(Resource.Id.weekday); break;
                }
                for (var count = 0; count < day.ChildCount; count++)
                {
                    var V = day.GetChildAt(count);
                    var 节 = (PxToDp((int)V.GetY()) + 10) / CardHeight + 1;
                    if (节 == Course.NewCourseTime.节[0])//重合
                    {
                        #region 把这节课添加到这个卡片里面
                        V.Tag += "/" + CourseCount;
                        #endregion
                        #region 设定显示的卡片
                        #endregion
                        goto cc;
                    }
                }
                CardView view = (CardView)LayoutInflater.From(Context).Inflate(Resource.Layout.Detail_CourseCard, null);                                                                                        //加载单个课程布局
                view.SetY(DpToPx(CardHeight) * (Course.NewCourseTime.节[0] - 1));                                                                                                                                //设置开始高度,即第几节课开始
                LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, (Course.NewCourseTime.节.Last() - Course.NewCourseTime.节.First() + 1) * DpToPx(CardHeight) - 2); //设置布局高度,即跨多少节课
                view.LayoutParameters = p;
                TextView text = view.FindViewById <TextView>(Resource.Id.text_view);
                text.Text = Course.CourseName + "\n" + Course.TeacherName; //显示课程名
                if (Coursedata.是否在课程周数内(Course.NewCourseTime, Week))
                {
                    view.SetCardBackgroundColor(Android.Graphics.Color.ParseColor("#6495ED"));
                }
                view.Tag    = CourseCount.ToString();
                view.Click += (object sender, EventArgs e) =>
                {
                    string[] ClassTag = ((CardView)sender).Tag.ToString().Split("/");
                    if (ClassTag.Length > 1)
                    {
                        var      Tag = int.Parse(ClassTag[1]);
                        TextView T   = view.FindViewById <TextView>(Resource.Id.text_view);
                        T.Text = NowRoom.Coursedates[Tag].CourseName + "\n" + NowRoom.Coursedates[Tag].TeacherName + "\n" + NowRoom.Coursedates[Tag].CourseTime;
                        var FirstTag = ClassTag[0];
                        for (var count = 0; count < ClassTag.Length - 1; count++)
                        {
                            ClassTag[count] = ClassTag[count + 1];
                        }
                        ClassTag[ClassTag.Length - 1] = FirstTag;
                        string NewTag = string.Empty;
                        foreach (var t in ClassTag)
                        {
                            NewTag += t + "/";
                        }
                        ((CardView)sender).Tag = NewTag.Substring(0, NewTag.Length - 1);
                    }
                };
                day.AddView(view);
                cc : CourseCount++;
            }
        }