Most működik a fénykép
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
<Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
|
||||
<CollectionView x:Name="CheckPointCheckListRows"
|
||||
HeightRequest="640"
|
||||
ItemsSource="{Binding CheckListRows}"
|
||||
ItemTemplate="{StaticResource AnswerTemplateSelector}">
|
||||
<CollectionView.EmptyView>
|
||||
<Label Text="Nincsenek feladatok." HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
@@ -33,7 +34,22 @@
|
||||
<Label Text="I" Grid.Column="0" HorizontalTextAlignment="Center"/>
|
||||
<Label Text="N" Grid.Column="1" HorizontalTextAlignment="Center"/>
|
||||
</Grid>
|
||||
<Label Grid.Column="3" Text="Válasz" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||
<Grid Grid.Column="3" RowDefinitions="Auto,Auto">
|
||||
<local:BindableRadioButton
|
||||
Grid.Row="0"
|
||||
Content="Igen"
|
||||
Value="Igen"
|
||||
BindableGroupName="{Binding GroupName}"
|
||||
IsChecked="{Binding SelectedAnswer, Converter={StaticResource RadioButtonConverter}, ConverterParameter=Igen}"
|
||||
HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
<local:BindableRadioButton
|
||||
Grid.Row="1"
|
||||
Content="Nem"
|
||||
Value="Nem"
|
||||
BindableGroupName="{Binding GroupName}"
|
||||
IsChecked="{Binding SelectedAnswer, Converter={StaticResource RadioButtonConverter}, ConverterParameter=Nem}"
|
||||
HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Frame>
|
||||
</DataTemplate>
|
||||
@@ -41,17 +57,25 @@
|
||||
<Frame BorderColor="Gray" Padding="1" Margin="2" HasShadow="True" CornerRadius="2">
|
||||
<Grid ColumnSpacing="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="3*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Text="{Binding CheckListTemplateRowDTO.RowIndex,StringFormat='{}{0:D1}.'}" BackgroundColor="WhiteSmoke" Grid.Column="0" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />
|
||||
<Label Text="{Binding CheckListTemplateRowDTO.OperationDescription}" BackgroundColor="WhiteSmoke" Grid.Column="1" />
|
||||
<Grid Grid.Column="2" ColumnDefinitions="*">
|
||||
<Label Text="Fénykép készítése szükséges" Grid.Column="0" HorizontalTextAlignment="Center"/>
|
||||
<Grid Grid.Column="2" ColumnDefinitions="Auto,Auto" VerticalOptions="Center">
|
||||
<Image Grid.Column="0"
|
||||
WidthRequest="95"
|
||||
HeightRequest="120"
|
||||
Aspect="AspectFill"
|
||||
Margin="0,0,10,0"
|
||||
VerticalOptions="Center"
|
||||
Source="{Binding Photo, Converter={StaticResource ByteArrayToImageSourceConverter}}" />
|
||||
<Button Text="📷" Grid.Column="1"
|
||||
VerticalOptions="Center"
|
||||
Command="{Binding BindingContext.CreatePhoto, Source={x:Reference CheckPointCheckListRows}}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</Grid>
|
||||
<Label Grid.Column="3" Text="Válasz" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />
|
||||
</Grid>
|
||||
</Frame>
|
||||
</DataTemplate>
|
||||
@@ -69,7 +93,10 @@
|
||||
<Grid Grid.Column="2" ColumnDefinitions="*">
|
||||
<Label Text="Érték megadása szükséges" Grid.Column="0" HorizontalTextAlignment="Center"/>
|
||||
</Grid>
|
||||
<Label Grid.Column="3" Text="Válasz" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||
<Entry Grid.Column="3"
|
||||
Text="{Binding Answer}"
|
||||
HorizontalTextAlignment="Center"
|
||||
VerticalOptions="Center" />
|
||||
</Grid>
|
||||
</Frame>
|
||||
</DataTemplate>
|
||||
@@ -88,7 +115,22 @@
|
||||
<Label Text="I" Grid.Column="0" BackgroundColor="Yellow" TextColor="Black" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||
<Label Text="N" Grid.Column="1" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||
</Grid>
|
||||
<Label Grid.Column="3" Text="Válasz" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||
<Grid Grid.Column="3" RowDefinitions="Auto,Auto">
|
||||
<local:BindableRadioButton
|
||||
Grid.Row="0"
|
||||
Content="Igen"
|
||||
Value="Igen"
|
||||
BindableGroupName="{Binding GroupName}"
|
||||
IsChecked="{Binding SelectedAnswer, Converter={StaticResource RadioButtonConverter}, ConverterParameter=Igen}"
|
||||
HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
<local:BindableRadioButton
|
||||
Grid.Row="1"
|
||||
Content="Nem"
|
||||
Value="Nem"
|
||||
BindableGroupName="{Binding GroupName}"
|
||||
IsChecked="{Binding SelectedAnswer, Converter={StaticResource RadioButtonConverter}, ConverterParameter=Nem}"
|
||||
HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Frame>
|
||||
</DataTemplate>
|
||||
@@ -202,5 +244,6 @@
|
||||
PI_N_Template="{StaticResource PI_N_Template}"
|
||||
I_PN_Template="{StaticResource I_PN_Template}"
|
||||
V_Template="{StaticResource V_Template}"/>
|
||||
<local:ByteArrayToImageSourceConverter x:Key="ByteArrayToImageSourceConverter"/>
|
||||
</ContentPage.Resources>
|
||||
</ContentPage>
|
||||
@@ -1,6 +1,10 @@
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
using Microsoft.Maui.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Globalization;
|
||||
using DevExpress.Data.Helpers;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Pages.CheckList;
|
||||
|
||||
@@ -11,6 +15,8 @@ public partial class CheckListWorkPage : ContentPage
|
||||
private int _checkListHeaderId;
|
||||
private UserDTO _userDTO;
|
||||
|
||||
public ObservableCollection<CheckListRowDTO> CheckListRows { get; set; } = new ObservableCollection<CheckListRowDTO>();
|
||||
public ICommand CreatePhoto { get; set; }
|
||||
|
||||
public CheckListWorkPage(int checkListHeaderId, string checkPointCode)
|
||||
{
|
||||
@@ -23,14 +29,47 @@ public partial class CheckListWorkPage : ContentPage
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
BindingContext = this;
|
||||
|
||||
CreatePhoto = new Command<CheckListRowDTO>(OnTakePhoto);
|
||||
await LoadCheckPointCheckListRows();
|
||||
BindingContext = this;
|
||||
}
|
||||
private async void OnTakePhoto(CheckListRowDTO checkListRowDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (MediaPicker.IsCaptureSupported)
|
||||
{
|
||||
var photo = await MediaPicker.CapturePhotoAsync();
|
||||
if (photo != null)
|
||||
{
|
||||
using var stream = await photo.OpenReadAsync();
|
||||
using var ms = new MemoryStream();
|
||||
await stream.CopyToAsync(ms);
|
||||
byte[] photoBytes = ms.ToArray();
|
||||
checkListRowDTO.Photo = photoBytes;
|
||||
|
||||
await _checkListService.UpdateCheckListRow(checkListRowDTO);
|
||||
await LoadCheckPointCheckListRows();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("A fényképezés nem támogatott ezen az eszközön.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Hiba történt a fényképezés közben: {ex.Message}");
|
||||
}
|
||||
}
|
||||
private async Task LoadCheckPointCheckListRows()
|
||||
{
|
||||
CheckPointCheckListRows.ItemsSource = await _checkListService.GetCheckListRowsByCheckPointCode(_userDTO.Id, _checkListHeaderId, _checkPointCode);
|
||||
CheckListRows.Clear();
|
||||
var checkListRowDTOs = await _checkListService.GetCheckListRowsByCheckPointCode(_userDTO.Id, _checkListHeaderId, _checkPointCode);
|
||||
foreach (var item in checkListRowDTOs)
|
||||
{
|
||||
CheckListRows.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class BindableRadioButton : RadioButton
|
||||
@@ -52,3 +91,19 @@ public class BindableRadioButton : RadioButton
|
||||
}
|
||||
}
|
||||
}
|
||||
public class ByteArrayToImageSourceConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is byte[] bytes && bytes.Length > 0)
|
||||
{
|
||||
return ImageSource.FromStream(() => new MemoryStream(bytes));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,5 +138,23 @@ namespace WorkFlowCheck.MAUI.Services
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public async Task<CheckListRowDTO> UpdateCheckListRow(CheckListRowDTO checkListRowDTO)
|
||||
{
|
||||
var retVal = checkListRowDTO;
|
||||
try
|
||||
{
|
||||
var checkListRow = await _dbContext.CheckListRows.Where(w => w.Id == checkListRowDTO.Id).FirstOrDefaultAsync();
|
||||
if (checkListRow != null)
|
||||
{
|
||||
checkListRow.Photo = checkListRowDTO.Photo;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,6 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
|
||||
Task<List<CheckListHeaderDTO>> GetCheckLists(int userId);
|
||||
Task<List<CheckListTemplateHeaderDTO>> GetCheckListTemplates(int userId);
|
||||
Task<List<CheckListRowDTO>> GetCheckListRowsByCheckPointCode(int userId, int checkListHeaderId, string checkPointCode);
|
||||
Task<CheckListRowDTO> UpdateCheckListRow(CheckListRowDTO checkListRowDTO);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user