Click here to Skip to main content
15,895,142 members
Home / Discussions / C#
   

C#

 
AnswerRe: Application Design & Archiecture Help Pin
Dave Kreskowiak4-Nov-10 14:54
mveDave Kreskowiak4-Nov-10 14:54 
GeneralRe: Application Design & Archiecture Help Pin
Richard Andrew x644-Nov-10 17:23
professionalRichard Andrew x644-Nov-10 17:23 
JokeRe: Application Design & Archiecture Help Pin
Richard MacCutchan4-Nov-10 23:29
mveRichard MacCutchan4-Nov-10 23:29 
GeneralRe: Application Design & Archiecture Help Pin
dsrao5-Nov-10 4:34
dsrao5-Nov-10 4:34 
GeneralRe: Application Design & Archiecture Help Pin
jschell5-Nov-10 8:49
jschell5-Nov-10 8:49 
GeneralRe: Application Design & Archiecture Help Pin
Dave Kreskowiak5-Nov-10 9:39
mveDave Kreskowiak5-Nov-10 9:39 
AnswerRe: Application Design & Archiecture Help Pin
Abhinav S5-Nov-10 2:51
Abhinav S5-Nov-10 2:51 
QuestionEye that follow cursor of the mouse [modified] Pin
VisualLive4-Nov-10 8:58
VisualLive4-Nov-10 8:58 
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 :

XML
<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 />
                    <RotateTransform />
                    <TranslateTransform />                 
                </TransformGroup>
            </Ellipse.RenderTransform>
        </Ellipse>
    </Border>
</Canvas>
</Window>



and in the code behind :
C#
private void mov(object sender, MouseEventArgs e)
        {
	 System.Windows.Point pt = e.GetPosition((Canvas)sender);
          Storyboard invokeStoryboard = this.Resources["OnLoaded1"] as Storyboard;
            ((DoubleAnimationUsingKeyFrames)invokeStoryboard.Children[0]).KeyFrames[0].Value = pt.X;
            ((DoubleAnimationUsingKeyFrames)invokeStoryboard.Children[1]).KeyFrames[0].Value = pt.Y;
            invokeStoryboard.Begin();
        }


now my purpose is when i move the mouse in the Canvas area(LayoutRoot) the Ellipse(ctrCircle) move only inside the Border(border_eye) and don't overcome the area of the "border_eye" this effect is similar an eye.

Do you have any idea how to perform this step?

Thanks so much for your attention Smile | :)

Have a nice day.

modified on Friday, November 5, 2010 1:16 AM

GeneralRe: Eye that follow cursor of the mouse Pin
AspDotNetDev4-Nov-10 10:13
protectorAspDotNetDev4-Nov-10 10:13 
GeneralRe: Eye that follow cursor of the mouse Pin
VisualLive4-Nov-10 10:41
VisualLive4-Nov-10 10:41 
GeneralRe: Eye that follow cursor of the mouse Pin
AspDotNetDev4-Nov-10 12:18
protectorAspDotNetDev4-Nov-10 12:18 
GeneralRe: Eye that follow cursor of the mouse Pin
Chris Maunder4-Nov-10 19:21
cofounderChris Maunder4-Nov-10 19:21 
GeneralRe: Eye that follow cursor of the mouse Pin
VisualLive4-Nov-10 21:06
VisualLive4-Nov-10 21:06 
AnswerRe: Eye that follow cursor of the mouse Pin
Richard MacCutchan4-Nov-10 23:27
mveRichard MacCutchan4-Nov-10 23:27 
GeneralRe: Eye that follow cursor of the mouse Pin
VisualLive5-Nov-10 0:01
VisualLive5-Nov-10 0:01 
QuestionCustomize VS2010 Start Page Pin
Kevin Marois4-Nov-10 8:48
professionalKevin Marois4-Nov-10 8:48 
AnswerRe: Customize VS2010 Start Page Pin
Nish Nishant4-Nov-10 9:45
sitebuilderNish Nishant4-Nov-10 9:45 
GeneralRe: Customize VS2010 Start Page Pin
RaviRanjanKr16-Nov-10 2:40
professionalRaviRanjanKr16-Nov-10 2:40 
Questionfull text search Pin
annie_bel4-Nov-10 3:31
annie_bel4-Nov-10 3:31 
AnswerRe: full text search Pin
JohnLBevan4-Nov-10 3:53
professionalJohnLBevan4-Nov-10 3:53 
AnswerRe: full text search Pin
Adam R Harris4-Nov-10 4:53
Adam R Harris4-Nov-10 4:53 
QuestionImpersonation using C# Pin
JohnLBevan4-Nov-10 1:45
professionalJohnLBevan4-Nov-10 1:45 
AnswerRe: Impersonation using C# Pin
Adam R Harris4-Nov-10 4:49
Adam R Harris4-Nov-10 4:49 
AnswerRe: Impersonation using C# Pin
Manfred Rudolf Bihy4-Nov-10 5:06
professionalManfred Rudolf Bihy4-Nov-10 5:06 
GeneralRe: Impersonation using C# Pin
JohnLBevan9-Nov-10 5:43
professionalJohnLBevan9-Nov-10 5:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.