Skip to content

Commit

Permalink
refactor: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
furesoft committed Oct 12, 2024
1 parent a6f6ffc commit a0956ab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
25 changes: 10 additions & 15 deletions src/MimaSim/MimaSim/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,17 @@ public override void OnFrameworkInitializationCompleted()

Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly());

if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
switch (ApplicationLifetime)
{
desktop.MainWindow = new MainWindow
{
//DataContext = new MainViewModel()
};
Locator.CurrentMutable.Register(() => desktop.MainWindow.StorageProvider);

}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView
{
//DataContext = new MainViewModel()
};
Locator.CurrentMutable.Register(() => TopLevel.GetTopLevel(singleViewPlatform.MainView)!.StorageProvider);
case IClassicDesktopStyleApplicationLifetime desktop:
desktop.MainWindow = new MainWindow();
Locator.CurrentMutable.Register(() => desktop.MainWindow.StorageProvider);
break;

case ISingleViewApplicationLifetime singleViewPlatform:
singleViewPlatform.MainView = new MainView();
Locator.CurrentMutable.Register(() => TopLevel.GetTopLevel(singleViewPlatform.MainView)!.StorageProvider);
break;
}

base.OnFrameworkInitializationCompleted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
ShowLineNumbers="True" SyntaxHighlighting="Assembler">
<Interaction.Behaviors>
<behaviors:DocumentTextBindingBehavior Text="{Binding Source, Mode=TwoWay}"/>

</Interaction.Behaviors>
</avaloniaEdit:TextEditor>
</StackPanel>
Expand Down
5 changes: 3 additions & 2 deletions src/MimaSim/MimaSim/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ public MainViewModel()

OpenMemoryPopupCommand = DialogService.CreateOpenCommand(new MemoryPopupControl(), new MemoryPopupViewModel());

var storage = Locator.Current.GetService<IStorageProvider>();

LoadCommand = ReactiveCommand.Create(async () =>
{
var storage = Locator.Current.GetService<IStorageProvider>();
var filenames = await storage!.OpenFilePickerAsync(new FilePickerOpenOptions()
{
Title = "Programm laden"
Expand All @@ -153,6 +153,7 @@ public MainViewModel()

SaveCommand = ReactiveCommand.Create(async () =>
{
var storage = Locator.Current.GetService<IStorageProvider>();
var file = await storage!.SaveFilePickerAsync(new() { Title = "Programm speichern" });
await using var writer = new StreamWriter(await file!.OpenWriteAsync());
Expand Down Expand Up @@ -239,7 +240,7 @@ private void InitHighlighting()
private void LoadHighlighting(string name, string extension, string filename)
{
IHighlightingDefinition customHighlighting;
using (Stream s = GetType().Assembly.GetManifestResourceStream($"MimaSim.Resources.Highligting.{filename}.xshd"))
using (Stream? s = GetType().Assembly.GetManifestResourceStream($"MimaSim.Resources.Highligting.{filename}.xshd"))
{
using (XmlReader reader = new XmlTextReader(s))
{
Expand Down

0 comments on commit a0956ab

Please sign in to comment.