private void Update() { if (string.IsNullOrEmpty(SelectedPath)) { if (!txtLocation.IsFocused) { ShowWatermark(true); } imgIcon.Source = null; return; } ShowWatermark(false); IDLWrapper wrapper = SelectedIDL == null ? new IDLWrapper(SelectedPath) : new IDLWrapper(SelectedIDL as byte[] ?? SelectedIDL.ToArray()); using (wrapper) { if (!lockText) { string text; if (File || wrapper.IDL == null) { text = wrapper.Path; } else { bool b = File ? wrapper.IsFileSystemFile : wrapper.IsFileSystemFolder; text = b ? wrapper.Path : wrapper.DisplayName; } SetTextboxText(text); } Icon icon = QTUtility.GetIcon(wrapper.PIDL); imgIcon.Source = (ImageSource) new OptionsDialog.BitmapToImageSourceConverter().Convert(icon.ToBitmap(), null, null, null); } }
private void CreateNotifyIcon() { if (notifyIcon != null) { return; } Thread thread = new Thread(() => { // We need to make a new thread because we have to guarantee // contextMenuNotifyIcon is only accessed from a single thread. // InstanceManager could call us from many different threads. lock (dicNotifyIcon) { if (notifyIcon != null) { return; // double check to prevent race conditions } icoNotify = QTUtility.GetIcon(string.Empty, false); contextMenuNotifyIcon = new ContextMenuStripEx(null, false); contextMenuNotifyIcon.ImageList = QTUtility.ImageListGlobal; contextMenuNotifyIcon.ItemClicked += contextMenuNotifyIcon_ItemClicked; contextMenuNotifyIcon.EnsureHandleCreated(); notifyIcon = new NotifyIcon { Icon = icoNotify, ContextMenuStrip = contextMenuNotifyIcon, Visible = false }; notifyIcon.MouseDoubleClick += notifyIcon_MouseDoubleClick; Monitor.Pulse(dicNotifyIcon); } Application.Run(); }) { IsBackground = true }; lock (dicNotifyIcon) { thread.Start(); Monitor.Wait(dicNotifyIcon); } }