Skip to content

Commit

Permalink
improve wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Nov 21, 2023
1 parent 88f0eef commit f58bd00
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 69 deletions.
10 changes: 3 additions & 7 deletions src/OneWare.Core/Services/WindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,9 @@ public async Task<MessageBoxStatus> ShowYesNoAsync(string title, string message,

public async Task<MessageBoxStatus> ShowYesNoCancelAsync(string title, string message, MessageBoxIcon icon, Window? owner)
{
var r = await Dispatcher.UIThread.InvokeAsync(async () =>
{
var msg = new MessageBoxWindow(title, message, MessageBoxMode.AllButtons, icon);
await ShowDialogAsync(msg, owner);
return msg.BoxStatus;
});
return r;
var msg = new MessageBoxWindow(title, message, MessageBoxMode.AllButtons, icon);
await ShowDialogAsync(msg, owner);
return msg.BoxStatus;
}

public async Task<MessageBoxStatus> ShowProceedWarningAsync(string message, Window? owner = null)
Expand Down
110 changes: 55 additions & 55 deletions src/OneWare.Core/Styles/Accents/Base.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,24 @@

<ResourceDictionary.ThemeDictionaries>

<!--Remove when Avalonia/Dock Bug is fixed-->
<ResourceDictionary x:Key="Default">
<Color x:Key="ThemeBackgroundColor">#FFF5F5F5</Color>
<Color x:Key="ThemeBorderLowColor">#FFAAAAAA</Color>
<Color x:Key="ThemeBorderMidColor">#FF888888</Color>
<Color x:Key="ThemeBorderHighColor">#FF333333</Color>
<Color x:Key="ThemeControlLowColor">#FFFFFFFF</Color>
<Color x:Key="ThemeControlMidColor">#FFF5F5F5</Color>
<Color x:Key="ThemeControlMidHighColor">#FFC2C3C9</Color>
<Color x:Key="ThemeControlHighColor">#FF686868</Color>
<Color x:Key="ThemeControlVeryHighColor">#FF5B5B5B</Color>
<Color x:Key="ThemeControlHighlightLowColor">#FFF0F0F0</Color>
<Color x:Key="ThemeControlHighlightMidColor">#FFD0D0D0</Color>
<Color x:Key="ThemeControlHighlightHighColor">#FF808080</Color>
<Color x:Key="ThemeForegroundColor">#FF000000</Color>
<Color x:Key="ThemeEditorColor">#FF000000</Color>
<Color x:Key="ThemeBackgroundColor">#FF303030</Color>
<Color x:Key="ThemeBorderLowColor">#FF505050</Color>
<Color x:Key="ThemeBorderMidColor">#FF808080</Color>
<Color x:Key="ThemeBorderHighColor">#FFA0A0A0</Color>
<Color x:Key="ThemeControlLowColor">#FF1e1e1e</Color>
<Color x:Key="ThemeControlMidColor">#FF505050</Color>
<Color x:Key="ThemeControlMidHighColor">#FF686868</Color>
<Color x:Key="ThemeControlHighColor">#FF808080</Color>
<Color x:Key="ThemeControlVeryHighColor">#FFEFEBEF</Color>
<Color x:Key="ThemeControlHighlightLowColor">#88A8A8A8</Color>
<Color x:Key="ThemeControlHighlightMidColor">#884c4c4c</Color>
<Color x:Key="ThemeControlHighlightHighColor">#88505050</Color>
<Color x:Key="ThemeForegroundColor">#FFd6d2d2</Color>
<Color x:Key="ThemeEditorColor">#FFDEDEDE</Color>

<SolidColorBrush x:Key="ThemeBackgroundBrush" Color="{StaticResource ThemeBackgroundColor}" />
<SolidColorBrush x:Key="ThemeBackgroundBrushOp" Color="{StaticResource ThemeBackgroundColor}" Opacity="0.8" />
<SolidColorBrush x:Key="ThemeBackgroundBrushOp" Color="{StaticResource ThemeBackgroundColor}" Opacity="0.9" />
<SolidColorBrush x:Key="ThemeBorderLowBrush" Color="{StaticResource ThemeBorderLowColor}" />
<SolidColorBrush x:Key="ThemeBorderMidBrush" Color="{StaticResource ThemeBorderMidColor}" />
<SolidColorBrush x:Key="ThemeBorderHighBrush" Color="{StaticResource ThemeBorderHighColor}" />
Expand All @@ -111,34 +110,34 @@
<SolidColorBrush x:Key="ThemeControlHighlightHighBrush"
Color="{StaticResource ThemeControlHighlightHighColor}" />
<SolidColorBrush x:Key="ThemeForegroundBrush" Color="{StaticResource ThemeForegroundColor}" />
<SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource ThemeAccentColor}" Opacity="0.7" />
<SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource ThemeAccentColor}" />
<SolidColorBrush x:Key="ThemeEditorBrush" Color="{StaticResource ThemeEditorColor}" />

<SolidColorBrush x:Key="IconColor" Opacity="1" Color="#424040" />
<SolidColorBrush x:Key="IconColor" Opacity="1" Color="#FFFFFF" />
<SolidColorBrush x:Key="IconContrastColor" Opacity="1" Color="#424040" />
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="avares://OneWare.Core/Styles/Icons.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

<ResourceDictionary x:Key="Light">
<Color x:Key="ThemeBackgroundColor">#FFF5F5F5</Color>
<Color x:Key="ThemeBorderLowColor">#FFAAAAAA</Color>
<Color x:Key="ThemeBorderMidColor">#FF888888</Color>
<Color x:Key="ThemeBorderHighColor">#FF333333</Color>
<Color x:Key="ThemeControlLowColor">#FFFFFFFF</Color>
<Color x:Key="ThemeControlMidColor">#FFF5F5F5</Color>
<Color x:Key="ThemeControlMidHighColor">#FFC2C3C9</Color>
<Color x:Key="ThemeControlHighColor">#FF686868</Color>
<Color x:Key="ThemeControlVeryHighColor">#FF5B5B5B</Color>
<Color x:Key="ThemeControlHighlightLowColor">#FFF0F0F0</Color>
<Color x:Key="ThemeControlHighlightMidColor">#FFD0D0D0</Color>
<Color x:Key="ThemeControlHighlightHighColor">#FF808080</Color>
<Color x:Key="ThemeForegroundColor">#FF000000</Color>
<Color x:Key="ThemeEditorColor">#FF000000</Color>
<ResourceDictionary x:Key="Dark">
<Color x:Key="ThemeBackgroundColor">#FF303030</Color>
<Color x:Key="ThemeBorderLowColor">#FF505050</Color>
<Color x:Key="ThemeBorderMidColor">#FF808080</Color>
<Color x:Key="ThemeBorderHighColor">#FFA0A0A0</Color>
<Color x:Key="ThemeControlLowColor">#FF1e1e1e</Color>
<Color x:Key="ThemeControlMidColor">#FF505050</Color>
<Color x:Key="ThemeControlMidHighColor">#FF686868</Color>
<Color x:Key="ThemeControlHighColor">#FF808080</Color>
<Color x:Key="ThemeControlVeryHighColor">#FFEFEBEF</Color>
<Color x:Key="ThemeControlHighlightLowColor">#88A8A8A8</Color>
<Color x:Key="ThemeControlHighlightMidColor">#884c4c4c</Color>
<Color x:Key="ThemeControlHighlightHighColor">#88505050</Color>
<Color x:Key="ThemeForegroundColor">#FFd6d2d2</Color>
<Color x:Key="ThemeEditorColor">#FFDEDEDE</Color>

<SolidColorBrush x:Key="ThemeBackgroundBrush" Color="{StaticResource ThemeBackgroundColor}" />
<SolidColorBrush x:Key="ThemeBackgroundBrushOp" Color="{StaticResource ThemeBackgroundColor}" Opacity="0.8" />
<SolidColorBrush x:Key="ThemeBackgroundBrushOp" Color="{StaticResource ThemeBackgroundColor}" Opacity="0.9" />
<SolidColorBrush x:Key="ThemeBorderLowBrush" Color="{StaticResource ThemeBorderLowColor}" />
<SolidColorBrush x:Key="ThemeBorderMidBrush" Color="{StaticResource ThemeBorderMidColor}" />
<SolidColorBrush x:Key="ThemeBorderHighBrush" Color="{StaticResource ThemeBorderHighColor}" />
Expand All @@ -154,34 +153,34 @@
<SolidColorBrush x:Key="ThemeControlHighlightHighBrush"
Color="{StaticResource ThemeControlHighlightHighColor}" />
<SolidColorBrush x:Key="ThemeForegroundBrush" Color="{StaticResource ThemeForegroundColor}" />
<SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource ThemeAccentColor}" Opacity="0.7" />
<SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource ThemeAccentColor}" />
<SolidColorBrush x:Key="ThemeEditorBrush" Color="{StaticResource ThemeEditorColor}" />

<SolidColorBrush x:Key="IconColor" Opacity="1" Color="#424040" />
<SolidColorBrush x:Key="IconColor" Opacity="1" Color="#FFFFFF" />
<SolidColorBrush x:Key="IconContrastColor" Opacity="1" Color="#424040" />
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="avares://OneWare.Core/Styles/Icons.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

<ResourceDictionary x:Key="Dark">
<Color x:Key="ThemeBackgroundColor">#FF303030</Color>
<Color x:Key="ThemeBorderLowColor">#FF505050</Color>
<Color x:Key="ThemeBorderMidColor">#FF808080</Color>
<Color x:Key="ThemeBorderHighColor">#FFA0A0A0</Color>
<Color x:Key="ThemeControlLowColor">#FF1e1e1e</Color>
<Color x:Key="ThemeControlMidColor">#FF505050</Color>
<Color x:Key="ThemeControlMidHighColor">#FF686868</Color>
<Color x:Key="ThemeControlHighColor">#FF808080</Color>
<Color x:Key="ThemeControlVeryHighColor">#FFEFEBEF</Color>
<Color x:Key="ThemeControlHighlightLowColor">#88A8A8A8</Color>
<Color x:Key="ThemeControlHighlightMidColor">#884c4c4c</Color>
<Color x:Key="ThemeControlHighlightHighColor">#88505050</Color>
<Color x:Key="ThemeForegroundColor">#FFd6d2d2</Color>
<Color x:Key="ThemeEditorColor">#FFDEDEDE</Color>
<ResourceDictionary x:Key="Light">
<Color x:Key="ThemeBackgroundColor">#FFF5F5F5</Color>
<Color x:Key="ThemeBorderLowColor">#FFAAAAAA</Color>
<Color x:Key="ThemeBorderMidColor">#FF888888</Color>
<Color x:Key="ThemeBorderHighColor">#FF333333</Color>
<Color x:Key="ThemeControlLowColor">#FFFFFFFF</Color>
<Color x:Key="ThemeControlMidColor">#FFF5F5F5</Color>
<Color x:Key="ThemeControlMidHighColor">#FFC2C3C9</Color>
<Color x:Key="ThemeControlHighColor">#FF686868</Color>
<Color x:Key="ThemeControlVeryHighColor">#FF5B5B5B</Color>
<Color x:Key="ThemeControlHighlightLowColor">#FFF0F0F0</Color>
<Color x:Key="ThemeControlHighlightMidColor">#FFD0D0D0</Color>
<Color x:Key="ThemeControlHighlightHighColor">#FF808080</Color>
<Color x:Key="ThemeForegroundColor">#FF000000</Color>
<Color x:Key="ThemeEditorColor">#FF000000</Color>

<SolidColorBrush x:Key="ThemeBackgroundBrush" Color="{StaticResource ThemeBackgroundColor}" />
<SolidColorBrush x:Key="ThemeBackgroundBrushOp" Color="{StaticResource ThemeBackgroundColor}" Opacity="0.9" />
<SolidColorBrush x:Key="ThemeBackgroundBrushOp" Color="{StaticResource ThemeBackgroundColor}" Opacity="0.8" />
<SolidColorBrush x:Key="ThemeBorderLowBrush" Color="{StaticResource ThemeBorderLowColor}" />
<SolidColorBrush x:Key="ThemeBorderMidBrush" Color="{StaticResource ThemeBorderMidColor}" />
<SolidColorBrush x:Key="ThemeBorderHighBrush" Color="{StaticResource ThemeBorderHighColor}" />
Expand All @@ -197,15 +196,16 @@
<SolidColorBrush x:Key="ThemeControlHighlightHighBrush"
Color="{StaticResource ThemeControlHighlightHighColor}" />
<SolidColorBrush x:Key="ThemeForegroundBrush" Color="{StaticResource ThemeForegroundColor}" />
<SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource ThemeAccentColor}" />
<SolidColorBrush x:Key="HighlightBrush" Color="{DynamicResource ThemeAccentColor}" Opacity="0.7" />
<SolidColorBrush x:Key="ThemeEditorBrush" Color="{StaticResource ThemeEditorColor}" />

<SolidColorBrush x:Key="IconColor" Opacity="1" Color="#FFFFFF" />
<SolidColorBrush x:Key="IconColor" Opacity="1" Color="#424040" />
<SolidColorBrush x:Key="IconContrastColor" Opacity="1" Color="#424040" />
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="avares://OneWare.Core/Styles/Icons.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

</ResourceDictionary.ThemeDictionaries>

</ResourceDictionary>
4 changes: 3 additions & 1 deletion src/OneWare.Core/Views/Windows/MainView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Avalonia.Interactivity;
using DynamicData;
using DynamicData.Binding;
using OneWare.Core.Extensions;
using OneWare.Core.Models;
using OneWare.Shared.Controls;
using OneWare.Shared.ViewModels;
Expand All @@ -25,7 +26,8 @@ public async Task ShowVirtualDialogAsync(FlexibleWindow window)

VirtualDialogModels.Add(dialog);

await Observable.FromEventPattern(h => window.Closed += h, h => window.Closed -= h).Take(1).GetAwaiter();
//Use Task.Run because of WASM Compatibility
await Task.Run(async () => await Observable.FromEventPattern(h => window.Closed += h, h => window.Closed -= h).Take(1).GetAwaiter()) ;

VirtualDialogModels.Remove(dialog);
}
Expand Down
2 changes: 1 addition & 1 deletion src/OneWare.Shared/ViewModels/ExtendedDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public virtual async Task<bool> TryCloseAsync()

var result = await _windowService.ShowYesNoCancelAsync("Warning", CloseWarningMessage, MessageBoxIcon.Warning,
_dockService.GetWindowOwner(this));

if (result == MessageBoxStatus.Yes)
{
if (await SaveAsync()) return true;
Expand Down
7 changes: 4 additions & 3 deletions src/OneWare.Vcd.Parser/VcdParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ await Task.Run(async () =>
await using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.ReadWrite);
stream.Seek(vcdFile.DefinitionParseEndPosition+1, SeekOrigin.Begin);
var reader = new StreamReader(stream);

await ReadSignals(reader, vcdFile.Definition.SignalRegister, vcdFile.Definition.ChangeTimes,
new Progress<int>(x => progress.Report((0, x))),
cancellationToken);
if(!cancellationToken.IsCancellationRequested) await Task.Delay(1, cancellationToken);
reader.Dispose();
});

}, cancellationToken);
return;
}

Expand Down Expand Up @@ -252,7 +252,8 @@ private static async Task ReadSignals(StreamReader reader, IReadOnlyDictionary<c
if (reader.EndOfStream)
{
//Wait for new input from simulator
await Task.Delay(50);
if(RuntimeInformation.OSArchitecture is not Architecture.Wasm)
await Task.Delay(50);
}

if (progress != null)
Expand Down
5 changes: 3 additions & 2 deletions src/OneWare.Vcd.Viewer/ViewModels/VcdViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
using Avalonia.Threading;
using DynamicData.Binding;
using OneWare.Shared.Models;
Expand Down Expand Up @@ -169,15 +170,15 @@ private async Task<bool> LoadAsync()
ReportProgress(progressAverage, _isLiveExecution);
return true;
}, TimeSpan.FromMilliseconds(100), DispatcherPriority.MaxValue);

await VcdParser.ReadSignalsAsync(FullPath, _vcdFile, progress, _cancellationTokenSource.Token, useThreads);

if(_vcdFile != null)
foreach (var (_, s) in _vcdFile.Definition.SignalRegister)
{
s.Invalidate();
}

WaveFormViewer.LoadingMarkerOffset = long.MaxValue;
Title = CurrentFile is ExternalFile ? $"[{CurrentFile.Header}]" : CurrentFile!.Header;
}
Expand Down

0 comments on commit f58bd00

Please sign in to comment.