Пример #1
0
        private void ShowClasses(Data data, GroupSettings groupSettings, DateTime date)
        {
            List<Class> classes = new List<Class>();

            int currentWeekday = (int)date.DayOfWeek - 1;
            if (currentWeekday == -1)
                currentWeekday = 6;

            int currentWeek = ((date - data.Schedule.SemesterStart).Days) / 7 + 1;

            int currentWeekCode = 2;
            if (currentWeek % 2 == 1)
                currentWeekCode = 1;

            bool zeroClasses = true;

            // Clear classes
            classesStackPanel.Children.Clear();

            ScheduleWeekday weekday = data.Schedule.GetWeekdayByNumber(currentWeekday);
            if (weekday != null)
            {
                emptyImage.Visibility = System.Windows.Visibility.Hidden;

                List<ScheduleClass> scheduleToday = weekday.Classes;

                for (int i = 0; i < scheduleToday.Count; i++)
                {
                    if (scheduleToday[i].Week == 0 || scheduleToday[i].Week == currentWeekCode)
                    {
                        string setting = groupSettings.GetSettingByCode(scheduleToday[i].Code);

                        if (setting == scheduleToday[i].Group)
                        {
                            ClassType type = data.Types.GetTypeById(scheduleToday[i].Type);
                            classesStackPanel.Children.Add((new Class(
                                data.Modules.GetModuleByCode(scheduleToday[i].Code).Name,
                                scheduleToday[i].Location,
                                scheduleToday[i].Hours,
                                scheduleToday[i].Minutes,
                                new SolidColorBrush(Color.FromRgb(type.ColorArray[0], type.ColorArray[1], type.ColorArray[2]))
                            )).Drawable);

                            zeroClasses = false;
                        }
                    }
                }
            }

            if (zeroClasses)
                emptyImage.Visibility = System.Windows.Visibility.Visible;
            else
                emptyImage.Visibility = System.Windows.Visibility.Hidden;
        }
Пример #2
0
        private void PrepareSettings(Data data)
        {
            groupSettings = new GroupSettings();
            settingsStackPanel.Children.Clear();

            foreach (GroupContainer i in data.Groups.GroupContainers)
            {
                GroupSetting groupSetting = new GroupSetting(i.AppliesTo, i.Name, i.Items[0].Code);
                groupSetting.PropertyChanged += groupSetting_PropertyChanged;
                groupSettings.Settings.Add(groupSetting);

                List<string> settingNames = new List<string>();

                foreach (Group group in i.Items)
                    settingNames.Add(group.Name);

                Setting setting = new Setting(i.Name, settingNames);
                setting.CurrentSetting = groupSettings.Settings[groupSettings.Settings.Count - 1];

                settingsStackPanel.Children.Add(setting.Drawable);
            }
        }