public DefaultTaskbarWindowService(IAppSettings settings) { _hookInstance = this; Settings = settings; ActivePlacement = settings.Placement; // install a win event hook to track taskbar resize/movement hookDelegate = new WinEventHook.WinEventDelegate(WinEventProc); var winHook = WinEventHook.SetHook(WinEventHook.EVENT_OBJECT_LOCATIONCHANGE, hookDelegate); Application.ApplicationExit += (s, e) => { if (winHook != IntPtr.Zero) { WinEventHook.RemoveHook(winHook); winHook = IntPtr.Zero; foreach (var f in GetWindows()) { f.Close(); f.RestoreTaskbar(); } } }; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += Application_ThreadException; IAppSettings settings = new AppSettings(); taskbarService = new DefaultTaskbarWindowService(settings); IDialogService dialogService = new DialogService(settings, taskbarService); (taskbarService as DefaultTaskbarWindowService).SetDialogService(dialogService); var taskbars = taskbarService.GetTaskBars(); if (taskbars.Count > 0) { taskbarService.RecreateAll(); Application.Run(); } else { MessageBox.Show("No taskbars found. Application will terminate.", "CalendarWeekView", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public DialogService(IAppSettings settings, ITaskbarWindowService taskbarWindowService) { Settings = settings; TaskbarWindowService = taskbarWindowService; }