WPF Flowchart Making series related Foundation one

Source: Internet
Author: User
Tags response code

WPF flowchart production is based on the need to develop a flowchart through WPF, which is a user-dragged configuration. If you have used a flowchart, you should be able to imagine what the flowchart will look like when you drag the configuration. The main technical point of reference here is WPF drag-related knowledge. But in fact, WPF drag is a number of different implementations of the idea of a corresponding mouse MouseDown MouseMove MouseUp and other events to let the flowchart tag followed by the move. Scenario two WPF comes with mouse drag events, but this drag is primarily focused on copying information from one place to another by dragging this action. Instead of the purely element that we mean, the displacement occurs on the artboard. Programme three is also our focus. WPF has a dedicated class under the System.windows.control.primitive namespace called Thumb to provide the implementation of drag displacements on the artboard. This thumb control is a partial base-level control that you can use to build other controls. In the visual stdio we have at hand, when we slide the mouse wheel down, the slider on the right will appear and we can drag the slider. We can observe that by dragging the slider, the code shown on the left will move accordingly. The core events of the thumb are: dragstarted--occurs when you press the left mouse button on the slider and start dragging, dragdelta--as long as your drag is still in operation (without releasing the left mouse button), it will continue to occur; dragcompleted--Needless to say,   This must have occurred at the end of the drag operation. We use a simple example to do a quiz, mainly is to drag the slider, on the label to show the position of the slider coordinates. Front Desk Interface
 <Grid>        <CanvasName= "G"Background= "AliceBlue"HorizontalAlignment= "Left"Height= "+"Margin= "41,72,0,0"VerticalAlignment= "Top"Width= "151">            <ThumbCanvas.Top= "2"Canvas.Left= "2"Width= "+"Height= "+"DragDelta= "Thumb_dragdelta"
DragStarted= "thumb_dragstarted"dragcompleted= "thumb_dragcompleted"></Thumb> <TextBlockCanvas.Top= "2"Canvas.Left= "2"x:name= "tt"FontSize= "+" ></TextBlock> </Canvas></Grid>
Background Event Response Code
 Private voidThumb_dragdelta (Objectsender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) {Thumb Mythumb=(Thumb) sender; DoubleNTop = Canvas. GetTop (MYTHUMB) +E.verticalchange; DoubleNleft = Canvas. GetLeft (MYTHUMB) +E.horizontalchange;            Canvas.settop (Mythumb, NTop);            Canvas.setleft (Mythumb, nleft); Tt. Text="Top:"+ ntop.tostring () +"\nleft:"+nleft.tostring (); }  Private voidThumb_dragstarted (Objectsender, Dragstartedeventargs e) {TT. Text="haha this thing can be dragged" ; }  Private voidThumb_dragcompleted (Objectsender, DragCompletedEventArgs e) {TT. Text="Finally, it's over." ; }
The thumb control looks just like a disgraced block. Of course we can set his face through ControlTemplate, which is beyond the topic. The effect is as follows

WPF Flowchart Making series related Foundation one

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.