Skip to content

Commit

Permalink
Obf Obz file type added
Browse files Browse the repository at this point in the history
Some samples added
  • Loading branch information
mateusz-kierepka-hl committed Oct 2, 2024
1 parent fd14714 commit 3c3ba69
Show file tree
Hide file tree
Showing 38 changed files with 1,537 additions and 187 deletions.
Binary file added ChatAAC/Assets/Samples/ck12.obz
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/communikate-20.obz
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/communikate-20.obz.pdf
Binary file not shown.
64 changes: 64 additions & 0 deletions ChatAAC/Assets/Samples/images_and_sounds.obf

Large diffs are not rendered by default.

Binary file added ChatAAC/Assets/Samples/images_and_sounds.obf.pdf
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/images_and_sounds.obz
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/images_and_sounds.obz.pdf
Binary file not shown.
48 changes: 48 additions & 0 deletions ChatAAC/Assets/Samples/inline_images.obf

Large diffs are not rendered by default.

Binary file added ChatAAC/Assets/Samples/inline_images.obf.pdf
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/inline_images.obz
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/inline_images.obz.pdf
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/links.obz
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/links.obz.pdf
Binary file not shown.
124 changes: 124 additions & 0 deletions ChatAAC/Assets/Samples/lots_of_stuff.obf

Large diffs are not rendered by default.

Binary file added ChatAAC/Assets/Samples/lots_of_stuff.obf.pdf
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/lots_of_stuff.obz
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/lots_of_stuff.obz.pdf
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/path_images.obz
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/path_images.obz.pdf
Binary file not shown.
951 changes: 951 additions & 0 deletions ChatAAC/Assets/Samples/project-core.obf

Large diffs are not rendered by default.

Binary file added ChatAAC/Assets/Samples/quick-core-112.obz
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/sequoia-15.obz
Binary file not shown.
27 changes: 27 additions & 0 deletions ChatAAC/Assets/Samples/simple.obf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"format": "open-board-0.1",
"id": "simple",
"locale": "en",
"name": "Simple Board",
"description_html": "This is a very basic .obf file, it contains no images or sounds, and assumes default styling.",
"grid": {
"rows": 2,
"columns": 2,
"order": [
[1, 2],
[null, null]
]
},
"buttons": [
{
"id": 1,
"label": "happy"
},
{
"id": 2,
"label": "sad"
}
],
"images": [],
"sounds": []
}
Binary file added ChatAAC/Assets/Samples/simple.obf.pdf
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/simple.obz
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/simple.obz.pdf
Binary file not shown.
Binary file added ChatAAC/Assets/Samples/url_images.obf.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions ChatAAC/ChatAAC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
<PackageReference Include="System.Speech" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="Assets\Categories\" />
</ItemGroup>
</Project>
23 changes: 23 additions & 0 deletions ChatAAC/Models/Obf/Button.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Text.Json.Serialization;

namespace ChatAAC.Models.Obf;

// Class for Button
public class Button
{
[JsonPropertyName("id")] public string Id { get; set; } = string.Empty;

[JsonPropertyName("label")] public string Label { get; set; } = string.Empty;

[JsonPropertyName("image_id")] public string ImageId { get; set; } = string.Empty;

[JsonPropertyName("border_color")] public string BorderColor { get; set; } = string.Empty;

[JsonPropertyName("background_color")] public string BackgroundColor { get; set; } = string.Empty;

[JsonPropertyName("vocalization")] public string Vocalization { get; set; } = string.Empty;

[JsonPropertyName("load_board")] public LoadBoard LoadBoard { get; set; } = new();

[JsonPropertyName("action")] public string Action { get; set; } = string.Empty;
}
13 changes: 13 additions & 0 deletions ChatAAC/Models/Obf/Grid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace ChatAAC.Models.Obf;
// Class for Grid (for button layout)
public class Grid
{
[JsonPropertyName("rows")] public int Rows { get; set; }

[JsonPropertyName("columns")] public int Columns { get; set; }

[JsonPropertyName("order")] public List<List<string>> Order { get; set; } = new();
}
18 changes: 18 additions & 0 deletions ChatAAC/Models/Obf/Image.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Text.Json.Serialization;

namespace ChatAAC.Models.Obf;
// Class for Image
public class Image
{
[JsonPropertyName("id")] public string Id { get; set; } = string.Empty;

[JsonPropertyName("url")] public string Url { get; set; } = string.Empty;

[JsonPropertyName("data")] public string Data { get; set; } = string.Empty;

[JsonPropertyName("content_type")] public string ContentType { get; set; } = string.Empty;

[JsonPropertyName("width")] public int Width { get; set; }

[JsonPropertyName("height")] public int Height { get; set; }
}
17 changes: 17 additions & 0 deletions ChatAAC/Models/Obf/LoadBoard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Text.Json.Serialization;

namespace ChatAAC.Models.Obf;

// Class for LoadBoard (button linked to another board)
public class LoadBoard
{
[JsonPropertyName("id")] public string Id { get; set; } = string.Empty;

[JsonPropertyName("name")] public string Name { get; set; } = string.Empty;

[JsonPropertyName("data_url")] public string DataUrl { get; set; } = string.Empty;

[JsonPropertyName("url")] public string Url { get; set; } = string.Empty;

[JsonPropertyName("path")] public string Path { get; set; } = string.Empty;
}
26 changes: 26 additions & 0 deletions ChatAAC/Models/Obf/ObfFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace ChatAAC.Models.Obf;

// Main OBF File class
public class ObfFile
{
[JsonPropertyName("format")] public string Format { get; set; } = string.Empty;

[JsonPropertyName("id")] public string Id { get; set; } = string.Empty;

[JsonPropertyName("locale")] public string Locale { get; set; } = string.Empty;

[JsonPropertyName("name")] public string Name { get; set; } = string.Empty;

[JsonPropertyName("description_html")] public string DescriptionHtml { get; set; } = string.Empty;

[JsonPropertyName("grid")] public Grid Grid { get; set; } = new();

[JsonPropertyName("buttons")] public List<Button> Buttons { get; set; } = new();

[JsonPropertyName("images")] public List<Image> Images { get; set; } = new();

[JsonPropertyName("sounds")] public List<Sound> Sounds { get; set; } = new();
}
18 changes: 18 additions & 0 deletions ChatAAC/Models/Obf/ObfLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.IO;
using System.Text.Json;

namespace ChatAAC.Models.Obf;


// Class for parsing OBF files
public class ObfLoader
{
public static ObfFile? LoadObf(string filePath)
{
// Read JSON content from the file
var jsonString = File.ReadAllText(filePath);
// Deserialize the JSON into an ObfFile object
var obfFile = JsonSerializer.Deserialize<ObfFile>(jsonString);
return obfFile;
}
}
15 changes: 15 additions & 0 deletions ChatAAC/Models/Obf/Sound.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;

namespace ChatAAC.Models.Obf;

// Class for Sound
public class Sound
{
[JsonPropertyName("id")] public string Id { get; set; } = string.Empty;

[JsonPropertyName("url")] public string Url { get; set; } = string.Empty;

[JsonPropertyName("data")] public string Data { get; set; } = string.Empty;

[JsonPropertyName("content_type")] public string ContentType { get; set; } = string.Empty;
}
59 changes: 55 additions & 4 deletions ChatAAC/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.VisualTree;
using ChatAAC.Models.Obf;
using ChatAAC.Views;

namespace ChatAAC.ViewModels;
Expand Down Expand Up @@ -158,6 +159,25 @@ public bool IsFullScreen
private List<Pictogram>? _allPictograms = [];
public IEnumerable<IGrouping<string, Pictogram>> GroupedPictograms =>
Pictograms.GroupBy(p => p.Categories.FirstOrDefault() ?? "Inne");


// Nowe właściwości dla plików OBF
private ObfFile? _obfData;
public ObfFile? ObfData
{
get => _obfData;
set => this.RaiseAndSetIfChanged(ref _obfData, value);
}

// Komendy do wczytywania plików
public ReactiveCommand<Unit, Unit> LoadPictogramsCommand { get; }
public ReactiveCommand<string, Unit> LoadObfFileCommand { get; }

// Ścieżka do pliku OBF (możesz dostosować)
private readonly string _obfFilePath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"ChatAAC",
"data.obf");
public MainViewModel()
{
AiResponseHistory = [];
Expand All @@ -183,7 +203,9 @@ public MainViewModel()
{
throw new PlatformNotSupportedException("Platforma nie jest wspierana przez TTS.");
}


LoadPictogramsCommand = ReactiveCommand.CreateFromTask(LoadPictogramsAsync);
LoadObfFileCommand = ReactiveCommand.CreateFromTask<string>(LoadObfFileAsync);

PictogramClickedCommand = ReactiveCommand.CreateFromTask<Pictogram>(OnPictogramClickedAsync);
RemovePictogramCommand = ReactiveCommand.Create<Pictogram>(OnRemovePictogram);
Expand Down Expand Up @@ -221,9 +243,38 @@ public MainViewModel()
FilterPictograms();
});

LoadPictogramsAsync();

// Wczytanie początkowych danych
LoadPictogramsCommand.Execute().Subscribe();
LoadObfFileCommand.Execute(_obfFilePath).Subscribe();
}
private async Task LoadObfFileAsync(string filePath)

Check warning on line 251 in ChatAAC/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in ChatAAC/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in ChatAAC/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in ChatAAC/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in ChatAAC/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in ChatAAC/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in ChatAAC/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in ChatAAC/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 251 in ChatAAC/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
try
{
IsLoading = true;
Console.WriteLine($"Rozpoczynanie wczytywania pliku OBF: {filePath}");
ObfData = ObfLoader.LoadObf(filePath);

if (ObfData != null)
{
Console.WriteLine("Plik OBF został pomyślnie wczytany.");
// Możesz tutaj dodać dodatkową logikę przetwarzania danych OBF
}
else
{
Console.WriteLine("Plik OBF jest pusty lub niepoprawny.");
}
}
catch (Exception ex)
{
Console.WriteLine($"Błąd podczas wczytywania pliku OBF: {ex.Message}");
}
finally
{
IsLoading = false;
}
}

private void OnOpenSettings()
{
var configWindow = new ConfigWindow
Expand Down Expand Up @@ -270,7 +321,7 @@ private void OnReturnToCategories()
SelectedCategory = Categories.FirstOrDefault(c => c.Id == "core");
FilterPictograms();
}
private async void LoadPictogramsAsync()
private async Task LoadPictogramsAsync()
{
try
{
Expand Down
Loading

0 comments on commit 3c3ba69

Please sign in to comment.