protected override void PopulateRecords(IEnumerable <Match> lines) { foreach (var line in lines) { var rawRecord = UtfStr(line).Split('\n'); var record = new TagLine(); var movieName = rawRecord.FirstOrDefault(m => m.StartsWith("# ")); if (string.IsNullOrWhiteSpace(movieName)) { continue; } movieName = movieName.Replace('#', ' '); FixMovieNames(record, movieName.Trim()); foreach (var str in rawRecord.Where(s => !s.StartsWith("#"))) { record.TagLines.Add(str.Trim()); } if (_records.ContainsKey((MovieBase)record)) { var recordToUpdate = _records.FirstOrDefault(m => m.Key == (MovieBase)record).Value; foreach (var tagLine in record.TagLines.ToArray()) { recordToUpdate.TagLines.Add(tagLine); record.TagLines.Remove(tagLine); } } if (record.TagLines.Any()) { _records.Add((MovieBase)record, record); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Probability,Text")] TagLine tagLine) { if (id != tagLine.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tagLine); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagLineExists(tagLine.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(tagLine)); }
public async Task <IActionResult> Create([Bind("Id,Probability,Text")] TagLine tagLine) { if (ModelState.IsValid) { _context.Add(tagLine); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tagLine)); }
/// <summary>Serves as a hash function for a particular type.</summary> /// <returns>A hash code for the current <see cref="T:System.Object" />.</returns> public override int GetHashCode() { unchecked { int result = (Id != null ? Id.GetHashCode() : 0); result = (result * 397) ^ (Title != null ? Title.GetHashCode() : 0); result = (result * 397) ^ Rating.GetHashCode(); result = (result * 397) ^ (Director != null ? Director.GetHashCode() : 0); result = (result * 397) ^ ReleaseDate.GetHashCode(); result = (result * 397) ^ (TagLine != null ? TagLine.GetHashCode() : 0); result = (result * 397) ^ (Genres != null ? Genres.GetHashCode() : 0); return(result); } }
/// <summary> /// Tag单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Label_MouseDown(object sender, MouseButtonEventArgs e) { if (tagType) { Label tmp = (Label)sender; if (e.LeftButton == MouseButtonState.Pressed) { lineMap.TagClick(Times, Convert.ToInt32(tmp.Tag), GetData, table, true); } else if (e.RightButton == MouseButtonState.Pressed) { int s = 0; List <object> list = null; bool type = false; int TagUnm = 0; int Index = 0; for (int i = 0; i < GetData.Items.Count; i++) { if (Convert.ToInt32(((DataRowView)GetData.Items[i])[0].ToString().Trim()).Equals(Convert.ToInt32(tmp.Tag))) { if (i.Equals(0)) { list = ((DataRowView)GetData.Items[i]).Row.ItemArray.ToList(); TagUnm = Convert.ToInt32(tmp.Tag); Index = i; type = true; } else { list = ((DataRowView)GetData.Items[i]).Row.ItemArray.ToList(); TagUnm = Convert.ToInt32(((DataRowView)GetData.Items[i - 1])["Tag"].ToString()); Index = i; } s++; } } if (s.Equals(1))//(判断Tag是否在表格中存在)存在重复Tag只可在表格修改 { TagLine tag = new TagLine(list, Times, type, TagUnm, GetData, Index, table, lineMap); tag.Show(); } } } }
public void LoadLogFile(string pathname) { string line; System.IO.StreamReader file = new System.IO.StreamReader(pathname); while ((line = file.ReadLine()) != null) { ParseTags(line, 0); //send message to UI if (null != TagLine) { TagLine.Invoke(line); } } file.Close(); }
public void LineMapShow(List <object> list, bool type, int TagUnm, int Index) { TagLine tag = new TagLine(list, Times, type, TagUnm, GetData, Index, table, lineMap); tag.Show(); }
//we have recieved serial data, get a line of it and send it to the parser private void serialDataReceived(object sender, SerialDataReceivedEventArgs e) { string temp; string Rx; int position = 0; if (TheSerialPort.IsOpen) { int cr; try { //get rx chars RXBuffer += TheSerialPort.ReadExisting(); //is there a \n? cr = RXBuffer.IndexOf("\n"); //there HAS to be at least 1 character to be at all valid; while (cr >= 0) { //copy all data up to \n //as long as there IS data //if (cr > 1) //{ Rx = RXBuffer.Substring(position, cr - position); //send message to UI if (null != TagLine) { TagLine.Invoke(Rx); } //Trace.WriteLine(Rx + "\n"); //Process the message //try //{ // //do //may have multiple tags per line // //{ position = ParseTags(Rx, position); // //} // //while ((position > 0) && (position < Rx.Length)); //} //catch (Exception ex) //{ // Trace.WriteLine("serial0, " + ex.Message + "\n"); // Type ep = ex.GetType(); // return; //} //} //Copy everything after \n back into rx buffer, removing string just sent int len = RXBuffer.Length - (cr + 1); temp = string.Empty; //Anything left to copy? if (len > 0) { temp = RXBuffer.Substring(cr + 1, len); } RXBuffer = temp; //any more \n? position = 0; cr = RXBuffer.IndexOf("\n", position); } //position = 0; //stripError.Text = "No Errors"; } catch (Exception ex) { Trace.WriteLine("serial, " + ex.Message + "\n"); Type ep = ex.GetType(); return; } } }
public override ActionResponse Play() { return(new ActionResponse(new Message(Enums.Severity.Info, string.Format("Exploding kitten defused {0}.", TagLine.ToLower())))); }