private void textBox3_Leave(object sender, EventArgs e) { int i = mpallets.IndexOf(mpallets.First(o => o.Palette.Id == pallets[comboBox2.SelectedIndex].Id)); if (textBox3.Text != "") { Event.MyPalette mph = mpallets[i]; mph.Plus = Int32.Parse(textBox3.Text); mpallets[i] = mph; } }
/// <summary>Populate the fields of the control using adb.exe</summary> private void PopulateUsingAdb() { try { m_btn_connect.Enabled = false; // Only if adb.exe is found if (!ValidAdbPath) { return; } UpdateAdbVersionInfo(true); // Setup the device list var output = Adb("devices"); var ofs = output.IndexOf("List", StringComparison.Ordinal); var list = ofs != -1 ? output.Substring(ofs) : string.Empty; var devices = list.Split(new[] { Environment.NewLine, "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries); m_device_list.Clear(); foreach (var device_row in devices.Skip(1)) { var device = device_row.Split(new[] { " ", "\t" }, StringSplitOptions.RemoveEmptyEntries); if (device.Length == 0) { continue; } m_device_list.Add(device[0].Trim()); } // Select the preferred device if (PreferredDevice.HasValue()) { int idx = PreferredDevice == UsbDevice ? m_device_list.IndexOf(x => !x.Contains(".")) // Select the one that doesn't look like an ip address : m_device_list.IndexOf(x => x.Contains(PreferredDevice)); if (idx != -1) { m_bs_device_list.CurrencyManager.Position = idx; } } // Enable the connect button m_btn_connect.Enabled = true; m_btn_resetadb.Enabled = true; UpdateAdbCommand(); } catch (Exception ex) { Log.Write(ELogLevel.Error, ex, "Error while running adb"); } }
private void saveProgram(Programme program) { program.Name = programNameTextBox.Text; program.Description = programDescriptionTextBox.Text; int index = programs.IndexOf(program); if (index == -1) { programs.Add(program); } }
public Int32 IndexOfProfileWithFilePath(String filePath) { foreach (NodeProfile pro in Profiles) { if (pro.FilePath == filePath) { return(Profiles.IndexOf(pro)); } } return(-1); }
private void saveOrganisation(Organisation organisation) { organisation.Name = organisationNameTextBox.Text; organisation.Size = Convert.ToInt32(organisationSizeTextBox.Text); organisation.Address = organisationAddressAddressControl.GetAddress(); int index = organisations.IndexOf(organisation); if (index == -1) { organisations.Add(organisation); } }
private void UpdateOverlay(object sender, EventArgs e) { ImageOverlay overlay = overlaysListBox.SelectedItem as ImageOverlay; overlay.FullPath = fileTextBox.Text; overlay.FileName = Path.GetFileName(overlay.FullPath); overlay.VerticalAlignment = _verticalAlignment; overlay.HorizontalAlignment = _horizontalAlignment; overlay.Margin = (int)marginNumericUpDown.Value; _overlays.ResetItem(_overlays.IndexOf(overlay)); ClearFields(); }
private void MoveUpButton_Click(object sender, EventArgs e) { var macro = macroListBox.SelectedItem as SavedMacro; var index = macros.IndexOf(macro); if (index > 0) { var temp = macros[index - 1]; macros[index - 1] = macro; macros[index] = temp; macroListBox.SelectedIndex = index - 1; } }
public void AddComponent(BasicNewtonian component, int numberAdded) { if (!ComponentList.Contains(component)) { ComponentList.Add(component); ComponentCount.Add(numberAdded); } else { int index = ComponentList.IndexOf(component); ComponentCount[index] += numberAdded; } }
protected virtual void OnFilterAdded(string filter) { int itemIndex = filters.IndexOf(filter); if (itemIndex != -1) { filters.RemoveAt(itemIndex); } filters.Insert(0, filter); FiltersChanged.Invoke(this, EventArgs.Empty); }
private void Delete(object sender, EventArgs e) { selectedUser = listBox1.GetItemText(listBox1.SelectedItem); foreach (Customer c in customer) { if (c.socialSec == selectedUser) { Index = customer.IndexOf(customer.Single(i => i.socialSec == selectedUser)); customer.RemoveAt(Index); return; } } MessageBox.Show("You need an item selected!"); }
private void SupprimerLigne(object sender, EventArgs e) { try { if (_currentDeclaration == null) { return; } if (_currentDeclaration.Cloturer) { throw new ApplicationException("Opération invalide! [Déclaration est validé]"); } List <LigneView> listLigne = new List <LigneView>(); foreach (var row in viewLigne.GetSelectedRows()) { listLigne.Add(viewLigne.GetRow(row) as LigneView); } var result = XtraMessageBox.Show( string.Format("Voulez vous supprimer {0} Ligne(s) ?", listLigne.Count), Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result != DialogResult.Yes) { return; } foreach (var ligne in listLigne) { if (ligne == null) { continue; } _controller.Delete(ligne); var indexOld = _listLignes.IndexOf(ligne); _listLignes.Remove(ligne); if (indexOld < 0) { return; } } //viewLigne.FocusedRowHandle = indexOld - 1; } catch (Exception ex) { XtraMessageBox.Show(ex.Message, ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void tool_moveUpTool_Click(object sender, EventArgs e) { if (listBox_seq.SelectedItem != null) { ElfBase elf = listBox_seq.SelectedItem as ElfBase; int index = elfList.IndexOf(elf); if (index <= 0) { return; } elfList.Remove(elf); elfList.Insert(index - 1, elf); listBox_seq.SelectedItem = elf; } }
private void buttonBuscarUsuario_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridViewUsuarios.Rows) { if (row.Cells[1].Value.ToString().Equals(textBoxBuscadorUsuarios.Text)) { dataGridViewUsuarios.ClearSelection(); row.Selected = true; FormAjustesUsuario f = new FormAjustesUsuario(listaUsuarios, (Usuario)dataGridViewUsuarios.SelectedRows[0].DataBoundItem); indexUsuarios = listaUsuarios.IndexOf((Usuario)dataGridViewUsuarios.SelectedRows[0].DataBoundItem); f.ShowDialog(); listaUsuarios[indexUsuarios] = (Usuario)dataGridViewUsuarios.SelectedRows[0].DataBoundItem; } } }
private void buttonBuscarActividad_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridViewActividades.Rows) { if (row.Cells[1].Value.ToString().Equals(textBoxBuscadorActividades.Text)) { dataGridViewActividades.ClearSelection(); row.Selected = true; FormAjustesActividad f = new FormAjustesActividad(listaActividades, (Actividad)dataGridViewActividades.SelectedRows[0].DataBoundItem); indexActividades = listaActividades.IndexOf((Actividad)dataGridViewActividades.SelectedRows[0].DataBoundItem); f.ShowDialog(); listaActividades[indexActividades] = (Actividad)dataGridViewActividades.SelectedRows[0].DataBoundItem; } } }
private void buttonBuscarLibrerias_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridViewLibrerias.Rows) { if (row.Cells[1].Value.ToString().Equals(textBoxBuscadorLibrerias.Text)) { dataGridViewLibrerias.ClearSelection(); row.Selected = true; FormAjustesLibreria f = new FormAjustesLibreria(listaLibrerias, (Libreria)dataGridViewLibrerias.SelectedRows[0].DataBoundItem); indexLibrerias = listaLibrerias.IndexOf((Libreria)dataGridViewLibrerias.SelectedRows[0].DataBoundItem); f.ShowDialog(); listaLibrerias[indexLibrerias] = (Libreria)dataGridViewLibrerias.SelectedRows[0].DataBoundItem; } } }
private void DownButton_Click(object sender, RoutedEventArgs e) { var item = OperationsList.SelectedItem as StringOperation; if (item != null) { int index = operationsList.IndexOf(item); if (index < operationsList.Count - 1) { operationsList.RemoveAt(index); operationsList.Insert(index + 1, item); OperationsList.SelectedIndex = index + 1; } } }
private void BT_CondicionadaAOtraRestricción_Click(object sender, EventArgs e) { Form_ListaRestricciones form_ListaRestricciones = new Form_ListaRestricciones(listaRestricciones); if (form_ListaRestricciones.ShowDialog() == DialogResult.OK) { IRestriccion restriccionActualConCondicion = restriccionActual(); restriccionActualConCondicion.condicion = new Condicion(); restriccionActualConCondicion.condicion.tipo = Tipo.CondicionadaPor; restriccionActualConCondicion.condicion.EtiquetaRestriccionAnidada = form_ListaRestricciones.restriccionElegida.etiqueta; IRestriccion restriccionCondicionante = listaRestricciones.Where(r => r.etiqueta == form_ListaRestricciones.restriccionElegida.etiqueta).First(); restriccionCondicionante.condicion = new Condicion(); restriccionCondicionante.condicion.tipo = Tipo.CondicionaA; restriccionCondicionante.condicion.EtiquetaRestriccionAnidada = restriccionActualConCondicion.etiqueta; //restriccionActualConCondicion.agregarALista(listaRestricciones); listaRestricciones.Insert(listaRestricciones.IndexOf(restriccionCondicionante) + 1, restriccionActualConCondicion); limpiarPrescripcion(); if (!CB_Estructura.Items.Contains(estructura().nombre)) { CB_Estructura.Items.Add(estructura().nombre); } fijarEsParaExtraccion(); MessageBox.Show("Se agregó la restricción a la lista"); } }
private void InsertToTheRightPlace(ViewModel currentfile) { Labels.CurrentStatus = Status.Processing; FaceFormToolStripStatusLabel.Text = $"{currentfile.File} {Utilities.GetValueOfSetting(FaceFormToolStripStatusLabel.Name)}"; if (!_viewModels.Any()) { _viewModels.Add(currentfile); return; } if (_viewModels.Select(v => v.File).ToArray().Contains(currentfile.File)) { return; } foreach (var v in _viewModels) { if (int.Parse(currentfile.File) <= int.Parse(v.File)) { _viewModels.Insert(_viewModels.IndexOf(v), currentfile); break; } if (v == _viewModels.Last()) { _viewModels.Add(currentfile); break; } } }
private void BtnAgregarArticulo_Click(object sender, EventArgs e) { if (int.TryParse(txtCantidad.Text, out int cantidad)) { if (cantidad > ExistenciaArticulo) { MessageBox.Show($"No contamos con la cantidad indicada de artículos en existencia.\n la cantidad actual del artículo es: {ExistenciaArticulo}"); txtCantidad.Text = ExistenciaArticulo.ToString(); } else { var detalleNota = DetallesNotas.FirstOrDefault(x => x.IdArticulo.ToString() == txtIdArticulo.Text); if (detalleNota != null) { detalleNota.Cantidad = cantidad; } else { DgvDetalleNota data = DetallesNotas.AddNew(); data.Cantidad = cantidad; data.IdArticulo = Convert.ToInt32(txtIdArticulo.Text); data.Articulo = txtDescripcionArticulo.Text; data.PrecioVenta = Convert.ToDecimal(txtPrecioUnitario.Text); data.Total = data.Cantidad * data.PrecioVenta; DetallesNotas.EndNew(DetallesNotas.IndexOf(data)); } LimpiarArticulo(); } } else { MessageBox.Show("Ingrese una cantidad válida."); } }
/// <summary> 检查编辑后的定义集合是否符合命名的唯一性规范 </summary> /// <param name="originaldefinitions"></param> /// <param name="defToEdit">被编辑的定义,此定义是位于 originaldefinitions 集合中的</param> /// <param name="editedDef">被编辑后的新的定义</param> /// <param name="errorMessage"></param> /// <returns></returns> private bool CheckEditDefinition(BindingList <T> originaldefinitions, Definition defToEdit, Definition editedDef, out string errorMessage) { if (string.IsNullOrEmpty(editedDef.Name)) { errorMessage = "必须为当前参数定义指定一个名称。"; return(false); } // 先将新名称替换掉旧名称 var index = originaldefinitions.IndexOf((T)defToEdit); var namesT = originaldefinitions.Select(r => r.Name).ToList(); namesT[index] = editedDef.Name; // // 检查有没有重复的名称 SortedSet <string> names = new SortedSet <string>(); foreach (var n in namesT) { names.Add(n); } if (names.Count < namesT.Count) { errorMessage = "新添加的参数定义与现有集合中的定义重名。"; return(false); } errorMessage = "成功"; return(true); }
/// <summary> /// Suppression d'une requête /// </summary> /// <param name="id">id de la requête à supprimer</param> public void Delete(int id) { if (_requests.Any(a => a.Id == id)) { _requests.RemoveAt(_requests.IndexOf(_requests.First(a => a.Id == id))); } }
private void checkBoxWornByCorpse_CheckedChanged(object sender, EventArgs e) { var currentThing = (SaveThing)listBoxApparel.SelectedItem; currentThing.WornByCorpse = checkBoxWornByCorpse.Checked; _pawnApparelBindingList.ResetItem(_pawnApparelBindingList.IndexOf(currentThing)); }
public void RefreshProgram(IProgram program) { int index = -1; foreach (ProgramEntry CE in _MyObservPrograms) // let's search for index { if (CE.Id == program.Id) { index = _MyObservPrograms.IndexOf(CE); break; } } if (index >= 0) // we found it { // we update the observation collection program = _context.Programs.Where(c => c.Id == program.Id).FirstOrDefault(); //refresh if (program != null) { try // sometimes, index could be wrong id program has been deleted { _MyObservPrograms[index].State = program.State; } catch { } } } }
public void RefreshStreamingEndpoint(IStreamingEndpoint origin) { int index = -1; foreach (StreamingEndpointEntry CE in _MyObservStreamingEndpoints) // let's search for index { if (CE.Id == origin.Id) { index = _MyObservStreamingEndpoints.IndexOf(CE); break; } } if (index >= 0) // we found it { // we update the observation collection origin = _context.StreamingEndpoints.Where(o => o.Id == origin.Id).FirstOrDefault(); //refresh if (origin != null) { _MyObservStreamingEndpoints[index].State = origin.State; if (origin.ScaleUnits != null) { _MyObservStreamingEndpoints[index].ScaleUnits = (int)origin.ScaleUnits; } } Debug.WriteLine("Refresh streaming endpoint status"); } }
private void UpdateList(MultiSelectListBoxItem item = null) { SelectedItemNum = ListBoxItems.Count(x => x.ListItemFlag); lblNumber.Text = $"{SelectedItemNum}/{MaxListItem}"; if (item == null) { ListBoxItems.ResetBindings(); } else { ListBoxItems.ResetItem(ListBoxItems.IndexOf(item)); } if (SelectedItemNum > 0 && SelectedItemNum <= MaxListItem) { if (!cmdFinish.Enabled) { cmdFinish.Enabled = true; } } else if (cmdFinish.Enabled) { cmdFinish.Enabled = false; } }
/// <summary> /// Click auf Condition Group /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lbConditionList_SelectionChanged(object sender, SelectionChangedEventArgs e) { var k = ((ListBox)sender).SelectedIndex; if (k >= 0) { //Bedingungsgruppe ermitteln var conditongroup = Playlists.GetPlaylists[lbPlaylist.SelectedIndex].PlaylistConditionGroups[ lbConditionList.SelectedIndex]; //Namen der Felder hinterlegen lbFelder.ItemsSource = conditongroup.FieldNamesList; //Operator für ide Felder anzeigen. string z = conditongroup.CombineOperator.ToString(); var d = conditionGroupOperator.IndexOf(z); cbConditionGroupOperator.SelectedIndex = d; btnAddField.IsEnabled = true; lbFelder.Visibility = Visibility.Visible; gridlbfelder.Visibility = Visibility.Visible; btnDeleteConditionGroup.IsEnabled = true; btnEditConditionGroup.IsEnabled = true; } else { btnDeleteConditionGroup.IsEnabled = false; btnEditConditionGroup.IsEnabled = false; btnAddField.IsEnabled = false; lbFelder.ItemsSource = null; lbFelder.Visibility = Visibility.Hidden; gridlbfelder.Visibility = Visibility.Hidden; } gridStringIntFelder.Visibility = Visibility.Hidden; }
public void RefreshChannel(IChannel channel) { int index = -1; foreach (ChannelEntry CE in _MyObservChannels) // let's search for index { if (CE.Id == channel.Id) { index = _MyObservChannels.IndexOf(CE); break; } } if (index >= 0) // we found it { // we update the observation collection channel = _context.Channels.Where(c => c.Id == channel.Id).FirstOrDefault(); //refresh if (channel != null) { _MyObservChannels[index].State = channel.State; } Debug.WriteLine("Refresh channel status"); // this.Refresh(); } }
/// <summary> /// 更新表格显示 /// </summary> /// <param name="arch">编辑记录信息</param> private void UpdateGridView(ArchiveInfoDto arch) { string curOpera = null;// ctrlPanel.Tag.ToString(); switch (curOpera) { case "Add": // “新增”操作时对表格的更新 // 更新记录集 arvList.Add(arch); if (gcArvInfo.DataSource != arvList) { // 表格关联数据集发生变化,更新数据集 gcArvInfo.DataSource = arvList; ClearSearch(); // 清除搜索结果 } break; case "Edit": // “修改”操作时对表格的更新 // 获取当前表格中记录 BindingList <ArchiveInfoDto> bindingList = (BindingList <ArchiveInfoDto>)gcArvInfo.DataSource; // 查找被修改的记录 ArchiveInfoDto arv = bindingList.First(p => p.ID == arch.ID); //(p => p.ArvID == arch.ArvID); // 用新的记录替代原纪录,表格自动更新 bindingList[bindingList.IndexOf(arv)] = arch; break; default: break; } }
protected override void OnPackageReceived(Package package) { base.OnPackageReceived(package); switch ((Commands)package.Command) { case Commands.InstantMessage: Pusher.Push(InstantMessageContent.Deserialize(package.Content)); break; case Commands.Screenshot: Pusher.Push(ScreenshotContent.Deserialize(package.Content)); break; case Commands.CursorPosition: var args = ClientCursorContent.Deserialize(package.Content); var find = clientCursorPositions.FirstOrDefault(c => c.ClientName == args.ClientName); if (find == null) { clientCursorPositions.Add(args); } else { int index = clientCursorPositions.IndexOf(find); if (index != -1) { clientCursorPositions[index] = args; } } break; } }
private void Update1(Student student, Student stuNeedUpdate) { int index = students.IndexOf(student); students.Remove(student); students.Insert(index, stuNeedUpdate); }
public static void PopulatePosition(DataRow TeamData, BindingList<string> Position) { if (TeamData[3].ToString() != "") index = Position.IndexOf(TeamData[3].ToString() + ' ' + TeamData[2].ToString()); else index = Position.IndexOf(TeamData[2].ToString()); if (index >= 0) { } else { if (TeamData[3].ToString() != "") Position.Add(TeamData[3].ToString() + ' ' + TeamData[2].ToString()); else Position.Add(TeamData[2].ToString()); index = Position.IndexOf(TeamData[2].ToString()); } }
private void UpdateImagesInfoGrid() { string selectedRowFileName = string.Empty; if (ImagesInfoGrid.SelectedRows.Count != 0) selectedRowFileName = ((ImageFileData)ImagesInfoGrid.SelectedRows[0].DataBoundItem).FileName; IEnumerable<ImageFileData> imagesInfo = manager.GetAllImagesInfo(true); if (imagesInfo == null) return; ImagesInfoGrid.Rows.Clear(); var bindingList = new BindingList<ImageFileData>(new List<ImageFileData>(imagesInfo)); ImagesInfoGrid.Invoke(new MethodInvoker(delegate() { ImagesInfoGrid.DataSource = bindingList; })); ImageFileData rowObject = bindingList.SingleOrDefault(p => p.FileName.Equals(selectedRowFileName)); if (rowObject != null) ImagesInfoGrid.Rows[bindingList.IndexOf(rowObject)].Selected = true; }
public void MovePositionRow(CBatch_detail_aa_twofold row_ini, CBatch_detail_aa_twofold row_end) { CBatch_detail_aa_twofoldFactory faBatch_detail_aa_twofold = new CBatch_detail_aa_twofoldFactory(); BindingList<CBatch_detail_aa_twofold> lst = new BindingList<CBatch_detail_aa_twofold>(ListSamples); // --- copiar muestra drag como temporal CBatch_detail_aa_twofold tmp_row_ini = lst.Single(c => c.Cod_interno == row_ini.Cod_interno); CBatch_detail_aa_twofold tmp_row_end = lst.Single(c => c.Cod_interno == row_end.Cod_interno); // --- quitar muestra drag de la lista lst.Remove(tmp_row_ini); // --- obetener indice o posición a donde será movido int new_index_end = lst.IndexOf(tmp_row_end); // --- insertar la muestra que fue removida lst.Insert(new_index_end, tmp_row_ini); // --- reset orden de las muestras short count = 1; foreach (CBatch_detail_aa_twofold item in lst) { item.Order_sample_batch = count; count++; faBatch_detail_aa_twofold.Update(item); } // --- get source data dtPivotBatch = new BindingList<CBatch_detail_aa_twofold>( faBatch_detail_aa_twofold .GetAll() .Where(c => c.Idbatch == Idbatch && c.Idtemplate_method == Idtemplate_method).ToList()); }
private void FormAddPerson_Load(object sender, EventArgs e) { BindingList<Address> addresses = new BindingList<Address>(_repo.GetAddresses()); comboBoxAddresses.DataSource = addresses; var index = (from a in addresses where a.Id == _addressId select addresses.IndexOf(a)).FirstOrDefault(); comboBoxAddresses.SelectedIndex = index; }
private bool CheckLabelsListWithXml(out string summary_results) { TextWriter summary_file_csv = null; TextWriter summary_file_html = null; bool Is_LabelsList_Valid = true; summary_results = ""; string[] str_temp; try { DateTime start_time, end_time; TimeSpan ts, ts_start, ts_end, total_time, total_time_inv; string category, current_label, readline; //Create Summary Lists BindingList<string> List_Annotated = new BindingList<string>(); BindingList<string> List_NoAnnotated = new BindingList<string>(); BindingList<string> List_Invalid = new BindingList<string>(); BindingList<TimeSpan> List_Time = new BindingList<TimeSpan>(); BindingList<TimeSpan> List_Time_Inv = new BindingList<TimeSpan>(); BindingList<string> List_Current_XML; //Create the files for summarizing results // Create the csv file if (File.Exists(Folder_audioannotation + "AnnotationSummary.csv")) { File.Delete(Folder_audioannotation + "AnnotationSummary.csv"); } summary_file_csv = new StreamWriter(Folder_audioannotation + "AnnotationSummary.csv"); summary_file_csv.WriteLine("Label,Time(hh:mm:ss)"); // Create the html file if (File.Exists(Folder_audioannotation + "AnnotationSummary.html")) { File.Delete(Folder_audioannotation + "AnnotationSummary.html"); } summary_file_html = new StreamWriter(Folder_audioannotation + "AnnotationSummary.html"); summary_file_html.WriteLine("<table border=\"1\">\n"); summary_file_html.WriteLine("<tr><td>Label</td><td>Time(hh:mm:ss)</td></tr>"); // ---------- Load labels ------------------ int count = 0; int index = 0; for (int c = 1; c <= 2; c++) { //Initialize lists List_Annotated.Clear(); List_NoAnnotated.Clear(); List_Invalid.Clear(); List_Time.Clear(); List_Time_Inv.Clear(); total_time = TimeSpan.Zero; total_time_inv = TimeSpan.Zero; //Indicate the category if (c == 1) { count = LabelsList_1.Count; List_Current_XML = list_category_1; //category = "Postures"; category = list_category_name[0]; } else { count = LabelsList_2.Count; List_Current_XML = list_category_2; //category = "Activities"; category = list_category_name[1]; } //Read each item from the list for (int i = 0; i < count; i++) { if (c == 1) { readline = LabelsList_1[i]; } else { readline = LabelsList_2[i]; } string[] tokens = readline.Split(';'); //Check the row has valid start/end times if (tokens[0].CompareTo("ok") == 0) { current_label = tokens[5]; //filter labels comming from blank rows if (current_label.Trim().CompareTo("") != 0) { //Check if the label is valid according to the Xml protocol list //if not, flag the label as invalid if (List_Current_XML.Contains(current_label)) { //Start Time str_temp = tokens[3].Split('.'); start_time = DateTime.Parse(StartDate + " " + str_temp[0]); ts_start = (start_time - new DateTime(1970, 1, 1, 0, 0, 0)); //Stop Time str_temp = tokens[4].Split('.'); end_time = DateTime.Parse(EndDate + " " + str_temp[0]); ts_end = (end_time - new DateTime(1970, 1, 1, 0, 0, 0)); ts = ts_end.Subtract(ts_start); total_time = total_time + ts; if (!List_Annotated.Contains(current_label)) { List_Annotated.Add(current_label); List_Time.Add(ts); } else { index = List_Annotated.IndexOf(current_label); //ts_start = List_Time[index]; //ts = ts + ts_start; List_Time[index] = ts + List_Time[index]; } //Check if the total time spend on this label makes sense (greater than 0) //If so, add the label to the annotated list //Otherwise, highlighted as problematic and don't generate the xml file if ( ts.TotalSeconds == 0) { Is_LabelsList_Valid = false; #region highlight label in yellow int iloop = 0; int irow = 0; while(iloop <2) { if(iloop == 0) { //Highlight Start Row irow = Int32.Parse(tokens[1]); } else if(iloop == 1) { //Highlight End Row irow = Int32.Parse(tokens[2]); } iloop++; if (c == 1) { dataGridView1.Rows[irow].Cells[C1.category_label].Style.BackColor = System.Drawing.Color.Khaki; dataGridView1.Rows[irow].Cells[C1.category_label].Style.ForeColor = System.Drawing.Color.DimGray; dataGridView1.Rows[irow].Cells[C1.StartEnd].Style.BackColor = System.Drawing.Color.Khaki; dataGridView1.Rows[irow].Cells[C1.StartEnd].Style.ForeColor = System.Drawing.Color.DimGray; } else if (c == 2) { dataGridView1.Rows[irow].Cells[C2.category_label].Style.BackColor = System.Drawing.Color.Khaki; dataGridView1.Rows[irow].Cells[C2.category_label].Style.BackColor = System.Drawing.Color.DimGray; dataGridView1.Rows[irow].Cells[C2.StartEnd].Style.BackColor = System.Drawing.Color.Khaki; dataGridView1.Rows[irow].Cells[C2.StartEnd].Style.ForeColor = System.Drawing.Color.DimGray; } } #endregion } } // if label not found in xml protocol, flag as invalid else { Is_LabelsList_Valid = false; #region higlight row in red int iloop = 0; int irow = 0; while (iloop < 2) { if (iloop == 0) { //Highlight Start Row irow = Int32.Parse(tokens[1]); } else if (iloop == 1) { //Highlight End Row irow = Int32.Parse(tokens[2]); } iloop++; if (c == 1) { dataGridView1.Rows[irow].Cells[C1.category_label].Style.BackColor = System.Drawing.Color.Tomato; dataGridView1.Rows[irow].Cells[C1.category_label].Style.ForeColor = System.Drawing.Color.White; dataGridView1.Rows[irow].Cells[C1.StartEnd].Style.BackColor = System.Drawing.Color.Tomato; dataGridView1.Rows[irow].Cells[C1.StartEnd].Style.ForeColor = System.Drawing.Color.White; } else if (c == 2) { dataGridView1.Rows[irow].Cells[C2.category_label].Style.BackColor = System.Drawing.Color.Tomato; dataGridView1.Rows[irow].Cells[C2.category_label].Style.BackColor = System.Drawing.Color.White; dataGridView1.Rows[irow].Cells[C2.StartEnd].Style.BackColor = System.Drawing.Color.Tomato; dataGridView1.Rows[irow].Cells[C2.StartEnd].Style.ForeColor = System.Drawing.Color.White; } } #endregion //Start Time str_temp = tokens[3].Split('.'); start_time = DateTime.Parse(StartDate + " " + str_temp[0]); ts_start = (start_time - new DateTime(1970, 1, 1, 0, 0, 0)); //Stop Time str_temp = tokens[4].Split('.'); end_time = DateTime.Parse(EndDate + " " + str_temp[0]); ts_end = (end_time - new DateTime(1970, 1, 1, 0, 0, 0)); ts = ts_end.Subtract(ts_start); total_time_inv = total_time_inv + ts; if (!List_Invalid.Contains(current_label)) { List_Invalid.Add(current_label); List_Time_Inv.Add(ts); } else { index = List_Invalid.IndexOf(current_label); ts_start = List_Time_Inv[index]; ts = ts + ts_start; List_Time_Inv[index] = ts; } } } //else (if label == blank), do nothing }//if token ok }//for labels list per category //------------------------------------------ //Compute the No-Annotated Labels //check for blank labels foreach(string ilabel in List_Current_XML) { if (ilabel.Trim().CompareTo("") != 0) { if (!List_Annotated.Contains(ilabel)) { List_NoAnnotated.Add(ilabel); } } //else if(label == blank), do nothing } //------------------------------------------ // Write the summary of results to file //------------------------------------------- string font_color_open = ""; string font_color_close = ""; // Annotatated List summary_file_csv.WriteLine("Annotated "+ category + ","); summary_results = summary_results + "Annotated " + category + ":,," + "#" + ";"; summary_file_html.WriteLine("<tr bgcolor=\"#E6E6E6\">\n<td><strong>Annotated " + category + "</strong></td><td> </td></tr>"); int it = 0; foreach (string clabel in List_Annotated) { ts = List_Time[it]; // Save record to the correspondent session summary_file_csv.WriteLine(clabel + "," + ts.ToString()); summary_file_html.WriteLine("<tr>\n<td>" + clabel + "</td><td>" + ts.ToString() + "</td></tr>"); summary_results = summary_results + clabel + "," + ts.ToString() + ";"; it++; } summary_file_csv.WriteLine("Total Time Annotated "+ category + "," + total_time.ToString()); summary_file_csv.WriteLine(""); font_color_open = "<strong><font color=\"#4E8975\">"; font_color_close = "</font><strong>"; summary_file_html.WriteLine("<tr>\n<td>"+ font_color_open +"Total Time Annotated " + category + font_color_close +"</td>" + "<td>"+ font_color_open + total_time.ToString() + font_color_close + "</td></tr>"); summary_file_html.WriteLine("<tr>\n<td> </td><td> </td></tr>"); summary_results = summary_results + "Total Time Annotated " + category + "," + total_time.ToString() + ",##;"; summary_results = summary_results +";"; // No Annotated List summary_file_csv.WriteLine("No Annotated " + category + " in Xml Protocol,"); summary_file_html.WriteLine("<tr bgcolor=\"#E6E6E6\">\n<td><strong>No Annotated " + category + " in Xml Protocol</strong></td><td> </td></tr>"); summary_results = summary_results + "No Annotated " + category + " in Xml Protocol:,,#" + ";"; foreach (string jlabel in List_NoAnnotated) { summary_file_csv.WriteLine(jlabel); summary_file_html.WriteLine("<tr>\n<td>" + jlabel + "</td><td> </td></tr>"); summary_results = summary_results + jlabel + ";"; } summary_file_csv.WriteLine(""); summary_file_html.WriteLine("<tr>\n<td> </td><td> </td></tr>"); summary_results = summary_results + ";"; summary_file_csv.WriteLine("Invalid " + category + ","); summary_file_html.WriteLine("<tr bgcolor=\"#E6E6E6\">\n<td><strong> Invalid " + category + "</strong></td><td> </td></tr>"); summary_results = summary_results + "Invalid " + category + ":,," + "#" + ";"; font_color_open = "<font color=\"#FA5858\">"; font_color_close = "</font>"; it = 0; foreach (string klabel in List_Invalid) { ts = List_Time_Inv[it]; // Save record to the correspondent session summary_file_csv.WriteLine(klabel + "," + ts.ToString()); summary_file_html.WriteLine("<tr>\n<td>" + font_color_open + klabel + font_color_close + "</td>" + "<td>" + font_color_open + ts.ToString() + font_color_close + "</td></tr>"); summary_results = summary_results + klabel + "," + ts.ToString() + ",###;"; it++; } summary_file_csv.WriteLine("Total Time Invalid " + category + "," + total_time_inv.ToString()); summary_file_csv.WriteLine(""); font_color_open = "<strong><font color=\"#FA5858\">"; font_color_close = "</font></strong>"; summary_file_html.WriteLine("<tr>\n<td>"+ font_color_open + "Total Time Invalid " + category + font_color_close+"</td>" + "<td>"+ font_color_open + total_time_inv.ToString() + font_color_close + "</td></tr>"); summary_file_html.WriteLine("<tr>\n<td> </td><td> </td></tr>"); summary_results = summary_results + "Total Time Invalid " + category + "," + total_time_inv.ToString() + ",#-;"; summary_results = summary_results + ";"; //-------------------------------------------- }//for each category label // Close summary file csv summary_file_csv.Flush(); summary_file_csv.Close(); // Close summary file csv summary_file_html.WriteLine("</table>"); summary_file_html.Flush(); summary_file_html.Close(); return Is_LabelsList_Valid; } catch { Is_LabelsList_Valid = false; if (summary_file_csv != null) { summary_file_csv.Flush(); summary_file_csv.Close(); } if (summary_file_html != null) { summary_file_html.Flush(); summary_file_html.Close(); } return Is_LabelsList_Valid; } }