public void On_Activate() { ActiveWindow aw = new ActiveWindow(); TextSelHandler textsel = new TextSelHandler(this); IntPtr hWnd = IntPtr.Zero; InfoItem activeItem = null; System.Windows.Clipboard.Clear(); try { //support for synchronizing droplist with filesystem dynamically hWnd = aw.GetActiveWindowHandle(); textsel.SendCtrlC(hWnd); //wait for the copy to be completed Thread.Sleep(100); activeItem = aw.GetActiveItem(); newNoteText = System.Windows.Clipboard.GetText().Replace("\r\n", " ").Replace("\t", " ").Trim(); if (newNoteText.Length > StartProcess.MAX_EXTRACTTEXT_LENGTH) { newNoteText = newNoteText.Substring(0, StartProcess.MAX_EXTRACTTEXT_LENGTH) + "..."; } if ((activeItem != null) && (activeItem.Uri != null) && (activeItem.Uri.Length != 0)) { newInfoItem = activeItem; if (newNoteText.Length != 0) { newNoteText = "\"" + newNoteText + "\" "; } else if (newInfoItem.Title != null) { newNoteText = "\"" + newInfoItem.Title + "\" "; } string title; if (newInfoItem.Title == null || newInfoItem.Title.Length == 0) { title = newNoteText.Replace("/", "").Replace("\\", "").Replace("*", "").Replace("?", "").Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "").Replace(":", ""); if (title.Length > StartProcess.MAX_EXTRACTNAME_LENGTH) { title = title.Substring(0, StartProcess.MAX_EXTRACTNAME_LENGTH); } } else { title = newInfoItem.Title; } checkBox_URI.IsEnabled = true; checkBox_URI.IsChecked = true; if (title.Length > ACTIVEITEM_TITLE_LENGTH) { checkBox_URI.Content = "Include link to: " + "\"" + title.Substring(0, ACTIVEITEM_TITLE_LENGTH) + "..." + "\""; } else { checkBox_URI.Content = "Include link to: " + "\"" + title + "\""; } } textBox_Note.Text = newNoteText; } catch (Exception) { ReInitilize(); } updateComboBox_SaveLoc(); int selectedIndex = 0; int i; for (i = 0; i < comboBox_SaveLoc.Items.Count; i++) { ComboBoxItem cbi_Item = (ComboBoxItem)comboBox_SaveLoc.Items[i]; if (cbi_Item.Tag.ToString() == selectedItem.Tag.ToString() && cbi_Item.Content.ToString() == selectedItem.Content.ToString()) { selectedIndex = i; } } comboBox_SaveLoc.SelectedIndex = selectedIndex; this.Visibility = Visibility.Visible; this.Activate(); textBox_Note.Focus(); textBox_Note.Select(newNoteText.Length, 0); bNoteModified = false; this.Topmost = true; System.Windows.Clipboard.Clear(); aw = null; textsel = null; hWnd = IntPtr.Zero; activeItem = null; GC.Collect(); }