Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved WPF
12 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Prajeesh
    wrote on last edited by
    #1

    [Message Deleted]

    A 1 Reply Last reply
    0
    • P Prajeesh

      [Message Deleted]

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      When are you calling OnMouseUp ? Taking a guess, I think you do not need it. Looks like OnMouseDown and OnMouseMove are doing what you want ??

      P 1 Reply Last reply
      0
      • A ABitSmart

        When are you calling OnMouseUp ? Taking a guess, I think you do not need it. Looks like OnMouseDown and OnMouseMove are doing what you want ??

        P Offline
        P Offline
        Prajeesh
        wrote on last edited by
        #3

        [Message Deleted]

        A 1 Reply Last reply
        0
        • P Prajeesh

          [Message Deleted]

          A Offline
          A Offline
          ABitSmart
          wrote on last edited by
          #4

          Prajeesh wrote:

          StartPoint = Args.GetPosition(PhotoBox);

          In the MoveDown event, what is PhotoBox? shouldn't it be DrawingCanvas ? I did the same thing you are doing, on the MouseMove and MouseLeftButtonDown event of the Canvas, and I never got any extra lines.

          P 1 Reply Last reply
          0
          • A ABitSmart

            Prajeesh wrote:

            StartPoint = Args.GetPosition(PhotoBox);

            In the MoveDown event, what is PhotoBox? shouldn't it be DrawingCanvas ? I did the same thing you are doing, on the MouseMove and MouseLeftButtonDown event of the Canvas, and I never got any extra lines.

            P Offline
            P Offline
            Prajeesh
            wrote on last edited by
            #5

            [Message Deleted]

            A 1 Reply Last reply
            0
            • P Prajeesh

              [Message Deleted]

              A Offline
              A Offline
              ABitSmart
              wrote on last edited by
              #6

              private void OnMouseMove(object Sender, MouseEventArgs Args) { if (Args.LeftButton == MouseButtonState.Pressed) { EndPoint = Args.GetPosition(DrawingCanvas); DrawLine(StartPoint, EndPoint, DrawingCanvas); //do not reset the startpoint //StartPoint = EndPoint; } } And in your DrawLine method, delete the old line before adding the new line.

              P 1 Reply Last reply
              0
              • A ABitSmart

                private void OnMouseMove(object Sender, MouseEventArgs Args) { if (Args.LeftButton == MouseButtonState.Pressed) { EndPoint = Args.GetPosition(DrawingCanvas); DrawLine(StartPoint, EndPoint, DrawingCanvas); //do not reset the startpoint //StartPoint = EndPoint; } } And in your DrawLine method, delete the old line before adding the new line.

                P Offline
                P Offline
                Prajeesh
                wrote on last edited by
                #7

                [Message Deleted]

                A 1 Reply Last reply
                0
                • P Prajeesh

                  [Message Deleted]

                  A Offline
                  A Offline
                  ABitSmart
                  wrote on last edited by
                  #8

                  Searching for the control and removing it from the Children collection. Something like this,

                  Line previousLine = null;
                  foreach (UIElement child in TargetCanvas.Children )
                  {
                  if( child is Line)
                  {
                  previousLine = child as Line;
                  break;
                  }
                  }

                  if (null != previousLine)
                  {
                  TargetCanvas.Children.Remove(previousLine);
                  }

                  please update it to fit your needs.

                  P 1 Reply Last reply
                  0
                  • A ABitSmart

                    Searching for the control and removing it from the Children collection. Something like this,

                    Line previousLine = null;
                    foreach (UIElement child in TargetCanvas.Children )
                    {
                    if( child is Line)
                    {
                    previousLine = child as Line;
                    break;
                    }
                    }

                    if (null != previousLine)
                    {
                    TargetCanvas.Children.Remove(previousLine);
                    }

                    please update it to fit your needs.

                    P Offline
                    P Offline
                    Prajeesh
                    wrote on last edited by
                    #9

                    [Message Deleted]

                    A 1 Reply Last reply
                    0
                    • P Prajeesh

                      [Message Deleted]

                      A Offline
                      A Offline
                      ABitSmart
                      wrote on last edited by
                      #10

                      Yes, I hope you can build ahead from the help you have been provided. What you could do is generate a new line name everytime you start drawing and use that line name in the MoveMouse for adding the new line and also for deleting the existing line.

                      P 1 Reply Last reply
                      0
                      • A ABitSmart

                        Yes, I hope you can build ahead from the help you have been provided. What you could do is generate a new line name everytime you start drawing and use that line name in the MoveMouse for adding the new line and also for deleting the existing line.

                        P Offline
                        P Offline
                        Pete OHanlon
                        wrote on last edited by
                        #11

                        I'd leave it if I were you. It looks like he wants you to give him the complete code.

                        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                        My blog | My articles | MoXAML PowerToys

                        A 1 Reply Last reply
                        0
                        • P Pete OHanlon

                          I'd leave it if I were you. It looks like he wants you to give him the complete code.

                          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                          As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                          My blog | My articles | MoXAML PowerToys

                          A Offline
                          A Offline
                          ABitSmart
                          wrote on last edited by
                          #12

                          I reminded him about the advise you had provided him few posts ago, but he doesn't seem to pay any heed to it.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups