Example #1
0
        /// <summary>
        /// 获取子菜单
        /// </summary>
        /// <param name="database"></param>
        /// <param name="baseNode"></param>
        public void CreateTreeNodeRecursive(TreeNode baseNode)
        {
            DataTable dt = SqliteHelper.ExecuteDataset(DB, "SELECT tree.id,tree.name,tree.content_url,tree.parent_id,tree.isroot,tree.online_url,tree.word_url,tree.code_url,tree.author_id,download.tree_id FROM tree LEFT JOIN download ON tree.id = download.tree_id AND download.path like '%.htm' WHERE tree.parent_id='" + baseNode.Name + "' ORDER BY tree.name").Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                TreeNode node = new TreeNode();
                Article article = new Article();
                string name = SqliteHelper.DBToString(dr["name"]);
                if (string.IsNullOrEmpty(name))
                    continue;
                article.Id = dr["id"].ToString();
                article.Name = name;
                article.ContentUrl = SqliteHelper.DBToString(dr["content_url"]);
                article.ParentId = SqliteHelper.DBToString(dr["parent_id"], "0");
                article.IsRoot = SqliteHelper.DBToString(dr["isroot"]) == "1";
                article.Online = SqliteHelper.DBToString(dr["online_url"]);
                article.WordUrl = SqliteHelper.DBToString(dr["word_url"]);
                article.CodeUrl = SqliteHelper.DBToString(dr["code_url"]);
                article.AuthorId = SqliteHelper.DBToString(dr["author_id"]);
                //node.ToolTipText = dr[2].ToString();
                node.Text = article.Name;
                node.Name = article.Id; //id
                node.Tag = article;  //path

                if (article.IsRoot)
                {
                    node.Nodes.Add("");
                    node.ImageIndex = 0;
                }
                else
                    node.ImageIndex = 2;

                //CreateTreeNodeRecursive(node, dataSource);
                baseNode.Nodes.Add(node);
            }
        }
Example #2
0
 private void setNodeImageState(TreeNode node, Article article)
 {
     if (article.IsRoot)
     {
         if (node.IsExpanded)
         {
             node.ImageIndex = 1;
             node.SelectedImageIndex = 1;
         }
         else
         {
             node.ImageIndex = 0;
             node.SelectedImageIndex = 0;
         }
     }
     else
     {
         node.ImageIndex = 2;
         node.SelectedImageIndex = 2;
     }
 }
Example #3
0
        /// <summary>
        /// 创建树菜单
        /// </summary>
        /// <param name="database"></param>
        /// <returns></returns>
        public TreeNode[] GetTree()
        {
            DataTable dt = SqliteHelper.ExecuteDataset(DB, "SELECT tree.id,tree.name,tree.content_url,tree.parent_id,tree.isroot,tree.online_url,tree.word_url,tree.code_url,tree.author_id,download.tree_id FROM tree LEFT JOIN download ON tree.id = download.tree_id AND download.path like '%.htm' WHERE tree.parent_id=0 ORDER BY tree.name").Tables[0];
            //获取顶级目录
            //DataRow[] drs = dt.Rows;// dt.Select("parent_id=0", "name");
            TreeNode[] result = new TreeNode[dt.Rows.Count];
            for (int i = 0, j = dt.Rows.Count; i < j; i++)
            {
                DataRow dr = dt.Rows[i];
                Article article = new Article();
                string name = SqliteHelper.DBToString(dr["name"]);
                if (string.IsNullOrEmpty(name))
                    continue;
                article.Id = dr["id"].ToString();
                article.Name = name;
                article.ContentUrl = SqliteHelper.DBToString(dr["content_url"]);
                article.ParentId = SqliteHelper.DBToString(dr["parent_id"], "0");
                article.IsRoot = SqliteHelper.DBToString(dr["isroot"]) == "1";
                article.Online = SqliteHelper.DBToString(dr["online_url"]);
                article.WordUrl = SqliteHelper.DBToString(dr["word_url"]);
                article.CodeUrl = SqliteHelper.DBToString(dr["code_url"]);
                article.AuthorId = SqliteHelper.DBToString(dr["author_id"]);
                article.IsManualUpdate = dr.IsNull("tree_id");
                TreeNode node = new TreeNode();
                node.Text = article.Name;
                //node.ToolTipText = dr[2].ToString();
                node.Name = article.Id; //id
                node.Tag = article; //path

                if (article.IsRoot)
                {
                    node.Nodes.Add("");
                    //CreateTreeNodeRecursive(node, dt);
                    node.ImageIndex = 0;
                }
                else
                    node.ImageIndex = 2;

                result[i] = node;
            }
            return result;
        }
Example #4
0
        private void setArticle(TreeNode node, Article article)
        {
            if (!string.IsNullOrEmpty(article.ContentUrl))
            {
                webBrowser1.Navigate(new Uri(CurrentDirectory + CurrentConfig.HtmlRoot + article.ContentUrl));
                //webBrowser1.Url = new Uri(CurrentDirectory + CurrentConfig.HtmlRoot + article.ContentUrl);

                for (int ind = 0; ind < 5; ind++)
                {
                    tips[ind].Visible = false;
                }

                int i = 0;
                //���������Ϣ
                if (!string.IsNullOrEmpty(article.AuthorId))
                {
                    Author author = service.GetAuthorById(article.AuthorId);
                    //��������
                    setArticleDetail(author.About, global::AndroidBox.API.Properties.Resources.user_business_boss, ref i, "");
                    //���߲���
                    setArticleDetail(author.Blog, global::AndroidBox.API.Properties.Resources.blog, ref i, author.Blog);
                }
                //�����ĵ���ַ
                setArticleDetail(article.Online, global::AndroidBox.API.Properties.Resources.link, ref i, article.Online);
                //WORD����
                setArticleDetail(article.WordUrl, global::AndroidBox.API.Properties.Resources.page_white_word, ref i, article.WordUrl);
                //��������
                setArticleDetail(article.CodeUrl, global::AndroidBox.API.Properties.Resources.attach, ref i, article.CodeUrl);
            }
        }