private static Speaker MappingSpeakerSetToSpeaker(SpeakerSet speakerSet) { var separater = new string[] { ";" }; return(new Speaker { Avatar = speakerSet.Avatar, Name = speakerSet.Name, Subtitle = speakerSet.Subtitle, Skills = speakerSet.Skills.Split(separater, StringSplitOptions.RemoveEmptyEntries), Experiences = speakerSet.Experiences.Split(separater, StringSplitOptions.RemoveEmptyEntries), Introduction = speakerSet.Introduction, Remark = speakerSet.Remark }); }
/// <summary> /// Parses a cell once the user has entered data into it. /// </summary> /// <param name="e">Event Args</param> protected override void OnCellParsing(DataGridViewCellParsingEventArgs e) { int r = e.RowIndex; int c = e.ColumnIndex; switch (Columns[c].Name) { case ColumnNames.Number: break; //Set Begin, End, or Duration value case ColumnNames.Begin: case ColumnNames.End: case ColumnNames.Duration: try { //Attempt to convert the value e.Value = new Timestamp(e.Value.ToString()); } catch (InvalidTimestampException) { //Leave the value as it is e.Value = (Timestamp)Rows[r].Cells[c].Value; } finally { e.ParsingApplied = true; } break; case ColumnNames.Speaker: string s = (string)e.Value; if (SpeakerSet.ContainsKey(s)) { e.Value = SpeakerSet[s]; } else { SpeakerSet[s] = new Speaker(s); e.Value = SpeakerSet[s]; } e.ParsingApplied = true; break; case ColumnNames.Alignment: string a = (string)e.Value; //Check to see if value is equal to the alignment text name if (a.Equals("Left", StringComparison.OrdinalIgnoreCase)) { e.Value = Alignment.Left; } else if (a.Equals("Center", StringComparison.OrdinalIgnoreCase)) { e.Value = Alignment.Center; } else if (a.Equals("Right", StringComparison.OrdinalIgnoreCase)) { e.Value = Alignment.Right; } else { e.Value = Rows[r].Cells[c].Value; //If no match reset value } e.ParsingApplied = true; break; case ColumnNames.Location: break; case ColumnNames.Text: break; default: throw new ArgumentException("Invalid Column " + e.ColumnIndex, "e"); } base.OnCellParsing(e); }