Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

I want a label to drag into the Cone image,follow my code

$
0
0
<Window x:Class="Alphabetical_Game.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowState="Maximized"
        Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded" Background="#FFFA0000" SizeToContent="Manual" ResizeMode="CanResizeWithGrip" ManipulationDelta="Window_ManipulationDelta" ManipulationStarting="Window_ManipulationStarting"><Viewbox><Grid><Grid.RowDefinitions><RowDefinition Height="92*" /><RowDefinition Height="219*" /></Grid.RowDefinitions><Label Content="A" AllowDrop="True" FontSize="36"  FontWeight="Bold" FontStyle="Normal" Name="A" Margin="133,74,-133,-74" TouchEnter="A_TouchEnter" Grid.RowSpan="2" DragEnter="A_DragEnter" MouseDown="A_MouseDown" TouchDown="A_TouchDown" TouchUp="A_TouchUp"></Label><Label Content="B" FontSize="36"  FontWeight="Bold" FontStyle="Normal" Name="B" Margin="133,74,-133,-74" Grid.RowSpan="2"></Label><Image Source="Home.jpg" Width="250" Margin="129,85,125,189" Grid.RowSpan="2"></Image><Grid Name="LayoutRoot" Margin="0,0,-21,0"></Grid><Button Content="Show and play" x:Name="Playit" Height="40" Width="80" Click="Playit_Click" Margin="196,168,227,11" Grid.Row="1"></Button><Button Content="Restart" x:Name="Restart" Height="40" Width="80" Margin="282,168,140,11" Grid.Row="1" Click="Restart_Click"></Button><Image Source="timer.png" Margin="-171,56,297,210" Grid.Row="1"></Image><Label Content="0" Name="lblSeconds" Grid.Row="1" Height="59" HorizontalAlignment="Left" Margin="4,126,0,0" VerticalAlignment="Top" FontSize="26" Foreground="#FFC4ED34" Width="43" /><Image Source="Cone.png" Height="150" Margin="314,299,-314,0" Grid.Row="1" MouseDown="Image_MouseDown" Name="Conerec"></Image></Grid></Viewbox></Window>
How do i drag the label a and label b into the basket image.how do i click it any ideas
 private void Playit_Click(object sender, RoutedEventArgs e)
        {

            DoubleAnimation da = new DoubleAnimation(0, 150, new Duration(TimeSpan.FromSeconds(10)));
            RotateTransform rt = new RotateTransform();
            A.RenderTransform = rt;
            B.RenderTransform = rt;
            A.RenderTransformOrigin = new Point(0.35, 0.35);
            B.RenderTransformOrigin = new Point(0.30, 0.30);
            da.RepeatBehavior = RepeatBehavior.Forever;
            rt.BeginAnimation(RotateTransform.AngleProperty, da);
            Countdown(30, TimeSpan.FromSeconds(1), cur => lblSeconds.Content = cur.ToString());
            Playit.IsEnabled = false;
        }
        void Countdown(int count, TimeSpan interval, Action<int> ts)
        {
            var dt = new System.Windows.Threading.DispatcherTimer();
            dt.Interval = interval;
            dt.Tick += (_, a) =>
            {
                if (count-- == 0)
                {
                    A.Visibility = Visibility.Hidden;
                    B.Visibility = Visibility.Hidden;
                    dt.Stop();
                }
                else
                {
                    ts(count);
                }
            };
            ts(count);
            dt.Start();
        }



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>