//req addNewMsg(newMsg) private void OnaddNewMsg(string obj) { MyTitle newMsg = new MyTitle(); newMsg = JsonToTitle(obj); var tnParent = m_nodeDict[newMsg.path]; var parent = tnParent.title; newMsg.groupID = parent.groupID; newMsg.parentID = parent.ID; if (parent.type == "group") { newMsg.parentID = 0; newMsg.groupID = parent.ID; } //add to db var newObj = m_content.newTitle(newMsg); //update tree var tnChild = new Node() { id = newObj.path, name = newObj.title, title = newObj }; m_nodeDict.Add(newObj.path, tnChild); tnParent.childs.Add(tnChild); updateTree(tnParent, tnChild); //update wb string jsTxt = TitleToJson(newObj); m_wb.Navigate("javascript:onSendChatDone('" + jsTxt + "')"); }
string TitlesLstToJson(MyTitle title) { List <MyTitle> titleLst = new List <MyTitle>() { title }; return(TitlesLstToJson(titleLst)); }
string TitleToJson(MyTitle title) { //var x = createSerializer(title.GetType()); //var mem = new MemoryStream(); //x.WriteObject(mem, title); //StreamReader sr = new StreamReader(mem); //mem.Position = 0; //string myStr = sr.ReadToEnd(); //return myStr; return(JsonConvert.SerializeObject(title)); }
void DisplayTitle2(MyTitle title) { if (m_curTitle == title.zPath) { return; } DisplayTitle(title); if (isEditing) { BeginEditTitle(title); } m_curTitle = title.zPath; }
private void BeginEditTitle(MyTitle title) { //edit m_edtPanel.m_title = new MyTitle() { ID = title.ID, zPath = title.zPath, zTitle = title.zTitle }; m_loadTitleCompleted = false; m_edtPanel.loadTitle(); m_loadTitleCompleted = true; m_rsc.Panel2Collapsed = false; m_rsc.Panel2.Show(); }
//req addProgReg(msg) private void OnaddProgReg(string obj) { MyTitle msg = new MyTitle(); msg = JsonToTitle(obj); MyTitle u = m_content.editTitle(msg); if (u != null) { //msg.path = u.path; msg.title = u.title; string jsTxt = TitleToJson(msg); m_wb.Navigate("javascript:onAddNewProgRegDone('" + jsTxt + "')"); } }
public override List <MyTitle> getTitles2() { OleDbConnection cnn = m_cnn; //get paths var pathLst = new List <pathItem>(); var qry = "select * from paths order by ord ASC"; var cmd = new OleDbCommand(qry, cnn); var reader = cmd.ExecuteReader(); while (reader.Read()) { pathLst.Add(new pathItem() { id = Convert.ToUInt64(reader["ID"]), path = Convert.ToString(reader["path"]) }); } reader.Close(); //get title var titleLst = new List <MyTitle>(); var qry2 = "select * from titles WHERE pathId = @pathId order by ord ASC"; var cmd2 = new OleDbCommand(qry2, cnn); cmd2.Parameters.Add("@pathId", OleDbType.Integer); foreach (var pi in pathLst) { cmd2.Parameters[0].Value = pi.id; var reader2 = cmd2.ExecuteReader(); int ord = 0; while (reader2.Read()) { var title = new MyTitle(); title.ID = Convert.ToUInt64(reader2["ID"]); title.zTitle = Convert.ToString(reader2["title"]) .TrimEnd(new char[] { '\r', '\n', '\v' }); title.pathId = Convert.ToUInt64(reader2["pathId"]); title.zPath = pi.path + "/" + title.zTitle; title.ord = Convert.ToInt32(reader2["ord"]); titleLst.Add(title); Debug.Assert(title.ord > ord); ord = title.ord; } reader2.Close(); } return(titleLst); }
private void SpeechTitle(MyTitle title) { //throw new NotImplementedException(); if (m_ss == null) { var ss = new SpeechSynthesizer(); ss.SetOutputToDefaultAudioDevice(); var iv = ss.GetInstalledVoices(); var vn = iv.First(v => { return(v.VoiceInfo.Culture.Name == "vi-VN"); }); ss.SelectVoice(vn.VoiceInfo.Name); m_ss = ss; } foreach (MyParagraph p in title.paragraphLst) { m_ss.SpeakAsync(p.content); } }
private void RenderFullTitle(MyTitle title) { #if use_rtb m_rtb.Clear(); m_rtb.Multiline = true; foreach (MyParagraph par in title.paragraphLst) { Font font; font = new Font("Arial", par.fontSize, style: FontStyle.Regular); if (par.fontBold != 0) { font = new Font(font, FontStyle.Bold); } if (par.fontItalic != 0) { font = new Font(font, FontStyle.Italic); } switch (par.alignment) { case 0: m_rtb.SelectionAlignment = HorizontalAlignment.Left; break; case 1: m_rtb.SelectionAlignment = HorizontalAlignment.Center; break; case 2: m_rtb.SelectionAlignment = HorizontalAlignment.Right; break; } m_rtb.SelectionIndent = par.leftIndent + 5; m_rtb.SelectionFont = font; m_rtb.SelectedText = par.content; m_rtb.SelectedText = Environment.NewLine; } #else var node = m_nodeDict[title.path]; var lst = getAllTitleR(node); string jsTxt = TitlesLstToJson(lst); string htmlTxt = GenHtmlTxt(jsTxt); UpdateWB(htmlTxt); #endif }
//req addLikeMsg(msg) private void OnaddLikeMsg(string obj) { MyTitle msg = new MyTitle(); msg = JsonToTitle(obj); MyTitle u = m_content.editTitle(msg); if (u == null) { } else if (msg.type == "like") { //update tree var tnChild = new Node() { id = u.path, name = u.title, title = u }; m_nodeDict.Add(u.path, tnChild); var tnParent = m_nodeDict[msg.path + "/likes"]; tnParent.childs.Add(tnChild); updateTree(tnParent, tnChild); } else if (msg.type == "unlike") { //update tree var tnParent = m_nodeDict[msg.path + "/likes"]; var tnChild = m_nodeDict[u.path]; tnParent.childs.Remove(tnChild); tnParent.tnode.Nodes.Remove(tnChild.tnode); m_nodeDict.Remove(u.path); } if (u != null) { //msg.path = u.path; msg.title = u.title; string jsTxt = TitleToJson(msg); m_wb.Navigate("javascript:onUpdateMsgChkDone('" + jsTxt + "')"); } }
private void DisplayTitle(MyTitle title) { Debug.Assert(title.zPath != m_curTitle); title.paragraphLst = m_content.getTitleParagraphs(title.ID); RenderFullTitle(title); }