private void HandleLoaded(object sender, RoutedEventArgs e) { WindowStyles.SetExtended(this, WindowStyles.GetExtended(this) | ExtendedWindowStyle.WS_EX_TOOLWINDOW | ExtendedWindowStyle.WS_EX_NOACTIVATE | ExtendedWindowStyle.WS_EX_TOPMOST); ThemeManager.Reapply(); Hide(); }
protected override void OnInitialized(EventArgs eventArgs) { base.OnInitialized(eventArgs); try { instance = this; // Update the position and size of the window. UpdatePosition(); // Set the window as NO_ACTIVATE, TOOLWINDOW and TOPMOST, WindowStyles.SetExtended(this, WindowStyles.GetExtended(this) | ExtendedWindowStyle.WS_EX_NOACTIVATE | ExtendedWindowStyle.WS_EX_TOOLWINDOW | ExtendedWindowStyle.WS_EX_TOPMOST); // Apply the user-selected locale. IntlManager.Apply(new CultureInfo(AppState.Current.UserSettings.Locale)); // Apply the user-selected theme. ThemeManager.Apply(AppState.Current.UserSettings.Theme); // Initialize the drop shadow. _dropShadow = new WindowDropShadow(this) { Radius = 15.0, Strength = 2.0, Opacity = 0.0, }; // Set the window's view-model. _viewModel = new OverviewViewModel(); InitializeQuickInfoWindow(); // Request the needed window permissions. (>= Windows 8) _clipboardPermission = new UIPermission(PermissionState.Unrestricted) { Clipboard = UIPermissionClipboard.AllClipboard }; // Setup the clipboard manager and the according event listeners. _clipboardManager = new ClipboardManager(this); _clipboardManager.StateChanged += OnClipboardStateChanged; // Initially hidden. _isVisible = false; _transitions = new TaskChain(); // Initialize the window message receiver with a name. _wmr = new WindowMessageReceiver("MULTICLIP_IPC", null); // Setup the IPC handler. _wmr.MessageReceived += OnMessageReceived; // Initialize and set the low-level mouse hook. _mouseHook = new LowLevelMouseHook(); _mouseHook.LButtonDown += OnMouseHookButtonDown; _mouseHook.RButtonDown += OnMouseHookButtonDown; _mouseHook.XButtonDown += OnMouseHookButtonDown; _mouseHook.SetHook(); // Initialize and register the overview hotkey. _overviewHotkey = new GlobalHotkey(HotkeyModfier.Ctrl, Keys.Space); _overviewHotkey.Pressed += OnOverviewHotkeyPressed; _overviewHotkey.Register(); // Initialize and register the secure-copy hotkey. _secureCopyHotkey = new GlobalHotkey(HotkeyModfier.Ctrl | HotkeyModfier.Alt, Keys.C); _secureCopyHotkey.Pressed += OnSecureCopyHotkeyPressed; _secureCopyHotkey.Register(); // Show the help window on the first run of the app. if ((bool)Properties.Settings.Default["IsFirstRun"] == true) { Properties.Settings.Default["IsFirstRun"] = false; Properties.Settings.Default.Save(); HelpWindow helpWindow = new HelpWindow(); helpWindow.Show(); } ClipboardList.ItemsSource = _viewModel.ClipboardItems; // When a file-drop item is about to open a subwindow, // hide the main window. FileDropItem.PreviewShellExecute += delegate { if (_isVisible) { HideAsync().GetAwaiter(); } }; } catch (Exception e) { _logger.LogCritical(LogEvents.FatalErr, "Failed to initialize the main window!", e); Exceptions.NotifyCritical(e); } }