Exemplo n.º 1
0
    public void AddButtonToCore(int numberGroup)
    {
        _firstElement = NamePrep.GetFirstIndex(numberGroup);
        _groupList    = transform.GetChild(0).GetComponent <TSSItem>();
        _coreScheme   = transform.parent.gameObject.GetComponent <TSSCore>();

        for (int i = 0; i < _listButtonPrep.transform.childCount; i++)
        {
            if (i < NamePrep._countPrepOnScheme[numberGroup])
            {
                int x = i + 1;
                _listButton.Add(_listButtonPrep.transform.GetChild(i).GetComponent <Button>());
                _listButton[i].onClick.AddListener(delegate { SelectPrep(x); });
                if (x < _coreScheme.Count)
                {
                    _coreScheme[x].AddItem(_listButton[i].GetComponent <TSSItem>());
                }

                SetNamePrep(_listButtonPrep.transform.GetChild(i).gameObject, numberGroup, i);
            }
            else
            {
                _listButtonPrep.transform.GetChild(i).gameObject.SetActive(false);
            }
        }
        _buttonOpen.OpenBranchImmediately();
    }
Exemplo n.º 2
0
        private void сформироватьГрафикЗанятийДляПечатиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Word.Document document = null;
            try
            {
                #region Открываем doc-файл Word из ресурса
                this.Cursor = Cursors.WaitCursor;                                                           // показываем ожидающий курсор, мол - "жди, идет запуск" :)
                Word.Application docApp = new Word.Application();
                var fullName            = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "608au.doc"); // составляем строку для хранения документа во временной папке
                if (File.Exists(fullName) == true)                                                          // проверка на наличие уже существующего файла и его удаление
                {
                    File.Delete(fullName);
                }
                byte[] resource_doc = Properties.Resources.word_test; // находим и считываем документ из ресурса программы
                File.WriteAllBytes(fullName, resource_doc);           // копируем данные из документа байтового масиисва в ресурсах, в документ временной папки
                document = docApp.Documents.Open(fullName, ReadOnly: false, Visible: false);
                document.Activate();
                #endregion
                #region Вставляем текущую дату рассписания
                Word.Bookmarks date_book = document.Bookmarks;
                Word.Range     date_range;
                foreach (Word.Bookmark mark in date_book)
                {
                    date_range      = mark.Range;
                    date_range.Text = label1.Text.ToString();
                }
                #endregion
                #region Записываем расписание пар в таблицу
                Word.Table   table       = docApp.ActiveDocument.Tables[1];
                string       path_file   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Расписание кафедры");
                string       file_rasp   = Path.Combine(path_file, Properties.Settings.Default.date_rasp.ToString("dd.MM.yyyy") + ".txt");
                StreamReader rasp_reader = new StreamReader(file_rasp);

                string bufferfile = "";
                string NamePrep;
                int    i = 4, q = 1;
                while (bufferfile != null)
                {
                    bufferfile = rasp_reader.ReadLine();
                    if ((bufferfile != null) && (bufferfile.IndexOf("#ff00ff\"> ") >= 0))
                    {
                        // сохраняем сокращенное имя препода в хранилище
                        NamePrep   = bufferfile.Substring(bufferfile.IndexOf("COLOR=\"#ff00ff\"> ") + 17, bufferfile.Length - bufferfile.IndexOf("COLOR=\"#ff00ff\"> ") - 28);
                        NamePrep   = NamePrep.Remove(1, NamePrep.IndexOf(" ")); // удаляем лишние символы в строке до пробела (без учета первого символа)
                        NamePrep   = NamePrep.Replace(".", "");                 // удаление оставшегося лишнего символа .
                        bufferfile = rasp_reader.ReadLine();
                        #region 1 неделя
                        while (i <= 44)                                                     // пока не достигли конца таблицы - конца недели
                        {
                            while (bufferfile.IndexOf("SIZE=2><P ALIGN=\"CENTER\">") == -1) // тег для поиска дня недели
                            {
                                bufferfile = rasp_reader.ReadLine();
                            }
                            bufferfile = rasp_reader.ReadLine();
                            while (q <= 6) // счетчик пар
                            {
                                bufferfile = rasp_reader.ReadLine();
                                if ((bufferfile.IndexOf("\">_") == -1) && (bufferfile.IndexOf("а.608а") >= 0))
                                {
                                    table.Rows[i].Cells[3].Range.Text = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2);
                                }
                                else
                                if ((bufferfile.IndexOf("\">_") == -1) && (bufferfile.IndexOf("а.608б") >= 0))
                                {
                                    table.Rows[i].Cells[4].Range.Text = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2);
                                }
                                bufferfile = rasp_reader.ReadLine();
                                q++; i++;
                            }
                            i++; q     = 1;
                            bufferfile = rasp_reader.ReadLine();
                        }
                        i = 4;
                        #endregion
                        #region 2 неделя
                        while (i <= 44)
                        {
                            while (bufferfile.IndexOf("SIZE=2 COLOR=\"#0000ff\"><P ALIGN=\"CENTER\">") == -1)
                            {
                                bufferfile = rasp_reader.ReadLine();
                            }
                            bufferfile = rasp_reader.ReadLine();
                            while (q <= 6)
                            {
                                bufferfile = rasp_reader.ReadLine();
                                if ((bufferfile.IndexOf("\"> _") == -1) && (bufferfile.IndexOf("а.608а") >= 0))
                                {
                                    table.Rows[i].Cells[7].Range.Text = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2);
                                }
                                else
                                if ((bufferfile.IndexOf("\"> _") == -1) && (bufferfile.IndexOf("а.608б") >= 0))
                                {
                                    table.Rows[i].Cells[8].Range.Text = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2);
                                }
                                bufferfile = rasp_reader.ReadLine();
                                q++; i++;
                            }
                            i++; q     = 1;
                            bufferfile = rasp_reader.ReadLine();
                        }
                        i = 4;
                        #endregion
                    }
                }
                rasp_reader.Dispose();
                #endregion
                this.Cursor    = Cursors.Default;
                docApp.Visible = true;
                document       = null;
            }
            catch (Exception ex)
            {
                // ошибки выводим
                MessageBox.Show("Ошибка при создании документа: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                document = null;
            }
        }
Exemplo n.º 3
0
        private void Form608_Load(object sender, EventArgs e)
        {
            // заполнение таблицы графика базовыми строками и столбцами при запуске
            dataGridView2.RowCount         = 18; dataGridView2.ColumnCount = 7;
            dataGridView2.Columns[0].Width = 50;
            #region Красим заголовки недель таблицы
            for (int i = 0; i < 7; i++)
            {
                dataGridView2.Rows[0].Cells[i].Style.BackColor = Color.SteelBlue;
            }
            for (int i = 0; i < 7; i++)
            {
                dataGridView2.Rows[9].Cells[i].Style.BackColor = Color.SteelBlue;
            }
            for (int i = 0; i < 7; i++)
            {
                dataGridView2.Rows[2].Cells[i].Style.BackColor = Color.LightSteelBlue;
            }
            for (int i = 3; i < 9; i++)
            {
                dataGridView2.Rows[i].Cells[0].Style.BackColor = Color.LightSteelBlue;
            }
            for (int i = 0; i < 7; i++)
            {
                dataGridView2.Rows[11].Cells[i].Style.BackColor = Color.LightSteelBlue;
            }
            for (int i = 12; i < 18; i++)
            {
                dataGridView2.Rows[i].Cells[0].Style.BackColor = Color.LightSteelBlue;
            }
            #endregion
            #region Неделя 1
            dataGridView2.Rows[0].Cells[3].Style.ForeColor = Color.White;
            dataGridView2.Rows[0].Cells[3].Value           = "1 неделя";
            dataGridView2.Rows[1].Cells[0].Value           = "Пары";
            dataGridView2.Rows[1].Cells[1].Value           = "1-я";
            dataGridView2.Rows[1].Cells[2].Value           = "2-я";
            dataGridView2.Rows[1].Cells[3].Value           = "3-я";
            dataGridView2.Rows[1].Cells[4].Value           = "4-я";
            dataGridView2.Rows[1].Cells[5].Value           = "5-я";
            dataGridView2.Rows[1].Cells[6].Value           = "6-я";
            dataGridView2.Rows[2].Cells[0].Value           = "Время";
            dataGridView2.Rows[2].Cells[1].Value           = "09:00-10:35";
            dataGridView2.Rows[2].Cells[2].Value           = "10:45-12:20";
            dataGridView2.Rows[2].Cells[3].Value           = "13:00-14:35";
            dataGridView2.Rows[2].Cells[4].Value           = "14:45-16:20";
            dataGridView2.Rows[2].Cells[5].Value           = "16:25-18:00";
            dataGridView2.Rows[2].Cells[6].Value           = "18:05-19:40";
            dataGridView2.Rows[3].Cells[0].Value           = "Пнд";
            dataGridView2.Rows[4].Cells[0].Value           = "Втр";
            dataGridView2.Rows[5].Cells[0].Value           = "Срд";
            dataGridView2.Rows[6].Cells[0].Value           = "Чтв";
            dataGridView2.Rows[7].Cells[0].Value           = "Птн";
            dataGridView2.Rows[8].Cells[0].Value           = "Сбт";
            #endregion
            #region Неделя 2
            dataGridView2.Rows[9].Cells[3].Style.ForeColor = Color.White;
            dataGridView2.Rows[9].Cells[3].Value           = "2 неделя";
            dataGridView2.Rows[10].Cells[0].Value          = "Пары";
            dataGridView2.Rows[10].Cells[1].Value          = "1-я";
            dataGridView2.Rows[10].Cells[2].Value          = "2-я";
            dataGridView2.Rows[10].Cells[3].Value          = "3-я";
            dataGridView2.Rows[10].Cells[4].Value          = "4-я";
            dataGridView2.Rows[10].Cells[5].Value          = "5-я";
            dataGridView2.Rows[10].Cells[6].Value          = "6-я";
            dataGridView2.Rows[11].Cells[0].Value          = "Время";
            dataGridView2.Rows[11].Cells[1].Value          = "09:00-10:35";
            dataGridView2.Rows[11].Cells[2].Value          = "10:45-12:20";
            dataGridView2.Rows[11].Cells[3].Value          = "13:00-14:35";
            dataGridView2.Rows[11].Cells[4].Value          = "14:45-16:20";
            dataGridView2.Rows[11].Cells[5].Value          = "16:25-18:00";
            dataGridView2.Rows[11].Cells[6].Value          = "18:05-19:40";
            dataGridView2.Rows[12].Cells[0].Value          = "Пнд";
            dataGridView2.Rows[13].Cells[0].Value          = "Втр";
            dataGridView2.Rows[14].Cells[0].Value          = "Срд";
            dataGridView2.Rows[15].Cells[0].Value          = "Чтв";
            dataGridView2.Rows[16].Cells[0].Value          = "Птн";
            dataGridView2.Rows[17].Cells[0].Value          = "Сбт";
            #endregion
            HighlightColor(); // выделяем цветом активную пару недели
            #region Заполняем график занятий 608 ау.
            string       path_file   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Расписание кафедры");
            string       file_rasp   = Path.Combine(path_file, Properties.Settings.Default.date_rasp.ToString("dd.MM.yyyy") + ".txt");
            StreamReader rasp_reader = new StreamReader(file_rasp);

            string bufferfile = "";
            string NamePrep;
            while (bufferfile != null)
            {
                bufferfile = rasp_reader.ReadLine();
                if ((bufferfile != null) && (bufferfile.IndexOf("#ff00ff\"> ") >= 0))
                {
                    // сокращаем имя препода
                    NamePrep = bufferfile.Substring(bufferfile.IndexOf("COLOR=\"#ff00ff\"> ") + 17, bufferfile.Length - bufferfile.IndexOf("COLOR=\"#ff00ff\"> ") - 28);
                    NamePrep = NamePrep.Remove(1, NamePrep.IndexOf(" ")); // удаляем лишние символы в строке до пробела (без учета первого символа)
                    NamePrep = NamePrep.Replace(".", "");                 // удаление оставшегося лишнего символа .
                    #region 1 неделя
                    for (int i = 3; i <= 8; i++)
                    {
                        while (bufferfile.IndexOf("SIZE=2><P ALIGN=\"CENTER\">") == -1)
                        {
                            bufferfile = rasp_reader.ReadLine();
                        }
                        bufferfile = rasp_reader.ReadLine();
                        for (int j = 1; j < 7; j++)
                        {
                            bufferfile = rasp_reader.ReadLine();
                            // если пара в 608б
                            if (bufferfile.IndexOf("а.608б") >= 0)
                            {
                                if (dataGridView2.Rows[i].Cells[j].Value == null)
                                {
                                    dataGridView2.Rows[i].Cells[j].Value = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2) + "\n608б";
                                }
                                else
                                {
                                    dataGridView2.Rows[i].Cells[j].Value += "\n-------------------\n" + NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2) + "\n608б";
                                }
                            }
                            else
                            // если пар нет или они в 608а
                            if ((bufferfile.IndexOf("\">_") == -1) && (bufferfile.IndexOf("а.608а") >= 0))
                            {
                                if (dataGridView2.Rows[i].Cells[j].Value == null)
                                {
                                    dataGridView2.Rows[i].Cells[j].Value = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2) + "\n608а";
                                }
                                else
                                {
                                    dataGridView2.Rows[i].Cells[j].Value += "\n-------------------\n" + NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2) + "\n608а";
                                }
                            }
                            bufferfile = rasp_reader.ReadLine();
                        }
                    }
                    #endregion
                    #region 2 неделя
                    bufferfile = rasp_reader.ReadLine();
                    for (int i = 12; i <= 17; i++)
                    {
                        while (bufferfile.IndexOf("SIZE=2 COLOR=\"#0000ff\"><P ALIGN=\"CENTER\">") == -1)
                        {
                            bufferfile = rasp_reader.ReadLine();
                        }
                        bufferfile = rasp_reader.ReadLine();
                        for (int j = 1; j < 7; j++)
                        {
                            bufferfile = rasp_reader.ReadLine();
                            // если пара в 608б
                            if (bufferfile.IndexOf("а.608б") >= 0)
                            {
                                if (dataGridView2.Rows[i].Cells[j].Value == null)
                                {
                                    dataGridView2.Rows[i].Cells[j].Value = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2) + "\n608б";
                                }
                                else
                                {
                                    dataGridView2.Rows[i].Cells[j].Value += "\n-------------------\n" + NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2) + "\n608б";
                                }
                            }
                            else
                            // если пар нет или они в 608а
                            if ((bufferfile.IndexOf("\"> _") == -1) && (bufferfile.IndexOf("а.608а") >= 0))
                            {
                                if (dataGridView2.Rows[i].Cells[j].Value == null)
                                {
                                    dataGridView2.Rows[i].Cells[j].Value = NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2) + "\n608а";
                                }
                                else
                                {
                                    dataGridView2.Rows[i].Cells[j].Value += "\n-------------------\n" + NamePrep + " - " + bufferfile.Substring(bufferfile.IndexOf("ALIGN=\"CENTER\">") + 15, bufferfile.Length - bufferfile.IndexOf("</F") - 2) + "\n608а";
                                }
                            }
                            bufferfile = rasp_reader.ReadLine();
                        }
                    }
                    #endregion
                }
            }
            dataGridView2.Enabled = true;
            SetDoubleBuffered2(dataGridView2, true);
            rasp_reader.Dispose();
            #endregion
        }