Results 1 to 6 of 6

Thread: HELP: Rotate Line constant WPF

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2016
    Posts
    15

    Exclamation HELP: Rotate Line constant WPF

    Hello,
    I do not fail to rotate that line consistently,
    ie not jumping out six in 6 degrees tick,
    I need to rotate fluently,
    Angle="{Binding SecAngle}" its update to second.
    This is for Analog Clock.
    I'm a beginner
    Code:
        <Grid>
            <Line Stroke="Blue" StrokeThickness="10" VerticalAlignment="Center" HorizontalAlignment="Center" X1="5" X2="5" Y1="0" Y2="-175" RenderTransformOrigin="0.5,0.5">
                <Line.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform/>
                        <SkewTransform/>
                        <RotateTransform Angle="{Binding SecAngle}"/>
                    </TransformGroup>
                </Line.RenderTransform>
            </Line>
       </Grid>
    I do not want to use this From="0" To="360" Duration="0:1:0" I want to be in real time
    Last edited by VBEdw; Jun 7th, 2016 at 06:11 AM.

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: HELP: Rotate Line constant WPF

    Perhaps the rotation should be done in backing code, rather than tied through xaml.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2016
    Posts
    15

    Re: HELP: Rotate Line constant WPF

    Ok, but how can you do?

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: HELP: Rotate Line constant WPF

    Perhaps I misunderstood the question.
    Rereading it I thing you are saying that the hand does move in one second increments (i.e. six degrees at a time).
    But you want it to move smoothly, in one degree increments, rather than six degree increments, but still in sync with real time of day.

    How are you setting secAngle?
    Are you setting it like,
    secAngle = Now.Second * 6
    periodically in a timer?

    Perhaps set it to
    secAngle = (Now.Second * 6) + (Now.Millisecond * 0.006)

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2016
    Posts
    15

    Re: HELP: Rotate Line constant WPF

    Hi Passel,
    time interval is TimeSpan.FromMilliseconds(1)
    and SecAngle = ((DateTime.Now.Second * 1000) + DateTime.Now.Millisecond) * (360 / 60000)
    this work, but is not fluently .
    I need to move like this: https://youtu.be/ttDj1AvyhHQ

    Thank you in advance Passel .

  6. #6
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: HELP: Rotate Line constant WPF

    I haven't really done any WPF, just looked at it a bit, so don't know all the mechanics behind how it updates the window in the various drawing type scenarios.
    For instance, at what rate do you update SecAngle? Is it faster than 6 times a second, perhaps 18 times a second would be a good choice.
    But even if you update it 18 times a second, since the connection to the value is Binding done in XAML, what does that mean for the window update. Perhaps the framework is designed to update the GUI (check all the binding values) at 4hz, and do any drawing necessary, so it doesn't matter how quickly you change the value, the display will only update at a fixed rate by default.

    I'm not saying that is the case since I'm really not familiar with the underpinnings of WPF at all, and perhaps there is a "refresh" type method that can force the display to redraw more often, but since I don't know WPF, I guess I'm going to have to bow out.
    I don't have the time to try to start learning WPF anytime soon.

    Sitten Spynne has worked with WPF quite a bit, and would definitely be a better sounding board than I am, but he has been moving away from WPF into other areas, so may be ignoring this thread as it is outside of a subject he currently wants to get involved in, or perhaps has just missed it.
    Using the built in animation would of course be the smoothest since it is designed for that, and should be synchronized with the vertical sync, and be stable, but getting the animation synchronized with an external input is probably problematic. It would seem that there are approaches where you could use the animation feature, but manipulate another value and tie one animation you see with perhaps the builtin animation you don't see, but since I don't know WPF, I can't even begin to test any theories.

    Good luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width