Skip to content

Commit

Permalink
Merge pull request #101 from lacmus-foundation/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
gosha20777 authored May 11, 2020
2 parents a4eafb2 + 6e809a2 commit 88ea0a8
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 44 deletions.
5 changes: 5 additions & 0 deletions src/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
<StyleInclude Source="resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"/>
-->
</Application.Styles>
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="About Lacmus"/>
</NativeMenu>
</NativeMenu.Menu>
</Application>
5 changes: 2 additions & 3 deletions src/LacmusApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<Company>Lacmus Foundation</Company>
<AssemblyVersion>0.4.1.0</AssemblyVersion>
<FileVersion>0.4.1.0</FileVersion>
<AssemblyVersion>0.4.2.0</AssemblyVersion>
<FileVersion>0.4.2.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
Expand All @@ -25,7 +25,6 @@
<PackageReference Include="Avalonia.ReactiveUI" Version="0.9.9" />
<PackageReference Include="Avalonia.Skia.Linux.Natives" Version="1.68.0.2" />
<PackageReference Include="Citrus.Avalonia" Version="1.2.4" />
<PackageReference Include="CUDAfy.NET" Version="1.29.5576.13786" />
<PackageReference Include="Docker.DotNet" Version="3.125.2" />
<PackageReference Include="Material.Avalonia" Version="0.9.0" />
<PackageReference Include="MessageBox.Avalonia" Version="0.9.6.1" />
Expand Down
11 changes: 11 additions & 0 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ public static string GetVersion()

private static AppBuilder BuildAvaloniaApp()
{
//FOR TEST IN VirtualBox
/*
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return AppBuilder.Configure<App>()
.UsePlatformDetect()
.With(new Win32PlatformOptions {EnableMultitouch = true, AllowEglInitialization = true})
.With(new AvaloniaNativePlatformOptions {UseGpu = false})
.UseReactiveUI()
.LogToDebug();
*/

return AppBuilder.Configure<App>()
.UsePlatformDetect()
.With(new Win32PlatformOptions {EnableMultitouch = true, AllowEglInitialization = true})
Expand Down
68 changes: 39 additions & 29 deletions src/Services/LocalizationContext.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ViewModels/AboutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void OpenUrl(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start(url);
Process.Start("cmd", $"/C start {url}");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ private void OpenUrl(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start(url);
Process.Start("cmd", $"/C start {url}");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/MetadataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private void OpenUrl(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start(url);
Process.Start("cmd", $"/C start {url}");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Expand Down
5 changes: 2 additions & 3 deletions src/ViewModels/ModelManagerWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Threading;
using Cudafy;
using Cudafy.Host;
using Docker.DotNet.Models;
using DynamicData;
using GASS.CUDA;
using LacmusApp.Extensions;
using LacmusApp.Managers;
using LacmusApp.Models;
Expand Down Expand Up @@ -320,6 +317,7 @@ public async Task DownloadModel()
throw new Exception($"Incorrect OS for {SelectedAvailableModel.Type} inference type");
}

/*
if (CudafyHost.GetDeviceCount(eGPUType.Emulator) == 0)
{
var msgbox = MessageBoxManager.GetMessageBoxStandardWindow(new MessageBoxStandardParams
Expand All @@ -334,6 +332,7 @@ public async Task DownloadModel()
var result = await msgbox.Show();
throw new Exception($"No CUDA devises.");
}
*/
}

var config = new MLModelConfig();
Expand Down
24 changes: 19 additions & 5 deletions src/ViewModels/SaveAsWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ public SaveAsWindowViewModel(Window window, SourceList<PhotoViewModel> photos, A
viewModel => viewModel.OutputPath,
Directory.Exists,
path => $"Incorrect path {path}");

SaveCommand = ReactiveCommand.Create(SavePhotos);

SelectPathCommand = ReactiveCommand.Create(SelectOutputFolder);
SaveCommand = ReactiveCommand.Create(SavePhotos, this.IsValid());
}
[Reactive] public string OutputPath { get; set; }
[Reactive] public int FilterIndex { get; set; } = 0;
Expand All @@ -44,20 +45,33 @@ public SaveAsWindowViewModel(Window window, SourceList<PhotoViewModel> photos, A
[Reactive] public bool IsDraw { get; set; } = false;
[Reactive] public bool IsCrop { get; set; } = false;
[Reactive] public LocalizationContext LocalizationContext { get; set; }
public ReactiveCommand<Unit, Unit> SelectPathCommand { get; set; }
public ReactiveCommand<Unit, Unit> SaveCommand { get; set; }
public async void SavePhotos()

private async void SelectOutputFolder()
{
try
{
_applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Working, "");
var dig = new OpenFolderDialog()
{
//TODO: Multi language support
Title = "Select folder to save"
};
var dirPath = await dig.ShowAsync(new Window());
OutputPath = dirPath;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}

private async void SavePhotos()
{
try
{
_applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Working, "");
if(!Directory.Exists(OutputPath))
throw new Exception($"No such directory: {OutputPath}.");

Expand Down
5 changes: 5 additions & 0 deletions src/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
Title="LacmusApp"
Width="800"
Height="600">
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="About Lacmus" Command="{Binding AboutCommand}"/>
</NativeMenu>
</NativeMenu.Menu>
<Grid Name="Main">
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
Expand Down
16 changes: 15 additions & 1 deletion src/Views/SaveAsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,21 @@
<TextBox Margin="0 5" UseFloatingWatermark="True"
Watermark="{Binding LocalizationContext.WizardSecondOutputWatermark}"
Text="{Binding OutputPath, Mode=TwoWay}" />
<Button Margin="0 2 0 5" Content="{Binding LocalizationContext.WizardSecondSavePhotosButton}" Command="{Binding SaveCommand}"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
Content="{Binding LocalizationContext.SaveAsSelectPath}"
Command="{Binding SelectPathCommand}"
/>
<Button Grid.Column="2"
Classes="Primary"
Content="{Binding LocalizationContext.WizardSecondSavePhotosButton}"
Command="{Binding SaveCommand}"/>
</Grid>
</StackPanel>
</Border>
</StackPanel>
Expand Down

0 comments on commit 88ea0a8

Please sign in to comment.