コード例 #1
0
 public sClassRecord(ClassRecord classRecord, sSchedule schedule) : base(classRecord)
 {
     if (classRecord == null)
     {
         return;
     }
     Subject   = classRecord.Subject == null ? null : schedule.sDictionaries.Subjects[classRecord.Subject.GetHashCode()];
     Lecturer  = classRecord.Lecturer == null ? null : schedule.sDictionaries.Lecturers[classRecord.Lecturer.GetHashCode()];
     Classroom = classRecord.Classroom == null ? null : schedule.sDictionaries.Classrooms[classRecord.Classroom.GetHashCode()];
     ClassTime = classRecord.ClassTime == null ? null : schedule.sDictionaries.TimeLine[classRecord.ClassTime.GetHashCode()];
     Group     = classRecord.Group == null ? null : schedule.sDictionaries.Groups[classRecord.Group.GetHashCode()];
 }
コード例 #2
0
ファイル: Elements.cs プロジェクト: lada-gagina/Schedule
 public static void Copy(ClassRecord from, ClassRecord to)
 {
     if (from == null || to == null)
     {
         return;
     }
     to.Subject   = from.Subject;
     to.Group     = from.Group;
     to.Lecturer  = from.Lecturer;
     to.Classroom = from.Classroom;
     to.ClassTime = from.ClassTime;
 }
コード例 #3
0
ファイル: ClassesTable.cs プロジェクト: lada-gagina/Schedule
        public ClassRecord SetClass(int timeIndex, int subjectIndex, ClassRecord classRecord)
        {
            if (!AreIndexesCorrect(timeIndex, subjectIndex))
            {
                return(null);
            }
            var subject = Subjects[subjectIndex];
            var time    = Schedule.TimeLine[timeIndex];

            if (TableDictionary[subject].ContainsKey(time))
            {
                Schedule.RemoveClass(TableDictionary[subject][time]);
            }
            SetSubject(classRecord, subject);
            classRecord.ClassTime = time;
            Schedule.AddClass(classRecord);
            TableDictionary[subject][time] = classRecord;
            return(classRecord);
        }
コード例 #4
0
ファイル: ScheduleRepository.cs プロジェクト: GorelH/Schedule
 //        private void InitClasses()
 //        {
 //            Schedule.CreateNewTables();
 //            foreach (var classesTable in Schedule.Tables)
 //            {
 //                int classCount = classesTable.Groups.Count() * Schedule.TimeLine.Count;
 //                for (int i = 0; i < classCount; i++)
 //                {
 //                    Subject s = Schedule.Subjects[Rnd.Next(Schedule.Subjects.Count)];
 //                    Lecturer l = Schedule.Lecturers[Rnd.Next(Schedule.Lecturers.Count)];
 //                    Classroom c = Schedule.Classrooms[Rnd.Next(Schedule.Classrooms.Count)];
 //
 //                    var timeIndex = Rnd.Next(Schedule.TimeLine.Count);
 //                    var groupIndex = Rnd.Next(classesTable.Groups.Count());
 //
 //                    if (classesTable.Table[timeIndex][groupIndex] == null)
 //                    {
 //                        classesTable.Table[timeIndex][groupIndex] = new ClassRecord
 //                        {
 //                            Subject = s,
 //                            Lecturer = l,
 //                            Classroom = c
 //                        };
 //                    }
 //
 //                }
 //            }
 //            
 //        }
 private void InitClasses()
 {
     //int classCount = Schedule.Groups.Count() * Schedule.TimeLine.Count;
     foreach (var classTime in Schedule.TimeLine)
     {
         foreach (var @group in Schedule.Groups)
         {
             Subject s = Schedule.Subjects[Rnd.Next(Schedule.Subjects.Count)];
             Lecturer l = Schedule.Lecturers[Rnd.Next(Schedule.Lecturers.Count)];
             Classroom c = Schedule.Classrooms[Rnd.Next(Schedule.Classrooms.Count)];
             if (Rnd.Next(100) < 40) continue;
                 var @class = new ClassRecord
                 {
                     Classroom = c,
                 Group = @group,
                     Subject = s,
                     Lecturer = l,
                     ClassTime = classTime
                 };
                 Schedule.ClassRecords.Add(@class);
         }
     }
 }
コード例 #5
0
 public void RemoveClass(ClassRecord classRecord)
 {
     ClassRecords.Remove(classRecord);
 }
コード例 #6
0
 public void AddClass(ClassRecord classRecord)
 {
     ClassRecords.Add(classRecord);
 }
コード例 #7
0
ファイル: Elements.cs プロジェクト: GorelH/Schedule
 protected bool Equals(ClassRecord other)
 {
     return Equals(_subject, other._subject) && Equals(_group, other._group) && Equals(_lecturer, other._lecturer) && Equals(_classroom, other._classroom) && Equals(_classTime, other._classTime);
 }
コード例 #8
0
ファイル: Elements.cs プロジェクト: GorelH/Schedule
 public static void Copy(ClassRecord from, ClassRecord to)
 {
     if (from == null || to == null) return;
     to.Subject = from.Subject;
     to.Group = from.Group;
     to.Lecturer = from.Lecturer;
     to.Classroom = from.Classroom;
     to.ClassTime = from.ClassTime;
 }
コード例 #9
0
ファイル: Schedule.cs プロジェクト: GorelH/Schedule
 public void RemoveClass(ClassRecord classRecord)
 {
     ClassRecords.Remove(classRecord);
 }
コード例 #10
0
ファイル: TableViewModel.cs プロジェクト: GorelH/Schedule
        private void OnCutClass()
        {
            if (_selectedCard == null || _selectedCard.Class == null) return;
            var classCard = ClassesCards[_selectedRow][_selectedColumn];
            if (classCard == null) return;
            var row = Grid.GetRow(classCard) - TitleRowsCount;
            var col = Grid.GetColumn(classCard) - TimeColumnsCount;

            var @class = new ClassRecord();
            ClassRecord.Copy(_groupClasses.GetClass(row, col), @class);
            ClipboardService.SetData(@class);

            var vmodel = classCard.DataContext as ClassCardViewModel;
            if (vmodel == null) return;

            vmodel.Class = null;
            _groupClasses.RemoveClass(row, col);
        }
コード例 #11
0
ファイル: GroupClasses.cs プロジェクト: lada-gagina/Schedule
 protected override void SetSubject(ClassRecord classRecord, Group subject)
 {
     classRecord.Group = subject;
 }
コード例 #12
0
ファイル: GroupClasses.cs プロジェクト: lada-gagina/Schedule
//        public void AddGroup(Group group)
//        {
//            if (group == null || group.YearOfStudy != YearOfStudy || Subjects.Contains(group)) return;
//
//            var oldGroups = Subjects.ToList();
//            oldGroups.Add(group);
//            Subjects = sortGroups(oldGroups);
//            SetSubjectIndexes();
//
//            if (group.Specialization == null) return;
//
//            var countGroups = Subjects.Length;
//            var countTime = TimeIndexes.Count;
//            var indexOfNewGroup = SubjectIndexes[group];
//            var newTable = new ClassRecord[countTime][];
//
//            for (int i = 0; i < countTime; ++i)
//            {
//                newTable[i] = new ClassRecord[countGroups];
//                for (int j = 0; j < countGroups; ++j)
//                    if (j != indexOfNewGroup)
//                        newTable[i][j] = Table[i][j < indexOfNewGroup ? j : j - 1];
//            }
//            Table = newTable;
//        }
//
//        public void AddGroup(Group group, ClassRecord[] classes)
//        {
//            AddGroup(group);
//            var countTime = TimeIndexes.Count;
//            var indexOfGroup = SubjectIndexes[group];
//            for (int i = 0; i < countTime; ++i)
//                Table[i][indexOfGroup] = classes[i];
//        }
//
//        public void RemoveGroup(Group group)
//        {
//            if (group == null || Subjects.All(g => g != group)) return;
//
//            var indexOfGroup = SubjectIndexes[group];
//            var countTime = TimeIndexes.Count;
//            var newCountGroups = Subjects.Length - 1;
//            var newGroups = new Group[newCountGroups];
//
//            for (int j = 0; j < newCountGroups + 1; ++j)
//                if (j != indexOfGroup)
//                    newGroups[j < indexOfGroup ? j : j - 1] = Subjects[j];
//
//            Subjects = newGroups;
//            SetSubjectIndexes();
//
//            var newTable = new ClassRecord[countTime][];
//
//            if (countTime != 0 && indexOfGroup < Table[0].Length)
//            {
//                for (int i = 0; i < countTime; ++i)
//                {
//                    newTable[i] = new ClassRecord[newCountGroups];
//                    for (int j = 0; j < newCountGroups + 1; ++j)
//                        if (j != indexOfGroup)
//                            newTable[i][j < indexOfGroup ? j : j - 1] = Table[i][j];
//                }
//
//                Table = newTable;
//            }
//        }
//
//        public ClassRecord[] AllClassesOfGroup(Group group)
//        {
//            if (group == null || Subjects.All(g => g != group)) return null;
//
//            var indexOfGroup = SubjectIndexes[group];
//            var countTime = TimeIndexes.Count;
//            var classes = new ClassRecord[countTime];
//
//            if (countTime != 0 && indexOfGroup < Table[0].Length)
//                for (int i = 0; i < countTime; ++i)
//                    classes[i] = Table[i][indexOfGroup];
//
//            return classes;
//        }

        protected override Group GetSubject(ClassRecord classRecord)
        {
            return(classRecord.Group);
        }
コード例 #13
0
ファイル: Elements.cs プロジェクト: lada-gagina/Schedule
 protected bool Equals(ClassRecord other)
 {
     return(Equals(_subject, other._subject) && Equals(_group, other._group) && Equals(_lecturer, other._lecturer) && Equals(_classroom, other._classroom) && Equals(_classTime, other._classTime));
 }
コード例 #14
0
ファイル: ClassesTable.cs プロジェクト: lada-gagina/Schedule
 protected abstract void SetSubject(ClassRecord classRecord, TSubject subject);
コード例 #15
0
ファイル: ClassesTable.cs プロジェクト: lada-gagina/Schedule
 protected abstract TSubject GetSubject(ClassRecord classRecord);
コード例 #16
0
ファイル: ClassCardViewModel.cs プロジェクト: GorelH/Schedule
 public ClassCardViewModel(ClassRecord @class)
 {
     Class = @class;
     PropertyChanged += OnPropertyChanged;
 }
コード例 #17
0
ファイル: TableViewModel.cs プロジェクト: GorelH/Schedule
 private void OnCopyClassCommand()
 {
     if (_selectedCard == null || _selectedCard.Class == null) return;
     var @class = new ClassRecord();
     ClassRecord.Copy(_selectedCard.Class, @class);
     ClipboardService.SetData(@class);
 }
コード例 #18
0
 public void AddClassRecord(ClassRecord classRecord)
 {
 }
コード例 #19
0
ファイル: SQLiteDatabaseIO.cs プロジェクト: GorelH/Schedule
        private static void LoadRecords(Schedule schedule, SQLiteCommand command)
        {
            command.CommandText = "select * from records";

            var reader = command.ExecuteReader();
            while (reader.Read())
            {
                var record = new ClassRecord
                {
                    Subject = schedule.Subjects[(int) reader["sub"]],
                    Group = schedule.Groups[(int) reader["grp"]],
                    Lecturer = schedule.Lecturers[(int) reader["lect"]],
                    Classroom = schedule.Classrooms[(int) reader["room"]],
                    ClassTime = schedule.TimeLine[(int) reader["time"]]
                };
                schedule.ClassRecords.Add(record);
            }
            reader.Close();
        }
コード例 #20
0
ファイル: Schedule.cs プロジェクト: GorelH/Schedule
 public void AddClass(ClassRecord classRecord)
 {
     ClassRecords.Add(classRecord);
 }