89 messaggi dal 04 settembre 2010
Buongiorno,
sto realizzando un progetto per monitorare l'andamento delle gare di tiro a segno degli atleti di un tiro a segno.
Premetto che WPF e nuovo per me per quanto riguarda la parte grafica, sono riuscito a creare dei cerchi dentro un controllo image posto il codice xaml per farvi vedere la configurazione
 <Grid x:Name="grid">
        <Canvas x:Name="Canvas1" Height="214" VerticalAlignment="Top" HorizontalAlignment="Left" Width="197">
            <!--<Ellipse x:Name="ellipse" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="300" Stroke="Black" VerticalAlignment="Top" Width="300" MouseDown="ellipse_MouseDown" MouseMove="ellipse_MouseMove" MouseUp="ellipse_MouseUp" Canvas.Top="53" Canvas.Left="10"/>-->
            <Image x:Name="image1" Width="197" Source="Images\Bersaglio.jpg" Height="214" Canvas.Top="28">
                <Image.OpacityMask>
                    <ImageBrush ImageSource="Images/Bersaglio.jpg"/>
                </Image.OpacityMask>
            </Image>
            <Button x:Name="btnDelete" Content="Cancella" HorizontalAlignment="Left" VerticalAlignment="Top" Width="98" Canvas.Left="674" Canvas.Top="163"/>
            <Label Content="Asse X" Canvas.Left="674" Canvas.Top="28" Width="47"/>
            <Label Content="Asse Y" Canvas.Left="674" Canvas.Top="69" Width="47" RenderTransformOrigin="0.46,-0.312"/>
            <TextBox x:Name="txtX" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="362,4" VerticalAlignment="Top" Width="46" UndoLimit="163" Canvas.Left="726" Canvas.Top="73"/>
            <TextBox x:Name="txtY" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="320,8" VerticalAlignment="Top" Width="46" Canvas.Left="726" Canvas.Top="31"/>
            <TextBox x:Name="txtPunto" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="46" UndoLimit="163" Text="10" Canvas.Left="726" Canvas.Top="121"/>
            <Image x:Name="image2" Source="Images/Bersaglio.jpg" HorizontalAlignment="Left" Width="197" Height="214" VerticalAlignment="Top" Canvas.Top="265">
                <Image.OpacityMask>
                    <ImageBrush ImageSource="Images/Bersaglio.jpg"/>
                </Image.OpacityMask>
            </Image>
            <Image x:Name="image3" Source="Images/Bersaglio.jpg" HorizontalAlignment="Left" Width="197" Height="214" VerticalAlignment="Top" Canvas.Top="494">
                <Image.OpacityMask>
                    <ImageBrush ImageSource="Images/Bersaglio.jpg"/>
                </Image.OpacityMask>
            </Image>
            <Label x:Name="lblPserie" Content="1° Serie" Margin="10,10,0,0" FontSize="20" FontWeight="Bold" Foreground="#FF1F06EE" HorizontalAlignment="Left" Width="172" Height="39" VerticalAlignment="Top"/>
            <Label Content="2° Serie" Margin="10,231,0,0" FontSize="20" FontWeight="Bold" Foreground="#FF1F06EE" HorizontalAlignment="Left" Width="172" Height="41" VerticalAlignment="Top"/>
            <Label Content="3° Serie" Margin="10,453,0,0" FontSize="20" FontWeight="Bold" Foreground="#FF1F06EE" HorizontalAlignment="Left" Width="172" Height="41" VerticalAlignment="Top"/>
            <Label Content="4° Serie" FontSize="20" FontWeight="Bold" Foreground="#FF1F06EE" HorizontalAlignment="Left" Width="172" Height="39" VerticalAlignment="Top" Canvas.Left="232" Canvas.Top="1"/>
            <Label Content="5° Serie" Margin="221,233,0,0" FontSize="20" FontWeight="Bold" Foreground="#FF1F06EE" HorizontalAlignment="Left" Width="172" Height="39" VerticalAlignment="Top"/>
            <Label Content="6° Serie" Margin="221,455,0,0" FontSize="20" FontWeight="Bold" Foreground="#FF1F06EE" HorizontalAlignment="Left" Width="172" Height="39" VerticalAlignment="Top"/>
            <Image x:Name="image4" Source="Images/Bersaglio.jpg" HorizontalAlignment="Left" Width="197" Height="214" VerticalAlignment="Top" Canvas.Left="221" Canvas.Top="40">
                <Image.OpacityMask>
                    <ImageBrush ImageSource="Images/Bersaglio.jpg"/>
                </Image.OpacityMask>
            </Image>
            <Image x:Name="image5" Source="Images/Bersaglio.jpg" Margin="221,263,0,0" HorizontalAlignment="Left" Width="197" Height="214" VerticalAlignment="Top">
                <Image.OpacityMask>
                    <ImageBrush ImageSource="Images/Bersaglio.jpg"/>
                </Image.OpacityMask>
            </Image>
            <Image x:Name="image6" Source="Images/Bersaglio.jpg" Margin="221,494,0,-8.8" HorizontalAlignment="Left" Width="197" Height="214" VerticalAlignment="Top">
                <Image.OpacityMask>
                    <ImageBrush ImageSource="Images/Bersaglio.jpg"/>
                </Image.OpacityMask>
            </Image>
        </Canvas>
        <Button Content="Button" HorizontalAlignment="Left" Margin="512,128,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
        <Button Content="Button" HorizontalAlignment="Left" Margin="541,243,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
        <Label Content="Punto" Margin="674,121,97.8,552.2"/>
    </Grid>


Posto il codice per la creazione dei cerchi
 Private Sub Window1_MouseDoubleClick(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseDoubleClick
        txtX.Text = Mouse.GetPosition(Canvas1).X
        txtY.Text = Mouse.GetPosition(Canvas1).Y
        e1 = New Ellipse
        e1.Height = 16
        e1.Width = 16
        'e1.Stroke = Brushes.Red
        If txtPunto.Text = "10" Then
            'e1.Stroke = Brushes.Red
            e1.Fill = Brushes.Red
        ElseIf txtPunto.Text = "9" Then
            e1.Fill = Brushes.Yellow
            'e1.Stroke = Brushes.Yellow
        ElseIf txtPunto.Text = "8" Then
            e1.Fill = Brushes.Green
            'e1.Stroke = Brushes.Green
        ElseIf txtPunto.Text = "7" Then
            e1.Fill = Brushes.GreenYellow
            'e1.Stroke = Brushes.GreenYellow
        End If
        e1.StrokeThickness = 5
        Canvas.SetLeft(e1, Mouse.GetPosition(Canvas1).X)
        Canvas.SetTop(e1, Mouse.GetPosition(Canvas1).Y)
        'e1.MouseDown = (e1.MouseDown + ellipse_MouseDown())
        Canvas1.Children.Add(e1)
    End Sub


Chiedo un aiuto per quanto riguarda lo spostamento dei cerchi all'interno del controllo image registrando la relativa posizione, ho trovato molti esempi su internet ma nessuno funziona per la mia applicazione.
Chiedo un piccolo aiuto grazie

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.