public AnswerData GetSchedule(DateTime date) { HttpWebResponse response = _getSchedule(date); StreamReader sr = new StreamReader(response.GetResponseStream()); string data = sr.ReadToEnd(); sr.Close(); response.Close(); //Deserialize data to anser object JObject jsonObj = JObject.Parse(data); AnswerData answer = new AnswerData( (Status)Enum.Parse(typeof(Status), jsonObj.Value<string>("status"), true), jsonObj["data"].Value<int>("week_number"), jsonObj["data"].Value<string>("day") ); if (answer.Status == Status.Success) { foreach (JToken tLesson in jsonObj["data"].Value<JArray>("lessons").Children()) { Lesson lesson = new Lesson( tLesson.Value<string>("time"), tLesson.Value<string>("place"), tLesson.Value<string>("subject"), tLesson.Value<string>("person_name") ); answer.Lessons.Add(lesson); } } return answer; }
private void _renderLesson(Lesson lesson) { Panel lessonPanel = new Panel(); lessonPanel.Width = mainSchedulePanel.Width; lessonPanel.Height = _lessonControlHeight; //Time Label timeLabel = new Label(); timeLabel.Location = new Point(0, 0); timeLabel.Width = lessonPanel.Width / 5; timeLabel.Height = lessonPanel.Height; timeLabel.TextAlign = ContentAlignment.MiddleCenter; timeLabel.BorderStyle = BorderStyle.Fixed3D; timeLabel.BackColor = Color.White; timeLabel.Text = lesson.Time; lessonPanel.Controls.Add(timeLabel); //Place Label placeLabel = new Label(); placeLabel.Location = new Point(lessonPanel.Width / 5, 0); placeLabel.Width = lessonPanel.Width / 5; placeLabel.Height = lessonPanel.Height; placeLabel.TextAlign = ContentAlignment.MiddleCenter; placeLabel.BorderStyle = BorderStyle.Fixed3D; placeLabel.BackColor = Color.White; placeLabel.Text = lesson.Place; lessonPanel.Controls.Add(placeLabel); //Subject TextBox subjectTextBox = new TextBox(); subjectTextBox.Multiline = true; subjectTextBox.ScrollBars = ScrollBars.Vertical; subjectTextBox.Location = new Point(lessonPanel.Width * 2 / 5, 0); subjectTextBox.Width = lessonPanel.Width * 2 / 5; subjectTextBox.Height = lessonPanel.Height; subjectTextBox.TextAlign = HorizontalAlignment.Left; subjectTextBox.Text = lesson.Subject; lessonPanel.Controls.Add(subjectTextBox); //Person Label personLabel = new Label(); personLabel.Location = new Point(lessonPanel.Width * 4 / 5, 0); personLabel.Width = lessonPanel.Width / 5; personLabel.Height = lessonPanel.Height; personLabel.TextAlign = ContentAlignment.MiddleCenter; personLabel.BorderStyle = BorderStyle.Fixed3D; personLabel.BackColor = Color.White; personLabel.Text = lesson.PersonName; lessonPanel.Controls.Add(personLabel); //Render panel lessonPanel.Location = new Point(0, lessonPanel.Height * mainSchedulePanel.Controls.Count); this.Height += lessonPanel.Height; _setPopupFormLocation(); mainSchedulePanel.Height += lessonPanel.Height; mainSchedulePanel.Controls.Add(lessonPanel); }