Analysis of core technology of network acquisition software series (7)---How to build a program framework using the C # language (Classic WinForm interface, top menu bar, toolbars, left tree list, right multi-tab interface)

Source: Internet
Author: User
Tags svn client

An overview of a series of essays and the resulting background

own development of the Bean John Blog backup expert software tools since the advent of more than 3 years, by the vast number of bloggers writing and reading enthusiasts love. At the same time, there are some technical enthusiasts consulting me, the software is a variety of practical functions of how to achieve.

The software is used. NET technology development, in order to give back to the community, now the software used in the core technology, open up a column, write a series of articles to treat the vast number of technology enthusiasts.

This series of articles in addition to explaining the network acquisition and the use of a variety of important technologies, but also provides a number of solutions to problems and interface development programming experience, very suitable. NET development of the beginner, intermediate readers, I hope you have a lot of support.

Many beginners often have this kind of confusion, "Why I read the book, C # related to all aspects of knowledge, but it is impossible to write a decent application?" ”,

This actually still did not learn to use the knowledge comprehensively, exercise out of programming thinking, build up learning interest, I think the series of articles may help you, I hope so.

Development environment: VS2008

This section source location: Https://github.com/songboriceboy/SimpleFrameWork

Source code Download method: Install the SVN client (provided at the end of this article), and then checkout the following address: Https://github.com/songboriceboy/SimpleFrameWork

The outline of the article series is as follows:

1. How to use the C # language to obtain the blog of a blogger's full essay link and title;
2. How to use the C # language to get the content of the blog post;
3. How to convert HTML pages to PDF (html2pdf) using the C # language
4. How to use the C # language to download all the pictures in the blog post to local and can browse offline
5. How to use the C # language to synthesize multiple individual PDF files into a PDF and generate a table of contents
6. NetEase Blog Links How to use C # language to obtain, NetEase blog particularity;
7. How to use the C # language to download the public number articles;
8. How to obtain the full text of any one article
9. How to use the C # language to get rid of all the tags in HTML for plain text (html2txt)
10. How to compile multiple HTML files into CHM (Html2chm) using the C # language
11. How to use the C # language to publish articles remotely to Sina Blog
12. How to develop a static site builder using the C # language
13. How to build a program framework using the C # language (Classic WinForm interface, top menu bar, toolbars, left tree list, right multi-tab interface)
14. How to implement the Web page Editor (Winform) using the C # language ...

The seventh section of the main content of the introduction (how to use the C # language to build the program framework (classic WinForm Interface, the top menu bar, toolbars, the left tree list, the right Multi-tab interface))

How to use C # language to build a program framework (classic WinForm interface, top menu bar, toolbar, left tree list, right multi-tab interface) solution, demo demo as shown: executable file download

Demo Function Introduction:

After the program starts, the Websitedb folder of the directory where the scanner is located (see the previous section, which holds all bloggers ' blogs, xxx.db file), load the database name on the left tree control, double-click a child node of the tree control, add a browser-like tab to the right, and automatically load the blogger's blog list information in the newly opened interface.

Three basic principles

This simple framework, there are 3 main areas of comparative importance:

1. Recursive loading of tree-shaped control nodes;

2. The Right tab form is created (mainly using the famous WeifenLuo.WinFormsUI.Docking.dll);

3. Click on the tree node to open a new window (the first 2 of them are combined).

First of all, the 1th, the recursive loading of the tree control node, the main code is as follows :

    Private voidLoadwebsitetree () { This. TreeViewTask.Nodes.Clear (); TreeNode Noderoot=NewTreeNode (); Noderoot.text="Site List"; Noderoot.tag= -1;  This. TREEVIEWTASK.NODES.ADD (Noderoot); Getsubdirectorynodes (Noderoot, M_strdbfolder,true);  This. Treeviewtask.selectednode = This. Treeviewtask.topnode; }

Create the root node, and then call the Getsubdirectorynodes function to recursively load the child nodes:

  Private voidGetsubdirectorynodes (TreeNode parentnode,stringFullName,BOOLgetfilenames) {            if(!directory.exists (FullName))            {directory.createdirectory (fullName); } DirectoryInfo dir=NewDirectoryInfo (fullName); Directoryinfo[] Dirsubs=dir.            GetDirectories (); //Add a child node for each subdirectory            foreach(DirectoryInfo dirsubinchdirsubs) {                //do not show hidden folders                if((Dirsub.attributes & fileattributes.hidden)! =0)                {                    Continue; } TreeNode Node=NewTreeNode (); Node. Text=Dirsub.name; Node. Tag=0; Node. ImageIndex=0;                PARENTNODE.NODES.ADD (node); //Recursive invocationgetsubdirectorynodes (node, dirsub.fullname, GetFileNames); }            //Add a child node for each subdirectory            foreach(DirectoryInfo dirsubinchdirsubs) {                //do not show hidden folders                if((Dirsub.attributes & fileattributes.hidden)! =0)                {                    Continue; }            }            if(GetFileNames)//In the source code of the book, this part is inside the foreach, incorrect            {                //get all the files for this nodefileinfo[] Files =dir.                GetFiles (); //after the node is placed. Place the files in the subdirectory.                 foreach(FileInfo fileinchfiles) {                    if(file. Extension.tostring ()! =". DB")                        Continue; stringStrnodename = file. Name.remove (file. Name.length-3,3); if(Strnodename = ="Home")                        Continue; TreeNode node=NewTreeNode (); Node. Text=Strnodename; Node. Tag=1; Node. ImageIndex=1;                PARENTNODE.NODES.ADD (node); }            }        }  

Next look at 2nd,2. Creation of the Right tab form (mainly using the famous WeifenLuo.WinFormsUI.Docking.dll), the main code is as follows:

 PublicDockcontent Showcontent (stringCaption/*, Type formtype*/) {dockcontent frm=Finddocument (caption); if(frm = =NULL) {Frm_targeturlview Frm_targeturlview=NewFrm_targeturlview ((string) This. TreeViewTask.SelectedNode.Parent.Text, M_strdbconstringpath+M_strtreenodename, (string) This. TreeViewTask.SelectedNode.Text, This); Frm_targeturlview.mdiparent= This; Frm_targeturlview.windowstate=formwindowstate.maximized; Frm_targeturlview.show ( This. DockPanel1);                Frm_targeturlview.focus ();                Frm_targeturlview.bringtofront (); returnFrm_targeturlview; } frm. Show ( This. DockPanel1); frm.            Focus (); frm.            BringToFront (); returnfrm; }

First Call Finddocument (caption), determine whether the current tab window is open, if it is open, activate it, if it is not already open, create a new tab window and make the window that you just created become the activation window.

3. Click on the tree node to open a new window (the first 2 of them are combined). The main code is as follows:

  Private voidTreeviewtask_mousedoubleclick (Objectsender, MouseEventArgs e) {Point pos=NewPoint (e.x, e.y); TreeNode Nodeclick= This. Treeviewtask.getnodeat (POS); if(Nodeclick.text = ="Site List")            {                 This. Treeviewtask.contextmenustrip =NULL; return; }            if(Nodeclick! =NULL&& E.button = =mousebuttons.left) {intNTag = (int) Nodeclick.tag; if(NTag = =0)                    return;  This. Treeviewtask.selectednode =Nodeclick;            Loadinfobynode (); } showcontent ( This. TreeViewTask.SelectedNode.Text); }

In the tree node of the mouse double-click processing function, call the second step above the Showcontent function, pop up the corresponding tab form.

For more detailed code, please download the study yourself.

Song Bo
Source: http://www.cnblogs.com/ice-river/
The copyright of this article is owned by the author and the blog Park, welcome reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to give the original link.
is looking at my blog This children's shoes, I see you imposing, there is a faint of the king's Breath, there will be a future! Next to the word "recommended", you can conveniently point it, action quasi, I do not accept a penny, you also good to come back to me!

Analysis of core technology of network acquisition software series (7)---How to build a program framework using the C # language (Classic WinForm interface, top menu bar, toolbars, left tree list, right multi-tab interface)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.