private void backgroundWorker2_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            while (true)
            {
                var code = CourseManager.GetDownloadingCode();

                try
                {
                    if (CourseManager.CourseCodeList.Count > 0)
                    {
                        int i        = CourseManager.CourseCodeList.FindIndex(item => item == code) + 1;
                        int progress = (int)(((double)i / (double)CourseManager.CourseCodeList.Count) * 100.0);
                        Console.Write("Downloading ");
                        Console.Write(progress);
                        Console.WriteLine(" / 100");
                        backgroundWorker1.ReportProgress(progress);
                    }



                    //string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                    //if (code != "")
                    //{
                    //    int j = alphabet.IndexOf(code[0]) + 1;
                    //    backgroundWorker1.ReportProgress((int)(((float)j / (float)alphabet.Length) * 100.0));
                    //}
                }
                catch (Exception ex)
                {
                    Console.Write("EXXX: ");
                    Console.WriteLine(ex);
                }

                label1.Invoke((MethodInvoker) delegate
                {
                    label1.Text = code;
                });
            }
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //CourseManager.UpdateCache();

            // OLD
            //Course.Deserialize();
            //foreach (CourseXml item in Course.CoursesXml)
            //{
            //    CourseManager.AddCourse(CourseManager.GetCourseByCRN(item.Code, item.CRN));
            //}

            if (!File.Exists("AllProfiles.xml"))
            {
                Updater u = new Updater();
                u.ShowDialog();
            }
            CourseManager.Deserialize();
            string[] crn_list = Course.LoadCRNList();
            foreach (var item in crn_list)
            {
                Console.WriteLine(item);
            }
            foreach (var item in crn_list)
            {
                var c = CourseManager.GetCourseByCRNLocal(item);
                Console.Write("Adding Course: ");
                Console.WriteLine(c);
                CourseManager.AddCourse(c);
            }

            SystemEvents.UserPreferenceChanging += SystemEvents_UserPreferenceChanging;
            d  = new Graphix(panel1, Days.Monday);
            d1 = new Graphix(panel2, Days.Tuesday);
            d2 = new Graphix(panel3, Days.Wednesday);
            d3 = new Graphix(panel4, Days.Thursday);
            d4 = new Graphix(panel5, Days.Friday);

            for (int i = 0; i < 17; i++)
            {
                Buttons[i] = new Button();
                buttonsP.Controls.Add(Buttons[i]);
                Buttons[i].Size     = new Size(buttonsP.Width, Graphix.Height);
                Buttons[i].Location = new Point(0, (Graphix.Height) * i);
                Buttons[i].FlatAppearance.BorderSize  = 0;
                Buttons[i].FlatAppearance.BorderColor = Color.FromArgb(0, 0, 0, 0);
                Buttons[i].FlatStyle = FlatStyle.Flat;
                string AfterText = (8 + (i + 2) / 2).ToString() + ":" + (30 * ((i + 2) % 2)).ToString();
                Buttons[i].Text = (8 + (i + 1) / 2).ToString() + ":" + (30 * ((i + 1) % 2)).ToString() + "-" + AfterText;
            }
            panel6.BackColor = Color.FromArgb(255, 30, 30, 30);
            Graphix.UpdatePanelColor(panel8, Graphix.GetAccentColor());
            foreach (Control item in panel6.Controls)
            {
                if (item is Panel)
                {
                    Panel p = (Panel)item;
                    Graphix.UpdateColor(p, Graphix.GetAccentColor());
                }
            }
            this.Size = panel8.Size;

            foreach (Button item in panel7.Controls)
            {
                item.Click += Item_Click;
            }
            gg[0] = d;
            gg[1] = d1;
            gg[2] = d2;
            gg[3] = d3;
            gg[4] = d4;
            List <Panel> lop = GetPanels(this);

            foreach (Panel item in lop)
            {
                item.MouseDown += Item_MouseDown;
            }
        }
 private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     CourseManager.GetAllCourses(callback);
     CourseManager.Serialize();
 }