Enable a button, when finish work
Eduardo Gomez
3,431
Reputation points
I am doing some work in azure and I have a function, that will disable a button when I start
switch (obj) {
case (int)TilesIdentifiers.Audio:
var AudioName = CreateDialog(out dlg, ConstantsHelpers.AUDIO);
var Audiofilename = Path.Combine(AudioFolderPath, $"{AudioName}{ext}");
ToggleTile(true, (int)TilesIdentifiers.Audio);
Converter(dlg, Audiofilename, out _, out _);
await ConvertToTextAsync(Audiofilename);
ToggleTile(false, (int)TilesIdentifiers.Audio);
break;
case (int)TilesIdentifiers.Video:
var VideoName = CreateDialog(out dlg, ConstantsHelpers.VIDEO);
var VideoFilename = Path.Combine(AudioFolderPath, $"{VideoName}{ext}");
var inputFile = new MediaFile { Filename = dlg.FileName };
var outputFile = new MediaFile { Filename = VideoFilename };
var options = new ConversionOptions {
AudioSampleRate = AudioSampleRate.Hz22050
};
var engine = new Engine();
if (!string.IsNullOrEmpty(inputFile.Filename)) {
engine.Convert(inputFile, outputFile, options);
await ConvertToTextAsync(VideoFilename);
}
break;
case (int)TilesIdentifiers.Ocr:
break;
case (int)TilesIdentifiers.Account:
Debug.WriteLine("Account", "Debug");
break;
case (int)TilesIdentifiers.document:
var storageService = new AzureStorageService();
CreateDialog(out dlg, ConstantsHelpers.DOCUMENTS);
var path = CreateFolder(ConstantsHelpers.TRANSLATIONS);
if (!string.IsNullOrEmpty(dlg.FileName)) {
var sourceUri = await storageService.UploadToAzureBlobStorage(Path.GetFullPath(dlg.FileName));
var targetUri = await storageService.SaveFromdAzureBlobStorage(Path.GetFullPath(dlg.FileName));
await AzureTranslationService.TranslatorAsync(sourceUri, targetUri);
var PathToSave = Path.Combine(path, dlg.FileName);
//using var client = new HttpClient();
//using var s = await client.GetStreamAsync(targetUri);
//using var fs = new FileStream(PathToSave, FileMode.OpenOrCreate);
//await s.CopyToAsync(fs);
}
break;
case (int)TilesIdentifiers.About:
Debug.WriteLine("about", "Debug");
break;
}
private void ToggleTile(bool isWoking, int id) {
if (isWoking) {
Tiles![id].IsTileActive = false;
} else {
Tiles![id].IsTileActive = true;
}
}
When the app starts working, the button disables itself (and I can see it grayed out in the UI), but when I finished working, my button doesn't activate again
app : https://github.com/eduardoagr/TranscribeMe (I will update the azure keys, when finished)
Sign in to answer