| 1 | using Core.Servicers.Interfaces; |
| 2 | using System; |
| 3 | using System.Collections.Generic; |
| 4 | using System.Linq; |
| 5 | using System.Text; |
| 6 | using System.Threading.Tasks; |
| 7 | |
| 8 | namespace UI.Servicers |
| 9 | { |
| 10 | public class MainServicer : IMainServicer |
| 11 | { |
| 12 | private readonly IMain main; |
| 13 | private readonly IThemeServicer themeServicer; |
| 14 | private readonly IInputServicer inputServicer; |
| 15 | private readonly IAppContextMenuServicer appContextMenuServicer; |
| 16 | private readonly IWebSiteContextMenuServicer _webSiteContext; |
| 17 | private readonly IStatusBarIconServicer _statusBarIconServicer; |
| 18 | private readonly IAppConfig _config; |
| 19 | private bool isSelfStart = false; |
| 20 | public MainServicer( |
| 21 | IMain main, |
| 22 | IThemeServicer themeServicer, |
| 23 | IInputServicer inputServicer, |
| 24 | IAppContextMenuServicer appContextMenuServicer, |
| 25 | IWebSiteContextMenuServicer webSiteContext_, |
| 26 | IStatusBarIconServicer statusBarIconServicer_, |
| 27 | IAppConfig config_) |
| 28 | { |
| 29 | this.main = main; |
| 30 | this.themeServicer = themeServicer; |
| 31 | this.inputServicer = inputServicer; |
| 32 | this.appContextMenuServicer = appContextMenuServicer; |
| 33 | _webSiteContext = webSiteContext_; |
| 34 | _statusBarIconServicer = statusBarIconServicer_; |
| 35 | _config = config_; |
| 36 | } |
| 37 | public void Start(bool isSelfStart) |
| 38 | { |
| 39 | this.isSelfStart = isSelfStart; |
| 40 | _statusBarIconServicer.Init(); |
| 41 | |
| 42 | main.OnStarted += Main_OnStarted; |
| 43 | main.Run(); |
| 44 | } |
| 45 | |
| 46 | private void Main_OnStarted(object sender, EventArgs e) |
| 47 | { |
| 48 | themeServicer.Init(); |
| 49 | inputServicer.Start(); |
| 50 | appContextMenuServicer.Init(); |
| 51 | _webSiteContext.Init(); |
| 52 | |
| 53 | if (!isSelfStart && _config.GetConfig().General.IsStartupShowMainWindow) |
| 54 | { |
| 55 | _statusBarIconServicer.ShowMainWindow(); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | } |