First, the previous words
Before I started, I always struggled to finish the tool, because the last time I gave it a code was more than a year ago, referring to your own hands-on tool----Xsmartnote [Beta 2.0], this blog post, many of the park friends put forward valuable comments. Finally decided to absorb the suggestions of the park friends to reconstruct this tool. First it was changed to a name, Xsmartnote. Because of various reasons, and did not complete the basic function of the tool, but the implementation of the basic framework. Recently a little time to engage in a bit, right as lay the foundation. Originally want to use B/s structure to re-engage, after all, there are a lot of cows in the garden is focused on ASP. NET MVC, but think about it or not always write some bad tail building works well, in fact, the use of that architecture is irrelevant, after all, is a personal tool, one is the event-driven, a request response model, The difference is not the same way of expression.
Second, what can xsmartnote do?
Every day is concerned about the dynamics of the garden, watching the great God to share a variety of new technologies, feel that they want to learn too much, but a variety of knowledge points fragmented not categorized, after seeing and forget, it is difficult to achieve the effect of learning. So I hope that through the labeling of knowledge, sorting the summary of the sorting, want to see, through the label to find out the relevant knowledge points, to learn and consolidate, not beautiful ~ This is also applicable to the summary of programming experience, the habit, after a long time, the accumulation of a wealth of knowledge is not small. To add, some people will say that there are a lot of ready-made tools on the Web now, such as Evernote, Youdao Cloud notes, various notes ... Why not? I just wanted to say that it would be nice to have something you made.
What is the difference between the third and the previous version?
In the previous release, it simply sketched out a rough outline, and the current version was expanded and implemented in the previous version, with a large area of the previous version
1, the bottom data operation
The data layer by the original Basic foundation of the ADO operation, the new version abandoned the most basic SQL operations, the use of the NHibernate framework, the framework for us to encapsulate a lot of functionality, so that greatly reduce the workload, avoid the writing of too much SQL script, but also avoid the number of scripts too large inevitably produce bugs Problem. The NHibernate framework provides support for native SQL, multi-table queries, and complex queries that can be used directly from native SQL and also support example queries. NHibernate is equipped with a very powerful query language HQL, which looks like SQL. But instead of being fooled by the similarity in grammatical structures, HQL is consciously designed to be a fully object-oriented query language that understands concepts such as inheritance, polymorphism, and correlation. The NHibernate framework also has many advanced features, such as transactional concurrency, high-performance level two caching, and so on, which is not discussed for the moment.
The following code finds all tags based on the ID of the post, With the ADO native data operation, you can see that you need to manually write SQL script, this is only a small function point, if the table involved is relatively large, the probability of error will be greatly improved, and errors in the compilation period is not visible, so that the error may be pushed to the runtime.
1 Private StaticDataTable QueryTable (StringBuilder sbcmd)2 {3 using(SqlConnection conn =sqlhelper.createconnection ())4 {5 Conn. Open ();6 using(SqlCommand cmd =NewSqlCommand (sbcmd. ToString (), conn))7 {8DataTable dt =NewDataTable ();9SqlDataAdapter SDA =NewSqlDataAdapter ();TenSda. SelectCommand =cmd; One SDA. Fill (DT); A returnDT; - } - } the}
1 //gets the label contained in the specified article ID2 Public StaticDataTable Gettagsbypostid (intID)3 {4StringBuilder cmd =NewStringBuilder (5 string. Format ("Select T.tagcontent,t.tagid from table_content c,table_content_tag ct,table_tag t"));6Cmd. Append (string. Format ("where C.id=ct.postid and T.tagid=ct.tagid and c.id={0}", id));7 returnQueryTable (cmd);8}
Here's a look at the implementation of this code after adopting the NHibernate framework. It is obvious that the code volume is reduced, the structure is clear, and only one line of code is needed to get all the tags of the specified post.
1 //gets the label contained in the specified article ID2 PublicIlist<tag>Gettagsbypostid (Guid Id)3 {4Ilist<model.tags.tag> Tags =NULL;5 using(ISession session=sessionfactory.opensession ())6 {7ITransaction trans =session. BeginTransaction ();8 Try9 {Tentags = session. Createcriteria (typeof(Tag)). Createcriteria ("Posts"). ADD (Restrictions.eq ("Id", Id)). List<tag>(); One } A Catch(Exception) - { - Trans. Rollback (); the Throw; - } - returntags; - } +}
2. Interface optimization
First look at the overall effect:
Multi-Theme Support:
In the previous version, there was no focus on the beautification of the interface due to the design of the architectural function. This version uses the free Cskin interface library, which is good for improving the overall UI of the interface, just referencing the relevant DLL components. Cskin Interface Library is free to use, but the source code is not open source. The following is a brief description of the official Cskin interface library.
Streamline large amounts of unnecessary code, reduce the size of the UI library, optimize program speed, and make the library more lightweight and usable.
Enable the new Cskin interface engine to reshape every corner of the UI to create a new experience that is smoother , lighter, and less simple .
Dramatically reduce the harshness of the transformation effect, inject more light and flexible change feedback, response quickly.
At the same time support multi-theme switch, currently has rose, Sapphire blue, green, small ducklings theme (theme name is I think, have better opinion can tell me), follow-up will support more theme color scheme, and open Interface, allow to develop their favorite theme style in plug-in way. At the same time, the main interface to the various resolution screen size adaptive. Let tools not only tools, use more comfortable, improve the use of enthusiasm.
3. Improve performance
Refactoring the code, found that there are many pieces of code to create a lot of new objects, if we use the process, accumulated more and more notes and tags will affect the performance of the tool, so some common design patterns into the software. For example, each entity has its own database operation class, where I encapsulate the database operations class into a singleton pattern, so that the same object is used every time, and if the object does not exist or the object is destroyed, the new object is created, which improves the performance of the tool. For example, the following topic manages the class:
1 //Topic Management Class2 Public classThememanager:ithememanager3 {4 Private StaticThememanager Thememanager;5 Privatemainform mainform;6 Private EventAction<themeenums.themeenum>themechangeevent;7 Private Static Object_lock =New Object();8 PrivateThememanager (mainform mainform)9 {Ten This. MainForm =MainForm; OneThemechangeevent + =Mainform.settheme; A } - - Public Staticthememanager Createthememanager (mainform form) the { - Thememanager _thememanager; - if(Thememanager = =NULL) - { + Lock(_lock) - { + if(Thememanager = =NULL) A { at_thememanager =NewThememanager (form); -Thememanager =_thememanager; - } - } - } - returnThememanager; in } - to Public voidChangeformtheme (themeenums.themeenum enums) + { - if(Themechangeevent! =NULL) the { * themechangeevent (enums); $ }Panax Notoginseng } -}
And the data manipulation classes for each entity, here's an example of postcontents:
1 //postcontents Operation class2 Public classPostcontentsdao:ipostcontentsdao3 {4 Privateisessionfactory sessionfactory;5 Private StaticPostcontentsdao Postcontentsdao;6 Private Static Object_lock =New Object();7 PrivatePostcontentsdao ()8 {9 //gets the configuration in the constructor and produces the SessionfactoryTen varCFG =NewNHibernate.Cfg.Configuration (). Configure (".. /.. /config/hibernate.cfg.xml"); OneSessionfactory =CFG. Buildsessionfactory (); A } - - Public StaticPostcontentsdao Createpostcontentsdao () the { - Postcontentsdao _postcontentsdao; - if(NULL==Postcontentsdao) - { + Lock(_lock) - { + if(NULL==Postcontentsdao) A { at_postcontentsdao =NewPostcontentsdao (); -Postcontentsdao =_postcontentsdao; - } - } - } - returnPostcontentsdao; in } -}
4. Custom Controls
Updated several user-defined controls, including optional labels with a checkbox, plain note display labels, and rounded rectangle controls for display labels, with custom controls for maximum flexibility in controlling the properties of controls and events, both flexible and visually good choices. I'll share the controls separately in the following article.
Four, what will be cool features in the future?
On this issue, I think very seriously, probably summed up the following several functional points:
1, the current version has not yet been implemented according to the Label filter note function, just the label and note associated, subsequent versions will be based on the tag real-time filtering;
2, to support the code fragment, I will write a user control specifically for the code editing support, it and the text editing way is different, I think this is the most cool features of it;
3, add the Control Panel, the interface of some functions exposed, in order to control the way the panel display in front of the user, arbitrary configuration, such as the main interface transparency, color, control properties, more rich and flexible;
4, integrated custom paging control, the current version to the right of the note display area by default displays all the note under a category, and there is a vicious scroll bar, it is not very convenient to use, so I will integrate a beautiful page control, is currently under development;
5, support plug-in development, the tool will provide some interface, plug-in way to develop the user's own unique features, such as plug-in way to develop their favorite theme or some custom features;
6, add the system log, record each user's operation, as well as system error information collection.
7, multi-database support. I am currently using the database is SQL Server version R2, a bit overqualified, follow-up will support access, SQLite, so it will be easy to carry, on the U disk can also yo ~
Five, nagging
The gadget is still at an early stage in the functional level, and the features mentioned in 4th above are not yet implemented, and this article only captures a little bit of code to explain version differences, and all the code I'll post to GitHub. Because I have limited time and energy, I hope the garden interested in the park friends can work with me to improve the tool. Attach the GitHub address here, Xsmartnode. Ask for Star, Star, and star. In the following article I will put the relevant control development process to paste out, are some basic things, hoping to help beginners, the great god please bypass. I have limited ability, if there are any mistakes in the process of expression, please advise, thank you very much. In addition, I will publish this article in sync to my Jane book. If you think the article can also, please recommend the Oh, your recommendation is I write tools the biggest power!
Melodious Shepherd's flute
Blog Address: http://www.cnblogs.com/xhb-bky-blog/p/5504570.html
Disclaimer: The original text of this blog only represents my work in a certain time to summarize the views or conclusions, and my unit does not have a direct interest in the relationship. Non-commercial, unauthorized posts please retain the status quo, reproduced must retain this paragraph of the statement, and in the article page obvious location to the original connection.
"Original" DIY tools----Xsmartnote [Beta 3.0]