Example #1
0
 /// <summary>
 /// Кнопка Добавить
 /// </summary>
 private void AddWorkExecute(object sender, EventArgs e)
 {
     // проверка данных для добавления новой работы
     if (!radioButton1.Checked && !radioButton2.Checked)
     {
         MessageBox.Show("Не выбран тип добавления работы!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (radioButton2.Checked && numericUpDown1.Value == 0)
     {
         MessageBox.Show("Не задано количество добавляемых работ!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (!isLabCreated)
     {
         MessageBox.Show("Не задан состав работы!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (radioButton1.Checked)
     {
         // создание данных новой работы и ее добавление
         TListItem item = new TListItem(TSubject.GetLabName(CurrentSubject.List.Items.Length + 1), TSubject.GetLabDesc(), TSubject.GetElementsFromIndexes(ElementsIndexes));
         CurrentSubject.List.AddItem(item);
     }
     if (radioButton2.Checked)
     {
         CurrentSubject.AutoGenerateLabList((int)numericUpDown1.Value, ElementsIndexes);
     }
     // вывод сообщения об успешном завершении и обновление окна
     MessageBox.Show("Работа (-ы) успешно добавлены!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
     InitData();
     InitWindow();
 }
Example #2
0
        /// <summary>
        /// Загрузка данных из файла
        /// </summary>
        /// <param name="fname">Полный путь и имя файла для чтения</param>
        /// <returns>Возвращает список предметов с ихними работами</returns>
        public static TSubjectList LoadListFromFile(string fname)
        {
            XmlTextReader file = null;
            TSubjectList list = null;

            TSubject subj = null;
            TListItem item = null;

            try
            {
                // Load the reader with the data file and ignore all white space nodes.
                file = new XmlTextReader(fname);
                file.WhitespaceHandling = WhitespaceHandling.None;

                // Parse the file and display each of the nodes.
                while (file.Read())
                {
                    switch (file.NodeType)
                    {
                        case XmlNodeType.Element:
                            switch (file.Name) // проверяем элемент из XML файла
                            {
                                case "subjlist":
                                    // создание объекта списка
                                    list = new TSubjectList(file.GetAttribute("name"), file.GetAttribute("description"));
                                    break;
                                case "subject": // считываем описание предмета
                                    subj = new TSubject(file.GetAttribute("name"), (TStatus)Enum.Parse(typeof(TStatus), file.GetAttribute("status")));
                                    break;
                                case "lablist": // считываем описание списка работ
                                    if (subj != null)
                                        subj.List = new TLabList(file.GetAttribute("name"), file.GetAttribute("description"));
                                    break;
                                case "lab":
                                    item = new TListItem(file.GetAttribute("name"), file.GetAttribute("description"), (TStatus)Enum.Parse(typeof(TStatus), file.GetAttribute("status")));
                                    break;
                                case "element":
                                    if (item != null)
                                    {
                                        Element el = new Element();
                                        el.type = (ElementsTypes)Enum.Parse(typeof(ElementsTypes) ,file.GetAttribute("type"));
                                        el.isCompleted = bool.Parse(file.GetAttribute("iscompleted"));
                                        item.AddElement(el);
                                    }
                                    break;
                            }
                            break;
                        case XmlNodeType.EndElement:
                            switch (file.Name) // проверка на завершение блока элемента
                            {
                                case "lab": // добавление работы в список работ
                                    if (subj != null)
                                        subj.List.AddItem(item);
                                    break;
                                case "subject": // добавление предмета в список
                                    if (list != null)
                                        list.AddSubject(subj);
                                    break;
                            }
                            break;
                    }
                }
            }
            finally
            {
                if (file != null)
                    file.Close();
            }

            // возвращаем считанный список из файла
            return list;
        }
Example #3
0
 /// <summary>
 /// Автогенерация списка работ по типу элементов
 /// </summary>
 /// <param name="count">Количество работ</param>
 /// <param name="selels">Индексы элементов работы</param>
 /// <remarks>Все работы получаются одинаковыми!</remarks>
 public void AutoGenerateLabList(int count, int[] selels)
 {
     for (int i = 0; i < count; i++)
     {
         TListItem item = new TListItem(GetLabName(list.Items.Length + i + 1), GetLabDesc(), GetElementsFromIndexes(selels));
         list.AddItem(item);
     }
 }
Example #4
0
 /// <summary>
 /// Удаление элемента из списка по его названию
 /// </summary>
 /// <param name="name">Название элемента (работы)</param>
 public void RemoveItem(string name)
 {
     if (items.Length == 0)
         throw new Exception("Список работ пуст!");
     TListItem[] tmp = new TListItem[items.Length - 1];
     int k = 0;
     for (int i = 0; i < items.Length; i++)
         if (items[i].Name != name)
         {
             tmp[k] = items[i];
             k++;
         }
     items = tmp;
 }
Example #5
0
 /// <summary>
 /// Добавление элемента (работы) в список
 /// </summary>
 /// <param name="item">Новый элемент (работа)</param>
 /// <returns>Возвращает индекс новго вставленного элемента</returns>
 public int AddItem(TListItem item)
 {
     Array.Resize(ref items, items.Length + 1);
     items[items.Length - 1] = item;
     return items.Length - 1;
 }
Example #6
0
        CheckBox[] boxes; // массив чек боксов

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Инициализация окна с данными работы
        /// </summary>
        /// <param name="item">Работа</param>
        public FWorkInfo(TListItem item)
        {
            InitializeComponent();
            CurrentWork = item;
            InitData();
        }