The content of the invention
There is deployment, scaling difficulty for existing subscriber's interface implementing method or client master cannot be made full use of in the present invention
The problem of machine local resource, proposes a kind of user interface implementation method of combination WPF and JavaScript, and it uses following technology
Scheme is achieved:
A kind of user interface implementation method, including:
A, client obtain the network profile comprising XAML and JavaScript from server;
B, client draw user interface controls by XAML, and the interface control and boundary are managed by JavaScript
Face control event;
After C, interface control event are produced, event is read by affair logic dispatcher, and by event, the control of firing event
Part is tied to JavaScript function, calls JavaScript script interpreters to explain and performs the JavaScript function.
Further, user interface controls process is drawn in the step B also includes:Called by local control adapter
Client host local resource.
Further, also include calling local third party's window step after step C median surface control event is produced:Thing
Part logic dispatcher calls local third party's window by calling custom window loader.
Further, XML+ JavaScript loader load networks configuration files are passed through in the step A.
Further, also comprise the following steps before the step A:Server sends different nets according to client application
Network configuration file.
Further, the step A obtains all control types and handle after obtaining XAML by control renderer, passes through
Control data manager matches control data.
Further, the APP nodal communitys of the network profile include:Cipher mode, encryption Key values and close
Text, the APP nodes include:Runtime nodes, reference window node, reference JavaScript file, local JavaScript
File and window set are defined, and wherein window set definition includes:Can recursive attribute set, event sets, data acquisition system
And XAML window datas.
Further, the client host local resource includes:Local API, local control or local hardware resources connect
Mouthful.
Compared with prior art, advantages and positive effects of the present invention are as follows:
The interface of client of the present invention is drawn instruction and is carried out in server end, and client host is not deposited interface and drawn and refers to
Order, but the drafting at execute server end is instructed, and carries out the drafting of client, makes that based on functional upgrading carrying need not be descended
Family end updates bag, and generating new drafting by server end instructs, you can update the function interface of client.Relative to C/S visitors
Family end technology then makes the deployment light and flexible of client, solves the software system updating and client graphical user of C/S frameworks
The difficult problem of Interface maintenance.
After specific embodiment of the invention is read in conjunction with the figure, the other features and advantages of the invention will become more clear
Chu.
Specific embodiment
The present invention realizes that thought is as follows:HTML+JavaScript+Web browsers can only be performed in a browser, it is impossible to be filled
Divide the resource for calling client host, such as peripheral hardware of client host.The present invention combines HTML+JavaScript+Web browsers
Technology and C/S technologies, based on Net platform developments, run directly in client the machine, can directly invoke client the machine hard
The peripheral hardware of part resource, such as client host, reaches deployment, the easy spirit of upgrading of existing HTML+JavaScript+Web browsers
It is living, also there is C/S client-side program to make full use of the advantage of client host local resource.
The present invention is further detailed explanation with reference to the accompanying drawings and detailed description, the present invention based on WPF and
The user interface implementation method of JavaScript, including:
S01, client obtain the network profile comprising XAML and JavaScript from server;
S02, client by XAML draw user interface controls, by JavaScript manage the interface control and
Interface control event;
After S03, interface control event are produced, event is read by affair logic dispatcher, and by event, firing event
Control bundle calls JavaScript script interpreters to explain and performs the JavaScript function to JavaScript function.
May need to call local hardware resources information in the drawing process of interface(Such as cash box folding), the present invention is by local
Control adapter calls client host local resource(Such as cash box folding information), specifically, XML+JavaScript mixing texts
The special requirement included in part is called and uses client host local resource(Local API, local control, local hardware resources connect
Mouthful), local control adapter be responsible for initialize these resources.In addition, interface is likely to needs calls local third party's window journey
Sequence, step is as follows:After interface generation event, affair logic dispatcher calls JavaScript function, JavaScript function to adjust
Local third party's window is called with custom window loader.Custom window is, for special applications prepare, under special circumstances, to need
Native window is called, is created when these windows are not by running, but provided by client host, such as network dial journey
Sequence.Several certain types of event response functions are defined in program operation process, during operation), such as mouse event, KeyEvent,
After background event and system event etc., WPF controls, local control etc. send message, these events can be intercepted during operation, intercepted
Event definition in transferring to affair logic dispatcher to read event node, sends by the ID for binding and currently the control ID of event
These events are redirected in JavaScript function, that is, bind certain JavaScript function, JavaScript function ought
Preceding event definition and current trigger event control are transmitted to event interpreter, and control object is packaged into This pairs by event interpreter
JavaScript function is transmitted to as central.
Event of the present invention is distributed and separated with binding, is bound by run-time binding, and its advantage is:Interface is unified, and function can be replaced
It is transsexual strong, and distributing for event is not influenceed, bind efficiency high.
During practical application, each client realizes that function differs, its in the drawing process of interface, the requirement to configuration file
Differ, also comprised the following steps before step S01 in implementation process of the present invention:Server sends different according to client application
Network profile.
Additionally, client obtains the network profile comprising XAML and JavaScript from server, by XML+
JavaScript loader load networks configuration files, XML+ JavaScript loaders are responsible for parsing XAML+
Data in JavaScript file, transfer to WPF interpreters to explain XAML contents, obtain the institute after WPF interpreters are explained
There are control handle, control type.Call WPF controls renderer and local control adapter display XML+JavaScript files circle
Face content(Comprising control pattern, control location), control data manager is then called, initialize the data of these controls.Control
Number of packages from client host according to may obtain, it is also possible to be obtained from server end, control data manager is responsible for these data
Be converted to the recognizable data object of runs software;Control data may flow to server end, it is also possible to flow to local control(This
Ground peripheral hardware), control data manager is responsible for for these data being converted to server end or local control(Local peripheral hardware)Can know
Other data.
Wherein, the network profile structure is as follows:APP nodal communitys include:Cipher mode, encryption Key values and
Ciphertext, the APP nodes include:1st, runtime nodes:The node is mainly used to define main window, i.e., need display for the first time
Window;2nd, window node is quoted:Including network access src addresses and character code;3rd, JavaScript file is quoted same
Including network access SRC addresses and character code;4th, local JavaScript file;5th, window set definition, the window definition
Comprising five child nodes:5.1st, attribute set:Including multiple attribute nodes, each attribute node includes property set, attribute again
Collection correspondence multiple attributes again, such recurrence, can recurrence to 200 times, scalability is strong, the complicated attribute structure of definable, each
Attribute includes:ID, title, type and property value;5.2nd, event sets include:ID codings, title, message key, binding, type are adjusted
With function and event attribute collection, wherein event attribute collection can also recursive expansion;5.3rd, data acquisition system, comprising encryption under root roots
Mode, encryption Key values, ciphertext, the dateset data sets of root roots include multiple data set nodes, and each data includes word again
Section and sets of fields, field can both realize that field was nested with sets of fields, also can field it is parallel with sets of fields, its data support type is more
Plus extensively;5.4th, XAML window datas.Whole file uses encryption format, and transmission is safer, and supports to introduce, multiple windows
A set of file can be shared, file durability is increased, encoding amount and flourish error rate is reduced.
The realization of user interface of the present invention is included:1st, interface view;2nd, user's operation logic two parts.In implementation process
It was found that:If all transferring to server end to perform user's operation logic, the network data that will increase client and server end is handed over
Number of times and quantity are changed, the response speed that interface element is operated to user is reduced, increases the operand of server end, cause server
The load increase at end, necessarily causes client end interface and server end to be closely integrated, the change of program when being unfavorable for that demand is changed
It is dynamic, upgrading, and all transfer to server end to perform user's operation logic, client only carries out XML file parsing, such as Web
Without JavaScript in html page in exploitation, it is impossible to provide dynamic interface effect;On the other hand, causing client cannot depart from
Server end runs, it is necessary to have the server end could to run client.
Interface view of the present invention realizes that user's operation logic is by configuration file by the XAML in configuration file
JavaScript is realized.Interface view and user's operation logic part(JavaScript)All it is, by client executing, only to exist
(such as data at the reception server end) are just exchanged with server end and carry out network data exchange, most of user under the conditions of necessary
Logical operation is all locally executed in client, so greatly reduces quantity and number of times with server end network data exchange, is filled
The computing capability of client host is waved in distribution, reduces the computational load of server end.If there is client user's operation logic
Change, can only change client configuration file part, it is not necessary to change server end logic, the program demandd reduction when changing
Change amount.Therefore can depart from server end isolated operation with implementation client of the present invention.
Embodiment according to the inventive method realizes that flow is as follows:
Step 01:It is responsible for obtaining XML+JavaScript mixed files from server end during operation and creates window pair
As all of WPF contents and local control are included in window object the inside, are included wherein in XML file and meet WPF definition
Xaml file contents;
Step 02:XML+JavaScript loaders decompose XAML and JavaScript contents, and hand over WPF interpreter solutions
Release;
Step 03:Control renderer is called to draw interface control, while the handle of returning an object value, and wait user to operate,
This step may call local control adapter;
Step 04:User's clicking operation, produces control event, WPF to intercept event, and affair logic dispatcher is passed through during operation
Call the JavaScript function in JavaScript script interpreters, JavaScript script interpreters are by client end interface control
Part specific event unification be mapped in JavaScript function, do not recall hard coded, by the local code after compiling.
When JavaScript runs, call control data manager to obtain Data Concurrent and send, obtaining data may be from client host
Obtain, it is also possible to obtained from server end, the data started may flow to server end, it is also possible to flow to local control.
During practical application, can be provided with the after-sale service system of garage's industry towards the distribution system of apparel industry or business
Its user interface implementation method, specifically can be applicable to a SAAS(Software-as-a-service)Platform on.
Wherein, the client towards the distribution system of apparel industry needs various peripheral hardwares(Member card, bank brushing card POS,
Automatic cash box), these peripheral hardwares need to call local device to drive can just be operated, it is impossible to be solved by Web programs, Zhi Nengtong
Cross the driving of client local program.By the invention it is possible to call client the machine peripheral hardware to drive, outside operation client the machine
If.Distribution system and after-sale service system are in different fields, and operation flow, functional requirement, software interface are very different,
Distribution system marketing orientation, is concerned about product quantity, the consumption sum of sale;After-sale service system is concerned about maintenance cost, maintenance mans
Process;Cause software client user interface entirely different.By in server end a set of distribution system is provided for distribution system
System client configuration file, a set of after-sale service system client configuration file is provided for after-sale service system, flat in SAAS
Determine that the user belongs to distribution system user or after-sale service system user sends different configurations respectively during platform User logs in
File, reaches software interface, function that two systems user seen entirely different.
The present invention proposes a kind of user interface implementation method based on WPF and JavaScript, wherein, WPF is a kind of Microsoft
The interface rendering technique based on net platforms for providing, indicates WPF systems to draw interface by XAML, has drawn rear runtime and has returned
The handle of all controls is returned, complicated interface is capable of achieving and is drawn, and it is good to draw effect, in addition, with XAML document definition systems, form
Specification, semantic clear scalability is strong.JavaScript is a kind of script, the Dynamic Execution in the way of explaining, in HTML
It is middle to occur as client script, wide application, low cost.
The above, is only presently preferred embodiments of the present invention, is not the limitation for making other forms to the present invention, is appointed
What those skilled in the art changed possibly also with the technology contents of the disclosure above or be modified as equivalent variations etc.
Effect embodiment is applied to other fields, but every without departing from technical solution of the present invention content, according to technical spirit of the invention
Any simple modification, equivalent variations and the remodeling made to above example, still fall within the protection domain of technical solution of the present invention.