-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86d5591
commit 16ea7fc
Showing
3 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
.../UniversalAssetTool/UniversalAssetTool.Ui.Avalonia/common/buttons/ExportAssetButton.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" | ||
mc:Ignorable="d" | ||
x:Class="uni.ui.avalonia.common.buttons.ExportAssetButton"> | ||
<Button ToolTip.Tip="Import asset" | ||
Click="Button_OnClick"> | ||
<avalonia:MaterialIcon Kind="FileExport" /> | ||
</Button> | ||
</UserControl> |
94 changes: 94 additions & 0 deletions
94
...iversalAssetTool/UniversalAssetTool.Ui.Avalonia/common/buttons/ExportAssetButton.axaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Interactivity; | ||
|
||
namespace uni.ui.avalonia.common.buttons; | ||
|
||
public partial class ExportAssetButton : UserControl { | ||
public ExportAssetButton() => this.InitializeComponent(); | ||
|
||
private async void Button_OnClick(object? sender, RoutedEventArgs e) { } | ||
|
||
/*private void StartExportingModelsInBackground_( | ||
IReadOnlyList<IAnnotatedFileBundle<IModelFileBundle>> | ||
modelFileBundles) { | ||
var extractorPromptChoice = | ||
PromptIfModelFileBundlesAlreadyExported_( | ||
modelFileBundles, | ||
Config.Instance.Exporter.General.ExportedFormats); | ||
if (extractorPromptChoice != ExporterPromptChoice.CANCEL) { | ||
this.CancellationToken = new CancellationTokenSource(); | ||
Task.Run(() => { | ||
ExportAll(modelFileBundles, | ||
new GlobalModelImporter(), | ||
this.Progress, | ||
this.CancellationToken, | ||
Config.Instance.Exporter.General | ||
.ExportedFormats, | ||
extractorPromptChoice == | ||
ExporterPromptChoice | ||
.OVERWRITE_EXISTING); | ||
}); | ||
} | ||
} | ||
private string GetTotalNodeText_(IFileTreeNode node) { | ||
var totalText = ""; | ||
var directory = node; | ||
while (true) { | ||
if (totalText.Length > 0) { | ||
totalText = "/" + totalText; | ||
} | ||
totalText = directory.Text + totalText; | ||
directory = directory.Parent; | ||
if (directory?.Parent == null) { | ||
break; | ||
} | ||
} | ||
return totalText; | ||
} | ||
private static async Task<ExporterPromptChoice> | ||
PromptIfModelFileBundlesAlreadyExported_( | ||
IReadOnlyList<IAnnotatedFileBundle> modelFileBundles, | ||
IReadOnlySet<ExportedFormat> formats) { | ||
if (CheckIfModelFileBundlesAlreadyExported( | ||
modelFileBundles, | ||
formats, | ||
out var existingOutputFiles)) { | ||
var totalCount = modelFileBundles.Count; | ||
if (totalCount == 1) { | ||
var result = await MessageBoxManager | ||
.GetMessageBoxStandard( | ||
"Model has already been exported!", | ||
$"Model defined in \"{existingOutputFiles.First().FileBundle.DisplayFullPath}\" has already been exported. Would you like to overwrite it?", | ||
ButtonEnum.YesNo, | ||
Icon.Warning | ||
).ShowAsync(); | ||
return result switch { | ||
ButtonResult.Yes => ExporterPromptChoice.OVERWRITE_EXISTING, | ||
ButtonResult.No => ExporterPromptChoice.CANCEL, | ||
}; | ||
} else { | ||
var existingCount = existingOutputFiles.Count(); | ||
var result = await MessageBoxManager | ||
.GetMessageBoxStandard( | ||
$"{existingCount}/{totalCount} models have already been exported!", | ||
$"{existingCount} model{(existingCount != 1 ? "s have" : " has")} already been exported. Select 'Yes' to overwrite them, 'No' to skip them, or 'Cancel' to abort this operation.", | ||
ButtonEnum.YesNoCancel, | ||
Icon.Warning | ||
).ShowAsync(); | ||
return result switch { | ||
ButtonResult.Yes => ExporterPromptChoice.OVERWRITE_EXISTING, | ||
ButtonResult.No => ExporterPromptChoice.SKIP_EXISTING, | ||
ButtonResult.Cancel => ExporterPromptChoice.CANCEL, | ||
}; | ||
} | ||
} | ||
return ExporterPromptChoice.SKIP_EXISTING; | ||
}*/ | ||
} |