Class PHWin
- Namespace
- SunamoWinStd
- Assembly
- SunamoWinStd.dll
Windows-specific process helper for browser management, editor launching, and file operations.
public class PHWin
- Inheritance
-
PHWin
- Inherited Members
- Extension Methods
Properties
BrowserPaths
Browser executable paths indexed by browser type. Does not contain Browsers.None.
public static Dictionary<Browsers, string> BrowserPaths { get; set; }
Property Value
ExecutablePaths
Executable paths indexed by executable name.
public static Dictionary<string, string> ExecutablePaths { get; set; }
Property Value
Opened
Number of browser tabs opened in current session.
public static int Opened { get; set; }
Property Value
PreferredEditor
Preferred code editor to use for opening files.
public static Editor PreferredEditor { get; set; }
Property Value
WaitIfTen
Milliseconds to wait after every 10 opened tabs. 0 means no wait.
public static int WaitIfTen { get; set; }
Property Value
Methods
AddBrowser()
Adds the default browser to the browser paths dictionary.
public static void AddBrowser()
AddBrowser(Browsers)
Adds the specified browser executable path to the browser paths dictionary.
public static string AddBrowser(Browsers browser)
Parameters
browserBrowsersThe browser type to add.
Returns
- string
The executable path of the browser, or empty string if not found.
AddBrowsers()
Initializes browser executable paths for all known browsers.
public static void AddBrowsers()
BrowsersWhichDontHaveExeInDefinedPath()
Returns list of browser executable paths that do not exist on disk.
public static List<string> BrowsersWhichDontHaveExeInDefinedPath()
Returns
Code(ILogger, string, bool, int?)
Opens a file in VS Code or Cursor (if installed).
public static void Code(ILogger logger, string filePath, bool isThrowingOnError = false, int? openOnLine = null)
Parameters
loggerILoggerLogger instance.
filePathstringFile path to open.
isThrowingOnErrorboolWhether to throw on error.
openOnLineint?Optional line number to open at.
CodeInsider(ILogger, string, bool, int?)
Opens a file in VS Code Insiders.
public static void CodeInsider(ILogger logger, string filePath, bool isThrowingOnError = false, int? openOnLine = null)
Parameters
loggerILoggerLogger instance.
filePathstringFile path to open.
isThrowingOnErrorboolWhether to throw on error.
openOnLineint?Optional line number to open at.
Codium(ILogger, string, bool, int?)
Opens a file in VSCodium.
public static void Codium(ILogger logger, string filePath, bool isThrowingOnError = false, int? openOnLine = null)
Parameters
loggerILoggerLogger instance.
filePathstringFile path to open.
isThrowingOnErrorboolWhether to throw on error.
openOnLineint?Optional line number to open at.
ExecutableOfAllBrowsers()
Prints executable paths of all known browsers to console.
public static void ExecutableOfAllBrowsers()
IsUsed(string)
Checks if a file is currently in use by any process.
public static bool IsUsed(string fullPath)
Parameters
fullPathstringFull path to the file.
Returns
- bool
True if the file is locked by a process.
OpenFolder(string)
Opens a folder in Windows Explorer.
public static void OpenFolder(string folder)
Parameters
folderstringFolder path to open.
OpenFolderInTotalcmd(ILogger, string, bool)
Opens a folder in Total Commander.
public static void OpenFolderInTotalcmd(ILogger logger, string folder, bool isThrowingOnError = false)
Parameters
loggerILoggerLogger instance.
folderstringFolder path to open.
isThrowingOnErrorboolWhether to throw on error.
OpenInAllBrowsers(ILogger, IList<string>)
Opens multiple URIs in all known browsers.
public static void OpenInAllBrowsers(ILogger logger, IList<string> uris)
Parameters
OpenInAllBrowsers(ILogger, string)
Opens a single URI in all known browsers.
public static void OpenInAllBrowsers(ILogger logger, string uri)
Parameters
OpenInBrowser(ILogger, Browsers, string, int, bool, bool)
Opens a URL in the specified browser.
public static void OpenInBrowser(ILogger logger, Browsers browser, string text, int waitMs = 500, bool isForceAttemptingHttps = false, bool isThrowingIfNotValidUrl = false)
Parameters
loggerILoggerLogger instance.
browserBrowsersBrowser to use.
textstringURL or path to open.
waitMsintMilliseconds to wait after opening. 0 is not recommended as Google may show captcha for many searches.
isForceAttemptingHttpsboolWhether to force HTTPS prefix.
isThrowingIfNotValidUrlboolWhether to throw if the URL is invalid.
OpenInBrowser(ILogger, string, int)
Opens a URL in the default browser.
public static void OpenInBrowser(ILogger logger, string uri, int waitMs = 500)
Parameters
loggerILoggerLogger instance.
uristringURL to open.
waitMsintMilliseconds to wait after opening. 0 is not recommended as Google may show captcha for many searches.
OpenInBrowserAutomaticallyCountOfOpened(ILogger, Browsers, string, int)
Opens a URL in the specified browser and tracks open count.
public static void OpenInBrowserAutomaticallyCountOfOpened(ILogger logger, Browsers browser, string text, int waitMs = 500)
Parameters
loggerILoggerLogger instance.
browserBrowsersBrowser to use.
textstringURL or path to open.
waitMsintMilliseconds to wait after opening. 0 is not recommended as Google may show captcha for many searches.
PreferredEditorOpen(ILogger, string, bool)
Opens a file in the preferred editor.
public static void PreferredEditorOpen(ILogger logger, string filePath, bool isThrowingOnError = false)
Parameters
loggerILoggerLogger instance.
filePathstringFile path to open.
isThrowingOnErrorboolWhether to throw on error.
SaveAndOpenInBrowser(ILogger, Browsers, string)
Saves HTML content to a temp file and opens it in the specified browser.
public static void SaveAndOpenInBrowser(ILogger logger, Browsers browser, string htmlContent)
Parameters
loggerILoggerLogger instance.
browserBrowsersBrowser to use.
htmlContentstringHTML content to save and open.
WebStorm64(ILogger, string, bool)
Opens a file in WebStorm 64-bit.
public static void WebStorm64(ILogger logger, string filePath, bool isThrowingOnError = false)