Пример #1
0
        /// <summary>
        /// Sets the main instance to a given instance, if no instance exsists yet.
        /// Used to initiate the config instance when loading the config data from file.
        /// </summary>
        /// <param name="c">Instance of <c>UEKVConfig</c> to set the main instance to.</param>
        /// <returns>Main instance of <c>UEKVConfig</c>.</returns>
        public static UEKVConfig InitiateInstance(UEKVConfig c)
        {
            if (UEKVConfig.instance == null)
            {
                UEKVConfig.instance = c;
            }

            return(UEKVConfig.GetInstance());
        }
        //TODO Check if method should be moved
        private void RefreshAbbreviationInfo()
        {
            Library.ABBRV_INFORMATION = "Abbreviations:";
            List <string> _tmp = UEKVConfig.GetInstance().Subjects;

            _tmp.Sort();

            foreach (string s in _tmp)
            {
                Library.ABBRV_INFORMATION += $"\n{s} = {Library.COURSE_MAIN_ABBRV[Library.COURSE_MAIN_SUBJ[s]]}";
            }
        }
        private void checkedListBox_Profile_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            string subj = (((string)this.checkedListBox_Profile.Items[e.Index]).Split(new char[] { '(' }))[0].Trim();

            if (e.NewValue == CheckState.Checked)
            {
                if (!UEKVConfig.GetInstance().Subjects.Contains(subj))
                {
                    UEKVConfig.GetInstance().Subjects.Add(subj);
                }
            }
            else
            {
                if (UEKVConfig.GetInstance().Subjects.Contains(subj))
                {
                    UEKVConfig.GetInstance().Subjects.Remove(subj);
                }
            }
        }
        //TODO Check if method should be moved
        private List <CourseEvent> GetCoursesForDay(DateTime dt)
        {
            List <CourseEvent> ret             = new List <CourseEvent>();
            DateTime           comp            = new DateTime(dt.Year, dt.Month, dt.Day);
            List <CourseMain>  relevantCourses = new List <CourseMain>();

            foreach (string s in UEKVConfig.GetInstance().Subjects)
            {
                relevantCourses.Add(Library.COURSE_MAIN_SUBJ[s]);
            }

            foreach (CourseEvent ce in Library.ALL_COURSE_EVENT)
            {
                if (ce.Date == comp && relevantCourses.Contains(ce.Course))
                {
                    ret.Add(ce);
                }
            }
            return(ret);
        }
 //TODO Move method to UEKConfig.cs
 private UEKVConfig GetConfigJSON()
 {
     return(UEKVConfig.GetInstance());
 }