Skip to content

Commit

Permalink
Created an empty export button.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Dec 14, 2024
1 parent 86d5591 commit 16ea7fc
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
</ItemGroup>

<ItemGroup>
<AvaloniaXaml Update="common\buttons\ExportAssetButton.axaml">
<SubType>Designer</SubType>
</AvaloniaXaml>
<AvaloniaXaml Update="common\IconStyles.axaml">
<SubType>Designer</SubType>
</AvaloniaXaml>
Expand All @@ -60,6 +63,10 @@
</ItemGroup>

<ItemGroup>
<Compile Update="common\buttons\ExportAssetButton.axaml.cs">
<SubType>Code</SubType>
<DependentUpon>ExportAssetButton.axaml</DependentUpon>
</Compile>
<Compile Update="common\buttons\ImportAssetButton.axaml.cs">
<DependentUpon>ImportAssetButton.axaml</DependentUpon>
</Compile>
Expand Down
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>
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;
}*/
}

0 comments on commit 16ea7fc

Please sign in to comment.