mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Remove / move
This commit is contained in:
		
							parent
							
								
									60af7bb029
								
							
						
					
					
						commit
						861b8c64d2
					
				
					 2 changed files with 69 additions and 6 deletions
				
			
		|  | @ -7,6 +7,8 @@ using System.Linq; | ||||||
| using System.Runtime.Serialization.Json; | using System.Runtime.Serialization.Json; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
|  | using System.Windows.Input; | ||||||
|  | using Xamarin.Forms; | ||||||
| using Xamarin.Forms.Internals; | using Xamarin.Forms.Internals; | ||||||
| 
 | 
 | ||||||
| namespace AideDeJeu.ViewModels | namespace AideDeJeu.ViewModels | ||||||
|  | @ -25,6 +27,7 @@ namespace AideDeJeu.ViewModels | ||||||
|             "Bestiaire", |             "Bestiaire", | ||||||
|             "Sac", |             "Sac", | ||||||
|         }; |         }; | ||||||
|  | 
 | ||||||
|         private int _BookmarkCollectionIndex = 0; |         private int _BookmarkCollectionIndex = 0; | ||||||
|         public int BookmarkCollectionIndex |         public int BookmarkCollectionIndex | ||||||
|         { |         { | ||||||
|  | @ -51,6 +54,62 @@ namespace AideDeJeu.ViewModels | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |         private ICommand _RemoveItemCommand = null; | ||||||
|  |         public ICommand RemoveItemCommand | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return _RemoveItemCommand ?? (_RemoveItemCommand = new Command<Item>(ExecuteRemoveItemCommand)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private void ExecuteRemoveItemCommand(Item item) | ||||||
|  |         { | ||||||
|  |             BookmarkCollection.Remove(item); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private ICommand _MoveUpItemCommand = null; | ||||||
|  |         public ICommand MoveUpItemCommand | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return _MoveUpItemCommand ?? (_MoveUpItemCommand = new Command<Item>(ExecuteMoveUpItemCommand)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private void ExecuteMoveUpItemCommand(Item item) | ||||||
|  |         { | ||||||
|  |             var index = BookmarkCollection.IndexOf(item); | ||||||
|  |             if (index > 0) | ||||||
|  |             { | ||||||
|  |                 BookmarkCollection.RemoveAt(index); | ||||||
|  |                 BookmarkCollection.Insert(index - 1, item); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private ICommand _MoveDownItemCommand = null; | ||||||
|  |         public ICommand MoveDownItemCommand | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return _MoveDownItemCommand ?? (_MoveDownItemCommand = new Command<Item>(ExecuteMoveDownItemCommand)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private void ExecuteMoveDownItemCommand(Item item) | ||||||
|  |         { | ||||||
|  |             var index = BookmarkCollection.IndexOf(item); | ||||||
|  |             if (index < BookmarkCollection.Count - 1) | ||||||
|  |             { | ||||||
|  |                 BookmarkCollection.RemoveAt(index); | ||||||
|  |                 BookmarkCollection.Insert(index + 1, item); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|         public async Task<List<Item>> GetBookmarkCollection(string key) |         public async Task<List<Item>> GetBookmarkCollection(string key) | ||||||
|         { |         { | ||||||
|             if (key != null) |             if (key != null) | ||||||
|  |  | ||||||
|  | @ -22,17 +22,21 @@ | ||||||
| 
 | 
 | ||||||
|             <Entry Grid.Column="0" Grid.Row="0" Style="{StaticResource heading1}" HorizontalOptions="FillAndExpand" /> |             <Entry Grid.Column="0" Grid.Row="0" Style="{StaticResource heading1}" HorizontalOptions="FillAndExpand" /> | ||||||
| 
 | 
 | ||||||
|             <ListView Grid.Column="0" Grid.Row="1" x:Name="ItemsListView" ItemsSource="{Binding BookmarkCollection}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped"> |             <ListView Grid.Column="0" Grid.Row="1" x:Name="ItemsListView" SelectionMode="None" ItemsSource="{Binding BookmarkCollection}" VerticalOptions="FillAndExpand"> | ||||||
|                 <ListView.ItemTemplate> |                 <ListView.ItemTemplate> | ||||||
|                     <DataTemplate> |                     <DataTemplate> | ||||||
|                         <ViewCell> |                         <ViewCell> | ||||||
|                             <Grid Padding="10"> |                             <Grid Padding="10"> | ||||||
|                                  |                                 <Grid.RowDefinitions> | ||||||
|  |                                     <RowDefinition Height="auto" /> | ||||||
|  |                                     <RowDefinition Height="auto" /> | ||||||
|  |                                     <RowDefinition Height="auto" /> | ||||||
|  |                                 </Grid.RowDefinitions> | ||||||
|                                 <Label Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Text="{Binding Name}" LineBreakMode="WordWrap" Style="{DynamicResource heading3}" FontSize="16" /> |                                 <Label Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Text="{Binding Name}" LineBreakMode="WordWrap" Style="{DynamicResource heading3}" FontSize="16" /> | ||||||
|                                 <Label Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" Text="{Binding Link}" LineBreakMode="WordWrap" Style="{DynamicResource heading3}" FontSize="12" /> |                                 <Label Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" Text="{Binding Link}" LineBreakMode="WordWrap" Style="{DynamicResource heading3}" FontSize="12" /> | ||||||
|                                 <Image Grid.Column="0" Grid.Row="2" BackgroundColor="#FF0000" WidthRequest="20" HeightRequest="20" /> |                                 <Button Grid.Column="0" Grid.Row="2" Text="Sypprimer" Command="{Binding BindingContext.RemoveItemCommand, Source={x:Reference This}}" CommandParameter="{Binding}" /> | ||||||
|                                 <Image Grid.Column="1" Grid.Row="2" BackgroundColor="#00FF00" WidthRequest="20" HeightRequest="20" /> |                                 <Button Grid.Column="1" Grid.Row="2" Text="Monter" Command="{Binding BindingContext.MoveUpItemCommand, Source={x:Reference This}}" CommandParameter="{Binding}" /> | ||||||
|                                 <Image Grid.Column="2" Grid.Row="2" BackgroundColor="#0000FF" WidthRequest="20" HeightRequest="20" /> |                                 <Button Grid.Column="2" Grid.Row="2" Text="Descendre" Command="{Binding BindingContext.MoveDownItemCommand, Source={x:Reference This}}" CommandParameter="{Binding}" /> | ||||||
|                             </Grid> |                             </Grid> | ||||||
|                         </ViewCell> |                         </ViewCell> | ||||||
|                     </DataTemplate> |                     </DataTemplate> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez