Implementation method of multi-WPF window splicing into an operable canvas
By splicing multiple child windows onto the WPF main window and registering touch response events, the problem of not being able to display multiple charts and data in existing technologies is solved, enabling flexible canvas operations and improving the user experience.
Patent Information
- Application Number
- CN202310648191.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-01
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2043-06-01
AI Technical Summary
Existing WPF forms cannot effectively display multiple charts and data, and cannot implement overall touch, zoom, and scroll operations.
By creating a WPF main form and a Canvas container on it, multiple WPF child forms are joined together to form a canvas. Touch response events are registered, and the ManipulationDelta event is used to obtain the transformation amount, enabling the scaling and movement of the canvas.
It enables multiple WPF child windows to form a single canvas, supporting zoom, move, and scroll operations, improving the user experience and expanding its application range.
Smart Images

Figure CN116755585B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, specifically a method for combining multiple WPF windows into a single operable canvas. Background Technology
[0002] WPF (Windows Presentation Foundation) is a new user interface framework introduced by Microsoft, providing advanced features such as graphics rendering, layout, and animation effects. In a WPF form, the form acts as a basic control, capable of containing other controls such as buttons and text boxes. Therefore, for fields like data visualization that require displaying charts and data, WPF forms can be used. However, for situations requiring the simultaneous display of multiple charts and data that cannot or are inconvenient to display on a single form, the existing WPF form is insufficient. Furthermore, existing canvas displays often fail to allow for touch, zoom, and scrolling operations on the entire canvas as a whole. Therefore, a method based on WPF forms is needed that enables touch, zoom, and scrolling operations and allows for the display of more charts and data on a single canvas. Summary of the Invention
[0003] To address the shortcomings of existing technologies, the purpose of this invention is to provide a method for stitching multiple WPF windows together into an operable canvas, which can solve the problems described in the background art.
[0004] The technical solution to achieve the objective of this invention is as follows: a method for splicing multiple WPF windows into an operable canvas, comprising the following steps:
[0005] Step 1: Create a WPF main form, create a container on the WPF main form, and add at least two WPF child forms to the container to form the canvas. Then, stitch the WPF child forms together to form a canvas.
[0006] Step 2: Register touch response events for each WPF child form. Touch response events are used to respond to user operations on the canvas.
[0007] Step 3: Based on the touch response event, obtain the transformation amount of the operation on the canvas, including the horizontal displacement, vertical displacement and scaling ratio;
[0008] Step 4: Based on the transformation amount, respond to the scaling and moving operations of the container to realize the scaling and moving operations of the canvas composed of multiple WPF child windows.
[0009] Furthermore, the container is a Canvas container.
[0010] Furthermore, the touch response event is a ManipulationDelta event.
[0011] Furthermore, in step 3, the obtained transformation amount is assigned to an intermediate variable, the lateral displacement is assigned to the intermediate variable offsetX, the longitudinal displacement is assigned to the intermediate variable offsetY, and the scaling ratio is assigned to the intermediate variable scale.
[0012] Furthermore, the scaling factor (scale) is set to the larger of the horizontal or vertical scaling factor.
[0013] Furthermore, after step 4, it also includes,
[0014] Step 5: Add a ScrollViewer control to the main form and place the Canvas container inside the ScrollViewer control to enable the canvas to scroll by dragging the mouse or touching the screen.
[0015] The beneficial effects of this invention are as follows: This invention is simple to operate, more convenient to operate, and has a low learning cost. It can realize the display of multiple WPF child windows as a whole canvas, and can perform operations such as scaling and moving on the canvas. Therefore, it can be applied to scenarios that need to display multiple charts and data, with a wider range of applications and improved user experience. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the process of the present invention;
[0017] Figure 2 This is a schematic diagram showing the effect of three WPF child windows combined into a single canvas. Detailed Implementation
[0018] The present invention will now be further described with reference to the accompanying drawings and specific embodiments:
[0019] like Figure 1 and Figure 2 As shown, a method for combining multiple WPF windows into a single operable canvas includes the following steps:
[0020] Step 1: Create a WPF main form, create a Canvas container on the WPF main form, and add at least two WPF child forms to the Canvas container to form the canvas. Then, combine the WPF child forms into a single canvas.
[0021] In this step, using a Canvas container ensures that each WPF child window within the container can be freely positioned and resized within the WPF main window, thus achieving flexible layout. A WPF child window refers to a window relative to the WPF main window; both WPF child windows and the WPF main window are types of WPF windows.
[0022] Step 2: Register touch response events for each WPF child form. Touch response events are used to respond to user operations on the canvas, including touch, zoom, and move operations, such as touching the screen, dragging the mouse, etc. Touch response events will be triggered and executed.
[0023] In this step, the touch response event is the ManipulationDelta event, meaning that only registering the ManipulationDelta event is needed to generate a touch response event.
[0024] Step 3: Based on the touch response event, obtain the transformation amount of the operation on the canvas, including the horizontal displacement, vertical displacement and scaling ratio.
[0025] The transformation quantities can be obtained using the following code:
[0026] var deltaManipulation=e.DeltaManipulation
[0027] This program code represents the change quantity obtained from the event that describes the current operation (e.g., a gesture operation).
[0028] The obtained transformation values are assigned to intermediate variables. For example, the lateral displacement is assigned to the intermediate variable offsetX, the axial displacement to the intermediate variable offsetY, and the scaling factor to the intermediate variable scale. The scaling factor scale is the larger of the lateral or axial scaling factors.
[0029] Step 4: Based on the transformation amount, respond to the scaling and moving operations of the Canvas container, that is, scale the corresponding scaling ratio and move the corresponding displacement according to the value assigned by the intermediate variable, so as to realize the scaling and moving operations of the canvas spliced by multiple WPF child windows, wherein the scaling operation is performed with the center point of the canvas.
[0030] In an optional implementation, after step 4, the method further includes:
[0031] Step 5: Add a ScrollViewer control to the main form and place the Canvas container inside the ScrollViewer control to enable the canvas to scroll by dragging the mouse or touching the screen.
[0032] refer to Figure 2 , Figure 2 This is a schematic diagram showing the effect of a canvas composed of three WPF child windows. This canvas allows for the overall scaling of multiple WPF child windows combined into a single canvas, rather than scaling individual windows within the canvas proportionally.
[0033] This invention is simple and convenient to operate, with a low learning cost. It can combine multiple WPF child windows into a single canvas for display, and allows for scaling, moving, and other operations within that canvas. This makes it applicable to scenarios that require displaying multiple charts and data, broadening its scope of application and improving the user experience.
[0034] The embodiments disclosed in this specification are merely illustrative of one aspect of the invention, and the scope of protection of the invention is not limited to these embodiments. Any other functionally equivalent embodiments fall within the scope of protection of the invention. Those skilled in the art can make various other corresponding changes and modifications based on the technical solutions and concepts described above, and all such changes and modifications should fall within the scope of protection of the claims of this invention.
Claims
1. A method for assembling multiple WPF windows into a single operable canvas, characterized in that, Includes the following steps: Step 1: Create a WPF main form, create a Canvas container on the WPF main form, and add at least two WPF child forms to the Canvas container to form the canvas. Then, stitch the WPF child forms together into a canvas within the Canvas container. Step 2: Register a ManipulationDelta touch response event for each WPF child form. The touch response event is used to respond to user operations on the canvas. Step 3: Based on the ManipulationDelta touch response events reported by each WPF child window, obtain the transformation amounts generated by the operation on the canvas. The transformation amounts include horizontal displacement, vertical displacement, and scaling ratio. The horizontal displacement is assigned to the intermediate variable offsetX, the vertical displacement is assigned to the intermediate variable offsetY, and the scaling ratio is the larger of the horizontal and vertical scaling ratios and assigned to the intermediate variable scale. Step 4: Based on offsetX, offsetY, and scale, scale and move the Canvas container as a whole with the center point of the Canvas as the reference, so that all WPF child windows are scaled and moved as a whole as a whole, maintaining the relative position and uniform scale of the same canvas, instead of each WPF child window responding to touch independently and scaling and moving on its own.
2. The method for implementing multiple WPF windows into an operable canvas according to claim 1, characterized in that, After step 4, it also includes, Step 5: Add a ScrollViewer control to the main form and place the Canvas container inside the ScrollViewer control to enable the canvas to scroll when dragged with the mouse or touched on the screen.
