1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using Antmicro.Renode.Peripherals; 9 using Antmicro.Renode.Core; 10 using Xwt; 11 12 namespace Antmicro.Renode.UI 13 { 14 public abstract class GUIPeripheralBackendAnalyzer<T> : BasicPeripheralBackendAnalyzer<T>, IHasWidget where T: IAnalyzableBackend 15 { Show()16 public override void Show() 17 { 18 string tabName; 19 if(!EmulationManager.Instance.CurrentEmulation.TryGetEmulationElementName(Backend.AnalyzableElement, out tabName)) 20 { 21 tabName = "?"; 22 } 23 24 ApplicationExtensions.InvokeInUIThreadAndWait(() => Emulator.UserInterfaceProvider.ShowAnalyser(this, tabName)); 25 } 26 Hide()27 public override void Hide() 28 { 29 ApplicationExtensions.InvokeInUIThreadAndWait(() => Emulator.UserInterfaceProvider.HideAnalyser(this)); 30 } 31 AttachTo(T backend)32 public override void AttachTo(T backend) 33 { 34 base.AttachTo(backend); 35 ApplicationExtensions.InvokeInUIThreadAndWait(() => OnAttach(backend)); 36 } 37 38 /// <summary> 39 /// This method is called when backend analyzer is attached to a peripheral. 40 /// IT IS GUARANTEED THAT THIS METHOD IS CALLED FROM GUI THREAD, SO INITIALIZATION OF WIDGETS SHOULD BE MADE HERE. 41 /// </summary> 42 /// <param name="backend">Backend.</param> OnAttach(T backend)43 protected abstract void OnAttach(T backend); 44 45 public abstract Widget Widget { get; } 46 } 47 } 48 49