Browse Source

feat: add delete item list

Otter 4 months ago
parent
commit
e27f77605f

+ 3 - 0
HelloItQuantum/Assets/ImgCreateFriend/delete.svg

@@ -0,0 +1,3 @@
+<svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M9.43246 7.50891L15.1771 1.97818C15.5749 1.59513 15.5869 0.962084 15.2039 0.564223C14.8208 0.166362 14.1878 0.154354 13.7899 0.537401L8.02681 6.08595L2.47826 0.322826C2.09521 -0.0750349 1.46216 -0.0870434 1.0643 0.296004C0.666438 0.679052 0.65443 1.3121 1.03748 1.70996L6.60378 7.49153L0.938362 13.1569C0.547838 13.5475 0.547838 14.1806 0.938362 14.5712C1.32889 14.9617 1.96205 14.9617 2.35258 14.5712L8.00943 8.9143L13.6663 14.5712C14.0568 14.9617 14.69 14.9617 15.0805 14.5712C15.471 14.1806 15.471 13.5475 15.0805 13.1569L9.43246 7.50891Z" fill="white"/>
+</svg>

+ 1 - 0
HelloItQuantum/HelloItQuantum.csproj

@@ -54,6 +54,7 @@
     <None Remove="Assets\icon_labyrinth.png" />
     <None Remove="Assets\icon_labyrinth.svg" />
     <None Remove="Assets\ImgCreateFriend\body.svg" />
+    <None Remove="Assets\ImgCreateFriend\delete.svg" />
     <None Remove="Assets\ImgCreateFriend\eye.svg" />
     <None Remove="Assets\ImgCreateFriend\foot1.svg" />
     <None Remove="Assets\ImgCreateFriend\foot2.svg" />

+ 5 - 0
HelloItQuantum/Models/FriendElement.cs

@@ -65,5 +65,10 @@ namespace HelloItQuantum.Models
 			get => isVisibleNavigateTwo;
 			set => SetProperty(ref isVisibleNavigateTwo, value);
 		}
+
+		public void Delete()
+		{
+			GameCreateFriendVM.Delete(Id);
+		}
 	}
 }

+ 11 - 0
HelloItQuantum/ViewModels/GameCreateFriendViewModel.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Drawing.Printing;
+using System.Xml.Linq;
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Controls.Shapes;
@@ -83,6 +84,16 @@ namespace HelloItQuantum.ViewModels
 			}
 		}
 
+		public void Delete(int id)
+		{
+			pChildrens.Children.RemoveAt(id);
+			ListElements.RemoveAt(id);
+			for (int i = 0; i < ListElements.Count; i++)
+			{
+				ListElements[i].Id = i;
+			}
+		}
+
 		public void UpdateDrawing(int id)
 		{
 			Color color = keyValueColor[ListElements[id].SelectedColorIndex];

+ 44 - 24
HelloItQuantum/Views/GameCreateFriendView.axaml

@@ -18,51 +18,71 @@
 			<Setter Property="CornerRadius" Value="10"/>
 			<Setter Property="HorizontalContentAlignment" Value="Center"/>
 		</Style>
+		
+		<Style Selector="ComboBox">
+			<Setter Property="Background" Value="#E6EFD8"/>
+			<Setter Property="CornerRadius" Value="10"/>
+			<Setter Property="VerticalAlignment" Value="Center"/>
+			<Setter Property="BorderBrush" Value="Transparent"/>
+		</Style>
 	</UserControl.Styles>
 
-	<ScrollViewer>	
-		<StackPanel Background="#006838">		
+	<ScrollViewer>
+		<StackPanel Background="#006838">
 			<Grid ColumnDefinitions="auto, auto" RowDefinitions="*, auto" Margin="20" HorizontalAlignment="Center">
 
-				<Grid Grid.Column="0" Grid.Row="0" ColumnDefinitions="200, 20, 140, 20, 300, 30" RowDefinitions="auto, 20, *">
+				<Grid Grid.Column="0" Grid.Row="0" ColumnDefinitions="60, 200, 20, 140, 20, 300, 30" RowDefinitions="auto, 20, *">
 
-					<Border Grid.Column="0"  Grid.Row="0" CornerRadius="10" Background="#E6EFD8">
+					<Border Grid.Column="1"  Grid.Row="0" CornerRadius="10" Background="#E6EFD8">
 						<TextBlock Text="Фигура" VerticalAlignment="Stretch" Margin="10" TextAlignment="Center"/>
 					</Border>
 
-					<Border Grid.Column="2" Grid.Row="0" CornerRadius="10" Background="#E6EFD8">
+					<Border Grid.Column="3" Grid.Row="0" CornerRadius="10" Background="#E6EFD8">
 						<TextBlock Text="Цвет" VerticalAlignment="Stretch" Margin="10" TextAlignment="Center"/>
 					</Border>
 
-					<Border Grid.Column="4" Grid.Row="0" CornerRadius="10" Background="#E6EFD8">
+					<Border Grid.Column="5" Grid.Row="0" CornerRadius="10" Background="#E6EFD8">
 						<TextBlock Text="Положение" VerticalAlignment="Stretch" Margin="10" TextAlignment="Center"/>
 					</Border>
 
-					<StackPanel Grid.ColumnSpan="5" Grid.Row="2">
-						<ListBox ItemsSource="{Binding GameCreateFriendVM.ListElements}">
-							<ListBox.ItemTemplate>
+					<StackPanel Grid.ColumnSpan="7" Grid.Row="2">
+						<ItemsControl ItemsSource="{Binding GameCreateFriendVM.ListElements}">
+							<ItemsControl.ItemTemplate>
 								<DataTemplate>
-									<StackPanel Orientation="Horizontal">
-										<ComboBox ItemsSource="{Binding CbElement}" SelectedIndex="{Binding SelectedElementIndex}"
-												  Width="180" Height="130" Margin="0 0 40 0"/>
-										<ComboBox ItemsSource="{Binding CbColor}" SelectedIndex="{Binding SelectedColorIndex}"
-												  Width="120" Height="130" Margin="0 0 40 0"/>
-										<ComboBox ItemsSource="{Binding CbNavigateOne}" SelectedIndex="{Binding SelectedNavigateOne}" IsVisible="{Binding IsVisibleNavigateOne}"
-												  Width="100" Height="80" Margin="0 0 10 0"/>
-										<ComboBox ItemsSource="{Binding CbNavigateTwo}" SelectedIndex="{Binding SelectedNavigateTwo}" IsVisible="{Binding IsVisibleNavigateTwo}"
-												  Width="100" Height="80"/>
-									</StackPanel>
+									<Grid ColumnDefinitions="40, 20, *, 30" Margin="0 10">
+										
+										<Button Grid.Column="0" Background="#F26527" Width="40" Command="{Binding Delete}"
+												VerticalAlignment="Stretch">
+											<Svg Path="/Assets/ImgCreateFriend/delete.svg" Width="20"/>
+										</Button>
+										
+										<Border Grid.Column="2" CornerRadius="10"
+												Background="#7CBE41"
+												HorizontalAlignment="Stretch"
+												Padding="10">
+											<StackPanel Orientation="Horizontal">
+												<ComboBox ItemsSource="{Binding CbElement}" SelectedIndex="{Binding SelectedElementIndex}"
+														  Width="180" Height="125" Margin="0 0 40 0"/>
+												<ComboBox ItemsSource="{Binding CbColor}" SelectedIndex="{Binding SelectedColorIndex}"
+														  Width="120" Height="125" Margin="0 0 40 0"/>			
+												<ComboBox ItemsSource="{Binding CbNavigateOne}" SelectedIndex="{Binding SelectedNavigateOne}" IsVisible="{Binding IsVisibleNavigateOne}"
+														  Width="130" Height="125" Margin="0 0 10 0"/>
+												<ComboBox ItemsSource="{Binding CbNavigateTwo}" SelectedIndex="{Binding SelectedNavigateTwo}" IsVisible="{Binding IsVisibleNavigateTwo}"
+														  Width="130" Height="125"/>											
+											</StackPanel>
+										</Border>
+									</Grid>
 								</DataTemplate>
-							</ListBox.ItemTemplate>
-						</ListBox>
+							</ItemsControl.ItemTemplate>
+						</ItemsControl>
 						<Button Content="+" Command="{Binding GameCreateFriendVM.ClickCreateElement}"
-								Background="#E6EFD8" Width="200"/>
+								Background="#E6EFD8" Margin="60 0 30 0" HorizontalAlignment="Stretch"/>
 					</StackPanel>
 
 				</Grid>
 
-				<Panel Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Width="400">
-					<Image Source="/Assets/ImgCreateFriend/img_friend.png" Width="400"/>			
+				<Panel Grid.Column="1" Grid.Row="0" VerticalAlignment="Bottom" Width="400" Margin="0 0 0 20">
+					<Image Source="/Assets/ImgCreateFriend/img_friend.png" Width="400"/>
 					<Image Source="/Assets/ImgCreateFriend/hello.png" Width="150" Margin="0 0 140 -100"
 						   IsVisible="{Binding GameCreateFriendVM.IsVisibleHello}"/>
 					<ContentControl Width="140" Height="180" HorizontalAlignment="Right" VerticalAlignment="Bottom"