Enable a button, when finish work

Eduardo Gomez 3,416 Reputation points
2022-10-04T08:48:50.297+00:00

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)

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,666 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
760 questions
{count} votes