关于动态按钮的问题
想在win窗体上实现一个效果,大概是在一个圆盘(或者是圆形的图片?)上安置些按钮,鼠标指在一定区域按钮可以随圆盘
转动,各位高手指点下哈,不知道从哪里入手,还是需要借助其他什么工具实现呢?
[解决办法]
这个很复杂 如果用winform 只能使用api
幸好我们现在与wpf了
<Window x:Class="CaseAnalysis_WPF_.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Window.Resources> <Style TargetType="FrameworkElement" x:Key="CircleGrid"> <Setter Property="RenderTransform"> <Setter.Value> <RotateTransform /> </Setter.Value> </Setter> <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/> </Style> <EventTrigger x:Key="CircleButtons" RoutedEvent="MouseEnter"> <BeginStoryboard> <Storyboard Name="Circle"> <DoubleAnimation From="0" To="3600" Duration="0:0:30" Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Window.Resources> <Grid Style="{StaticResource CircleGrid}"> <Grid.Triggers> <StaticResource ResourceKey="CircleButtons"/> </Grid.Triggers> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="104,47,0,0" Name="button1" VerticalAlignment="Top" Width="75" /> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="33,119,0,0" Name="button2" VerticalAlignment="Top" Width="75" /> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="180,119,0,0" Name="button3" VerticalAlignment="Top" Width="75" /> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="104,200,0,0" Name="button4" VerticalAlignment="Top" Width="75" /> </Grid></Window>
[解决办法]