public InterfaceComment[] GetComments(string strFileHash) { CElement Element=(CElement)CKernel.FilesList[CKernel.StringToHash(strFileHash)]; if (Element==null) return null; InterfaceComment mycomment=null; int nComments=0; if ((Element.File!=null)&&(Element.File.Comment!=null)&&(Element.File.Comment.Length>0)) { mycomment=new InterfaceComment(); mycomment.ClientName=CKernel.Preferences.GetString("UserName"); mycomment.Rating=""; mycomment.Comment=Element.File.Comment; nComments=1; } if ((Element.Comments!=null)&&(Element.Comments.Count>0)) nComments+=(int)Element.Comments.Count; if (nComments==0) return null; InterfaceComment[] listaComments=new InterfaceComment[nComments]; int i=0; if (mycomment!=null) { listaComments[0]=mycomment; i++; } if ((Element.Comments!=null)&&(Element.Comments.Count>0)) { foreach (CedonkeyComment Comment in Element.Comments) { listaComments[i]=CommentToInterfaceComment(Comment); i++; } } return listaComments; }
private InterfaceComment CommentToInterfaceComment(CedonkeyComment Comment) { InterfaceComment ifaceComment=new InterfaceComment(); ifaceComment.ClientName=Comment.userName; ifaceComment.Comment=Comment.strComment; ifaceComment.Rating=Comment.rating.ToString(); return ifaceComment; }
private void m_UpdateOrAddComment(InterfaceComment comment) { bool updated=false; foreach (ListViewItem itemComment in this.Items) { if (itemComment.SubItems[2].Text==comment.Comment) { CommentToItem(comment,itemComment); updated=true; break; } } if (!updated) OnNewComment(comment); }
private void OnNewComment(InterfaceComment comment) { ListViewItem itemComment=new ListViewItem(new string[]{"","",""}); itemComment.Tag=comment; CommentToItem(comment,itemComment); lock(this) { Items.Add(itemComment); } }
private void CommentToItem(InterfaceComment comment,ListViewItem itemComment) { if (comment==null) return; if (itemComment.SubItems[0].Text!=comment.ClientName) itemComment.SubItems[0].Text=comment.ClientName; if (itemComment.SubItems[1].Text!=comment.Rating) itemComment.SubItems[1].Text=comment.Rating; if (itemComment.SubItems[2].Text!=comment.Comment) itemComment.SubItems[2].Text=comment.Comment; //itemComment.Tag=comment; }