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. Eye that follow cursor of the mouse [modified]

Eye that follow cursor of the mouse [modified]

Scheduled Pinned Locked Moved C#
wpfcsharpcom
8 Posts 4 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.
  • V Offline
    V Offline
    VisualLive
    wrote on last edited by
    #1

    Hi , i wish build a control(wpf) that the Eye(Ellipse) follow the cursor of the mouse. here is a snippet code that i am developing :

    <Window Height="480" Title="Window2" Width="640" x:Class="WpfApplication5.Window2"
    x:Name="Window" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.Resources>
    <Storyboard x:Key="OnLoaded1">
    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ctrCircle"
    Storyboard.TargetProperty="(UIElement.RenderTransform).( TransformGroup.Children)[3].(TranslateTransform.X)">
    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1">
    <EasingDoubleKeyFrame.EasingFunction>
    <ExponentialEase EasingMode="EaseOut" />
    </EasingDoubleKeyFrame.EasingFunction>
    </EasingDoubleKeyFrame>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ctrCircle"
    Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1">
    <EasingDoubleKeyFrame.EasingFunction>
    <ExponentialEase EasingMode="EaseOut" />
    </EasingDoubleKeyFrame.EasingFunction>
    </EasingDoubleKeyFrame>
    </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    <Style TargetType="Ellipse">
    <Setter Property="RenderTransform">
    <Setter.Value>
    <ScaleTransform ScaleX="1" ScaleY="1"/>
    </Setter.Value>
    </Setter>
    <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
    </Style>
    </Window.Resources>
    <Canvas MouseMove="mov" x:Name="LayoutRoot">
    <Border ackground="Black" B="" Canvas.Left="178" Canvas.Top="103"
    CornerRadius="250" Height="255.5" Width="290" x:Name="border_eye">
    <Ellipse Fill="#FFFFC600" Height="12" HorizontalAlignment="Left"
    Margin="0" RenderTransformOrigin="0.5,0.5" Stroke="{x:Null}"
    VerticalAlignment="Center" Visibility="Visible" Width="12" x:Name="ctrCircle">
    <Ellipse.RenderTransform>
    <TransformGroup>
    <ScaleTransform />
    <SkewTransform />
    &

    A L 2 Replies Last reply
    0
    • V VisualLive

      Hi , i wish build a control(wpf) that the Eye(Ellipse) follow the cursor of the mouse. here is a snippet code that i am developing :

      <Window Height="480" Title="Window2" Width="640" x:Class="WpfApplication5.Window2"
      x:Name="Window" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <Window.Resources>
      <Storyboard x:Key="OnLoaded1">
      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ctrCircle"
      Storyboard.TargetProperty="(UIElement.RenderTransform).( TransformGroup.Children)[3].(TranslateTransform.X)">
      <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1">
      <EasingDoubleKeyFrame.EasingFunction>
      <ExponentialEase EasingMode="EaseOut" />
      </EasingDoubleKeyFrame.EasingFunction>
      </EasingDoubleKeyFrame>
      </DoubleAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ctrCircle"
      Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
      <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1">
      <EasingDoubleKeyFrame.EasingFunction>
      <ExponentialEase EasingMode="EaseOut" />
      </EasingDoubleKeyFrame.EasingFunction>
      </EasingDoubleKeyFrame>
      </DoubleAnimationUsingKeyFrames>
      </Storyboard>
      <Style TargetType="Ellipse">
      <Setter Property="RenderTransform">
      <Setter.Value>
      <ScaleTransform ScaleX="1" ScaleY="1"/>
      </Setter.Value>
      </Setter>
      <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
      </Style>
      </Window.Resources>
      <Canvas MouseMove="mov" x:Name="LayoutRoot">
      <Border ackground="Black" B="" Canvas.Left="178" Canvas.Top="103"
      CornerRadius="250" Height="255.5" Width="290" x:Name="border_eye">
      <Ellipse Fill="#FFFFC600" Height="12" HorizontalAlignment="Left"
      Margin="0" RenderTransformOrigin="0.5,0.5" Stroke="{x:Null}"
      VerticalAlignment="Center" Visibility="Visible" Width="12" x:Name="ctrCircle">
      <Ellipse.RenderTransform>
      <TransformGroup>
      <ScaleTransform />
      <SkewTransform />
      &

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

      That XAML makes my brain hurt. Maybe you should use the PRE tag on it rather than the CODE tag. The PRE tag maintains the indentation.

      [Forum Guidelines]

      V 1 Reply Last reply
      0
      • A AspDotNetDev

        That XAML makes my brain hurt. Maybe you should use the PRE tag on it rather than the CODE tag. The PRE tag maintains the indentation.

        [Forum Guidelines]

        V Offline
        V Offline
        VisualLive
        wrote on last edited by
        #3

        Hi aspodotnetdev, i tried to modify it but i can not fix it well i don't know why,:confused: i will try again. Thanks :) Edit... i tried to use PRE tag but when i post the code many lines of code disappear ,i am so sorry if it is not fix well.

        A C 2 Replies Last reply
        0
        • V VisualLive

          Hi aspodotnetdev, i tried to modify it but i can not fix it well i don't know why,:confused: i will try again. Thanks :) Edit... i tried to use PRE tag but when i post the code many lines of code disappear ,i am so sorry if it is not fix well.

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

          VisualLive wrote:

          i tried to use PRE tag but when i post the code many lines of code disappear

          Hmmm, maybe that's related to a bug I reported here.

          [Forum Guidelines]

          1 Reply Last reply
          0
          • V VisualLive

            Hi aspodotnetdev, i tried to modify it but i can not fix it well i don't know why,:confused: i will try again. Thanks :) Edit... i tried to use PRE tag but when i post the code many lines of code disappear ,i am so sorry if it is not fix well.

            C Offline
            C Offline
            Chris Maunder
            wrote on last edited by
            #5

            You needed to HTML encode your XML. I've fixed it

            cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

            V 1 Reply Last reply
            0
            • C Chris Maunder

              You needed to HTML encode your XML. I've fixed it

              cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

              V Offline
              V Offline
              VisualLive
              wrote on last edited by
              #6

              Hi Chris, you are so kind to do that,i will remind for the next time i post a code. :) Thanks so much . Have a nice day.

              1 Reply Last reply
              0
              • V VisualLive

                Hi , i wish build a control(wpf) that the Eye(Ellipse) follow the cursor of the mouse. here is a snippet code that i am developing :

                <Window Height="480" Title="Window2" Width="640" x:Class="WpfApplication5.Window2"
                x:Name="Window" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
                <Window.Resources>
                <Storyboard x:Key="OnLoaded1">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ctrCircle"
                Storyboard.TargetProperty="(UIElement.RenderTransform).( TransformGroup.Children)[3].(TranslateTransform.X)">
                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1">
                <EasingDoubleKeyFrame.EasingFunction>
                <ExponentialEase EasingMode="EaseOut" />
                </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ctrCircle"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1">
                <EasingDoubleKeyFrame.EasingFunction>
                <ExponentialEase EasingMode="EaseOut" />
                </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                </Storyboard>
                <Style TargetType="Ellipse">
                <Setter Property="RenderTransform">
                <Setter.Value>
                <ScaleTransform ScaleX="1" ScaleY="1"/>
                </Setter.Value>
                </Setter>
                <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
                </Style>
                </Window.Resources>
                <Canvas MouseMove="mov" x:Name="LayoutRoot">
                <Border ackground="Black" B="" Canvas.Left="178" Canvas.Top="103"
                CornerRadius="250" Height="255.5" Width="290" x:Name="border_eye">
                <Ellipse Fill="#FFFFC600" Height="12" HorizontalAlignment="Left"
                Margin="0" RenderTransformOrigin="0.5,0.5" Stroke="{x:Null}"
                VerticalAlignment="Center" Visibility="Visible" Width="12" x:Name="ctrCircle">
                <Ellipse.RenderTransform>
                <TransformGroup>
                <ScaleTransform />
                <SkewTransform />
                &

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                You may get a better reponse to your query in the WPF forum.

                Just say 'NO' to evaluated arguments for diadic functions! Ash

                V 1 Reply Last reply
                0
                • L Lost User

                  You may get a better reponse to your query in the WPF forum.

                  Just say 'NO' to evaluated arguments for diadic functions! Ash

                  V Offline
                  V Offline
                  VisualLive
                  wrote on last edited by
                  #8

                  Hi Richard, truly i believed it was the WPF Forum :-D ,so it was my mistake :doh: . Thanks for your suggest,i moved this question to the WPF Forum. Have a nice day. :)

                  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