public TextResult(MySortableBindingList<Rijec> lr, string n, Tekst t) { naziv = n; lista_rijeci = lr; lista_rijeci_gramatika = new MySortableBindingList<Rijec>(); lista_rijeci_poslije_gramatike = new MySortableBindingList<Rijec>(); Gramatika = false; tekst = t; InitializeComponent(); }
public InsertWords(MySortableBindingList<Rijec> lr) { lista_svih_rijeci = new List<Rijec>(); lista_svih_rijeci_koje_su_root = new List<Rijec>(); lista_tipova = new List<TipRijeci>(); filtrirana_lista_rijeci = new MySortableBindingList<Rijec>(); lista_rijeci = lr; brojUnesenihRijeci = 0; InitializeComponent(); }
public override void RefreshList(UpdateList <Categoria> obj) { try { using (var uof = new UnitOfWork()) { var listCurrent = uof.CategorieRepository.Find( a => a.Nome.Contains(TestoRicerca) || TestoRicerca == "") .ToList(); DataSource = new MySortableBindingList <CategoriaItem>(listCurrent.Select(a => new CategoriaItem(a) { Nome = a.Nome, Entity = a, ID = a.ID }).ToList()); } } catch (Exception ex) { new Action(() => { ExceptionManager.ManageError(ex); }).BeginInvoke(null, null); } }
private void InitializeDatasetGrid() { try { // dgDataset.DataSource = SubscriberDatasetManager.GetAllDataset(); var list1 = SubscriberDatasetManager.GetAllDataset(); // To enable sorting in a DataGridView bound to a List // See https://www.codeproject.com/Articles/31418/Implementing-a-Sortable-BindingList-Very-Very-Quic MySortableBindingList <Dataset> sortableBindingList = new MySortableBindingList <Dataset>(list1); //new SortableList<SubscriberDataset>(); dgDataset.DataSource = sortableBindingList; var col = dgDataset.Columns["DatasetId"]; dgDataset.Sort(col, ListSortDirection.Ascending); foreach (DataGridViewColumn column in dgDataset.Columns) { column.SortMode = DataGridViewColumnSortMode.Automatic; } dgDataset.AutoSize = true; //dgDataset.AllowUserToOrderColumns = true; // 20171113-Leg // 20171113-Leg: AutoSizeColumnsMode must be set to None in order to AllowUserToResizeColumns and AllowUserToResizeRows to work. //dgDataset.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; } catch (Exception ex) { var errMsg = "Form1_Load failed when opening database:" + SubscriberDatasetManager.GetDatasource(); logger.Error(ex, errMsg); errMsg += "\r\n" + "Remember to copy the database to the the folder:" + AppDomain.CurrentDomain.GetData("APPBASE"); MessageBox.Show(ex.Message + "\r\n" + errMsg); } }
private void ButtonSearch_Click(object sender, EventArgs e) { SectionController scontroller = new SectionController(); List <SectionModel> sectionList = scontroller.GetByFaculty(faculty); dataGridViewSerial.ScrollBars = ScrollBars.None; MySortableBindingList <ProperStudentUserModel> properStudentList = new MySortableBindingList <ProperStudentUserModel>(); foreach (SectionModel model in sectionList) { UserController ucontroller = new UserController(); List <StudentUserModel> studentListByAcademicId = ucontroller.SearchByAcademidIdAndSectionId(textBoxSearch.Text, model.Id); //Console.WriteLine(studentListByAcademicId.Count + " student found in " + model.SectionName); foreach (StudentUserModel smodel in studentListByAcademicId) { ProperStudentUserModel properStudentModel = new ProperStudentUserModel(); properStudentModel.AcademicId = smodel.AcademicId; properStudentModel.FirstName = smodel.FirstName; properStudentModel.Id = smodel.Id; properStudentModel.LastName = smodel.LastName; properStudentModel.SectionName = model.SectionName; properStudentList.Add(properStudentModel); } List <StudentUserModel> studentListByName = ucontroller.SearchByNameAndSectionId(textBoxSearch.Text, model.Id); //Console.WriteLine(studentListByName.Count + " student found in " + model.SectionName); foreach (StudentUserModel smodel in studentListByName) { ProperStudentUserModel properStudentModel = new ProperStudentUserModel(); properStudentModel.AcademicId = smodel.AcademicId; properStudentModel.FirstName = smodel.FirstName; properStudentModel.Id = smodel.Id; properStudentModel.LastName = smodel.LastName; properStudentModel.SectionName = model.SectionName; properStudentList.Add(properStudentModel); } } foreach (ProperStudentUserModel student in properStudentList) { dataGridViewSerial.Rows.Add(); } dataGridViewStudentList.DataBindingComplete += (o, ev) => { foreach (DataGridViewRow row in dataGridViewSerial.Rows) { row.Cells["sln"].Value = (row.Index + 1).ToString(); } foreach (DataGridViewColumn column in dataGridViewStudentList.Columns) { column.SortMode = DataGridViewColumnSortMode.Programmatic; } }; dataGridViewStudentList.AutoGenerateColumns = false; dataGridViewStudentList.DataSource = properStudentList; dataGridViewStudentList.Update(); dataGridViewStudentList.Refresh(); dataGridViewSerial.Update(); dataGridViewSerial.Refresh(); foreach (DataGridViewColumn column in dataGridViewStudentList.Columns) { column.SortMode = DataGridViewColumnSortMode.Automatic; } }
void loadGrid() { var hs = HistoryHoiVienController.GetToDay(); MySortableBindingList<HistoryHoiVien> li = new MySortableBindingList<HistoryHoiVien>(hs); dataGridView1.DataSource = li; }
public FormStudentList(FacultyUserModel gotFaculty, SectionModel gotSection) { InitializeComponent(); faculty = gotFaculty; section = gotSection; labelWelcome.Text = faculty.FullName; labelStudents.Text = "Students of " + section.SectionName; //try //{ UserController controller = new UserController(); studentList = controller.GetBySection(section); ClassController ccontroller = new ClassController(); classList = ccontroller.GetBySectionId(section.Id); AttendanceController acontroller = new AttendanceController(); attendanceList = acontroller.GetAllBySection(section.Id); Console.WriteLine("Found student: " + studentList.Count); Console.WriteLine("Found classes: " + classList.Count); Console.WriteLine("Found attendances: " + attendanceList.Count); List <StudentView> mainList = new List <StudentView>(); int i = 0; foreach (StudentUserModel student in studentList) { Console.WriteLine("doing student no. " + i); StudentView view = new StudentView(); view.AcademicId = student.AcademicId; view.FullName = student.FullName; int c = 0; foreach (ClassModel Class in classList) { AttendanceModel att = attendanceList.Find(x => (x.ClassId == Class.Id) && (x.StudentId == student.Id)); Console.WriteLine("Found attendance id: " + att.Id + " for: " + student.Id + " on: " + Class.Id + " entry: " + att.Entry); view.attendances.Add(att.Entry); DataGridViewColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = Class.ClassDate; int colIndex = dataGridViewStudentList.Columns.Add(col); //dataGridViewStudentList.Rows[i].Cells[c+2].Value = att.Entry.ToString(); c++; } mainList.Add(view); i++; } Console.WriteLine("Main list count: " + mainList.Count); MySortableBindingList <StudentView> mainListBinding = new MySortableBindingList <StudentView>(mainList); dataGridViewStudentList.AutoGenerateColumns = false; dataGridViewStudentList.DataSource = mainListBinding; dataGridViewSerial.AutoGenerateColumns = false; dataGridViewSerial.DataSource = mainListBinding; dataGridViewSerial.Columns[0].DefaultCellStyle.Padding = new Padding(3, 0, 0, 0); dataGridViewStudentList.DataBindingComplete += (o, e) => { foreach (DataGridViewRow row in dataGridViewSerial.Rows) { row.Cells["sln"].Value = (row.Index + 1).ToString(); } foreach (DataGridViewColumn column in dataGridViewStudentList.Columns) { column.SortMode = DataGridViewColumnSortMode.Programmatic; } }; foreach (DataGridViewColumn column in dataGridViewStudentList.Columns) { column.SortMode = DataGridViewColumnSortMode.Automatic; } //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} }
private void OptionsCalculator_Loaded(object sender, RoutedEventArgs e) { try { DataManager.Init(); lstPortfolios = new BindingList<Entities.Portfolio>(DataManager.Portfolios); lstInstruments = new BindingList<Entities.Instrument>(DataManager.Instruments); lstDesc = new MySortableBindingList<ViewModel.DeskViewModel>(); allViewModels = new BindingList<ViewModel.DeskViewModel>(); listBaseContract = new List<string>(); MatDates2BaseContracts=new Dictionary<string,List<DateTime>>(); ConnectionManager.OnAccount += DataManager.UpdateAccount; ConnectionManager.OnNewInstrument += DataManager.AddInstrument; ConnectionManager.OnInstrument += DataManager.UpdateInstrument; ConnectionManager.OnPosition += DataManager.UpdatePosition; ConnectionManager.OnConnected += new Action<string>(ConnectionManager_OnConnected); ConnectionManager.OnError += new Action<string>(ConnectionManager_OnError); ConnectionManager.OnNewAccount+=DataManager.AddAccount; ConnectionManager.OnNewPosition += DataManager.AddPosition; dgrPortfolios.ItemsSource = lstPortfolios; //dgrODesk.ItemsSource = lstInstruments; dgrDesc.CanUserSortColumns = true; dgrDesc.ItemsSource = lstDesc; comboBoxBaseContract.ItemsSource = listBaseContract; comboBoxBaseContract.SelectionChanged += new SelectionChangedEventHandler(comboBoxBaseContract_SelectionChanged); } catch (Exception exp) { mainLog.Error("Error on DataManager or ConnectionManager initialization {0}",exp.Message); } }
public ViewTexts(List<Tekst> lt) { lista_teksta = lt; lista_rijeci = new MySortableBindingList<Rijec>(); InitializeComponent(); }
private static void LoadConfig() { authors.Clear(); //author_texts.Clear(); try { if (File.Exists(config)) using (StreamReader st = new StreamReader(config)) { XmlSerializer sr = new XmlSerializer(typeof(MySortableBindingList<Author>)); authors = (MySortableBindingList<Author>)sr.Deserialize(st); } //if (File.Exists(author_texts_file)) // using (StreamReader st = new StreamReader(author_texts_file)) // { // SerializableDictionary<string, MySortableBindingList<AuthorText>> author_texts_temp = new SerializableDictionary<string, MySortableBindingList<AuthorText>>(); // XmlSerializer sr = new XmlSerializer(typeof(SerializableDictionary<string, MySortableBindingList<AuthorText>>)); // author_texts = (SerializableDictionary<string, MySortableBindingList<AuthorText>>)sr.Deserialize(st); // } } catch(Exception){} }
public static bool UpdateAuthorInfo(string page, Author author) { Match match = Regex.Match(page, @"Обновлялось:</font></a></b>\s*(.*?)\s*$", RegexOptions.Multiline); DateTime date = DateTime.MinValue; bool retValue = false; if (match.Success) { string[] newDateStr = match.Groups[1].Value.Split('/'); date = new DateTime(int.Parse(newDateStr[2]), int.Parse(newDateStr[1]), int.Parse(newDateStr[0])); } if (author != null) { #region проанализируем данные на страничке. если раньше их не загружали, то в любом случае не показываем, что есть обновления, просто заполняем данные MySortableBindingList<AuthorText> texts_temp = new MySortableBindingList<AuthorText>(); MatchCollection matches = Regex.Matches(page, "<DL><DT><li>(?:<font.*?>.*?</font>)?\\s*(<b>(?<Authors>.*?)\\s*</b>\\s*)?<A HREF=(?<LinkToText>.*?)><b>\\s*(?<NameOfText>.*?)\\s*</b></A>.*?<b>(?<SizeOfText>\\d+)k</b>.*?<small>(?:Оценка:<b>(?<DescriptionOfRating>(?<rating>\\d+(?:\\.\\d+)?).*?)</b>.*?)?\\s*\"(?<Section>.*?)\"\\s*(?<Genres>.*?)?\\s*(?:<A HREF=\"(?<LinkToComments>.*?)\">Комментарии:\\s*(?<CommentsDescription>(?<CommentCount>\\d+).*?)</A>\\s*)?</small>.*?(?:<br><DD>(?<Description>.*?))?</DL>"); if (matches.Count > 0) { int cnt = 0; foreach (Match m in matches) { AuthorText item = new AuthorText(); item.Description = NormalizeHTML(m.Groups["Description"].Value).Trim(); item.Genres = NormalizeHTML(m.Groups["Genres"].Value); item.Link = m.Groups["LinkToText"].Value; item.Name = NormalizeHTML(m.Groups["NameOfText"].Value); item.Order = cnt; item.SectionName = NormalizeHTML(m.Groups["Section"].Value).Replace("@",""); item.Size = int.Parse(m.Groups["SizeOfText"].Value); texts_temp.Add(item); cnt++; } } if (author.Texts.Count > 0) // если раньше загружали проводим стравнение { foreach (AuthorText txt in texts_temp) { bool bFound = false; for (int i = 0; i < author.Texts.Count; i++) { if (txt.Description == author.Texts[i].Description && txt.Name == author.Texts[i].Name && txt.Size == author.Texts[i].Size) { bFound = true; txt.IsNew = author.Texts[i].IsNew;// переносим значение isNew в новый массив, чтобы не потерять непрочитанные новые тексты break; } } if (!bFound) { txt.IsNew = author.IsNew = retValue = true;// да, автор обновился if (date <= author.UpdateDate) // поменяем дату на сегодняшнюю, если дата обновления на страничке старее, чем зарегистрированная у нас author.UpdateDate = DateTime.Today; else // иначе ставим дату, указанную автором author.UpdateDate = date; } } // доп проверка по количеству произведений if (texts_temp.Count != author.Texts.Count) { retValue = true; if (date <= author.UpdateDate) // поменяем дату на сегодняшнюю, если дата обновления на страничке старее, чем зарегистрированная у нас author.UpdateDate = DateTime.Today; else// иначе ставим дату, указанную автором author.UpdateDate = date; } // запоминаем новые данные } author.Texts = texts_temp; #endregion } return retValue; }
public FormStudentList(FacultyUserModel gotFaculty, SectionModel gotSection) { InitializeComponent(); faculty = gotFaculty; section = gotSection; labelWelcome.Text = faculty.FullName; labelStudents.Text = "Students of " + section.SectionName; try { UserController controller = new UserController(); studentList = controller.GetBySection(section); ClassController ccontroller = new ClassController(); classList = ccontroller.GetBySectionId(section.Id); AttendanceController acontroller = new AttendanceController(); attendanceList = acontroller.GetAllBySection(section.Id); //Console.WriteLine("Found student: " + studentList.Count); //Console.WriteLine("Found classes: " + classList.Count); //Console.WriteLine("Found attendances: " + attendanceList.Count); DataGridViewColumn sln = new DataGridViewTextBoxColumn(); sln.HeaderText = "#"; sln.Width = 30; sln.ReadOnly = true; dataGridViewSln.Columns.Add(sln); DataGridViewColumn IdCol = new DataGridViewTextBoxColumn(); IdCol.HeaderText = "ID"; IdCol.Width = 75; IdCol.ReadOnly = true; dataGridViewStudentList.Columns.Add(IdCol); DataGridViewColumn FullNameCol = new DataGridViewTextBoxColumn(); FullNameCol.HeaderText = "Name"; FullNameCol.Width = 200; FullNameCol.ReadOnly = true; dataGridViewStudentList.Columns.Add(FullNameCol); foreach (ClassModel Class in classList) { DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); DateTime date = DateTime.Parse(Class.ClassDate); string dateMod = date.ToString("MMM-dd"); col.HeaderText = dateMod; col.ReadOnly = false; col.Width = 50; col.MaxInputLength = 1; col.ValueType = typeof(string); col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridViewStudentList.Columns.Add(col); } int i = 0; foreach (StudentUserModel student in studentList) { //Console.WriteLine("doing student no. " + i); StudentView view = new StudentView(); view.AcademicId = student.AcademicId; view.FullName = student.FullName; dataGridViewStudentList.Rows.Add(); dataGridViewSln.Rows.Add(); dataGridViewSln.Rows[i].Cells[0].Value = i + 1; dataGridViewStudentList.Rows[i].Cells[0].Value = student.AcademicId; dataGridViewStudentList.Rows[i].Cells[1].Value = student.FullName; int c = 0; foreach (ClassModel Class in classList) { AttendanceModel att = attendanceList.Find(x => (x.ClassId == Class.Id) && (x.StudentId == student.Id)); //Console.WriteLine("Found attendance id: " + att.Id + " for: " + student.Id + " on: " + Class.Id + " entry: " + att.Entry); if (att.Entry == 2) { dataGridViewStudentList.Rows[i].Cells[c + 2].Value = "L"; } else { dataGridViewStudentList.Rows[i].Cells[c + 2].Value = att.Entry.ToString(); } c++; } i++; } MySortableBindingList <StudentUserModel> studentListSortable = new MySortableBindingList <StudentUserModel>(studentList); dataGridViewStudentList.DataBindingComplete += (o, e) => { foreach (DataGridViewColumn column in dataGridViewStudentList.Columns) { column.SortMode = DataGridViewColumnSortMode.Programmatic; } }; foreach (DataGridViewColumn column in dataGridViewStudentList.Columns) { column.SortMode = DataGridViewColumnSortMode.Automatic; } } catch (Exception ex) { MessageBox.Show(ex.Message); } if (classList.Count != 0) { DataGridViewTextBoxColumn totalCol = new DataGridViewTextBoxColumn(); totalCol.HeaderText = "Total"; totalCol.Width = 38; totalCol.ReadOnly = true; totalCol.Name = "Total"; totalCol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridViewStudentList.Columns.Add(totalCol); foreach (DataGridViewRow row in dataGridViewStudentList.Rows) { int sum = 0; int classNo = 0; foreach (ClassModel Class in classList) { if (row.Cells[classNo + 2].Value.ToString() == "L" || row.Cells[classNo + 2].Value.ToString() == "l") { sum += 1; } else if (row.Cells[classNo + 2].Value.ToString() == "1") { sum += 1; } classNo++; } row.Cells["Total"].Value = sum.ToString(); } } }