예제 #1
0
파일: Form1.cs 프로젝트: Folkmancer/OOP
        //==============================Work with file==============================//
        public void OpenFile()
        {
            OpenFileDialog XmlDataFile = new OpenFileDialog();

            XmlDataFile.InitialDirectory = Application.StartupPath;
            XmlDataFile.Filter           = "xml files (*.xml)|*.xml";
            XmlDataFile.FilterIndex      = 0;
            XmlDataFile.RestoreDirectory = true;
            if (XmlDataFile.ShowDialog() == DialogResult.OK)
            {
                try {
                    if ((XmlDataFile.OpenFile()) != null)
                    {
                        using (FileStream fStream = File.OpenRead(XmlDataFile.FileName)) {
                            XmlSerializer formatter = new XmlSerializer(typeof(List <Trial>));
                            List <Trial>  listObj   = (List <Trial>)formatter.Deserialize(fStream);
                            ListElements.Clear();
                            UniqId.Clear();
                            foreach (Trial i in listObj)
                            {
                                ListElements.Insert(ListElements.Count, i);
                                UniqId.Insert(UniqId.Count, i.ID);
                            }
                            fStream.Close();
                        }
                    }
                }
                catch (Exception ex) {
                    MessageBox.Show("Ошибка: невозможно прочитать файл с диска. Original error: " + ex.Message);
                }
                _pathXmlFile = XmlDataFile.FileName;
            }
        }
예제 #2
0
        private void AddListElement()
        {
            var newItem = new ListElementViewModel {
                Description = "List Element"
            };

            ListElements.Add(newItem);
            newItem.Selected = true;
        }
예제 #3
0
        public void GlobalContactList(String GlobalContactLists, String UserToclick)
        {
            IList <IWebElement> ListContacts = _driver.FindElementsByXPath(GlobalContactLists);

            foreach (var ListElements in ListContacts)
            {
                if (ListElements.Text.Equals(UserToclick))
                {
                    ListElements.Click();
                    break;
                }
            }
        }
예제 #4
0
 public void Add(Elements anElement)
 {
     try
     {
         for (int i = 0; i < Number; i++)
         {
             if (ListElements[i] == anElement)
             {
                 throw new Exception($"Error: Element {anElement.Name} already exists in elements-list");
             }
         }
         ListElements.Add(anElement);
         Number++;
     }
     catch { }
 }
예제 #5
0
파일: Form1.cs 프로젝트: Folkmancer/OOP
 public void Deleting()
 {
     try {
         int               index   = listView1.FocusedItem.Index;
         string            message = "Вы уверены, что хотите удалить эту запись?\n" + ListElements[index].ToString();
         string            caption = "Внимание";
         MessageBoxButtons buttons = MessageBoxButtons.YesNo;
         MessageBoxIcon    icon    = MessageBoxIcon.Question;
         DialogResult      result  = MessageBox.Show(message, caption, buttons, icon);
         if (result == DialogResult.Yes)
         {
             listView1.Items[index].Remove();
             ListElements.RemoveAt(index);
         }
     }
     catch {
         string            message = "Отсутствует или не выбрана строка для удаления!";
         string            caption = "Ошибка";
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         MessageBoxIcon    icon    = MessageBoxIcon.Error;
         MessageBox.Show(message, caption, buttons, icon);
     }
 }
예제 #6
0
파일: Form1.cs 프로젝트: Folkmancer/OOP
        //==============================Work with table==============================//
        private void SortTable(ColumnClickEventArgs e)
        {
            switch (e.Column)
            {
            case 0:
                if (_switches[0] == false)
                {
                    ListElements.Sort((a, b) => b.ID.CompareTo(a.ID));
                    _switches[0] = true;
                }
                else
                {
                    ListElements.Sort((a, b) => a.ID.CompareTo(b.ID));
                    _switches[0] = false;
                }
                break;

            case 1:
                if (_switches[1] == false)
                {
                    ListElements.Sort((a, b) => b.NameOfDiscipline.CompareTo(a.NameOfDiscipline));
                    _switches[1] = true;
                }
                else
                {
                    ListElements.Sort((a, b) => a.NameOfDiscipline.CompareTo(b.NameOfDiscipline));
                    _switches[1] = false;
                }
                break;

            case 2:
                if (_switches[2] == false)
                {
                    ListElements.Sort((a, b) => b.Date.CompareTo(a.Date));
                    _switches[2] = true;
                }
                else
                {
                    ListElements.Sort((a, b) => a.Date.CompareTo(b.Date));
                    _switches[2] = false;
                }
                break;

            case 3:
                if (_switches[3] == false)
                {
                    ListElements.Sort((a, b) => b.NameOfTeacher.CompareTo(a.NameOfTeacher));
                    _switches[3] = true;
                }
                else
                {
                    ListElements.Sort((a, b) => a.NameOfTeacher.CompareTo(b.NameOfTeacher));
                    _switches[3] = false;
                }
                break;

            case 4:
                if (_switches[4] == false)
                {
                    ListElements.Sort((a, b) => b.GetGrade().CompareTo(a.GetGrade()));
                    _switches[4] = true;
                }
                else
                {
                    ListElements.Sort((a, b) => a.GetGrade().CompareTo(b.GetGrade()));
                    _switches[4] = false;
                }
                break;

            case 5:
                if (_switches[5] == false)
                {
                    ListElements.Sort((a, b) => b.TypeOfTrial().CompareTo(a.TypeOfTrial()));
                    _switches[5] = true;
                }
                else
                {
                    ListElements.Sort((a, b) => a.TypeOfTrial().CompareTo(b.TypeOfTrial()));
                    _switches[5] = false;
                }
                break;

            default:
                string            message = "Что-то пошло не так!";
                string            caption = "Ошибка";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBoxIcon    icon    = MessageBoxIcon.Error;
                MessageBox.Show(message, caption, buttons, icon);
                break;
            }
        }
예제 #7
0
 private void RemoveListElement()
 {
     ListElements.Remove((ListElementViewModel)Manager.SelectedElement);
 }