Skip to content

Commit

Permalink
optimize and update
Browse files Browse the repository at this point in the history
  • Loading branch information
PHAN Xuan Quang committed Nov 2, 2024
1 parent 133e296 commit 4ce15ce
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Adobe Camera Profiles Unlocker Neo/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<HyperlinkButton Background="{StaticResource AcrylicInAppFillColorBaseBrush}" Content="Find the project on GitHub" NavigateUri="https://github.com/phanxuanquang/Adobe-Camera-Profiles-Unlocker" Margin="0,0,10,0"/>
<HyperlinkButton Background="{StaticResource AcrylicInAppFillColorBaseBrush}" Content="Buy me a coffee" NavigateUri="https://i.imgur.com/XYXfisQ.jpeg" />
<HyperlinkButton x:Name="VietcombankBtn" Background="{StaticResource AcrylicInAppFillColorBaseBrush}" Content="Support me via banking" NavigateUri="https://i.imgur.com/XYXfisQ.jpeg" />
</StackPanel>
</StackPanel>
</Border>
Expand Down
94 changes: 77 additions & 17 deletions Adobe Camera Profiles Unlocker Neo/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -48,7 +47,7 @@ private async void MainWindow_Activated(object sender, WindowActivatedEventArgs
{
try
{
await Task.Delay(300);
await CheckUpdate("Neo 2.1");

if (!IsSupportedOS())
{
Expand Down Expand Up @@ -82,7 +81,7 @@ private async void MainWindow_Activated(object sender, WindowActivatedEventArgs
ContentDialog confirmationDialog = new ContentDialog
{
XamlRoot = RootGrid.XamlRoot,
Title = "Confirmation",
Title = "Error",
Content = "The Camera Raw has not been installed on your device.",
PrimaryButtonText = "Download Camera Raw",
CloseButtonText = "Cancel",
Expand All @@ -93,11 +92,7 @@ private async void MainWindow_Activated(object sender, WindowActivatedEventArgs

if (result == ContentDialogResult.Primary)
{
Process.Start(new ProcessStartInfo
{
FileName = "https://www.adobe.com/go/acr_installer_win",
UseShellExecute = true
});
await Launcher.LaunchUriAsync(new Uri("https://www.adobe.com/go/acr_installer_win"));
}

Application.Current.Exit();
Expand Down Expand Up @@ -127,11 +122,71 @@ private async void MainWindow_Activated(object sender, WindowActivatedEventArgs
Directory.CreateDirectory(CameraRaw.CameraProfilesDir_LR);
}

var modelDirs = await DirectoryHelper.GetFolders(CameraRaw.InputModelsDir);
var modelDirsAlt = await DirectoryHelper.GetFolders(CameraRaw.InputModelsDirAlt, false);
var modelDirsTask = DirectoryHelper.GetFolders(CameraRaw.InputModelsDir);
var modelDirsAltTask = DirectoryHelper.GetFolders(CameraRaw.InputModelsDirAlt, false);

await Task.WhenAll(modelDirsTask, modelDirsAltTask);

var modelDirs = modelDirsTask.Result;
var modelDirsAlt = modelDirsAltTask.Result;

if (modelDirs.Count == 0)
{
ContentDialog noDcpDialog = new ContentDialog
{
XamlRoot = RootGrid.XamlRoot,
Title = "Error",
Content = "Cannot load default profiles of Camera Raw. Try reinstalling Camera Raw, and Adobe Lightroom or Adobe Photoshop.",
PrimaryButtonText = "Download Camera Raw",
CloseButtonText = "Skip",
DefaultButton = ContentDialogButton.Primary
};

ModelDirs.AddRange(modelDirs);
ModelDirs.AddRange(modelDirsAlt);
if (await noDcpDialog.ShowAsync() == ContentDialogResult.Primary)
{
await Launcher.LaunchUriAsync(new Uri("https://www.adobe.com/go/acr_installer_win"));
}
}
else
{
ModelDirs.AddRange(modelDirs);
}

if (modelDirsAlt.Count == 0)
{
ContentDialog noXmlDialog = new ContentDialog
{
XamlRoot = RootGrid.XamlRoot,
Title = "Error",
Content = "Cannot load camera profiles of Adobe, Sigma, Nikon, Panasonic, and Fujifilm. Try reinstalling Camera Raw, and Adobe Lightroom or Adobe Photoshop.",
PrimaryButtonText = "Download Camera Raw",
CloseButtonText = "Skip",
DefaultButton = ContentDialogButton.Primary
};

if (await noXmlDialog.ShowAsync() == ContentDialogResult.Primary)
{
await Launcher.LaunchUriAsync(new Uri("https://www.adobe.com/go/acr_installer_win"));
}
}
else
{
ModelDirs.AddRange(modelDirsAlt);
}

if (ModelDirs.Count == 0)
{
ContentDialog noAdobeDialog = new ContentDialog
{
XamlRoot = RootGrid.XamlRoot,
Title = "Error",
Content = "Cannot load camera profiles from Adobe. Try reinstalling Camera Raw, and Adobe Lightroom or Adobe Photoshop.",
PrimaryButtonText = "OK",
DefaultButton = ContentDialogButton.Primary
};
await noAdobeDialog.ShowAsync();
Application.Current.Exit();
}

var models = ModelDirs
.AsParallel()
Expand All @@ -146,7 +201,6 @@ private async void MainWindow_Activated(object sender, WindowActivatedEventArgs
}

InputSearchBox.ItemsSource = OutputSearchBox.ItemsSource = DataSource;
await CheckUpdate("Neo 2.0");
}
catch (Exception ex)
{
Expand Down Expand Up @@ -262,7 +316,7 @@ private async void InstallButton_Click(object sender, RoutedEventArgs e)
return;
}

if (!ModelDirs.Any(dir => dir.Contains(OutputSearchBox.Text.Trim()) || dir.Contains(InputSearchBox.Text.Trim())))
if (!ModelDirs.Exists(dir => dir.Contains(OutputSearchBox.Text.Trim()) || dir.Contains(InputSearchBox.Text.Trim())))
{
ContentDialog errorDialog = new ContentDialog
{
Expand Down Expand Up @@ -336,9 +390,15 @@ private async void InstallButton_Click(object sender, RoutedEventArgs e)
XamlRoot = RootGrid.XamlRoot,
Title = "Success",
Content = "Please restart the Lightroom and the Photoshop applications to apply changes.",
PrimaryButtonText = "OK"
PrimaryButtonText = VietcombankBtn.Content.ToString(),
SecondaryButtonText = "OK",
DefaultButton = ContentDialogButton.Primary
};
await successDialog2.ShowAsync();

if (await successDialog2.ShowAsync() == ContentDialogResult.Primary)
{
await Launcher.LaunchUriAsync(new Uri(VietcombankBtn.NavigateUri.AbsoluteUri));
}
}
private async void ResetButton_Click(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -462,7 +522,7 @@ private void FilterResult(AutoSuggestBox sender)
sender.ItemsSource = new List<string>() { "Error while finding the camera" };
}
}
public bool IsSupportedOS()
public static bool IsSupportedOS()
{
var minOsVersion = new Version(10, 0, 17763, 0);

Expand Down
6 changes: 5 additions & 1 deletion Engineer/DirectoryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ public static List<string> GetProfileFiles(string folderPath)
var xmpFiles = Directory.GetFiles(folderPath, "*.xmp").ToList();
return dcpFiles.Concat(xmpFiles).ToList();
}

public static async Task<List<string>> GetFolders(string path, bool getDirectChildrenOnly = true)
{
if (!Directory.EnumerateFileSystemEntries(path).GetEnumerator().MoveNext())
{
return new List<string>();
}

if (getDirectChildrenOnly)
{
return await Task.Run(() => Directory.GetDirectories(path).ToList());
Expand Down

0 comments on commit 4ce15ce

Please sign in to comment.