Disclosure of Invention
The invention aims to solve the technical problems by providing a positioning method, a device, a terminal device and a storage medium for a control sub-item of a virtualized node, aiming at solving the problems in the prior art that after the set control starts virtualization, the control sub-item corresponding to the virtualized node can be determined through positioning data.
The technical scheme adopted for solving the technical problems is as follows:
in a first aspect, the present invention provides a method for positioning a child item of a virtualized node control, where the method includes:
positioning data corresponding to a preset virtualized node is obtained, and a corresponding father layout set is determined according to the positioning data;
circularly detecting control child items of each parent layout in the parent layout set to obtain a first detection result;
and determining the end of the circulation according to the first detection result, and determining a control sub-item corresponding to the positioning data when the circulation is ended.
In one implementation, the obtaining positioning data corresponding to a preset virtualized node, and determining a corresponding parent layout set according to the positioning data includes:
recursively querying all parent layouts of the positioning data;
and storing all the parent layouts in a reverse order to form the parent layout set.
In one implementation, the loop detecting the control child item of each parent layout in the set of parent layouts, where obtaining the first detection result includes:
acquiring the content of a control child item of each father layout through a preset control view;
detecting the content of the control child item of the parent layout to obtain a second detection result;
when the second detection result is that the content of the control child item of the parent layout is empty, moving the index of the control child item of the parent layout;
and acquiring a control sub-item corresponding to the moved index, and detecting the content of the control sub-item corresponding to the moved index to obtain a first detection result.
In one implementation, when the second detection result is that the content of the control child item of the parent layout is empty, moving the index of the control child item of the parent layout includes:
acquiring a control container through the control view;
acquiring indexes of control child items of the parent layout through the control view;
when the index of the control sub-item of the parent layout is larger than 0, the position of the index of the control sub-item of the parent layout is forced to be scrolled into the visualization area through the control container and the index.
In one implementation, the determining, according to the first detection result, that the cycle ends, and determining, when the cycle ends, the control sub-item corresponding to the positioning data includes:
when the first detection result is that the content of the control sub-item corresponding to the moved index is not empty, assigning the content of the control sub-item corresponding to the moved index to a control view;
acquiring the content of the control child item of each parent layout in the parent layout set through the control view again;
and when the circulation is finished, determining the control child item of the last parent layout as the control child item corresponding to the positioning data.
In one implementation, the loop detecting the control child item of each parent layout in the set of parent layouts, and obtaining the first detection result further includes:
and when the second detection result is that the content of the control child item of the parent layout is not empty, assigning the content of the control child item of the parent layout to the control view, and continuing to acquire the content of the control child item of each parent layout in the parent layout set through the control view.
In one implementation manner, the determining, according to the first detection result, that the cycle ends, and determining, when the cycle ends, the control sub-item corresponding to the positioning data further includes:
and when the first detection result is that the content of the control sub item corresponding to the moved index is empty, ending the circulation.
In a second aspect, an embodiment of the present invention further provides a positioning device for a virtualized node control sub-item, where the device includes:
the parent layout set determining module is used for acquiring preset positioning data corresponding to the virtualized node and determining a corresponding parent layout set according to the positioning data;
the circulation detection module is used for circularly detecting the control child item of each parent layout in the parent layout set to obtain a first detection result;
and the control sub-item determining module is used for determining the end of the circulation according to the first detection result and determining the control sub-item corresponding to the positioning data when the circulation is ended.
In a third aspect, an embodiment of the present invention further provides a terminal device, where the terminal device includes: a processor, a storage medium communicatively coupled to the processor, the storage medium adapted to store a plurality of instructions; the processor is adapted to invoke instructions in the storage medium to perform a positioning method implementing a virtualized node control sub-item as described in any of the above schemes.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, where the computer readable storage medium stores one or more programs, where the one or more programs are executable by one or more processors to implement a positioning method for a virtualized node control subitem according to any one of the above schemes.
The invention has the beneficial effects that: compared with the prior art, the invention provides a positioning method of a control sub-item of a virtualized node, which comprises the steps of obtaining positioning data corresponding to a preset virtualized node, and determining a corresponding parent layout set according to the positioning data.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more clear and clear, the present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
A collection is a data structure that may represent collection data that has a hierarchical relationship or a large number of collection data that has no relationship. The WPF has a set control such as Tree View and List Box, and many scenes in real life are a set structure, for example, administrative division is applied to a number structure, and for example, the organization structure of a company is as follows: the board length-total manager-department manager-main responsible person all have a common characteristic that each node has only one father node, the Tree control View is a development control for bearing a Tree data structure, when a user needs to present the Tree structure such as an organization structure on an interface, the control needs to be developed, and a large amount of data of the same type needs to be represented, for example, all students displaying a class, all monitoring cameras displaying a group and the like are listed, so that the List Box control can be used.
The virtualization is a loading strategy of the set control or the list control, when the data volume is very large, the control cannot load a large amount of data at one time, at the moment, the virtualization function of starting the control is set, the control only loads part of visible data of the current interface control, and only the father node is sequentially unfolded to dynamically load and generate node data which is not displayed in a visual area, so that the loading, optimizing loading and rolling efficiency of the data can be effectively reduced, and the phenomenon of blocking of the control rendering data is greatly reduced under the condition of large data volume.
According to research, in a WPF program, the collection control is a common data loading control, so that data such as an organization structure, a collection with a superior-subordinate relation and the like can be effectively displayed, and if the data volume is large to a certain level, the control loading needs to be provided with a virtualization function, so that program rendering can be reduced, and the loading speed is greatly improved; however, after the virtualization is started, if a piece of data is taken from the data layer, but the node corresponding to the piece of data of the set control is to be jumped and positioned, and if the node is just outside the visible area, the node cannot be jumped and positioned, because the node is not generated at the moment, and the position of the control child item of the node cannot be found. For example, in practical application, after the virtualization is started, a certain piece of data, such as Zhang Sanu, is searched from a data source, in order to select a certain position of Zhang Sanu under a certain organization structure, normally, a node which is not generated cannot be automatically expanded, and only after a parent node of Zhang Sanu is expanded, the node of Zhang Sanu is generated, so that the node can be selected.
In order to solve the problems in the prior art, the present embodiment provides a positioning method for a control child item of a virtualized node, the method includes obtaining positioning data corresponding to a preset virtualized node, and determining a corresponding parent layout set according to the positioning data.
Exemplary method
The positioning method of the sub items of the virtualized node control in the embodiment can be applied to terminal equipment, wherein the terminal equipment is provided with a set control and virtualization is started. In specific implementation, as shown in fig. 1, the positioning method of the control sub-item of the virtualized node in this embodiment includes the following steps:
step S100, positioning data corresponding to a preset virtualized node are obtained, and a corresponding father layout set is determined according to the positioning data.
In implementation, in this embodiment, the parent layout set needs to be circularly detected, so that a control child item corresponding to preset positioning data is determined, so that the preset positioning data needs to be acquired first, and the corresponding parent layout set is determined according to the positioning data. Specifically, after positioning data corresponding to a preset virtualized node is acquired, recursively querying all parent layouts of the positioning data, and storing all the parent layouts in a reverse order to form a parent layout set. For example, assuming that a preset virtualized Node is a data item Node, the Node is a type with a part attribute, and the acquired positioning data is Node a, by storing the queried Parent layout in a reverse order, the Top Parent Node is always the Top layer of the Parent layout set, for example, the final obtained Parent layout set List a may be { Parent Top Node, parent Second Node, parent Third Node. Preferably, in this embodiment, the positioning data is assigned to a preset virtualized node to trigger a recursive query on the positioning data. Further, in this embodiment, before obtaining positioning data, it is necessary to bind the Item Control type Control to the data Source of the Item Source attribute from the View model View Mode and start the virtualization attribute, so as to facilitate obtaining the virtualization node. Further, in this embodiment, a Behavior behavir is added in advance in the control, a dependency attribute is set, and a virtualized node in the view model is bound to be used for processing service logic in the behavir class, and by assigning positioning data to the virtualized node, a parent layout of the positioning data in the behavir class is triggered to perform recursive query.
Step 200, circularly detecting control child items of each parent layout in the parent layout set to obtain a first detection result.
After the parent layout set is obtained, the embodiment can detect the control child item of each parent layout in the parent layout set, and then obtain the first detection result, so that the control child item corresponding to the positioning data can be conveniently determined according to the first detection result.
In one implementation, as shown in fig. 2, the step S200 includes the following steps:
s201, acquiring the content of the control child item of each parent layout through a preset control view.
S202, detecting the content of the control child item of the parent layout to obtain a second detection result.
And S203, when the second detection result is that the content of the control child item of the parent layout is empty, moving the index of the control child item of the parent layout.
S204, acquiring a control sub-item corresponding to the moved index, and detecting the content of the control sub-item corresponding to the moved index to obtain a first detection result.
When the method is implemented, a current control view is acquired, then a parent layout set is circulated, the content of a control child item of each parent layout in circulation is detected through the current control view, a second detection result is obtained, when the second detection result is that the content of the control child item of the parent layout is empty, the index of the control child item of the parent layout is moved, when the second detection result is that the content of the control child item of the parent layout is not empty, the content of the control child item of the parent layout is assigned to the current control view, and the content of the control child item of each parent layout in the parent layout set is continuously acquired through the control view. For example, as shown in fig. 3, a current control View current part is acquired, then a Parent layout set List a is circulated, a control child Item View Item of each Parent layout Node in the List a is acquired through the current control View current part, when the View Item is not empty, the View Item is assigned to the current control View current part, and the Parent layout set List a is continuously circulated. Preferably, when the second detection result indicates that the content of the control child item of the parent layout is empty, it is indicated that the virtualization node is not in the visualization area, and special processing is required at this time, that is, the index of the control child item of the parent layout is moved. Specifically, a control container is acquired through a control view, then an index of a control child item of a parent layout is acquired through the control view, when the acquired index of the control child item of the parent layout is larger than 0, the index of the control child item of the parent layout is forcedly scrolled into a visual area through the control container and the index, and when the acquired index of the control child item of the parent layout is smaller than 0, the data is indicated to be not bound to the current control. As shown in fig. 3, when the View Item is empty, the current control container Virtualizing Panel is acquired through the control View current component, the index of the current Node is acquired through the control View current component, and when the index is greater than 0, the index position is forced to be scrolled into the visualization area through Virtualizing Panel and the index. And finally, acquiring a control sub-item corresponding to the moved index, and detecting the content of the control sub-item corresponding to the moved index to obtain a first detection result.
And step S300, determining that the circulation is ended according to the first detection result, and determining a control sub-item corresponding to the positioning data when the circulation is ended.
After the first detection result is obtained, the embodiment can determine whether the circulation of the parent layout set is finished according to the first detection result, and determine the control child item corresponding to the positioning data when the circulation is finished.
In one implementation, as shown in fig. 4, the step S300 includes the following steps:
and S301, when the first detection result is that the content of the control sub-item corresponding to the moved index is not empty, assigning the content of the control sub-item corresponding to the moved index to a control view.
S302, acquiring the content of the control child item of each parent layout in the parent layout set through the control view again.
And S303, when the circulation is finished, determining the control child item of the last parent layout as the control child item corresponding to the positioning data.
When the first detection result is that the content of the control sub item corresponding to the moved index is not empty, assigning the content of the control sub item corresponding to the moved index to the control view, as shown in fig. 3, and then continuously and circularly obtaining the content of the control sub item of each parent layout in the parent layout set through the control view again until the circulation is finished, and determining that the control sub item of the last parent layout is the control sub item corresponding to the positioning data. For example, after the entire parent layout set List a is circulated, it is determined that the control child item acquired by the last Node a is the control child item to be positioned. Preferably, when the first detection result is that the content of the control sub-item corresponding to the moved index is empty, the loop is ended if the content of the control sub-item is not represented.
In summary, in this embodiment, positioning data corresponding to a preset virtualized node is first obtained, and a corresponding parent layout set is determined according to the positioning data, and since this embodiment needs to cycle through the parent layout set corresponding to the positioning data, the corresponding parent layout set needs to be determined according to the positioning data, control child items of each parent layout in the parent layout set are detected in a cycle, a first detection result is obtained, then whether the cycle is ended is determined according to the first detection result, and when the cycle is ended, the control child item corresponding to the positioning data is determined, so that even if the virtualized node is located outside the visible area, the control child item corresponding to the virtualized node can be determined through the positioning data.
Exemplary apparatus
As shown in fig. 5, the present embodiment further provides a positioning device for a control child item of a virtualized node, where the device includes a parent layout set determining module 10, a loop detecting module 20, and a control child item determining module 30. Specifically, the parent layout set determining module 10 is configured to obtain preset positioning data corresponding to the virtualized node, and determine a corresponding parent layout set according to the positioning data. The loop detection module 20 is configured to loop detect a control child item of each parent layout in the parent layout set, so as to obtain a first detection result. The control sub-item determining module 30 is configured to determine that the cycle is ended according to the first detection result, and determine a control sub-item corresponding to the positioning data when the cycle is ended.
In one implementation, the cycle detection module 20 includes:
the content acquisition unit is used for acquiring the content of the control child item of each father layout through a preset control view;
the second detection unit is used for detecting the content of the control child item of the father layout to obtain a second detection result;
the mobile unit is used for moving the index of the control child item of the parent layout when the second detection result is that the content of the control child item of the parent layout is empty;
the first detection unit is used for acquiring the control sub-item corresponding to the moved index, detecting the content of the control sub-item corresponding to the moved index, and obtaining a first detection result.
In one implementation, the mobile unit includes:
a control container acquisition subunit, configured to acquire a control container through the control view;
an index obtaining subunit, configured to obtain, through the control view, an index of a control child item of the parent layout;
and the index moving subunit is used for forcedly scrolling the position of the index of the control child item of the parent layout into the visualization area through the control container and the index when the index of the control child item of the parent layout is larger than 0.
In one implementation, the control sub-item determination module 30 includes:
the assignment unit is used for assigning the content of the control sub-item corresponding to the moved index to the control view when the first detection result is that the content of the control sub-item corresponding to the moved index is not empty;
a re-acquiring content unit, configured to re-acquire, through the control view, content of a control child item of each parent layout in the parent layout set;
and the control sub-item determining unit is used for determining that the control sub-item of the last parent layout is the control sub-item corresponding to the positioning data when the circulation is finished.
Based on the above embodiment, the present invention further provides a terminal device, and a functional block diagram thereof may be shown in fig. 6. The terminal equipment comprises a processor, a memory, a network interface, a display screen and a temperature sensor which are connected through a system bus. Wherein the processor of the terminal device is adapted to provide computing and control capabilities. The memory of the terminal device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the terminal device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a method of positioning a virtualized node control sub-item. The display screen of the terminal equipment can be a liquid crystal display screen or an electronic ink display screen, and the temperature sensor of the terminal equipment is preset in the terminal equipment and is used for detecting the running temperature of the internal equipment.
It will be appreciated by those skilled in the art that the functional block diagram shown in fig. 6 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the terminal device to which the present inventive arrangements are applied, and that a particular terminal device may include more or less components than those shown, or may combine some of the components, or may have a different arrangement of components.
In one embodiment, a terminal device is provided, where the terminal device includes a memory, a processor, and a positioning program of a virtualized node control sub-item stored in the memory and capable of running on the processor, and when the processor executes the positioning program of the virtualized node control sub-item, the processor implements the following operation instructions:
positioning data corresponding to a preset virtualized node is obtained, and a corresponding father layout set is determined according to the positioning data;
circularly detecting control child items of each parent layout in the parent layout set to obtain a first detection result;
and determining the end of the circulation according to the first detection result, and determining a control sub-item corresponding to the positioning data when the circulation is ended.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
In summary, the present invention provides a positioning method for control children of a virtualized node, where the method includes obtaining positioning data corresponding to a preset virtualized node, and determining a corresponding parent layout set according to the positioning data, because the embodiment needs to cycle through the parent layout set corresponding to the positioning data, the corresponding parent layout set needs to be determined according to the positioning data, and the control children of each parent layout in the parent layout set are detected in a cycle mode to obtain a first detection result, then determining whether the cycle is finished according to the first detection result, and determining the control children corresponding to the positioning data when the cycle is finished, so that the control children corresponding to the virtualized node can be determined through the positioning data even if the virtualized node is located outside a visible area.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.