public MainWindow() { InitializeComponent(); // Check singleton violation mutex = new System.Threading.Mutex(true, registryHelper.GetGuid(), out mutexInitialOwnership); if (!mutexInitialOwnership) { MessageBox.Show("BookmarksManager can't be opened twice.", "Fatal error : Singleton", MessageBoxButton.OK, MessageBoxImage.Error); fatalError = true; this.Close(); return; } // Check BookmarkManager settings CheckSettings(); // Populate bookmark handlers and browsers infos infos[Browser.IE] = new BookmarkHandlerInfos() { stackPanel = IEStackPanel, handlerType = typeof(IE.BookmarkHandler) }; infos[Browser.Chrome] = new BookmarkHandlerInfos() { stackPanel = ChromeStackPanel, handlerType = typeof(Chrome.BookmarkHandler) }; infos[Browser.Firefox] = new BookmarkHandlerInfos() { stackPanel = FirefoxStackPanel, handlerType = typeof(Firefox.BookmarkHandler) }; // Check running browser, fail if user click cancel or exit if (CheckRun(Browser.Chrome)) { infos[Browser.Chrome].initializationSuccessful = false; } if (CheckRun(Browser.Firefox)) { infos[Browser.Firefox].initializationSuccessful = false; } // Initialize bookmark handlers foreach (KeyValuePair <Browser, BookmarkHandlerInfos> info in infos) { try { info.Value.handler = info.Value.initializationSuccessful ? (BookmarkHandlerBase)Activator.CreateInstance(info.Value.handlerType) : null; } catch (BookmarkHandlerInitializationException e) { MessageBox.Show(e.Message, BookmarkHandlerInitializationException.title, MessageBoxButton.OK, MessageBoxImage.Warning); info.Value.initializationSuccessful = false; } } // init bookmarks bookmarks = new Bookmarks(infos[Browser.IE].handler, infos[Browser.Chrome].handler, infos[Browser.Firefox].handler); try { bookmarks.Deserialize(); } catch (System.IO.IOException) { MessageBox.Show( "Fatal error while getting bookmark list from bookmarkList.xml, file does not exist or is not accessible.", "Fatal error : file IO", MessageBoxButton.OK, MessageBoxImage.Error); fatalError = true; this.Close(); return; } // UI UIBuilder(); }