private void ShowListerForm() { var fileName = (string)null; try { fileName = WindowUtils.GetSelectedFileFromDesktopOrExplorer(); } catch (Exception e) { MessageBox.Show("Failed to get selected file. " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Environment.CurrentDirectory = AssemblyUtils.AssemblyDirectory; if (_listerForm != null && _listerForm.IsHandleCreated) { _listerForm.Close(); } if (_listerForm == null || _listerForm.IsDisposed) { _listerForm = new ListerForm(_settings, _plugins, fileName); } if (_listerForm.IsDisposed) { _listerForm = null; } else { var hwnd = NativeMethods.GetForegroundWindow(); var className = WindowUtils.GetClassName(hwnd); if (className == "WorkerW" || className == "Progman") { _listerForm.Show(); } else { _listerForm.Show(new Win32WindowWrapper(hwnd)); } _listerForm.Activate(); } }
private void ShowListerForm() { IList <string> files = new List <string>(); try { files = WindowUtils.GetSelectedFilesFromForegroundExplorerWindow(); } catch { MessageBox.Show("Failed to get selected file in windows explorer.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (files.Count != 1) { return; } Environment.CurrentDirectory = AssemblyUtils.AssemblyDirectory; if (_listerForm != null && _listerForm.IsHandleCreated) { _listerForm.Close(); } if (_listerForm == null || _listerForm.IsDisposed) { _listerForm = new ListerForm(_settings, _plugins, files[0]); } if (_listerForm.IsDisposed) { _listerForm = null; } else { var foregroundWindowHandle = NativeMethods.GetForegroundWindow(); _listerForm.Show(new Win32WindowWrapper(foregroundWindowHandle)); _listerForm.Activate(); } }