public ViewDocumentWindow(Project project)
        {
            _dbHelper = project.DbHelper;
            _timeTableCaretaker = project.TimeTableCaretaker;

            InitializeComponent();
            DataContext = this;
            var state = _timeTableCaretaker.GetState();
            FirstWeek = state.FirstWeek;
            SecondWeek = state.SecondWeek;
        }
        public ViewDocumentWindow(Project project)
        {
            _project = project;
            _excelHelper = project.ExcelHelper;
            _timeTableCaretaker = new TimeTableCaretaker();
            _timeTableCaretaker.SaveState(project);

            InitializeComponent();
            DataContext = this;

            FirstWeek = project.FirstWeek;
            SecondWeek = project.SecondWeek;
        }
示例#3
0
        private Week GetWeekFromXml(XElement weekXml)
        {
            var resultWeek = new Week
            {
                Name = weekXml.Element(WeekName).Value,
                Days = new List<Day>()
            };

            foreach (var dayXml in weekXml.Elements(Day))
            {
                var resultDay = GetDayFromXml(dayXml);

                resultWeek.Days.Add(resultDay);
            }
            return resultWeek;
        }
        private void Control_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var dataGrid = (DataGrid) sender;
            
            var day = (Day) dataGrid.SelectedItem;
            if (day == null)
            {
                return;
            }

            var editShowWindow = new EditDayWindow(day);

            if (editShowWindow.ShowDialog() == false)
            {
                var memento = _timeTableCaretaker.GetState();
                FirstWeek = memento.FirstWeek;
                SecondWeek = memento.SecondWeek;
            }

            CheckWeek(FirstWeek);
            CheckWeek(SecondWeek);

            SaveState();
        }
 private void CheckWeek(Week week)
 {
     foreach (var day in week.Days)
     {
         for (var i = 0; i < day.ListOfLessons.Count; i++)
         {
             var lesson = day.ListOfLessons[i];
             if (string.IsNullOrEmpty(lesson.Name) &&
                 string.IsNullOrEmpty(lesson.Classroom) &&
                 string.IsNullOrEmpty(lesson.Teacher) &&
                 string.IsNullOrEmpty(lesson.StartTime))
             {
                 day.ListOfLessons.Remove(lesson);
                 i--;
             }
         }
     }
 }
示例#6
0
 public TimeTableMemento(Week firstWeek, Week secondWeek, ExcelHelper excelHelper)
 {
     ExcelHelper = excelHelper;
     FirstWeek = firstWeek;
     SecondWeek = secondWeek;
 }
示例#7
0
        private XElement GetWeekToXml(Week week)
        {
            var weekXml = new XElement(Week);

            weekXml.Add(new XElement(WeekName, week.Name));

            foreach (var day in week.Days)
            {
                var dayXml = GetDayToXml(day);

                weekXml.Add(dayXml);
            }

            return weekXml;
        }
示例#8
0
 public TimeTableMemento(Week firstWeek, Week secondWeek)
 {
     FirstWeek = firstWeek;
     SecondWeek = secondWeek;
 }