ACAT.Extensions.Default.FunctionalAgents.FileBrowserAgent.FileBrowserAgent.activateWindowIfAlreadyOpen C# (CSharp) Method

activateWindowIfAlreadyOpen() private method

For text files, checks if the file is already open in notepad. IF so, activates the window
private activateWindowIfAlreadyOpen ( String fileName ) : bool
fileName String name of the file
return bool
        private bool activateWindowIfAlreadyOpen(String fileName)
        {
            String extension = Path.GetExtension(fileName);
            Log.Debug("Extension: [" + extension + "]");
            if (extension.Equals(".txt", StringComparison.InvariantCultureIgnoreCase) || String.IsNullOrEmpty(extension))
            {
                String name = Path.GetFileName(fileName);
                String title = name + " - Notepad";
                Log.Debug("Finding window " + title);
                IntPtr h = User32Interop.FindWindow(null, title);
                Log.Debug("handle h = " + h);
                if (h != IntPtr.Zero)
                {
                    User32Interop.ShowWindowAsync(h, User32Interop.SW_RESTORE);
                    activateWindow(h);
                    return true;
                }

                Log.Debug("Could not find window");
            }

            return false;
        }