- leonid_golovko
- Posts: 13
- Joined:
mouse_args.position problem in view model.
I have a problem. I can't get the position that I should be able to get.(mouse_args.position.x). How to fix it? It don't seem to change at all.
Code: Select all
<Button x:Name="LeftOneIncisionPoint" Width="35" Height="35" Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding IncisionVisibility, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource TransparentButtonStyle}">
<Grid>
<Image Source="{StaticResource CenterCircleButtonOff}" Stretch="Uniform" Visibility="{Binding IncisionCenterOffMouseVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<Image Source="{StaticResource CenterCircleButtonOn}" Stretch="Uniform" Visibility="{Binding IncisionCenterOnMouseVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<Image Source="{StaticResource CenterRotator}" Stretch="Uniform" Visibility="{Binding IncisionCenterOnMousePressVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
</Grid>
<Button.RenderTransform>
<TranslateTransform X="{Binding CenterIncisionPointX}" Y="{Binding CenterIncisionPointY}"/>
</Button.RenderTransform>
<b:Interaction.Triggers>
<b:EventTrigger EventName="MouseEnter">
<b:InvokeCommandAction Command="{Binding HandleCenterButtomEnterCommand}" PassEventArgsToCommand="True"/>
</b:EventTrigger>
<b:EventTrigger EventName="MouseLeave">
<b:InvokeCommandAction Command="{Binding HandleCenterButtomLeaveCommand}" PassEventArgsToCommand="True"/>
</b:EventTrigger>
<b:EventTrigger EventName="PreviewMouseLeftButtonDown">
<b:InvokeCommandAction Command="{Binding HandleCenterButtomDownCommand}" PassEventArgsToCommand="True" CommandParameter="{Binding RelativeSource={RelativeSource Self}}"/>
</b:EventTrigger>
<b:EventTrigger EventName="PreviewMouseLeftButtonUp">
<b:InvokeCommandAction Command="{Binding HandleCenterButtomUpCommand}" PassEventArgsToCommand="True" CommandParameter="{Binding RelativeSource={RelativeSource Self}}"/>
</b:EventTrigger>
<b:EventTrigger EventName="PreviewMouseMove">
<b:InvokeCommandAction Command="{Binding HandleCenterButtomMoveCommand}" PassEventArgsToCommand="True" CommandParameter="{Binding RelativeSource={RelativeSource Self}}"/>
</b:EventTrigger>
</b:Interaction.Triggers>
</Button>
Code: Select all
void IncisionViewModel::HandleMouseMoveSideButtom(Noesis::BaseComponent* param)
{
const Noesis::EventArgs *event_args = Noesis::Boxing::Unbox<const Noesis::EventArgs *>(param);
// Cast the unboxed event arguments to the relevant event argument type
const Noesis::MouseEventArgs &mouse_args = *(const Noesis::MouseEventArgs *) (event_args);
if (is_dragging) {
Noesis::Point incision_ellipse_center_point = GetCenterEllipseIncisionPoint();
float angle = AngleOfPoint(Noesis::Point(mouse_args.position.x - incision_ellipse_center_point.x, mouse_args.position.y - incision_ellipse_center_point.y));
float incision_angle = GetIncisionAngle();
std::cout<< "Incision Angle is " << angle << std::endl;
if(std::abs(incision_angle - angle) > 1) {
SetArcAngle(std::abs(incision_angle - angle) * 2);
SetPointsOnScreen(incision_angle);
}
arc_length_mm = CalculateTotalLengthWithAngles(GetIncisionAngle() - GetArcAngle() / (float)2, GetIncisionAngle() + GetArcAngle() / (float)2);
}
}
-
sfernandez
Site Admin
- Posts: 3112
- Joined:
Re: mouse_args.position problem in view model.
The position received in the mouse event args is in screen space. You can use Visual::PointFromScreen() funtion to transform it to a specific element in the UI.
Who is online
Users browsing this forum: No registered users and 1 guest