private void CreateNewBook() { if (m_current == null) { throw new ArgumentNullException(nameof(m_current)); } var bookName = m_current.Title.Text; if (string.IsNullOrEmpty(bookName)) { m_general.SetError(m_current.Title, "请输入新作品的书名"); return; } if (m_story.ContainsBook(bookName)) { m_general.SetError(m_current.Title, $"作品【{bookName}】已存在"); return; } var m = m_story.AddBook(bookName); if (m != null) { m_current.SetModel(m); } SetBookCount(m_list.Count); m_general.EndEdit(m_current.Title); }
private void EditTitle() { if (m_current == null || m_general.LastText == null) { throw new ArgumentNullException((m_current == null) ? nameof(m_current) : nameof(m_general.LastText)); } if (m_current.Title.IsReadOnly) { return; } var titleType = (m_current.Children == null) ? "章节名" : "卷名"; var newName = m_current.Title.Text; if (string.IsNullOrEmpty(newName)) { m_general.SetError(m_current.Title, "请输入新的" + titleType); return; } if (newName == m_general.LastText) { m_general.SetError(m_current.Title, titleType + "并未修改"); return; } m_current.Title.Text = newName; if (m_story.Update(m_current.Model)) { m_general.EndEdit(m_current.Title); } else { m_general.SetError(m_current.Title, $"保存作品【{newName}】失败"); } }