Move image according to mouse movement

Hello
I am beuilding a game similer to the classic pong game.
I trying the build it a way that the user will control it "player" with the mouse.
The "player" only have to move in up or down
I cant make the  "Player" move exactly as the mouse
Does anyone have an idea how to make it work?
Thanks
Amir

Perfect: that was it. Many thanks..
jwc

Similar Messages

  • Move container sprite according to mouse movement

    Hi All,
    Currently I'm developing a game where there is a object which follows mouse. Also there are other objects and a map on the screen.I want all of background content(whole map and other objects) to move when user moves mouse left or right. That is, if user moves mouse on right side then all content(except object which moves as per mouse) should move left side so that user can see remaining part of map on the right side.
    As of now I have created new Container sprite in which I have added all of my objects and map. So when user moves the mouse right, I move the container sprite to left so it looks all stuff moves to left. Code looks like as below
    var pt:Point = new Point(character.x, character.y);
    pt = dori.localToGlobal(pt);
    if (pt.x > (stage.width * 0.5))
                        container.x -= 5;
    Structure of project is such that, I add Container directly to stage. and this container contains everything like map, character and other objects.
    Now issue is that as soon as mouse goes beyond middle of stage...it creates distance between mouse location and character..!! I mean it does move according to mouse but some distance get created between mouse and character. and this distance keeps increasing as I continue to move mouse away from center of stage!!
    I'm really stuck with this issue. Please someone help with this. I hope I have explained this well. Let me know if you need more info but please help.

    No see......I dont want ease in n all....and character following the mouse logic is working fine if I dont use above linear interpolation to move the container mc.....
    but I do want to move container mc as well so I will have to use what you gave to move the all background objects when user moves mouse....
    so Again to clarify, in the game when user moves mouse the character should follow and at the same time bakckground objects which are in container mc should move opposite to mouse movement so that remainng mape gets visible to the user....
    just now when I was debuggin the linear interpolation logic...I got to know that there something I need to change in it...because accroding to that logic...let say for example
    stageWidth is 480
    maze.width is 551
    then x1 will be  480
    y1 will be -71
    x2 will be 0 and
    y2 will be 0
    so m = (y1 - y2) / (x1 - x2) = -71 - 0 / 480 - 0
    m = -0.147
    b = y1 - m * x1 = -71 - (-0.147 * 480) = 0
    so on each enter frame when mouseX wil be multiplied with m....it will create lag in moving container(character is in container as well!
    bcoz
    container.x = m * stageRef.mouseX + b;
    so I'm confused!!
    where do u think shall correction be made??

  • Drag'n drop : reacting/animating on drag, according to mouse pos in target

    Hi fellow Java coders,
    I'm using drag'n drop support for some JPanel I'm using in order to make them able to change their layout in their parent or to stack themselves in a tab panel.
    The drag n drop itself works fine (I took the example provided in do, the one with drag'n'dropped children pics).
    But I would like to be able to react according to mouse position in the target panel, the one that receives the drop. I would like to change mouse cursor according to where is the mouse position inside the target panel, or animating / repainting things inside this target panel.
    The lock I have is that with drag'n drop, MouseListener is not called at all when in drag movement, so I can't handle mouse events.
    Is there a way to handle this case, when you wan't to react when dragging data above a possible target component, before having dropped it ?
    Thank you in advance,
    Alexis.

    This grew larger than I planned, but here is an example that show different cursors for different components.
    Drag from the center and the cursor will change for each of the border labels.
    The code I origionally used this in uses custom cursors Crated by System.createCustomCursor.
    This is not really pretty, but it works.
    import java.awt.*;
    import java.awt.dnd.*;
    import javax.swing.*;
    import java.awt.dnd.peer.*;
    import java.awt.datatransfer.*;
    public class DnDFeedBack extends JFrame
        public DnDFeedBack()
            super( "DnD Feed Back Example");
            setDefaultCloseOperation( EXIT_ON_CLOSE );
            JPanel panel = new JPanel( new BorderLayout() );
            JLabel comp = new JLabel( "North Drop" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new DTFeedBackListener( comp, Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
            panel.add( comp, BorderLayout.NORTH );
            comp = new JLabel( "East Drop" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new DTFeedBackListener( comp, Cursor.getPredefinedCursor( Cursor.CROSSHAIR_CURSOR ));
            panel.add( comp, BorderLayout.EAST );
            comp = new JLabel( "West Drop" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new DTFeedBackListener( comp, Cursor.getPredefinedCursor( Cursor.TEXT_CURSOR ));
            panel.add( comp, BorderLayout.WEST );
            comp = new JLabel( "South Drop" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new DTFeedBackListener( comp, Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ));
            panel.add( comp, BorderLayout.SOUTH );
            comp = new JLabel( "Drag Source" );
            comp.setBorder( BorderFactory.createLineBorder( Color.black ) );
            new FeedBackDS( comp );
            panel.add( comp, BorderLayout.CENTER );
            setContentPane( panel );
            pack();
            setLocationRelativeTo( null );
            setVisible( true );
        public static void main( String[] args )
            new DnDFeedBack();
        public class FeedBackDS extends DragSourceAdapter implements DragGestureListener
            public FeedBackDS( JComponent comp )
                new MYDragSource().createDefaultDragGestureRecognizer(
                                                                     comp, // component where drag originates
                                                                     DnDConstants.ACTION_COPY_OR_MOVE, // actions
                                                                     this); // drag gesture listener
            public void dragGestureRecognized(DragGestureEvent dge)
                dge.startDrag( DragSource.DefaultMoveNoDrop,
                               new java.awt.datatransfer.StringSelection( "FAKE DATA") );
        public class DTFeedBackListener extends DropTargetAdapter
            JComponent comp;
            Cursor cursor;
            public DTFeedBackListener( JComponent comp, Cursor cursor )
                DropTarget dt = new DropTarget( comp, this );
                dt.setDefaultActions(DnDConstants.ACTION_COPY_OR_MOVE);
                this.comp = comp;
                this.cursor = cursor;
            public void dragExit(DropTargetEvent dte)
                setFeedBackCursor(DragSource.DefaultMoveNoDrop);
            public void dragEnter(DropTargetDragEvent dtde)
                dtde.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE );
                setFeedBackCursor(cursor);
            public void drop(DropTargetDropEvent dtde){}
        public class MYDragSource extends DragSource
            public MYDragSource()
                super();
            protected DragSourceContext createDragSourceContext(DragSourceContextPeer dscp, DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl)
                return new MYDragSourceContext(dscp, dgl, dragCursor, dragImage, imageOffset, t, dsl);
        private static Cursor fbCursor;
        public class MYDragSourceContext extends DragSourceContext
            private transient DragSourceContextPeer peer;
            private Cursor              cursor;
            public MYDragSourceContext(DragSourceContextPeer dscp, DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl)
                super( dscp, dgl, dragCursor, dragImage, imageOffset, t, dsl);
                peer         = dscp;
                cursor       = dragCursor;
            protected synchronized void updateCurrentCursor(int dropOp, int targetAct, int status)
                setCursorImpl(fbCursor);
            private void setCursorImpl(Cursor c)
                if( cursor == null || !cursor.equals(c) )
                    cursor = c;
                    if( peer != null ) peer.setCursor(cursor);
        public static void setFeedBackCursor( Cursor cursor )
            fbCursor = cursor;
    }

  • Moving Images with the mouse

    Sorry I am still fairly new to Java. I have a project due that will require me to move images with the mouse. And I was wondering if someone could give me the basics of doing this. Right now I only need to know how to move the image any where on the screen.

    sweety_baby wrote:
    It's not so usefull nebody plzz help me i wanna code for movinag an image from one place to another in frame
    plzzzzzzzz help me out its urgentIf it's so d�mn urgent, then why
    1) dredge up a thread that's more than 2 years old, and
    2) provide us with hardly any information about your problem, what you've done, what's worked, what's failed.
    Result: request denied.

  • When I create a calendar, in iphoto 8, I had an information pane lower left corner with date and time of the picture. Can it possibly be that the iphoto developers forgot about that in iphoto 9? This was very helpful when placing images according to date.

    Today I updated to the latest iphoto version. The update itself went smooth and nice as one is used to from Apple. But when I wanted to finish my already started calendar, I have encountered two problems. The first is that I can't view the aperture library anymore directly from iphoto. Instead I have to open the iphtoto library in aperture but then my calendar isn't there. So now I have to copy images back and forth. No problem.
    However, the old iphoto had a small information area in the lower left corner which was very nice to place images on an exact date. This seems to be gone...?? Really? How am I supposed to sort images according to date and time when I have to back to the library view every time? That's not very convenient..Or am I missing something?
    Thanks for ANY help!
    Patrick

    The first is that I can't view the aperture library anymore directly from iphoto.
    THat is exceeding strange since iPhoto '08 could not open or share an Aperture library - that ability was first introduced in iPhoto '11 - with the latest version of iPhoto and or Aperture you can open the same library with either application - http://support.apple.com/kb/HT5043
    In the current version of iPhoto the photos are sorted by date in the film strip - I've not recently done a calendar so do not remember the specifics -
    LN

  • How to make image resizable using mouse ?

    Hi,
    I want to know about that how to resize image by using mouse in Java Canvas. I created some tools like line, free hand, eraser. And want to know how to make an image resizable in canvas by using mouse. An image is jpeg, png, or gif format. I want to make image stretch and shrink by using mouse.
    Please help me..
    Thnax in advance.
    Manveer

    You make a listener to handle the mouse event that you want to capture, then program the affect you want using the event as the trigger.

  • Rotate an image according orientation sensors

    Hello Everybody !!
    I need to rotate an image according orientation sensors.
    In fact, I need when the user rotate the device to the left, the image rotate to the left (like an arrow in GPS).
    This is my XAML Code : 
    <Canvas Canvas.ZIndex="1"
    >
    <StackPanel Margin="140,385,0,0">
    <Image Source="ms-appx:///Assets/Icons/[email protected]"
    Height="50"
    x:Name="ArrowFontaine" />
    </StackPanel>
    </Canvas>
    And my C# Code : 
    private Compass _compass; // Our app's compass object
    // This event handler writes the current compass reading to
    // the textblocks on the app's main page.
    private async void ReadingChanged(object sender, CompassReadingChangedEventArgs e)
    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    CompassReading reading = e.Reading;
    var image = new Image
    Height = 50,
    Width = 50,
    RenderTransform = new RotateTransform()
    Angle = 45,
    CenterX = reading.HeadingMagneticNorth,
    CenterY = (double)reading.HeadingTrueNorth,
    Source = new BitmapImage(new Uri("ms-appx:///Assets/Icons/[email protected]"))
    ArrowFontaine=image;
    public MainPage()
    this.InitializeComponent();
    _compass = Compass.GetDefault(); // Get the default compass object
    // Assign an event handler for the compass reading-changed event
    if (_compass != null)
    // Establish the report interval for all scenarios
    uint minReportInterval = _compass.MinimumReportInterval;
    uint reportInterval = minReportInterval > 16 ? minReportInterval : 16;
    _compass.ReportInterval = reportInterval;
    _compass.ReadingChanged += new TypedEventHandler<Compass, CompassReadingChangedEventArgs>(ReadingChanged);
    I need the "ArrowFontaine" rotate according the device rotation to an angle of 45°.
    Can you tell me where the error in my code please?
    Please do not send me msdn link because most of my code from there
    Thanx

    Hi DiddyRennes,
    >>In fact, I need when the user rotate the device to the left, the image rotate to the left (like an arrow in GPS).
    I would suggest you creating RotateTransform in xaml and change the Angle from code behind:
    <Canvas>
    <StackPanel Canvas.Left="145" Canvas.Top="86">
    <Image Source="ms-appx:///Assets/Avatar.png"
    Height="100"
    x:Name="ArrowFontaine" RenderTransformOrigin="0.5,0.5" >
    <Image.RenderTransform>
    <RotateTransform x:Name="rotateTransform1" Angle="0" CenterX="0.5" CenterY="0.5"/>
    </Image.RenderTransform>
    </Image>
    <Button Content="Action" Click="Button_Click" />
    </StackPanel>
    </Canvas>
    private async void ReadingChanged(object sender, CompassReadingChangedEventArgs e)
    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    CompassReading reading = e.Reading;
    rotateTransform1.Angle = reading.HeadingMagneticNorth;//Change something here
    Screenshot:
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Capture a part of an image with the mouse ?

    Hi,
    I am really stuck with it ! I would like to capture a part of an image with the mouse. The selection can be a rectangle or an ellipse. For a rectangle a could use PixelGrabber but for an ellipse ?
    Thanks a lot !

    thanks a lot !

  • Large image popup on mouse over

    Does any one know of an extension which creates a large image
    popup on mouse over and it works with images from a database too?

    Does any one know of an extension which creates a large image
    popup on mouse over and it works with images from a database too?

  • How to create Image gallery with mouse move effect

    Hello frndz
                    Please give me any link or flash file which explain how to apply mouse move efect on images of gallery.
    i mean image sof gallery simply move with mosue direction and stop on mouse stop.its very urgent please help me  out
    Thanks and Regards
         Vineet osho

    Try this:
    http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9 b90204-7d00.html

  • How to Zoom an Image whereever the mouse moves?

    Hi,
    I have to zoom the image where ever the mouse cursor moves.
    If i am moving the mouse at the position (x,y) then that part of the image has to be zoomed.
    So that the pixels are clearly visible to user.
    Can any one suggest me what i have to do exactly.
    Thanks & Regards

    As always with such questions: have a look at the tutorial
    http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html
    -Puce

  • Re: WPF image scrolling with mouse move guestors

    hi i have one wpf application in that i have grid inside that i have button (with image and text block )
    sample code:
        <Grid Background="Black">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="350" />
                    <RowDefinition Height="350" />
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                </Grid.RowDefinitions>
                <Image  Source="/WpfApplication1;component/OpticResources/MB_Label.png" Grid.Row="0" Height="100" Width="450" Margin="80,80,0,0" HorizontalAlignment="Left"
    VerticalAlignment="Top"/>
                <Grid x:Name="HorizontalScrollBarGrid" Grid.Row="1" Height="350" >
                    <Grid.Background>
                        <ImageBrush  ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                    </Grid.Background>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition x:Name="LeftScrollRow" Width="Auto"/>
                        <ColumnDefinition x:Name="HorizontalContentRow" Width="*"/>
                        <ColumnDefinition x:Name="RightScrollRow" Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <RepeatButton x:Name="LeftButton" Grid.Column="0" Height="340" Style="{StaticResource ScrollBarButton}"
                      Width="40"  Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="LeftArrow"
                      Click="LeftButton_Click" >
                    </RepeatButton>
                    <ScrollViewer x:Name="HorizontalScroller"
                    Grid.Column="1"
                    VerticalScrollBarVisibility="Disabled"
                    HorizontalScrollBarVisibility="Hidden"
                    CanContentScroll="True"
                    SizeChanged="HorizontalScrollViewer_SizeChanged"
                    Loaded="HorizontalScrollViewer_Loaded"
                    ScrollChanged="HorizontalScrollViewer_ScrollChanged">
                        <StackPanel x:Name="HorizontalContentPanel" Orientation="Horizontal">
                            <Button x:Name="climate"  Width="287" Height="260" Style="{StaticResource TransparentStyle}"
    Click="climate_Click">
                                    <Button.Background>
                                        <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                    </Button.Background>
                                    <StackPanel>
                                        <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/climate.png" 
    />
                                        <TextBlock FontSize="35" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Climate</TextBlock>
                                    </StackPanel>
                                </Button>
                                <!--<Image  Width="20" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335">
                            </Rectangle>
                            <Button x:Name="Seat" Width="287" Height="260"  Style="{StaticResource TransparentStyle}"
    Click="Seat_Click" >
                                    <Button.Background>
                                        <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                    </Button.Background>
                                    <StackPanel>
                                        <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/seat.png" 
    />
                                        <TextBlock FontSize="35" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Seat</TextBlock>
                                    </StackPanel>
                                </Button>
                                <!--<Image  Width="10" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335"></Rectangle>
                                <Button x:Name="Remote" Width="287" Height="260" Style="{StaticResource
    TransparentStyle}">
                                    <Button.Background>
                                        <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                    </Button.Background>
                                    <StackPanel>
                                        <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/phone.png" 
    />
                                        <TextBlock FontSize="35" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Remote</TextBlock>
                                    </StackPanel>
                                </Button>
                                <!--<Image  Width="10" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335"></Rectangle>
                            <Button x:Name="Radio"  Width="287" Height="260" Style="{StaticResource TransparentStyle}">
                                    <Button.Background>
                                        <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                    </Button.Background>
                                    <StackPanel>
                                        <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/tuner.png" 
    />
                                        <TextBlock FontSize="35" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Radio</TextBlock>
                                    </StackPanel>
                                </Button>
                                <!--<Image  Width="10" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335"></Rectangle>
                            <Button x:Name="media"  Width="287" Height="260" Style="{StaticResource TransparentStyle}">
                                    <Button.Background>
                                        <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                    </Button.Background>
                                    <StackPanel>
                                        <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/media.png" 
    />
                                        <TextBlock FontSize="35" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Media</TextBlock>
                                    </StackPanel>
                                </Button>
                                <!--<Image  Width="10" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335"></Rectangle>
                            <Button x:Name="vehicle_functions"   Width="287" Height="260" Style="{StaticResource
    TransparentStyle}">
                                    <Button.Background>
                                        <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                    </Button.Background>
                                    <StackPanel>
                                        <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/vehicle_functions.png" 
    />
                                        <TextBlock FontSize="28" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Vehicle Functions</TextBlock>
                                    </StackPanel>
                                </Button>
                                <!--<Image  Width="10" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335"></Rectangle>
                            <Button x:Name="AmbienteLight"   Width="287" Height="260" Style="{StaticResource
    TransparentStyle}">
                                    <Button.Background>
                                        <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                    </Button.Background>
                                    <StackPanel>
                                        <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/vehicle_functions.png" 
    />
                                        <TextBlock FontSize="28" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Ambient Light</TextBlock>
                                    </StackPanel>
                                </Button>
                                <!--<Image  Width="10" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335"></Rectangle>
                            <Button x:Name="AmbienteLight1"   Width="287" Height="260" Style="{StaticResource
    TransparentStyle}">
                                <Button.Background>
                                    <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                </Button.Background>
                                <StackPanel>
                                    <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/vehicle_functions.png" 
    />
                                    <TextBlock FontSize="28" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Ambient Light</TextBlock>
                                </StackPanel>
                            </Button>
                            <!--<Image  Width="10" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335"></Rectangle>
                            <Button x:Name="AmbienteLight2"   Width="287" Height="260" Style="{StaticResource
    TransparentStyle}">
                                <Button.Background>
                                    <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                </Button.Background>
                                <StackPanel>
                                    <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/vehicle_functions.png" 
    />
                                    <TextBlock FontSize="28" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Ambient Light</TextBlock>
                                </StackPanel>
                            </Button>
                            <!--<Image  Width="10" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335"></Rectangle>
                            <Button x:Name="AmbienteLight3"   Width="287" Height="260">
                                <Button.Background>
                                    <ImageBrush ImageSource="/WpfApplication1;component/OpticResources/OverlayBack.png"/>
                                </Button.Background>
                                <StackPanel>
                                    <Image Stretch="UniformToFill" Source="/WpfApplication1;component/OpticResources/vehicle_functions.png" 
    />
                                    <TextBlock FontSize="28" Foreground="WhiteSmoke"
    FontStyle="Italic" FontWeight="SemiBold" FontFamily="Arial" HorizontalAlignment="Center" >Ambient Light</TextBlock>
                                </StackPanel>
                            </Button>
                            <!--<Image  Width="10" Source="/WpfApplication1;component/OpticResources/OverlayDivider.png" 
    />-->
                            <Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Silver"
    StrokeThickness="0.1" Height="335"></Rectangle>
                        </StackPanel>
                    </ScrollViewer>
                    <RepeatButton x:Name="RightButton"  Grid.Column="2" Width="40" Height="340" Click="RightButton_Click" 
    Focusable="False" Style="{StaticResource ScrollBarButton}"
                                 Microsoft_Windows_Themes:ScrollChrome.ScrollGlyph="RightArrow"   >
                    </RepeatButton>
                </Grid>
            </Grid>
        </Grid>
    I want to do the swipe functionality that should work in win8 tablet ???
    so when i swipe on second image to right it should move to right ....

    Following links should help you implement swipe functionality.
    http://egiardina.bloggingabout.net/2010/11/23/adding-swipe-functionality-to-wpf-applications/
    http://www.codeproject.com/Articles/370650/Simple-Metro-Style-Panorama-Control-for-WPF
    http://www.codeproject.com/Articles/741026/WPF-FlipView
    Gaurav Khanna | Microsoft .NET MVP | Microsoft Community Contributor

  • Bitmap Rotation According to Mouse Position?

    Hi,
    I am working on a 2d computer graphics project, and I need a good function to rotate a Bitmap 360 degree according to my mouse position.
    for example: 

    Hi,
    I am working on a 2d computer graphics project, and I need a good function to rotate a Bitmap 360 degree according to my mouse position.
    for example: 
    Hello,
    To rotate that image, we need to deal with the following tips.
    1. The image size.
    If the area for that image rotated is not big enough, it will just lose some parts of that image.
    Here is a nice code shared in this thread
    http://stackoverflow.com/questions/5199205/how-do-i-rotate-image-then-move-to-the-top-left-0-0-without-cutting-off-the-imag/5200280#5200280.
    private Bitmap RotateImage(Bitmap b, float Angle)
    // The original bitmap needs to be drawn onto a new bitmap which will probably be bigger
    // because the corners of the original will move outside the original rectangle.
    // An easy way (OK slightly 'brute force') is to calculate the new bounding box is to calculate the positions of the
    // corners after rotation and get the difference between the maximum and minimum x and y coordinates.
    float wOver2 = b.Width / 2.0f;
    float hOver2 = b.Height / 2.0f;
    float radians = -(float)(Angle / 180.0 * Math.PI);
    // Get the coordinates of the corners, taking the origin to be the centre of the bitmap.
    PointF[] corners = new PointF[]{
    new PointF(-wOver2, -hOver2),
    new PointF(+wOver2, -hOver2),
    new PointF(+wOver2, +hOver2),
    new PointF(-wOver2, +hOver2)
    for (int i = 0; i < 4; i++)
    PointF p = corners[i];
    PointF newP = new PointF((float)(p.X * Math.Cos(radians) - p.Y * Math.Sin(radians)), (float)(p.X * Math.Sin(radians) + p.Y * Math.Cos(radians)));
    corners[i] = newP;
    // Find the min and max x and y coordinates.
    float minX = corners[0].X;
    float maxX = minX;
    float minY = corners[0].Y;
    float maxY = minY;
    for (int i = 1; i < 4; i++)
    PointF p = corners[i];
    minX = Math.Min(minX, p.X);
    maxX = Math.Max(maxX, p.X);
    minY = Math.Min(minY, p.Y);
    maxY = Math.Max(maxY, p.Y);
    // Get the size of the new bitmap.
    SizeF newSize = new SizeF(maxX - minX, maxY - minY);
    // ...and create it.
    Bitmap returnBitmap = new Bitmap((int)Math.Ceiling(newSize.Width), (int)Math.Ceiling(newSize.Height));
    // Now draw the old bitmap on it.
    using (Graphics g = Graphics.FromImage(returnBitmap))
    g.TranslateTransform(newSize.Width / 2.0f, newSize.Height / 2.0f);
    g.RotateTransform(Angle);
    g.TranslateTransform(-b.Width / 2.0f, -b.Height / 2.0f);
    g.DrawImage(b, 0, 0);
    return returnBitmap;
    2. The location of that control which displays that image.
    If we use a picturebox, and set its sizemode to autosize like the following line, then if you just want to rotate that image to show, and you don't want to that affects the original image, then we need to keep its center point.
    this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
    We could add resize event handler after we set image for that picturebox.
            Point pOrign;
            Size sOrign;private void Form1_Load(object sender, EventArgs e)
    this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
    Image img = Image.FromFile(@"D:\Documents\New folder\New folder\TestImage.PNG");
    this.pictureBox1.Image = img;
    this.pictureBox1.InitialImage = img;
    pOrign = new Point(this.pictureBox1.Left , this.pictureBox1.Top );
    sOrign = new Size(this.pictureBox1.Width, this.pictureBox1.Height);
    this.pictureBox1.BorderStyle = BorderStyle.FixedSingle;
    this.pictureBox1.Resize += pictureBox1_Resize;
    private void pictureBox1_Resize(object sender, EventArgs e)
    this.pictureBox1.Left = this.pOrign.X + (this.sOrign.Width - this.pictureBox1.Width) / 2;
    this.pictureBox1.Top = this.pOrign.Y + (this.sOrign.Height - this.pictureBox1.Height) / 2;
    3. The angle between that center point and your mouse postion.
    We could get that value inside the picturebox's container's mouse_move event.
    Double angleNew ; private void pictureBoxContainer_MouseMove(object sender, MouseEventArgs e)
    angleNew = Math.Atan2(this.pOrign.Y + this.sOrign.Height / 2 - e.Y, this.pOrign.X + this.sOrign.Width/2 - e.X) * 180.0 / Math.PI;
    But when to start rotate that image, it should be your chooice, and you could decide when rotate that image with the following line.
    this.pictureBox1.Image = (Image)RotateImage(new Bitmap(this.pictureBox1.InitialImage), (float)angleNew);
    If you just want to save that change to that image, then you could save that bitmap to file directly.
    Happy new year.
    Regards.
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Bind a new shortcut to "save an image as" when mouse is hovering over a certain image

    In Opera, if on a page you see several pics, you only need to move mouse pointer to an image you wanna save and press "ctrl+alt+left click" and then a dialogue to save an image pops up.
    I already tried a few addons - none of them did what I need.
    So, I'm tired here a little bit plus... a bit lazy, yeah I could read it all:
    http://developer.mozilla.org/en/docs/XUL_Tutorial:Keyboard_Shortcuts
    http://www-archive.mozilla.org/unix/customizing.html#keys
    But maybe someone who's already prolific on this matter - help me out here? That would be greatly appreciated.

    '''finitarry''', you seem not to haven't read op post attentively, the catch here is how to easily save a certain picture on a page, in another browser you move mouse pointer to a picture and then left click mouse1 + ctrl+alt - then you're popped up to a dialog which asks you where to save the picture.
    In Firefox you have to right click (mouse2) on the picture and then choose "save as", it's not as convenient.

  • Moving image with the mouse?

    I have several Images which I paint directly on a panel. If the mouse pointer is over an image and the user holds the mouse button pressed he shall be able to move the image.
    How would you solve that? I mean there is no contains() method in a Image class so that I would be able to check if the mouse location is over a image or not (and over which in particular).
    Any ideas?

    Then it would look like this:
         void panel_mouseDragged(MouseEvent e) {
              Contianer c = this.getParent();
              if (c instanceof JViewport) {
                   JViewport jv = (JViewport) c;
                   Point p = jv.getViewPosition();
                   int newX = p.x - (e.getX() - m_XDifference);
                   int newY = p.y - (e.getY() - m_YDifference);
                   int maxX = this.getWidth() - jv.getWidth();
                   int maxY = this.getHeight() - jv.getHeight();
                   if (newX < 0)
                        newX = 0;
                   if (newX > maxX)
                        newX = maxX;
                   if (newY < 0)
                        newY = 0;
                   if (newY > maxY)
                        newY = maxY;
                   jv.setViewPosition(new Point(newX, newY));
         void panel_mousePressed(MouseEvent e) {
              setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
              m_XDifference = e.getX();
              m_YDifference = e.getY();
         void panel_mouseReleased(MouseEvent e) {
              setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         }Look at http://forum.java.sun.com/features.jsp#Formatting

Maybe you are looking for

  • Getting a "An error occurred while saving values to the app.config file." message

    The content of the title is just part of the message I get. The second line of the message is: "The file might be corrupted or contain invalid XML." I work with a lot of usercontrol libraries, and each one has 1 or 2 connection strings setup, and not

  • Unsaveddatawarning in JSFF

    Hi Experts, JDEV 11.1.1.2 I go through this link [http://www.oracle.com/technetwork/developer-tools/adf/unsaveddatawarning-100139.html] which illustrates how implement Unsaveddatawarning message..But it need to set , "<AF:document uncommittedDataWarn

  • Cisco ISE - CWA AD Authentication

    Hello, I'm using a Cisco ISE on 1.3 and have a CWA portal setup for AD Auth. When a user connects to a particular SSID (from a WLC) that is setup for mac filtering, it redirects to a CWA via the Auth Policy. the CWA is disabled, they login, the devic

  • How to run alert box when document opens

    I am using Acrobat 9 and would like an alert box come up when the document is opened. I have successfully gotten an alert box to pop up using the script below when saving using document actions, but do not know how to make it execute when the documen

  • I cannot drag or copy and paste files. 10.5.8

    Yesterday my MacBook Pro was working fine. Today I cannot drag files or cut and paste. I have rebooted  and repaired permissions. Nothing! i did trash some files late last night, but thought they were jpegs and quictimes. Any fresh help?