public ActionResult DeleteConfirmed(int id) { TextPiece textPiece = db.TextPieces.Find(id); db.TextPieces.Remove(textPiece); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Title,Author,Rating")] TextPiece textPiece) { if (ModelState.IsValid) { db.Entry(textPiece).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(textPiece)); }
//将文字数据应用到UI上 public void SetText(TextPiece currentPiece, string name, string dialog, string voice, string avatar = "") { this.currentPiece = currentPiece; nameLabel.text = AddColor(name); dialogLabel.text = ChangeName(dialog); //TODO : 头像 te.ResetToBeginning(); typewriting = true; //添加文字记录 AddToTable(new BacklogText(name, dialog, voice)); }
public ActionResult Create([Bind(Include = "Id,Title,Author,Rating")] TextPiece textPiece) { if (ModelState.IsValid) { var x = textPiece.Author; db.TextPieces.Add(textPiece); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(textPiece)); }
// GET: TextPieces/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TextPiece textPiece = db.TextPieces.Find(id); if (textPiece == null) { return(HttpNotFound()); } return(View(textPiece)); }
private void ReadNumber() { var start = position; var hasDecimal = false; if (current == '-') { position++; } while (char.IsDigit(current) || current == '_' || current == '.') { if (current == '.' && hasDecimal) { hasDecimal = true; position++; } else { position++; } } var t = input.Slice(start, position); //double? val = Convert.ToDouble(t); if (double.TryParse(t, out double val)) { value = val; type = SyntaxType.NUMBER_TOKEN; } else { var span = new TextSpan(start, position); var piece = new TextPiece(input, span); Error("Invalid number", piece); } /*if (!val.HasValue) * { * var span = new TextSpan(start, position); * var loc = new TextLocation(input, span); * * Error("Invalid number", loc); * } * * value = val; * type = SyntaxType.NUMBER_TOKEN;*/ }
/// <summary> /// 原有基础上添加文字 /// </summary> /// <param name="currentPiece"></param> /// <param name="dialog">文字</param> /// <param name="voice">对应语音</param> public void AddText(TextPiece currentPiece, string dialog) { // 设置成禁用右键和滚轮? DataManager.GetInstance().BlockRightClick(); DataManager.GetInstance().BlockWheel(); this.currentPiece = currentPiece; // 不显示姓名 namePanel.SetActive(false); // 替换主角姓名文本 dialog = ChangeName(dialog); SetContentStyle(); // 打字机 te.enabled = true; te.ResetTo(dialog); typewriting = true; // 关闭头像 avatarPanel.SetActive(false); }
/// <summary> /// 将文字数据应用到UI上 /// </summary> /// <param name="currentPiece"></param> /// <param name="name">角色姓名</param> /// <param name="dialog">对话</param> /// <param name="voice">语音文件</param> /// <param name="avatar">头像文件</param> public void SetText(TextPiece currentPiece, string dialog, string name, string avatar) { // 设置成禁用右键和滚轮? DataManager.GetInstance().BlockRightClick(); DataManager.GetInstance().BlockWheel(); this.currentPiece = currentPiece; SetNameText(name); // 替换主角姓名文本 dialog = ChangeName(dialog); //dialogLabel.text = ; SetContentStyle(); // 打字机 te.enabled = true; te.ResetToBeginning(dialog); typewriting = true; // 头像 SetAvatar(avatar); }
private void ReadString() { position++; var sb = ""; var done = false; while (!done) { switch (current) { case '\0': case '\r': case '\n': var span = new TextSpan(start, 1); var piece = new TextPiece(input, span); Error("Unterminated string", piece); done = true; break; case '"': if (peek == '"') { sb += current; position += 2; } else { position++; done = true; } break; default: sb += current; position++; break; } } type = SyntaxType.STRING_TOKEN; value = sb; }
//将文字数据应用到UI上 public void SetText(TextPiece currentPiece, string name, string dialog, string voice, string avatar = "") { //设置成禁用右键和滚轮? DataManager.GetInstance().BlockRightClick(); DataManager.GetInstance().BlockWheel(); this.currentPiece = currentPiece; //在原有基础上添加新文字? dialogLabel.text = "[FFFFFF]" + dialogLabel.text + "[-]"; dialogLabel.text += ChangeName(dialog); //去掉颜色标签符号 Regex rx = new Regex(@"\[[^\]]+\]"); DataManager.GetInstance().tempData.currentText = rx.Replace(dialogLabel.text, ""); //打字机 te.enabled = true; te.ResetToBeginning(); typewriting = true; //添加文字记录 AddToTable(new BacklogText(name, dialog, voice)); }
//将文字数据应用到UI上 public void SetText(TextPiece currentPiece, string name, string dialog, string voice, string avatar = "") { //设置成禁用右键和滚轮? DataManager.GetInstance().BlockRightClick(); DataManager.GetInstance().BlockWheel(); this.currentPiece = currentPiece; nameLabel.text = AddColor(name); //替换已读文本 dialogLabel.text = ChangeName(dialog); dialogLabel.alpha = DataManager.GetInstance().IsTextRead(currentPiece) ? 0.5f : 1f; //去掉颜色标签符号 DataManager.GetInstance().tempData.currentText = rx.Replace(dialogLabel.text, ""); //头像 SetAvatar(avatar); //打字机 te.enabled = true; te.ResetToBeginning(); typewriting = true; //添加文字记录 AddToTable(new BacklogText(name, dialog, voice)); }
public HWPFOldDocument(DirectoryNode directory) : base(directory) { // Where are things? int sedTableOffset = LittleEndian.GetInt(_mainStream, 0x88); int sedTableSize = LittleEndian.GetInt(_mainStream, 0x8c); int chpTableOffset = LittleEndian.GetInt(_mainStream, 0xb8); int chpTableSize = LittleEndian.GetInt(_mainStream, 0xbc); int papTableOffset = LittleEndian.GetInt(_mainStream, 0xc0); int papTableSize = LittleEndian.GetInt(_mainStream, 0xc4); //int shfTableOffset = LittleEndian.GetInt(_mainStream, 0x60); //int shfTableSize = LittleEndian.GetInt(_mainStream, 0x64); int complexTableOffset = LittleEndian.GetInt(_mainStream, 0x160); // We need to get hold of the text that Makes up the // document, which might be regular or fast-saved StringBuilder text = new StringBuilder(); if (_fib.IsFComplex()) { ComplexFileTable cft = new ComplexFileTable( _mainStream, _mainStream, complexTableOffset, _fib.GetFcMin() ); tpt = cft.GetTextPieceTable(); foreach (TextPiece tp in tpt.TextPieces) { text.Append(tp.GetStringBuilder()); } } else { // TODO Discover if these older documents can ever hold Unicode Strings? // (We think not, because they seem to lack a Piece table) // TODO Build the Piece Descriptor properly // (We have to fake it, as they don't seem to have a proper Piece table) PieceDescriptor pd = new PieceDescriptor(new byte[] { 0, 0, 0, 0, 0, 127, 0, 0 }, 0); pd.FilePosition = _fib.GetFcMin(); // Generate a single Text Piece Table, with a single Text Piece // which covers all the (8 bit only) text in the file tpt = new TextPieceTable(); byte[] textData = new byte[_fib.GetFcMac() - _fib.GetFcMin()]; Array.Copy(_mainStream, _fib.GetFcMin(), textData, 0, textData.Length); TextPiece tp = new TextPiece( 0, textData.Length, textData, pd ); tpt.Add(tp); text.Append(tp.GetStringBuilder()); } _text = tpt.Text; // Now we can fetch the character and paragraph properties _cbt = new OldCHPBinTable( _mainStream, chpTableOffset, chpTableSize, _fib.GetFcMin(), tpt ); _pbt = new OldPAPBinTable( _mainStream, chpTableOffset, papTableSize, _fib.GetFcMin(), tpt ); _st = new OldSectionTable( _mainStream, chpTableOffset, sedTableSize, _fib.GetFcMin(), tpt ); }
private Token Lex() { start = position; type = SyntaxType.BAD; value = null; text = ""; switch (current) { case '\0': type = SyntaxType.EOF; break; case ',': type = SyntaxType.COMMA; position++; break; case '[': type = SyntaxType.OPEN_BRACE; position++; break; case ']': type = SyntaxType.CLOSED_BRACE; position++; break; case '|': type = SyntaxType.PIPE; position++; break; case '"': ReadString(); break; case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ReadNumber(); break; case ' ': case '\t': case '\r': case '\n': ReadWhiteSpace(); return(Lex()); case '_': ReadNodeOrKeyword(); break; default: if (char.IsLetter(current)) { ReadNodeOrKeyword(); } else if (char.IsWhiteSpace(current)) { ReadWhiteSpace(); } else { var span = new TextSpan(start, 1); var piece = new TextPiece(input, span); Error("Bad token or character", piece); position++; } break; } if (string.IsNullOrEmpty(text)) { text = input.Slice(start, position); } return(new Token(text, start, type, value)); }
private static void Error(string message, TextPiece piece) => Console.WriteLine($"Commands: Lexer Error - {{Message: {message}, Location: {piece.Span}}}");