-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83a4294
commit 08e5ae7
Showing
10 changed files
with
679 additions
and
614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Globalization; | ||
using Avalonia.Data.Converters; | ||
|
||
namespace ChatAAC.Converters; | ||
|
||
public class NullToPlusConverter : IValueConverter | ||
{ | ||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
return value == null ? "+" : ""; | ||
} | ||
|
||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Reactive; | ||
using ReactiveUI; | ||
using ChatAAC.Models.Obf; | ||
|
||
namespace ChatAAC.ViewModels | ||
{ | ||
public class GridCellViewModel : ReactiveObject | ||
{ | ||
public int Row { get; } | ||
public int Column { get; } | ||
private Button? _button; | ||
public Button? Button | ||
{ | ||
get => _button; | ||
set => this.RaiseAndSetIfChanged(ref _button, value); | ||
} | ||
|
||
// Komenda edycji komórki – jeżeli w komórce nie ma przycisku, tworzy nowy, w przeciwnym razie edytuje istniejący | ||
public ReactiveCommand<Unit, Unit> EditCellCommand { get; } | ||
|
||
private readonly MainViewModel _parent; | ||
|
||
public GridCellViewModel(int row, int column, Button? button, MainViewModel parent) | ||
{ | ||
Row = row; | ||
Column = column; | ||
Button = button; | ||
_parent = parent; | ||
|
||
EditCellCommand = ReactiveCommand.Create(async () => | ||
{ | ||
if (Button == null) | ||
{ | ||
// Utwórz nowy przycisk z domyślnymi wartościami | ||
var newButton = new Button | ||
{ | ||
Id = Guid.NewGuid().ToString(), | ||
Label = "New", | ||
BorderColor = "#FF000000", | ||
BackgroundColor = "#FFFFFFFF", | ||
Vocalization = "", | ||
Action = "" | ||
}; | ||
Button = newButton; | ||
// Dodaj nowy przycisk do modelu | ||
_parent.ObfData?.Buttons.Add(newButton); | ||
// Zaktualizuj siatkę – przypisz do komórki nowy identyfikator | ||
_parent.UpdateGridOrderForCell(Row, Column, newButton.Id); | ||
} | ||
// Otwórz okno edycji przycisku | ||
await _parent.EditButtonAsync(Button); | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.