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
  1. Home
  2. General Programming
  3. C#
  4. Cross to follow mouse

Cross to follow mouse

Scheduled Pinned Locked Moved C#
question
4 Posts 2 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.
  • G Offline
    G Offline
    gwithey
    wrote on last edited by
    #1

    I have created a control which follows the mouse using MousePosition However i would actually like the mouse value produced by the control to start at 0 at the top and left sides of my control and finish at 1000. at the bottom and the right sides of the control. Does anyone know how i can do this? Thanx in advance

    C 1 Reply Last reply
    0
    • G gwithey

      I have created a control which follows the mouse using MousePosition However i would actually like the mouse value produced by the control to start at 0 at the top and left sides of my control and finish at 1000. at the bottom and the right sides of the control. Does anyone know how i can do this? Thanx in advance

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I'm not sure what you mean, but I think you mean you want to do some basic primary school math to convert the width and height of the control to be a range from 0 to 1000 ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      G 2 Replies Last reply
      0
      • C Christian Graus

        I'm not sure what you mean, but I think you mean you want to do some basic primary school math to convert the width and height of the control to be a range from 0 to 1000 ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        G Offline
        G Offline
        gwithey
        wrote on last edited by
        #3

        Yeah that is what i aim to do just don't really know how to implement this.

        1 Reply Last reply
        0
        • C Christian Graus

          I'm not sure what you mean, but I think you mean you want to do some basic primary school math to convert the width and height of the control to be a range from 0 to 1000 ?

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          G Offline
          G Offline
          gwithey
          wrote on last edited by
          #4

          Thanx for the help. I have created some code that works now dont know if this is the idea you thought but it functions correctly. Only the painted cross moves the same as the value ill just have to change this and it will be complete.

            private int MAX\_VALUE = 1000;
            private int MIN\_VALUE = 0;
          
            private double m\_WidthMultiplyNo = 0;
            private double m\_HeightMultiplyNo = 0;
          
             public Point Origin
            {
               get { return m\_origin; }
               set
               {
                  m\_origin = calculateNewPosition(value);
          
                  if (PositionChanged != null)
                  {
                     this.PositionChanged();
                  }
               }
            }
          
             private Point calculateNewPosition(Point Value)
            {
               if (Value.Y < m\_position.Y)
               {
                  if (Value.X > m\_position.X)
                  {
                     Value.Y -= 1;
                     Value.X += 1;
                  }
                  else if (Value.X < m\_position.X)
                  {
                     Value.Y -= 1;
                     Value.X -= 1;
                  }
               }
               else if (Value.Y > m\_position.Y)
               {
                  if (Value.X > m\_position.X)
                  {
                     Value.Y += 1;
                     Value.X += 1;
                  }
                  else if (Value.X < m\_position.X)
                  {
                     Value.Y += 1;
                     Value.X -= 1;
                  }
               }
          
               Value.X \*= (int)m\_WidthMultiplyNo;
               Value.Y \*= (int)m\_HeightMultiplyNo;
          
               Value = KeepInsideValue(Value);
               return Value;
            }
          
          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