diff --git a/ZS/Properties/AssemblyInfo.cs b/ZS/Properties/AssemblyInfo.cs index 8080a1f..e8c91c7 100644 --- a/ZS/Properties/AssemblyInfo.cs +++ b/ZS/Properties/AssemblyInfo.cs @@ -24,4 +24,4 @@ // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion ("1.2.0.6")] +[assembly: AssemblyVersion ("1.2.0.7")] diff --git a/ZS/ZS.cs b/ZS/ZS.cs index e6c32b8..7c7a648 100644 --- a/ZS/ZS.cs +++ b/ZS/ZS.cs @@ -1,4 +1,7 @@ using System; +using System.Globalization; +using System.Net.Mail; +using System.ServiceProcess; using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; @@ -7,6 +10,21 @@ using System.Web; using System.IO; using System.Drawing; +using System.Drawing.Text; +using System.Net.NetworkInformation; +using System.Drawing.Imaging; +using System.Collections.Generic; +using System.Diagnostics; +using System.Reflection; +using System.Threading; +using System.Net; +using System.Diagnostics.Eventing.Reader; +using System.Linq; +using Microsoft.Win32; +using Microsoft.VisualBasic; + + + namespace ZS { @@ -997,10 +1015,11 @@ public static Primitive ShowInputDialog(Primitive prompt) public static Primitive ShowOpenFileDialog() { OpenFileDialog openFileDialog = new OpenFileDialog(); + Primitive result = ""; if (openFileDialog.ShowDialog() == DialogResult.OK) { - return new Primitive(openFileDialog.FileName); + result = openFileDialog.FileName; } - return new Primitive(string.Empty); + return result; } /// @@ -1010,10 +1029,11 @@ public static Primitive ShowOpenFileDialog() public static Primitive ShowSaveFileDialog() { SaveFileDialog saveFileDialog = new SaveFileDialog(); + Primitive result = ""; if (saveFileDialog.ShowDialog() == DialogResult.OK) { - return new Primitive(saveFileDialog.FileName); + result = saveFileDialog.FileName; } - return new Primitive(string.Empty); + return result; } /// @@ -1094,10 +1114,11 @@ public static Primitive ShowYesNoDialog(Primitive question) public static Primitive ShowFolderBrowserDialog() { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); + Primitive result = ""; if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { - return new Primitive(folderBrowserDialog.SelectedPath); + result = folderBrowserDialog.SelectedPath; } - return new Primitive(string.Empty); + return result; } /// @@ -1147,14 +1168,16 @@ public static Primitive ShowCustomMessageBox(Primitive text, Primitive title, Pr } /// - /// Shows a progress dialog with a specified message. + /// Shows a progress dialog with a specified message and duration. /// /// The message to display in the progress dialog. - public static void ShowProgressDialog(Primitive message) + /// The duration in seconds for which the progress dialog should be displayed. + public static void ShowProgressDialog(Primitive message, Primitive durationInSeconds) { Form progressDialog = new Form(); Label label = new Label(); ProgressBar progressBar = new ProgressBar(); + System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); progressDialog.Text = "Progress"; label.Text = message; @@ -1173,6 +1196,14 @@ public static void ShowProgressDialog(Primitive message) progressDialog.StartPosition = FormStartPosition.CenterScreen; progressDialog.MinimizeBox = false; progressDialog.MaximizeBox = false; + + timer.Interval = (int)durationInSeconds * 1000; + timer.Tick += (sender, e) => { + timer.Stop(); + progressDialog.Close(); + }; + + timer.Start(); progressDialog.ShowDialog(); } @@ -1292,38 +1323,6 @@ public static Primitive ShowConfirmationDialog(Primitive text, Primitive title) return new Primitive(result == DialogResult.Yes); } - /// - /// Shows a save file dialog and returns the selected file path. - /// - /// The file types filter (e.g., "Text Files|*.txt|All Files|*.*"). - /// The path of the selected file or an empty string if canceled. - public static Primitive ShowSaveFileDialog(Primitive filter) - { - SaveFileDialog saveFileDialog = new SaveFileDialog(); - saveFileDialog.Filter = filter; - - if (saveFileDialog.ShowDialog() == DialogResult.OK) { - return new Primitive(saveFileDialog.FileName); - } - return new Primitive(string.Empty); - } - - /// - /// Shows an open file dialog and returns the selected file path. - /// - /// The file types filter (e.g., "Text Files|*.txt|All Files|*.*"). - /// The path of the selected file or an empty string if canceled. - public static Primitive ShowOpenFileDialog(Primitive filter) - { - OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.Filter = filter; - - if (openFileDialog.ShowDialog() == DialogResult.OK) { - return new Primitive(openFileDialog.FileName); - } - return new Primitive(string.Empty); - } - /// /// Shows a color dialog and returns the selected color as a string in the format "R,G,B". @@ -1342,17 +1341,26 @@ public static Primitive ShowCustomColorDialog() /// /// Shows an open file dialog with multi-select enabled and returns the selected file paths. /// - /// The file types filter (e.g., "Text Files|*.txt|All Files|*.*"). + /// The file types filter in the format "Display Name1|Pattern1|Display Name2|Pattern2|...". /// A semicolon-separated list of selected file paths or an empty string if canceled. + /// + /// Filters should be specified in pairs where: + /// - Display Name: The name shown in the dialog's filter dropdown. + /// - Pattern: The file pattern to filter files by extension (e.g., "*.txt", "*.jpg"). + /// Multiple filters can be separated by vertical bars ('|'). For example: + /// "Text Files|*.txt|All Files|*.*" + /// public static Primitive ShowMultiSelectOpenFileDialog(Primitive filter) { - OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.Filter = filter; - openFileDialog.Multiselect = true; + OpenFileDialog openFileDialog = new OpenFileDialog { + Filter = filter, + Multiselect = true + }; if (openFileDialog.ShowDialog() == DialogResult.OK) { return new Primitive(string.Join(";", openFileDialog.FileNames)); } + return new Primitive(string.Empty); } @@ -1548,10 +1556,10 @@ public static Primitive ShowImageFileDialog() } /// - /// Provides General Utilities For Small Basic. + /// Provides Image Functions For Small Basic. /// [SmallBasicType] - public static class ZSUtilities + public static class ZSImage { /// /// Determines if a sub-image is present within a main image. @@ -1593,9 +1601,2665 @@ private static bool IsMatch(Bitmap mainImage, Bitmap subImage, int startX, int s return true; } - + /// + /// Captures the entire screen and saves it as a PNG file. + /// + /// The file path where the screenshot will be saved. + /// True if the screen capture was successful; otherwise, false. + public static Primitive CaptureScreen(Primitive filePath) + { + try { + Rectangle bounds = Screen.PrimaryScreen.Bounds; + using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { + using (Graphics g = Graphics.FromImage(bitmap)) { + g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); + } + bitmap.Save(filePath, ImageFormat.Png); + return true; // Return true indicating successful capture + } + } catch (Exception ex) { + MessageBox.Show("Error capturing screen: " + ex.Message); + return false; // Return false indicating failure + } + } + + + /// + /// Resizes an image to the specified width and height. + /// + /// The file path of the input image. + /// The file path where the resized image will be saved. + /// The width of the resized image. + /// The height of the resized image. + /// True if the image resizing was successful; otherwise, false. + public static Primitive ResizeImage(Primitive inputFilePath, Primitive outputFilePath, Primitive width, Primitive height) + { + try { + // Convert Primitive types to appropriate types + string inputPath = inputFilePath.ToString(); + string outputPath = outputFilePath.ToString(); + int resizeWidth = (int)width; + int resizeHeight = (int)height; + + using (Bitmap original = new Bitmap(inputPath)) { + using (Bitmap resized = new Bitmap(resizeWidth, resizeHeight)) { + using (Graphics g = Graphics.FromImage(resized)) { + g.DrawImage(original, 0, 0, resizeWidth, resizeHeight); + } + resized.Save(outputPath, ImageFormat.Png); + return true; // Return true indicating successful resize + } + } + } catch (Exception ex) { + MessageBox.Show("Error resizing image: " + ex.Message); + return false; // Return false indicating failure + } + } + + /// + /// Gets the width of an image. + /// + /// The file path of the image. + /// The width of the image. + public static Primitive GetImageWidth(Primitive filePath) + { + try { + using (Bitmap image = new Bitmap(filePath)) { + return image.Width; + } + } catch (Exception ex) { + MessageBox.Show("Error getting image width: " + ex.Message); + return -1; // Return -1 to indicate an error + } + } + + /// + /// Gets the height of an image. + /// + /// The file path of the image. + /// The height of the image. + public static Primitive GetImageHeight(Primitive filePath) + { + try { + using (Bitmap image = new Bitmap(filePath)) { + return image.Height; + } + } catch (Exception ex) { + MessageBox.Show("Error getting image height: " + ex.Message); + return -1; // Return -1 to indicate an error + } + } + } + /// + /// Provides File Functions For Small Basic. + /// + [SmallBasicType] + public static class ZSFile + { + /// + /// Reads the content of a file. + /// + /// The path of the file to read. + /// The content of the file. + public static Primitive ReadFile(Primitive filePath) + { + try { + return System.IO.File.ReadAllText(filePath); + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Writes content to a file. + /// + /// The path of the file to write to. + /// The content to write. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive WriteFile(Primitive filePath, Primitive content) + { + try { + System.IO.File.WriteAllText(filePath, content); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Copies a file to a new location. + /// + /// The path of the file to copy. + /// The path where the file will be copied to. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive CopyFile(Primitive sourcePath, Primitive destinationPath) + { + try { + System.IO.File.Copy(sourcePath, destinationPath, true); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Deletes a file. + /// + /// The path of the file to delete. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive DeleteFile(Primitive filePath) + { + try { + System.IO.File.Delete(filePath); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Checks if a file exists. + /// + /// The path of the file to check. + /// True if the file exists; otherwise, false. + public static Primitive FileExists(Primitive filePath) + { + try { + return System.IO.File.Exists(filePath); + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Moves a file to a new location. + /// + /// The path of the file to move. + /// The path where the file will be moved to. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive MoveFile(Primitive sourcePath, Primitive destinationPath) + { + try { + System.IO.File.Move(sourcePath, destinationPath); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Creates a directory. + /// + /// The path of the directory to create. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive CreateDirectory(Primitive directoryPath) + { + try { + Directory.CreateDirectory(directoryPath); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Lists all files in a directory. + /// + /// The path of the directory to list files from. + /// A comma-separated string of file paths. + public static Primitive ListFiles(Primitive directoryPath) + { + try { + string[] files = Directory.GetFiles(directoryPath); + return string.Join(",", files); + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Renames a file. + /// + /// The current path of the file to rename. + /// The new path and name for the file. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive RenameFile(Primitive currentFilePath, Primitive newFilePath) + { + try { + System.IO.File.Move(currentFilePath, newFilePath); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Checks if a directory exists. + /// + /// The path of the directory to check. + /// True if the directory exists; otherwise, false. + public static Primitive DirectoryExists(Primitive directoryPath) + { + try { + return Directory.Exists(directoryPath); + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Deletes a directory. + /// + /// The path of the directory to delete. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive DeleteDirectory(Primitive directoryPath) + { + try { + Directory.Delete(directoryPath, true); // Set true to delete recursively + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Moves a directory to a new location. + /// + /// The current path of the directory to move. + /// The new path for the directory. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive MoveDirectory(Primitive sourcePath, Primitive destinationPath) + { + try { + Directory.Move(sourcePath, destinationPath); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Retrieves the last write time of a file. + /// + /// The path of the file to retrieve the last write time from. + /// A string representation of the last write time; or an error message if an exception occurs. + public static Primitive GetLastWriteTime(Primitive filePath) + { + try { + DateTime lastWriteTime = System.IO.File.GetLastWriteTime(filePath); + return lastWriteTime.ToString(); + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Retrieves the size of a file. + /// + /// The path of the file to get the size of. + /// The size of the file in bytes, or an error message if an exception occurs. + public static Primitive GetFileSize(Primitive filePath) + { + try { + long size = new FileInfo(filePath).Length; + return (Primitive)(decimal)size; // Explicitly cast long to decimal + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Retrieves the extension of a file. + /// + /// The path of the file to get the extension of. + /// The extension of the file, or an error message if an exception occurs. + public static Primitive GetFileExtension(Primitive filePath) + { + try { + string extension = Path.GetExtension(filePath); + return extension; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Creates a text file with specified content. + /// + /// The path of the file to create. + /// The content to write to the file. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive CreateTextFile(Primitive filePath, Primitive content) + { + try { + System.IO.File.WriteAllText(filePath, content); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Appends content to an existing file. + /// + /// The path of the file to append to. + /// The content to append. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive AppendToFile(Primitive filePath, Primitive content) + { + try { + System.IO.File.AppendAllText(filePath, content); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Retrieves the creation time of a file. + /// + /// The path of the file to retrieve the creation time from. + /// A string representation of the creation time, or an error message if an exception occurs. + public static Primitive GetFileCreationTime(Primitive filePath) + { + try { + DateTime creationTime = System.IO.File.GetCreationTime(filePath); + return creationTime.ToString(); + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Reads all lines from a file. + /// + /// The path of the file to read from. + /// A list of all lines in the file, or an error message if an exception occurs. + public static Primitive ReadAllLines(Primitive filePath) + { + try { + string[] lines = System.IO.File.ReadAllLines(filePath); + Primitive array = new Primitive(); + for (int i = 0; i < lines.Length; i++) { + array[i] = lines[i]; + } + return array; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Retrieves the attributes of a file. + /// + /// The path of the file to get the attributes of. + /// The attributes of the file, or an error message if an exception occurs. + public static Primitive GetFileAttributes(Primitive filePath) + { + try { + FileAttributes attributes = System.IO.File.GetAttributes(filePath); + return attributes.ToString(); + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Retrieves the last access time of a file. + /// + /// The path of the file to retrieve the last access time from. + /// A string representation of the last access time, or an error message if an exception occurs. + public static Primitive GetFileLastAccessTime(Primitive filePath) + { + try { + DateTime lastAccessTime = System.IO.File.GetLastAccessTime(filePath); + return lastAccessTime.ToString(); + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Deletes a directory and optionally all its contents. + /// + /// The path of the directory to delete. + /// True to delete the directory, its subdirectories, and all files; otherwise, false. + /// "Success" if the operation was successful; otherwise, an error message. + public static Primitive DeleteDirectory(Primitive directoryPath, Primitive recursive) + { + try { + Directory.Delete(directoryPath, recursive); + return "Success"; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } + + /// + /// Retrieves the file name and extension of a file path. + /// + /// The path of the file to retrieve the name from. + /// The file name and extension, or an error message if an exception occurs. + public static Primitive GetFileName(Primitive filePath) + { + try { + string fileName = Path.GetFileName(filePath); + return fileName; + } catch (Exception ex) { + return "Error: " + ex.Message; + } + } } + + + + /// + /// Provides General Utilities Functions For Small Basic. + /// + [SmallBasicType] + public static class ZSUtilities + { + [DllImport("user32.dll", SetLastError = true)] + private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo); + + private const uint MOUSEEVENTF_MOVE = 0x0001; + private const uint MOUSEEVENTF_LEFTDOWN = 0x0002; + private const uint MOUSEEVENTF_LEFTUP = 0x0004; + private const uint MOUSEEVENTF_RIGHTDOWN = 0x0008; + private const uint MOUSEEVENTF_RIGHTUP = 0x0010; + + /// + /// Sends a left mouse click at the specified screen coordinates. + /// + /// The x-coordinate of the screen position. + /// The y-coordinate of the screen position. + public static void SendLeftClick(Primitive x, Primitive y) + { + SetCursorPosition((uint)x, (uint)y); + mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)x, (uint)y, 0, UIntPtr.Zero); + } + + /// + /// Sends a right mouse click at the specified screen coordinates. + /// + /// The x-coordinate of the screen position. + /// The y-coordinate of the screen position. + public static void SendRightClick(Primitive x, Primitive y) + { + SetCursorPosition((uint)x, (uint)y); + mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, (uint)x, (uint)y, 0, UIntPtr.Zero); + } + + /// + /// Sets the cursor position to the specified screen coordinates. + /// + /// The x-coordinate of the screen position. + /// The y-coordinate of the screen position. + private static void SetCursorPosition(uint x, uint y) + { + System.Windows.Forms.Cursor.Position = new System.Drawing.Point((int)x, (int)y); + } + + + /// + /// Returns the current system time as a string. + /// + /// The current system time in HH:mm:ss format. + public static Primitive GetCurrentTime() + { + return DateTime.Now.ToString("HH:mm:ss"); + } + + /// + /// Returns the current system date as a string. + /// + /// The current system date in yyyy-MM-dd format. + public static Primitive GetCurrentDate() + { + return DateTime.Now.ToString("yyyy-MM-dd"); + } + + /// + /// Generates a random number between the specified minimum and maximum values. + /// + /// The minimum value. + /// The maximum value. + /// A random number between min and max. + public static Primitive GenerateRandomNumber(Primitive min, Primitive max) + { + Random random = new Random(); + return random.Next((int)min, (int)max + 1); + } + + /// + /// Converts the given string to uppercase. + /// + /// The string to convert. + /// The uppercase version of the input string. + public static Primitive ConvertToUpperCase(Primitive input) + { + return input.ToString().ToUpper(); + } + + /// + /// Converts the given string to lowercase. + /// + /// The string to convert. + /// The lowercase version of the input string. + public static Primitive ConvertToLowerCase(Primitive input) + { + return input.ToString().ToLower(); + } + + /// + /// Throws an exception with the specified message. + /// + /// The message for the exception. + public static void ThrowException(Primitive message) + { + throw new Exception(message.ToString()); + } + + /// + /// Calculates the square root of a number. + /// + /// The number. + /// The square root of a. + public static Primitive CalculateSquareRoot(Primitive a) + { + return System.Math.Sqrt(a); + } + + /// + /// Gets the machine name of the current computer. + /// + /// The machine name. + public static Primitive GetMachineName() + { + return Environment.MachineName; + } + + /// + /// Gets the operating system version of the current computer. + /// + /// The operating system version. + public static Primitive GetOSVersion() + { + return Environment.OSVersion.ToString(); + } + + /// + /// Gets the value of an environment variable. + /// + /// The name of the environment variable. + /// The value of the environment variable. + public static Primitive GetEnvironmentVariable(Primitive variable) + { + return Environment.GetEnvironmentVariable(variable); + } + + /// + /// Opens the specified URL in the default web browser. + /// + /// The URL to open. + public static void OpenUrl(Primitive url) + { + System.Diagnostics.Process.Start(url.ToString()); + } + + /// + /// Gets the current working directory. + /// + /// The current working directory. + public static Primitive GetCurrentDirectory() + { + return Environment.CurrentDirectory; + } + + /// + /// Gets the user name of the currently logged-in user. + /// + /// The user name. + public static Primitive GetUserName() + { + return Environment.UserName; + } + + /// + /// Gets the current culture name. + /// + /// The name of the current culture. + public static Primitive GetCurrentCulture() + { + return System.Globalization.CultureInfo.CurrentCulture.Name; + } + + /// + /// Generates a random GUID (Globally Unique Identifier). + /// + /// A random GUID as a string. + public static Primitive GetRandomGuid() + { + return Guid.NewGuid().ToString(); + } + + /// + /// Plays a simple beep sound. + /// + public static void PlayBeep() + { + Console.Beep(); + } + + /// + /// Checks if a file exists at the specified path. + /// + /// The path of the file. + /// True if the file exists, otherwise false. + public static Primitive IsFileExists(Primitive filePath) + { + return System.IO.File.Exists(filePath.ToString()); + } + + /// + /// Gets the path of the temporary folder. + /// + /// The path of the temporary folder. + public static Primitive GetTempPath() + { + return System.IO.Path.GetTempPath(); + } + + /// + /// Gets a list of all drive names on the current computer. + /// + /// A comma-separated list of drive names. + public static Primitive GetAllDrives() + { + var drives = System.IO.DriveInfo.GetDrives(); + string driveNames = string.Join(",", drives.Select(d => d.Name)); + return driveNames; + } + + /// + /// Creates a directory at the specified path. + /// + /// The path of the directory to create. + public static void CreateDirectory(Primitive path) + { + System.IO.Directory.CreateDirectory(path.ToString()); + } + + /// + /// Gets the process ID of the current process. + /// + /// The process ID of the current process. + public static Primitive GetCurrentProcessId() + { + return System.Diagnostics.Process.GetCurrentProcess().Id; + } + + /// + /// Gets the path of the system directory. + /// + /// The path of the system directory. + public static Primitive GetSystemDirectory() + { + return Environment.SystemDirectory; + } + + /// + /// Gets the path of the user profile directory. + /// + /// The path of the user profile directory. + public static Primitive GetUserProfileDirectory() + { + return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + } + + /// + /// Gets the current UTC date and time. + /// + /// The current UTC date and time in yyyy-MM-dd HH:mm:ss format. + public static Primitive GetUtcNow() + { + return DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); + } + + /// + /// Gets the number of currently running processes on the system. + /// + /// The number of running processes. + public static Primitive GetProcessCount() + { + return System.Diagnostics.Process.GetProcesses().Length; + } + + + /// + /// Gets the ID of the current thread. + /// + /// The ID of the current thread. + public static Primitive GetCurrentThreadId() + { + return System.Threading.Thread.CurrentThread.ManagedThreadId; + } + + /// + /// Gets the current local date and time. + /// + /// The current local date and time in yyyy-MM-dd HH:mm:ss format. + public static Primitive GetLocalTime() + { + return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + + /// + /// Gets the number of milliseconds elapsed since the system started. + /// + /// The number of milliseconds since the system started. + public static Primitive GetTickCount() + { + return Environment.TickCount; + } + + /// + /// Checks if the current operating system is 64-bit. + /// + /// True if the operating system is 64-bit, otherwise false. + public static Primitive CheckIs64BitOperatingSystem() + { + return Environment.Is64BitOperatingSystem; + } + + /// + /// Checks if the current process is running in 64-bit mode. + /// + /// True if the process is 64-bit, otherwise false. + public static Primitive CheckIs64BitProcess() + { + return Environment.Is64BitProcess; + } + + /// + /// Gets the number of logical processors on the current machine. + /// + /// The number of logical processors. + public static Primitive GetLogicalProcessors() + { + return Environment.ProcessorCount; + } + + /// + /// Gets the name of the current application domain. + /// + /// The name of the current application domain. + public static Primitive GetAppDomainName() + { + return AppDomain.CurrentDomain.FriendlyName; + } + + /// + /// Gets the version of the currently executing assembly. + /// + /// The version of the current assembly. + public static Primitive GetAssemblyVersion() + { + return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + } + + /// + /// Checks if the application is running with administrative privileges. + /// + /// True if running as an administrator, otherwise false. + public static Primitive IsRunningAsAdmin() + { + var identity = System.Security.Principal.WindowsIdentity.GetCurrent(); + var principal = new System.Security.Principal.WindowsPrincipal(identity); + return principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator); + } + + /// + /// Gets the current system time zone. + /// + /// The name of the current time zone. + public static Primitive GetSystemTimeZone() + { + return TimeZoneInfo.Local.StandardName; + } + + /// + /// Gets a list of all logical drives on the system. + /// + /// A comma-separated list of drive names. + public static Primitive GetLogicalDrives() + { + return string.Join(",", Environment.GetLogicalDrives()); + } + + /// + /// Gets the title of the currently active window. + /// + /// The title of the active window. + public static Primitive GetActiveWindowTitle() + { + const int nChars = 256; + StringBuilder Buff = new StringBuilder(nChars); + IntPtr handle = GetForegroundWindow(); + if (GetWindowText(handle, Buff, nChars) > 0) { + return Buff.ToString(); + } + return string.Empty; + } + + [DllImport("user32.dll")] + private static extern IntPtr GetForegroundWindow(); + + [DllImport("user32.dll")] + private static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); + + /// + /// Captures a segment of the screen and saves it as an image file. + /// + /// The x-coordinate of the upper-left corner of the segment. + /// The y-coordinate of the upper-left corner of the segment. + /// The width of the segment. + /// The height of the segment. + /// The path where the image file will be saved. + public static void CaptureScreenSegment(Primitive x, Primitive y, Primitive width, Primitive height, Primitive filePath) + { + int startX = x; + int startY = y; + int segmentWidth = width; + int segmentHeight = height; + + Bitmap bitmap = new Bitmap(segmentWidth, segmentHeight); + Graphics graphics = Graphics.FromImage(bitmap); + graphics.CopyFromScreen(startX, startY, 0, 0, new Size(segmentWidth, segmentHeight)); + bitmap.Save(filePath.ToString(), System.Drawing.Imaging.ImageFormat.Png); + bitmap.Dispose(); + graphics.Dispose(); + } + + /// + /// Checks if a debugger is attached to the process. + /// + /// True if a debugger is attached, otherwise false. + public static Primitive IsDebuggerAttached() + { + return System.Diagnostics.Debugger.IsAttached; + } + + /// + /// Gets the ID of the current managed thread. + /// + /// The ID of the current managed thread. + public static Primitive GetCurrentManagedThreadId() + { + return System.Threading.Thread.CurrentThread.ManagedThreadId; + } + + /// + /// Gets the path of the system directory. + /// + /// The path of the system directory. + public static Primitive GetSystemDirectoryPath() + { + return Environment.SystemDirectory; + } + + /// + /// Gets the domain name associated with the current user. + /// + /// The domain name of the current user. + public static Primitive GetUserDomainName() + { + return Environment.UserDomainName; + } + + /// + /// Gets the version of the operating system. + /// + /// The version of the operating system. + public static Primitive GetOsVersion() + { + return Environment.OSVersion.ToString(); + } + + /// + /// Checks if the current process is running in user-interactive mode. + /// + /// True if the process is running in user-interactive mode, otherwise false. + public static Primitive GetUserInteractive() + { + return Environment.UserInteractive; + } + + /// + /// Gets the system uptime in seconds. + /// + /// The system uptime in seconds. + public static Primitive GetSystemUptime() + { + return Environment.TickCount / 1000; + } + + /// + /// Gets the current UI culture of the operating system. + /// + /// The name of the current UI culture. + public static Primitive GetCurrentUICulture() + { + return System.Globalization.CultureInfo.CurrentUICulture.Name; + } + + /// + /// Gets a list of installed font names on the system. + /// + /// A comma-separated list of installed font names. + public static Primitive GetInstalledFontNames() + { + var fonts = new List(); + using (var fontCollection = new InstalledFontCollection()) { + foreach (var fontFamily in fontCollection.Families) { + fonts.Add(fontFamily.Name); + } + } + return string.Join(",", fonts); + } + + /// + /// Gets a list of network interface names on the system. + /// + /// A comma-separated list of network interface names. + public static Primitive GetNetworkInterfaceNames() + { + var interfaces = NetworkInterface.GetAllNetworkInterfaces(); + var interfaceNames = interfaces.Select(ni => ni.Name).ToArray(); + return string.Join(",", interfaceNames); + } + + /// + /// Gets a list of running process names on the system. + /// + /// A comma-separated list of running process names. + public static Primitive GetRunningProcesses() + { + var processes = Process.GetProcesses(); + var processNames = processes.Select(p => p.ProcessName).ToArray(); + return string.Join(",", processNames); + } + + /// + /// Gets the battery charge status. + /// + /// The battery charge status as a percentage. + public static Primitive GetBatteryStatus() + { + var powerStatus = SystemInformation.PowerStatus; + return powerStatus.BatteryLifePercent * 100; + } + + /// + /// Gets the current text content from the clipboard. + /// + /// The text content from the clipboard, or an empty string if the clipboard is empty or does not contain text. + public static Primitive GetClipboardText() + { + string clipboardText = string.Empty; + if (Clipboard.ContainsText()) { + clipboardText = Clipboard.GetText(); + } + return clipboardText; + } + + /// + /// Sets the specified text content to the clipboard. + /// + /// The text content to set to the clipboard. + public static void SetClipboardText(Primitive text) + { + Clipboard.SetText(text.ToString()); + } + + /// + /// Gets the current CPU usage percentage. + /// + /// The current CPU usage percentage. + public static Primitive GetCpuUsage() + { + var cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); + cpuCounter.NextValue(); + System.Threading.Thread.Sleep(1000); // Allow time to collect data + return cpuCounter.NextValue(); + } + + /// + /// Gets the MAC address of the first operational network interface. + /// + /// The MAC address as a string, or an empty string if no operational network interface is found. + public static Primitive GetMacAddress() + { + var interfaces = NetworkInterface.GetAllNetworkInterfaces(); + foreach (var ni in interfaces) { + if (ni.OperationalStatus == OperationalStatus.Up) { + return string.Join(":", ni.GetPhysicalAddress().GetAddressBytes().Select(b => b.ToString("X2"))); + } + } + return string.Empty; + } + + /// + /// Gets the local IP address of the machine. + /// + /// The local IP address, or an empty string if no network connection is found. + public static Primitive GetIpAddress() + { + string localIp = string.Empty; + var host = Dns.GetHostEntry(Dns.GetHostName()); + foreach (var ip in host.AddressList) { + if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { + localIp = ip.ToString(); + break; + } + } + return localIp; + } + + /// + /// Gets the system drive letter (e.g., "C"). + /// + /// The system drive letter. + public static Primitive GetSystemDrive() + { + return Path.GetPathRoot(Environment.SystemDirectory); + } + + /// + /// Gets the name of the current user. + /// + /// The name of the current user. + public static Primitive GetCurrentUser() + { + return Environment.UserName; + } + + /// + /// Gets the size of the system's memory page in bytes. + /// + /// The size of the memory page in bytes. + public static Primitive GetSystemPageSize() + { + return Environment.SystemPageSize; + } + + /// + /// Gets the memory usage of the current process in bytes. + /// + /// The memory usage of the current process in bytes. + public static Primitive GetCurrentProcessMemoryUsage() + { + using (var process = Process.GetCurrentProcess()) { + return (Primitive)(double)process.WorkingSet64; + } + } + + /// + /// Downloads a file from the specified URL to the specified destination path. + /// + /// The URL of the file to download. + /// The path where the file will be saved. + public static void DownloadFile(Primitive url, Primitive destinationPath) + { + using (var client = new WebClient()) { + client.DownloadFile(url.ToString(), destinationPath.ToString()); + } + } + + /// + /// Gets the external IP address of the machine. + /// + /// The external IP address as a string. + public static Primitive GetExternalIpAddress() + { + using (var client = new WebClient()) { + string ip = client.DownloadString("http://icanhazip.com").Trim(); + return ip; + } + } + + /// + /// Gets the machine GUID (Globally Unique Identifier). + /// + /// The machine GUID as a string. + public static Primitive GetMachineGuid() + { + string key = @"SOFTWARE\Microsoft\Cryptography"; + string value = "MachineGuid"; + + using (var registryKey = Registry.LocalMachine.OpenSubKey(key)) { + if (registryKey != null) { + object machineGuid = registryKey.GetValue(value); + if (machineGuid != null) { + return machineGuid.ToString(); + } + } + } + return string.Empty; + } + + /// + /// Gets a list of running services on the machine. + /// + /// A comma-separated list of running service names. + public static Primitive GetRunningServices() + { + var services = ServiceController.GetServices(); + var runningServices = services.Where(s => s.Status == ServiceControllerStatus.Running) + .Select(s => s.ServiceName) + .ToArray(); + return string.Join(",", runningServices); + } + + /// + /// Captures a screenshot of the active window and saves it as an image file. + /// + /// The path where the image file will be saved. + public static void CaptureActiveWindow(Primitive filePath) + { + var handle = GetForegroundWindow(); + RECT rect; + GetWindowRect(handle, out rect); + + int width = rect.Right - rect.Left; + int height = rect.Bottom - rect.Top; + + var bitmap = new Bitmap(width, height); + var graphics = Graphics.FromImage(bitmap); + graphics.CopyFromScreen(rect.Left, rect.Top, 0, 0, new Size(width, height)); + bitmap.Save(filePath.ToString(), System.Drawing.Imaging.ImageFormat.Png); + bitmap.Dispose(); + graphics.Dispose(); + } + + + [DllImport("user32.dll")] + private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); + + private struct RECT + { + public int Left; + public int Top; + public int Right; + public int Bottom; + } + + /// + /// Starts a process with the specified arguments. + /// + /// The name of the process to start. + /// The arguments to pass to the process. + public static void StartProcessWithArguments(Primitive processName, Primitive arguments) + { + var startInfo = new ProcessStartInfo { + FileName = processName.ToString(), + Arguments = arguments.ToString(), + UseShellExecute = true + }; + Process.Start(startInfo); + } + + /// + /// Kills a process by its name. + /// + /// The name of the process to kill. + public static void KillProcessByName(Primitive processName) + { + var processes = Process.GetProcessesByName(processName.ToString()); + foreach (var process in processes) { + process.Kill(); + } + } + + /// + /// Gets a list of all files in the current directory. + /// + /// A comma-separated list of file names in the current directory. + public static Primitive GetCurrentDirectoryFiles() + { + var files = Directory.GetFiles(Environment.CurrentDirectory); + return string.Join(",", files.Select(Path.GetFileName)); + } + + /// + /// Sends an email using SMTP. + /// + /// The recipient email address. + /// The email subject. + /// The email body. + /// The SMTP server address. + /// The SMTP server port. + /// The SMTP server username. + /// The SMTP server password. + public static void SendEmail(Primitive to, Primitive subject, Primitive body, Primitive smtpServer, Primitive smtpPort, Primitive username, Primitive password) + { + var mail = new MailMessage(); + mail.To.Add(to.ToString()); + mail.Subject = subject.ToString(); + mail.Body = body.ToString(); + mail.From = new MailAddress(username.ToString()); + + var smtp = new SmtpClient(smtpServer.ToString(), smtpPort); + smtp.Credentials = new System.Net.NetworkCredential(username.ToString(), password.ToString()); + smtp.EnableSsl = true; + smtp.Send(mail); + + } + + /// + /// Generates a unique identifier (UUID) as a string. + /// + /// A UUID string. + public static Primitive GenerateUUID() + { + return Guid.NewGuid().ToString(); + } + + /// + /// Converts a number from one base to another base. + /// + /// The number to convert. + /// The base of the input number. + /// The base to convert the number to. + /// The converted number as a string. + public static Primitive ConvertBase(Primitive number, Primitive fromBase, Primitive toBase) + { + var numberString = number.ToString(); + var fromBaseInt = (int)fromBase; + var toBaseInt = (int)toBase; + var decimalValue = Convert.ToInt32(numberString, fromBaseInt); + return Convert.ToString(decimalValue, toBaseInt); + } + + /// + /// Gets a random item from an array of items. + /// + /// An array of items. + /// A random item from the array. + public static Primitive GetRandomItem(Primitive[] items) + { + var random = new Random(); + return items[random.Next(items.Length)]; + } + + /// + /// Checks if a given string is a palindrome. + /// + /// The string to check. + /// True if the string is a palindrome, otherwise false. + public static Primitive IsPalindrome(Primitive text) + { + var str = text.ToString(); + var reversed = new string(str.Reverse().ToArray()); + return str.Equals(reversed, StringComparison.OrdinalIgnoreCase); + } + + /// + /// Calculates the sum of the digits of a given number. + /// + /// The number whose digits are to be summed. + /// The sum of the digits. + public static Primitive SumOfDigits(Primitive number) + { + return number.ToString().Sum(c => c - '0'); + } + + /// + /// Generates a Fibonacci sequence of a given length. + /// + /// The length of the Fibonacci sequence. + /// An array containing the Fibonacci sequence. + public static Primitive[] GenerateFibonacciSequence(Primitive length) + { + int n = (int)length; + var sequence = new int[n]; + if (n > 0) + sequence[0] = 0; + if (n > 1) + sequence[1] = 1; + for (int i = 2; i < n; i++) { + sequence[i] = sequence[i - 1] + sequence[i - 2]; + } + return sequence.Cast().ToArray(); + } + + /// + /// Checks if a given number is a prime number. + /// + /// The number to check. + /// True if the number is prime, otherwise false. + public static Primitive IsPrime(Primitive number) + { + int n = (int)number; + if (n <= 1) + return false; + if (n <= 3) + return true; + if (n % 2 == 0 || n % 3 == 0) + return false; + for (int i = 5; i * i <= n; i += 6) { + if (n % i == 0 || n % (i + 2) == 0) + return false; + } + return true; + } + + /// + /// Calculates the Levenshtein distance between two strings. + /// + /// The source string. + /// The target string. + /// The Levenshtein distance between the two strings. + public static Primitive LevenshteinDistance(Primitive source, Primitive target) + { + var s = source.ToString(); + var t = target.ToString(); + var dp = new int[s.Length + 1, t.Length + 1]; + for (int i = 0; i <= s.Length; i++) + dp[i, 0] = i; + for (int j = 0; j <= t.Length; j++) + dp[0, j] = j; + for (int i = 1; i <= s.Length; i++) { + for (int j = 1; j <= t.Length; j++) { + var cost = (s[i - 1] == t[j - 1]) ? 0 : 1; + dp[i, j] = System.Math.Min(System.Math.Min(dp[i - 1, j] + 1, dp[i, j - 1] + 1), dp[i - 1, j - 1] + cost); + } + } + return dp[s.Length, t.Length]; + } + + /// + /// Converts a given string to title case (each word starts with a capital letter). + /// + /// The text to convert. + /// The text in title case. + public static Primitive ConvertToTitleCase(Primitive text) + { + var words = text.ToString().ToLower().Split(' '); + var titleCased = words.Select(word => char.ToUpper(word[0]) + word.Substring(1)).Aggregate((current, next) => current + " " + next); + return titleCased; + } + + /// + /// Calculates the factorial of a given number. + /// + /// The number to calculate the factorial for. + /// The factorial of the number. + public static Primitive Factorial(Primitive number) + { + int n = (int)number; + if (n < 0) + throw new ArgumentException("Number must be non-negative."); + return Enumerable.Range(1, n).Aggregate(1, (acc, x) => acc * x); + } + + /// + /// Finds the median value in a given array of numbers. + /// + /// The array of numbers. + /// The median value of the array. + public static Primitive FindMedian(Primitive[] array) + { + var sorted = array.OrderBy(n => n).ToArray(); + int middle = sorted.Length / 2; + if (sorted.Length % 2 == 0) { + return (sorted[middle - 1] + sorted[middle]) / 2; + } + return sorted[middle]; + } + + /// + /// Checks if a given number is an Armstrong number (Narcissistic number). + /// + /// The number to check. + /// True if the number is an Armstrong number, otherwise false. + public static Primitive IsArmstrong(Primitive number) + { + var numStr = number.ToString(); + var numLength = numStr.Length; + var sum = numStr.Sum(digit => (int)System.Math.Pow(digit - '0', numLength)); + return sum == (int)number; + } + + /// + /// Counts the number of words in a given string. + /// + /// The text to count words in. + /// The number of words in the text. + public static Primitive CountWords(Primitive text) + { + return text.ToString().Split(new[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).Length; + } + + /// + /// Generates a list of prime numbers up to a specified number. + /// + /// The upper limit to generate prime numbers up to. + /// An array of prime numbers up to the specified limit. + public static Primitive[] GeneratePrimesUpTo(Primitive limit) + { + var num = (int)limit; + var primes = new List(); + for (int i = 2; i <= num; i++) { + if (IsPrime(i)) + primes.Add(i); + } + return primes.Cast().ToArray(); + } + + /// + /// Calculates the length of the hypotenuse in a right triangle given the lengths of the other two sides. + /// + /// The length of one side. + /// The length of the other side. + /// The length of the hypotenuse. + public static Primitive CalculateHypotenuse(Primitive a, Primitive b) + { + return System.Math.Sqrt(System.Math.Pow((double)a, 2) + System.Math.Pow((double)b, 2)); + } + + /// + /// Counts the number of vowels in a given string. + /// + /// The text to count vowels in. + /// The number of vowels in the text. + public static Primitive CountVowels(Primitive text) + { + var vowels = "aeiouAEIOU"; + return text.ToString().Count(c => vowels.Contains(c)); + } + + /// + /// Finds all substrings of a specified length from a given string. + /// + /// The text to extract substrings from. + /// The length of each substring. + /// An array of substrings of the specified length. + public static Primitive[] FindSubstrings(Primitive text, Primitive length) + { + var str = text.ToString(); + var substrings = new List(); + for (int i = 0; i <= str.Length - (int)length; i++) { + substrings.Add(str.Substring(i, (int)length)); + } + return substrings.Cast().ToArray(); + } + + /// + /// Converts RGB color values to a hex color code. + /// + /// The red component (0-255). + /// The green component (0-255). + /// The blue component (0-255). + /// The hex color code as a string. + public static Primitive RGBToHex(Primitive red, Primitive green, Primitive blue) + { + int r = (int)red; + int g = (int)green; + int b = (int)blue; + return string.Format("#{0:X2}{1:X2}{2:X2}", r, g, b); + } + + /// + /// Checks if a given string represents a numeric value. + /// + /// The string to check. + /// True if the string is numeric, otherwise false. + public static Primitive IsNumeric(Primitive text) + { + double number; + return double.TryParse(text.ToString(), out number); + } + + /// + /// Removes duplicate values from an array. + /// + /// The array with possible duplicate values. + /// An array with duplicates removed. + public static Primitive[] RemoveDuplicates(Primitive[] array) + { + return array.Distinct().ToArray(); + } + + /// + /// Gets the name of the day of the week for a given date. + /// + /// The date to get the day of the week for. + /// The name of the day of the week. + public static Primitive GetDayOfWeek(Primitive date) + { + DateTime dt = DateTime.Parse(date.ToString()); + return dt.DayOfWeek.ToString(); + } + + /// + /// Sorts an array of numbers in descending order. + /// + /// The array to sort. + /// The sorted array in descending order. + public static Primitive[] SortDescending(Primitive[] array) + { + return array.OrderByDescending(n => n).ToArray(); + } + + /// + /// Calculates the age of a person given their birthdate. + /// + /// The birthdate to calculate the age from. + /// The age in years. + public static Primitive CalculateAge(Primitive birthdate) + { + DateTime dob = DateTime.Parse(birthdate.ToString()); + DateTime today = DateTime.Today; + int age = today.Year - dob.Year; + if (dob.Date > today.AddYears(-age)) + age--; + return age; + } + + /// + /// Checks if a given string contains only letters. + /// + /// The string to check. + /// True if the string contains only letters, otherwise false. + public static Primitive ContainsOnlyLetters(Primitive text) + { + return text.ToString().All(char.IsLetter); + } + + /// + /// Calculates compound interest over a specified number of periods. + /// + /// The principal amount. + /// The annual interest rate (as a decimal). + /// The number of periods per year. + /// The number of years the money is invested for. + /// The compound interest amount. + public static Primitive CalculateCompoundInterest(Primitive principal, Primitive rate, Primitive periods, Primitive years) + { + double p = (double)principal; + double r = (double)rate; + double n = (double)periods; + double t = (double)years; + double compoundInterest = p * System.Math.Pow(1 + r / n, n * t) - p; + return compoundInterest; + } + + /// + /// Converts a given string to Base64 encoding. + /// + /// The string to encode. + /// The Base64 encoded string. + public static Primitive ConvertToBase64(Primitive text) + { + byte[] bytes = Encoding.UTF8.GetBytes(text.ToString()); + return Convert.ToBase64String(bytes); + } + + /// + /// Finds the maximum value in an array of numbers. + /// + /// The array to search. + /// The maximum value in the array. + public static Primitive FindMax(Primitive[] array) + { + return array.Max(); + } + + /// + /// Finds the minimum value in an array of numbers. + /// + /// The array to search. + /// The minimum value in the array. + public static Primitive FindMin(Primitive[] array) + { + return array.Min(); + } + + /// + /// Calculates the greatest common divisor (GCD) of two integers using the Euclidean algorithm. + /// + /// The first integer. + /// The second integer. + /// The GCD of the two integers. + public static Primitive CalculateGCD(Primitive a, Primitive b) + { + int x = (int)a; + int y = (int)b; + while (y != 0) { + int temp = y; + y = x % y; + x = temp; + } + return x; + } + + /// + /// Generates a random password of a specified length containing letters and digits. + /// + /// The length of the password. + /// The generated password. + public static Primitive GenerateRandomPassword(Primitive length) + { + int len = (int)length; + const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + return new string(Enumerable.Repeat(chars, len) + .Select(s => s[random.Next(s.Length)]).ToArray()); + } + + /// + /// Converts a DateTime object to ISO 8601 format (yyyy-MM-ddTHH:mm:ssZ). + /// + /// The DateTime object to convert. + /// The ISO 8601 formatted date string. + public static Primitive ToIso8601(Primitive dateTime) + { + DateTime dt = DateTime.Parse(dateTime.ToString()); + return dt.ToString("yyyy-MM-ddTHH:mm:ssZ"); + } + + /// + /// Merges two arrays into a single array. + /// + /// The first array. + /// The second array. + /// The merged array. + public static Primitive[] MergeArrays(Primitive[] array1, Primitive[] array2) + { + return array1.Concat(array2).ToArray(); + } + + /// + /// Checks if a given number is even. + /// + /// The number to check. + /// True if the number is even, otherwise false. + public static Primitive IsEven(Primitive number) + { + int num = (int)number; + return num % 2 == 0; + } + + /// + /// Checks if a given number is odd. + /// + /// The number to check. + /// True if the number is odd, otherwise false. + public static Primitive IsOdd(Primitive number) + { + int num = (int)number; + return num % 2 != 0; + } + + /// + /// Converts a Base64 encoded string back to its original string representation. + /// + /// The Base64 encoded string. + /// The decoded string. + public static Primitive ConvertFromBase64(Primitive base64) + { + byte[] bytes = Convert.FromBase64String(base64.ToString()); + return Encoding.UTF8.GetString(bytes); + } + + /// + /// Gets a color from its RGB components. + /// + /// The red component (0-255). + /// The green component (0-255). + /// The blue component (0-255). + /// The color in string format. + public static Primitive GetColorFromRGB(Primitive red, Primitive green, Primitive blue) + { + Color color = Color.FromArgb((int)red, (int)green, (int)blue); + return color.ToArgb().ToString(); + } + + /// + /// Converts a color from its RGB components to a hexadecimal string. + /// + /// The color in RGB string format. + /// The color in hexadecimal format. + public static Primitive ConvertColorToHex(Primitive color) + { + Color c = ColorTranslator.FromHtml(color.ToString()); + return "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2"); + } + + /// + /// Converts a hexadecimal color string to an RGB color. + /// + /// The hexadecimal color string (e.g., "#RRGGBB"). + /// An array containing the RGB values. + public static Primitive[] HexToRGB(Primitive hexColor) + { + string hex = hexColor.ToString().TrimStart('#'); + int r = Convert.ToInt32(hex.Substring(0, 2), 16); + int g = Convert.ToInt32(hex.Substring(2, 2), 16); + int b = Convert.ToInt32(hex.Substring(4, 2), 16); + return new Primitive[] { r, g, b }; + } + + + + + + + } + + /// + /// Provides System.Environment Functions For Small Basic. + /// + [SmallBasicType] + public class ZSEnvironment + { + /// + /// Gets the command line for the application. + /// + /// The command line arguments for the application. + public static Primitive CommandLine { + get { + return string.Join(" ", Environment.GetCommandLineArgs()); + } + } + + /// + /// Gets or sets the fully qualified path of the current working directory. + /// + /// The path of the current working directory. + public static Primitive CurrentDirectory { + get { + return Environment.CurrentDirectory; + } + set { + Environment.CurrentDirectory = value; + } + } + + /// + /// Gets the name of the machine on which the application is running. + /// + /// The name of the machine. + public static Primitive MachineName { + get { + return Environment.MachineName; + } + } + + /// + /// Gets a string representing the newline character(s) used by the current environment. + /// + /// The newline characters used by the current environment. + public static Primitive NewLine { + get { + return Environment.NewLine; + } + } + + /// + /// Gets an OperatingSystem object that describes the current platform. + /// + /// The current platform as a string. + public static Primitive OSVersion { + get { + return Environment.OSVersion.ToString(); + } + } + + /// + /// Gets the number of processors on the current machine. + /// + /// The number of processors. + public static Primitive ProcessorCount { + get { + return Environment.ProcessorCount; + } + } + + /// + /// Gets a string representation of the current call stack. + /// + /// The current call stack as a string. + public static Primitive StackTrace { + get { + return Environment.StackTrace; + } + } + + /// + /// Gets the full path of the system directory. + /// + /// The path to the system directory. + public static Primitive SystemDirectory { + get { + return Environment.SystemDirectory; + } + } + + /// + /// Gets the number of milliseconds elapsed since the system started. + /// + /// The number of milliseconds since the system started. + public static Primitive TickCount { + get { + return Environment.TickCount; + } + } + + /// + /// Gets the domain name of the current user. + /// + /// The domain name of the current user. + public static Primitive UserDomainName { + get { + return Environment.UserDomainName; + } + } + + /// + /// Gets the user name of the current thread. + /// + /// The user name of the current thread. + public static Primitive UserName { + get { + return Environment.UserName; + } + } + + /// + /// Gets the version of the common language runtime (CLR) that is installed on the operating system. + /// + /// The version of the CLR. + public static Primitive Version { + get { + return Environment.Version.ToString(); + } + } + + /// + /// Gets the amount of physical memory allocated for the process. + /// + /// The amount of physical memory allocated for the process, in bytes. + public static long WorkingSet { + get { + return Environment.WorkingSet; + } + } + + /// + /// Terminates the process and gives the exit code to the operating system. + /// + /// The exit code to pass to the operating system. + public static void Exit(Primitive exitCode) + { + Environment.Exit(exitCode); + } + + /// + /// Returns the command-line arguments for the process. + /// + /// An array of strings representing the command-line arguments. + public static string[] GetCommandLineArgs() + { + return Environment.GetCommandLineArgs(); + } + + /// + /// Retrieves the value of an environment variable. + /// + /// The name of the environment variable. + /// The value of the environment variable. + public static Primitive GetEnvironmentVariable(Primitive variable) + { + return Environment.GetEnvironmentVariable(variable); + } + + /// + /// Retrieves the value of an environment variable, using the specified target. + /// + /// The name of the environment variable. + /// The target for the environment variable. + /// The value of the environment variable. + public static Primitive GetEnvironmentVariable(Primitive variable, EnvironmentVariableTarget target) + { + return Environment.GetEnvironmentVariable(variable, target); + } + + + + /// + /// Returns the names of the logical drives on the current machine. + /// + /// An array of strings representing the names of the logical drives. + public static string[] GetLogicalDrives() + { + return Environment.GetLogicalDrives(); + } + + /// + /// Retrieves the value of a resource string by its key.Currently WILL Give Nothing + /// + /// The key of the resource string. + /// The value of the resource string. + public static Primitive GetResourceString(Primitive key) + { + // Note: `GetResourceString` is not a method of `System.Environment` in .NET. + // This is just a placeholder for completeness. + // You might need to implement your own resource string retrieval method. + return string.Empty; + } + + /// + /// Sets the value of an environment variable. + /// + /// The name of the environment variable. + /// The value to set for the environment variable. + public static void SetEnvironmentVariable(Primitive variable, Primitive value) + { + Environment.SetEnvironmentVariable(variable, value); + } + + /// + /// Sets the value of an environment variable, using the specified target. + /// + /// The name of the environment variable. + /// The value to set for the environment variable. + /// The target for the environment variable. + public static void SetEnvironmentVariable(Primitive variable, Primitive value, EnvironmentVariableTarget target) + { + Environment.SetEnvironmentVariable(variable, value, target); + } + } + + /// + /// Provides System.Math Functions For Small Basic. + /// + [SmallBasicType] + public static class ZSMath + { + /// + /// Returns the absolute value of a specified number. + /// + /// A number whose absolute value is to be found. + /// The absolute value of the specified number. + public static Primitive Abs(Primitive value) + { + return System.Math.Abs((double)value); + } + + /// + /// Returns the angle whose cosine is the specified number. + /// + /// A number representing a cosine, where d must be greater than or equal to -1, but less than or equal to 1. + /// The angle, measured in radians, whose cosine is the specified number. + public static Primitive Acos(Primitive d) + { + return System.Math.Acos((double)d); + } + + /// + /// Returns the angle whose sine is the specified number. + /// + /// A number representing a sine, where d must be greater than or equal to -1, but less than or equal to 1. + /// The angle, measured in radians, whose sine is the specified number. + public static Primitive Asin(Primitive d) + { + return System.Math.Asin((double)d); + } + + /// + /// Returns the angle whose tangent is the specified number. + /// + /// A number representing a tangent. + /// The angle, measured in radians, whose tangent is the specified number. + public static Primitive Atan(Primitive d) + { + return System.Math.Atan((double)d); + } + + /// + /// Returns the angle whose tangent is the quotient of two specified numbers. + /// + /// The y-coordinate of a point. + /// The x-coordinate of a point. + /// The angle, measured in radians, whose tangent is the quotient of two specified numbers. + public static Primitive Atan2(Primitive y, Primitive x) + { + return System.Math.Atan2((double)y, (double)x); + } + + /// + /// Returns the smallest integer greater than or equal to the specified number. + /// + /// A number. + /// The smallest integer greater than or equal to the specified number. + public static Primitive Ceiling(Primitive a) + { + return System.Math.Ceiling((double)a); + } + + /// + /// Returns the cosine of the specified angle. + /// + /// An angle, measured in radians. + /// The cosine of the specified angle. + public static Primitive Cos(Primitive d) + { + return System.Math.Cos((double)d); + } + + /// + /// Returns the hyperbolic cosine of the specified angle. + /// + /// An angle, measured in radians. + /// The hyperbolic cosine of the specified angle. + public static Primitive Cosh(Primitive value) + { + return System.Math.Cosh((double)value); + } + + /// + /// Returns e raised to the specified power. + /// + /// A number specifying a power. + /// The number e raised to the specified power. + public static Primitive Exp(Primitive d) + { + return System.Math.Exp((double)d); + } + + /// + /// Returns the largest integer less than or equal to the specified number. + /// + /// A number. + /// The largest integer less than or equal to the specified number. + public static Primitive Floor(Primitive d) + { + return System.Math.Floor((double)d); + } + + /// + /// Returns the remainder resulting from the division of a specified number by another specified number. + /// + /// A dividend. + /// A divisor. + /// A number equal to x - (y * Q), where Q is the quotient of x / y rounded to the nearest integer. + public static Primitive IEEERemainder(Primitive x, Primitive y) + { + return System.Math.IEEERemainder((double)x, (double)y); + } + + /// + /// Returns the natural (base e) logarithm of a specified number. + /// + /// A number whose logarithm is to be found. + /// The natural (base e) logarithm of the specified number. + public static Primitive Log(Primitive d) + { + return System.Math.Log((double)d); + } + + /// + /// Returns the base 10 logarithm of a specified number. + /// + /// A number whose logarithm is to be found. + /// The base 10 logarithm of the specified number. + public static Primitive Log10(Primitive d) + { + return System.Math.Log10((double)d); + } + + /// + /// Returns the larger of two specified numbers. + /// + /// The first of two numbers to compare. + /// The second of two numbers to compare. + /// The larger of the two numbers. + public static Primitive Max(Primitive val1, Primitive val2) + { + return System.Math.Max((double)val1, (double)val2); + } + + /// + /// Returns the smaller of two specified numbers. + /// + /// The first of two numbers to compare. + /// The second of two numbers to compare. + /// The smaller of the two numbers. + public static Primitive Min(Primitive val1, Primitive val2) + { + return System.Math.Min((double)val1, (double)val2); + } + + /// + /// Returns a specified number raised to the specified power. + /// + /// A double-precision floating-point number to be raised to a power. + /// A double-precision floating-point number that specifies a power. + /// The number x raised to the power y. + public static Primitive Pow(Primitive x, Primitive y) + { + return System.Math.Pow((double)x, (double)y); + } + + /// + /// Rounds a specified number to the nearest integer. + /// + /// A number to be rounded. + /// The integer nearest to the specified number. + public static Primitive Round(Primitive a) + { + return System.Math.Round((double)a); + } + + /// + /// Returns a value indicating the sign of a number. + /// + /// A signed number. + /// A number indicating the sign of the specified number. + public static Primitive Sign(Primitive value) + { + return System.Math.Sign((double)value); + } + + /// + /// Returns the sine of the specified angle. + /// + /// An angle, measured in radians. + /// The sine of the specified angle. + public static Primitive Sin(Primitive a) + { + return System.Math.Sin((double)a); + } + + /// + /// Returns the hyperbolic sine of the specified angle. + /// + /// An angle, measured in radians. + /// The hyperbolic sine of the specified angle. + public static Primitive Sinh(Primitive value) + { + return System.Math.Sinh((double)value); + } + + /// + /// Returns the square root of a specified number. + /// + /// A number. + /// The square root of the specified number. + public static Primitive Sqrt(Primitive d) + { + return System.Math.Sqrt((double)d); + } + + /// + /// Returns the tangent of the specified angle. + /// + /// An angle, measured in radians. + /// The tangent of the specified angle. + public static Primitive Tan(Primitive a) + { + return System.Math.Tan((double)a); + } + + /// + /// Returns the hyperbolic tangent of the specified angle. + /// + /// An angle, measured in radians. + /// The hyperbolic tangent of the specified angle. + public static Primitive Tanh(Primitive value) + { + return System.Math.Tanh((double)value); + } + + /// + /// Calculates the integral part of a specified number. + /// + /// A number to truncate. + /// The integral part of the specified number. + public static Primitive Truncate(Primitive d) + { + return System.Math.Truncate((double)d); + } + + /// + /// Represents the natural logarithmic base, specified by the constant, e. + /// + public static Primitive E { + get { + return System.Math.E; + } + + } + + + + + + /// + /// Represents the ratio of the circumference of a circle to its diameter, specified by the constant, PI. + /// + public static Primitive PI { + get { + return System.Math.PI; + + } + + } + } + + + /// + /// Provides methods and properties for managing processes. + /// This class allows you to start new processes, manage process information, and interact with running processes. + /// It includes functionalities for: + /// - Starting processes with or without arguments + /// - Retrieving process IDs and names + /// - Getting and setting process-related information such as file path, arguments, priority, and more + /// + [SmallBasicType] + public static class ZSProcess + { + private static Process process = new Process(); + + /// + /// Starts a new process with the specified executable file path. + /// + /// The path of the executable file to start. Example: "C:\\Windows\\System32\\notepad.exe" + public static void StartProcess(Primitive filePath) + { + Process.Start((string)filePath); + } + + /// + /// Starts a new process with the specified executable file path and arguments. + /// + /// The path of the executable file to start. Example: "C:\\Windows\\System32\\cmd.exe" + /// The arguments to pass to the executable file. Example: "/c echo Hello World" + public static void StartProcessWithArgs(Primitive filePath, Primitive arguments) + { + Process.Start((string)filePath, (string)arguments); + } + + /// + /// Starts a new process with the specified ProcessStartInfo. + /// + /// The path of the executable file to start. Example: "C:\\Windows\\System32\\notepad.exe" + /// The arguments to pass to the executable file. Example: "" + public static void StartProcessWithInfo(Primitive filePath, Primitive arguments) + { + ProcessStartInfo startInfo = new ProcessStartInfo { + FileName = (string)filePath, + Arguments = (string)arguments + }; + Process.Start(startInfo); + } + + /// + /// Gets or sets the file path of the application to start. + /// + /// + /// To set the file path:
+ /// ZSProcess.FilePath = "C:\\Windows\\System32\\notepad.exe" + ///
+ public static Primitive FilePath { + get { return process.StartInfo.FileName; } + set { process.StartInfo.FileName = (string)value; } + } + + /// + /// Gets or sets the arguments to pass to the executable file. + /// + /// + /// To set arguments:
+ /// ZSProcess.Arguments = "/c echo Hello World" + ///
+ public static Primitive Arguments { + get { return process.StartInfo.Arguments; } + set { process.StartInfo.Arguments = (string)value; } + } + + /// + /// Gets or sets a value that indicates whether to use the operating system shell to start the process. + /// + /// + /// To enable shell execution:
+ /// ZSProcess.UseShellExecute = true + ///
+ public static Primitive UseShellExecute { + get { return process.StartInfo.UseShellExecute; } + set { process.StartInfo.UseShellExecute = (bool)value; } + } + + /// + /// Gets or sets a value that determines whether to redirect standard input, output, and error streams. + /// + /// + /// To enable redirection:
+ /// ZSProcess.RedirectStandardOutput = true + ///
+ public static Primitive RedirectStandardOutput { + get { return process.StartInfo.RedirectStandardOutput; } + set { process.StartInfo.RedirectStandardOutput = (bool)value; } + } + + /// + /// Gets or sets the value of the process priority. + /// + /// + /// To set priority class:
+ /// ZSProcess.PriorityClass = "High" + ///
+ public static Primitive PriorityClass { + get { return process.PriorityClass.ToString(); } + set { process.PriorityClass = (ProcessPriorityClass)Enum.Parse(typeof(ProcessPriorityClass), (string)value); } + } + + /// + /// Gets or sets a value that indicates whether to create a new window for the process. + /// + /// + /// To disable window creation:
+ /// ZSProcess.CreateNoWindow = true + ///
+ public static Primitive CreateNoWindow { + get { return process.StartInfo.CreateNoWindow; } + set { process.StartInfo.CreateNoWindow = (bool)value; } + } + + /// + /// Gets a list of process IDs for all running processes on the local machine. + /// + /// A comma-separated string of process IDs. Example: "1234,5678" + public static Primitive GetProcessIds() + { + Process[] processes = Process.GetProcesses(); + string ids = string.Join(",", System.Array.ConvertAll(processes, p => p.Id.ToString())); + return ids; + } + + /// + /// Gets the process name for a specified process ID. + /// + /// The process ID. Example: 1234 + /// The process name. Example: "notepad" + public static Primitive GetProcessName(Primitive id) + { + try { + Process process = Process.GetProcessById((int)id); + return process.ProcessName; + } catch { + return "Invalid Process ID"; + } + } + + /// + /// Gets the process ID of the currently managed process. + /// + /// The process ID. Example: 1234 + public static Primitive GetProcessId() + { + return process.Id; + } + + /// + /// Gets the start time of the currently managed process. + /// + /// The start time of the process. Example: "2024-07-24 14:30:00" + public static Primitive GetStartTime() + { + return process.StartTime.ToString(); + } + + /// + /// Gets the exit time of the currently managed process. + /// + /// The exit time of the process. Example: "2024-07-24 15:00:00" + public static Primitive GetExitTime() + { + return process.ExitTime.ToString(); + } + + /// + /// Gets a value indicating whether the currently managed process has exited. + /// + /// true if the process has exited; otherwise, false. + public static Primitive HasExited() + { + return process.HasExited; + } + + /// + /// Gets the title of the main window of the currently managed process. + /// + /// The main window title. Example: "Untitled - Notepad" + public static Primitive GetMainWindowTitle() + { + return process.MainWindowTitle; + } + + /// + /// Gets a value indicating whether the currently managed process is responding. + /// + /// true if the process is responding; otherwise, false. + public static Primitive IsResponding() + { + return process.Responding; + } + + /// + /// Gets the total processor time for the currently managed process. + /// + /// The total processor time. Example: "00:00:01.2345678" + public static Primitive GetTotalProcessorTime() + { + return process.TotalProcessorTime.ToString(); + } + } + + /// + /// Provides methods and properties for working with globalization, including culture information, date and time formatting, number formatting, and text information. + /// This class also includes support for various calendars such as Gregorian, Hijri, Chinese, and Korean. + /// + [SmallBasicType] + public static class ZSGlobalization + { + private static CultureInfo cultureInfo = CultureInfo.CurrentCulture; + + /// + /// Gets or sets the current culture. Example: "en-US" + /// + /// + /// Get the current culture:
+ /// currentCulture = ZSGlobalization.CurrentCulture
+ /// Set the current culture to French (France):
+ /// ZSGlobalization.CurrentCulture = "fr-FR" + ///
+ public static Primitive CurrentCulture { + get { return cultureInfo.Name; } + set { cultureInfo = new CultureInfo((string)value); } + } + + /// + /// Gets the name of the calendar used by the current culture. Example: "GregorianCalendar" + /// + public static Primitive Calendar { + get { return cultureInfo.Calendar.ToString(); } + } + + /// + /// Gets or sets the date and time pattern for short dates. Example: "MM/dd/yyyy" + /// + /// + /// Get the short date pattern:
+ /// shortDatePattern = ZSGlobalization.ShortDatePattern
+ /// Set the short date pattern to day/month/year:
+ /// ZSGlobalization.ShortDatePattern = "dd/MM/yyyy" + ///
+ public static Primitive ShortDatePattern { + get { return cultureInfo.DateTimeFormat.ShortDatePattern; } + set { cultureInfo.DateTimeFormat.ShortDatePattern = (string)value; } + } + + /// + /// Gets or sets the date and time pattern for long dates. Example: "dddd, MMMM dd, yyyy" + /// + /// + /// Get the long date pattern:
+ /// longDatePattern = ZSGlobalization.LongDatePattern
+ /// Set the long date pattern to day of week, day month year:
+ /// ZSGlobalization.LongDatePattern = "dddd, dd MMMM yyyy" + ///
+ public static Primitive LongDatePattern { + get { return cultureInfo.DateTimeFormat.LongDatePattern; } + set { cultureInfo.DateTimeFormat.LongDatePattern = (string)value; } + } + + /// + /// Gets or sets the number decimal separator. Example: "." + /// + /// + /// Get the number decimal separator:
+ /// decimalSeparator = ZSGlobalization.NumberDecimalSeparator
+ /// Set the number decimal separator to a comma:
+ /// ZSGlobalization.NumberDecimalSeparator = "," + ///
+ public static Primitive NumberDecimalSeparator { + get { return cultureInfo.NumberFormat.NumberDecimalSeparator; } + set { cultureInfo.NumberFormat.NumberDecimalSeparator = (string)value; } + } + + /// + /// Gets or sets the currency symbol. Example: "$" + /// + /// + /// Get the currency symbol:
+ /// currencySymbol = ZSGlobalization.CurrencySymbol
+ /// Set the currency symbol to Euro:
+ /// ZSGlobalization.CurrencySymbol = "€" + ///
+ public static Primitive CurrencySymbol { + get { return cultureInfo.NumberFormat.CurrencySymbol; } + set { cultureInfo.NumberFormat.CurrencySymbol = (string)value; } + } + + + /// + /// Gets the text information (casing) of the current culture. Example: "Invariant" + /// + /// + /// Get the text info:
+ /// textInfo = ZSGlobalization.TextInfo + ///
+ public static Primitive TextInfo { + get { return cultureInfo.TextInfo.ToString(); } + } + + /// + /// Sets the text information (casing) of the culture. Example: "tr-TR" + /// + /// + /// Set the text info to a new culture:
+ /// ZSGlobalization.SetTextInfo("tr-TR") + ///
+ /// The name of the culture whose text info is to be used. + //public static void SetTextInfo(Primitive cultureName) + //{ + // cultureInfo = new CultureInfo(cultureInfo.Name) + // { + // TextInfo = new CultureInfo((string)cultureName).TextInfo + // }; + //} + + /// + /// Gets the ISO 639-1 two-letter code for the language of the current culture. Example: "en" + /// + public static Primitive TwoLetterISOLanguageName { + get { return cultureInfo.TwoLetterISOLanguageName; } + } + + /// + /// Gets the ISO 639-2 three-letter code for the language of the current culture. Example: "eng" + /// + public static Primitive ThreeLetterISOLanguageName { + get { return cultureInfo.ThreeLetterISOLanguageName; } + } + + /// + /// Gets the Windows three-letter code for the language of the current culture. Example: "ENU" + /// + public static Primitive ThreeLetterWindowsLanguageName { + get { return cultureInfo.ThreeLetterWindowsLanguageName; } + } + + /// + /// Gets the native name of the language of the current culture. Example: "English" + /// + public static Primitive NativeName { + get { return cultureInfo.NativeName; } + } + + // Additional calendar support + + /// + /// Gets the current date in the Hijri calendar. + /// + public static Primitive HijriDate { + get { + HijriCalendar hijriCalendar = new HijriCalendar(); + DateTime dateTime = DateTime.Now; + return hijriCalendar.GetYear(dateTime) + "/" + hijriCalendar.GetMonth(dateTime) + "/" + hijriCalendar.GetDayOfMonth(dateTime); + } + } + + /// + /// Gets the current date in the Chinese calendar. + /// + public static Primitive ChineseDate { + get { + ChineseLunisolarCalendar chineseCalendar = new ChineseLunisolarCalendar(); + DateTime dateTime = DateTime.Now; + return chineseCalendar.GetYear(dateTime) + "/" + chineseCalendar.GetMonth(dateTime) + "/" + chineseCalendar.GetDayOfMonth(dateTime); + } + } + + /// + /// Gets the current date in the Gregorian calendar. + /// + public static Primitive GregorianDate { + get { + GregorianCalendar gregorianCalendar = new GregorianCalendar(); + DateTime dateTime = DateTime.Now; + return gregorianCalendar.GetYear(dateTime) + "/" + gregorianCalendar.GetMonth(dateTime) + "/" + gregorianCalendar.GetDayOfMonth(dateTime); + } + } + + /// + /// Gets the current date in the Korean calendar. + /// + public static Primitive KoreanDate { + get { + KoreanCalendar koreanCalendar = new KoreanCalendar(); + DateTime dateTime = DateTime.Now; + return koreanCalendar.GetYear(dateTime) + "/" + koreanCalendar.GetMonth(dateTime) + "/" + koreanCalendar.GetDayOfMonth(dateTime); + } + } + } + + + } diff --git a/ZS/ZS.csproj b/ZS/ZS.csproj index 64145dd..42032c8 100644 --- a/ZS/ZS.csproj +++ b/ZS/ZS.csproj @@ -46,6 +46,9 @@ 4.0 + + ..\..\..\..\..\..\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.VisualBasic.dll + E:\study\code\Small Basic\SmallBasicLibrary.dll @@ -59,6 +62,9 @@ ..\..\..\..\..\..\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Runtime.InteropServices.dll + + ..\..\..\..\..\..\Windows\Microsoft.NET\Framework64\v4.0.30319\System.ServiceProcess.dll + ..\..\..\..\..\..\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Web.dll diff --git a/ZS/bin/Debug/ZS.dll b/ZS/bin/Debug/ZS.dll index 625d6de..d6ce5f5 100644 Binary files a/ZS/bin/Debug/ZS.dll and b/ZS/bin/Debug/ZS.dll differ diff --git a/ZS/bin/Debug/ZS.xml b/ZS/bin/Debug/ZS.xml index cc81202..678b005 100644 --- a/ZS/bin/Debug/ZS.xml +++ b/ZS/bin/Debug/ZS.xml @@ -627,11 +627,12 @@ The buttons to display in the message box (OK, OKCancel, YesNo). The text of the button that was clicked. - + - Shows a progress dialog with a specified message. + Shows a progress dialog with a specified message and duration. The message to display in the progress dialog. + The duration in seconds for which the progress dialog should be displayed. @@ -659,20 +660,6 @@ The title of the confirmation dialog. Returns true if Yes is clicked, otherwise returns false. - - - Shows a save file dialog and returns the selected file path. - - The file types filter (e.g., "Text Files|*.txt|All Files|*.*"). - The path of the selected file or an empty string if canceled. - - - - Shows an open file dialog and returns the selected file path. - - The file types filter (e.g., "Text Files|*.txt|All Files|*.*"). - The path of the selected file or an empty string if canceled. - Shows a color dialog and returns the selected color as a string in the format "R,G,B". @@ -683,8 +670,15 @@ Shows an open file dialog with multi-select enabled and returns the selected file paths. - The file types filter (e.g., "Text Files|*.txt|All Files|*.*"). + The file types filter in the format "Display Name1|Pattern1|Display Name2|Pattern2|...". A semicolon-separated list of selected file paths or an empty string if canceled. + + Filters should be specified in pairs where: + - Display Name: The name shown in the dialog's filter dropdown. + - Pattern: The file pattern to filter files by extension (e.g., "*.txt", "*.jpg"). + Multiple filters can be separated by vertical bars ('|'). For example: + "Text Files|*.txt|All Files|*.*" + @@ -717,12 +711,12 @@ The path of the selected image file or an empty string if canceled. - + - Provides General Utilities For Small Basic. + Provides Image Functions For Small Basic. - + Determines if a sub-image is present within a main image. @@ -730,5 +724,1521 @@ The file path of the sub-image. True if the sub-image is found within the main image, otherwise false. + + + Captures the entire screen and saves it as a PNG file. + + The file path where the screenshot will be saved. + True if the screen capture was successful; otherwise, false. + + + + Resizes an image to the specified width and height. + + The file path of the input image. + The file path where the resized image will be saved. + The width of the resized image. + The height of the resized image. + True if the image resizing was successful; otherwise, false. + + + + Gets the width of an image. + + The file path of the image. + The width of the image. + + + + Gets the height of an image. + + The file path of the image. + The height of the image. + + + + Provides File Functions For Small Basic. + + + + + Reads the content of a file. + + The path of the file to read. + The content of the file. + + + + Writes content to a file. + + The path of the file to write to. + The content to write. + "Success" if the operation was successful; otherwise, an error message. + + + + Copies a file to a new location. + + The path of the file to copy. + The path where the file will be copied to. + "Success" if the operation was successful; otherwise, an error message. + + + + Deletes a file. + + The path of the file to delete. + "Success" if the operation was successful; otherwise, an error message. + + + + Checks if a file exists. + + The path of the file to check. + True if the file exists; otherwise, false. + + + + Moves a file to a new location. + + The path of the file to move. + The path where the file will be moved to. + "Success" if the operation was successful; otherwise, an error message. + + + + Creates a directory. + + The path of the directory to create. + "Success" if the operation was successful; otherwise, an error message. + + + + Lists all files in a directory. + + The path of the directory to list files from. + A comma-separated string of file paths. + + + + Renames a file. + + The current path of the file to rename. + The new path and name for the file. + "Success" if the operation was successful; otherwise, an error message. + + + + Checks if a directory exists. + + The path of the directory to check. + True if the directory exists; otherwise, false. + + + + Deletes a directory. + + The path of the directory to delete. + "Success" if the operation was successful; otherwise, an error message. + + + + Moves a directory to a new location. + + The current path of the directory to move. + The new path for the directory. + "Success" if the operation was successful; otherwise, an error message. + + + + Retrieves the last write time of a file. + + The path of the file to retrieve the last write time from. + A string representation of the last write time; or an error message if an exception occurs. + + + + Retrieves the size of a file. + + The path of the file to get the size of. + The size of the file in bytes, or an error message if an exception occurs. + + + + Retrieves the extension of a file. + + The path of the file to get the extension of. + The extension of the file, or an error message if an exception occurs. + + + + Creates a text file with specified content. + + The path of the file to create. + The content to write to the file. + "Success" if the operation was successful; otherwise, an error message. + + + + Appends content to an existing file. + + The path of the file to append to. + The content to append. + "Success" if the operation was successful; otherwise, an error message. + + + + Retrieves the creation time of a file. + + The path of the file to retrieve the creation time from. + A string representation of the creation time, or an error message if an exception occurs. + + + + Reads all lines from a file. + + The path of the file to read from. + A list of all lines in the file, or an error message if an exception occurs. + + + + Retrieves the attributes of a file. + + The path of the file to get the attributes of. + The attributes of the file, or an error message if an exception occurs. + + + + Retrieves the last access time of a file. + + The path of the file to retrieve the last access time from. + A string representation of the last access time, or an error message if an exception occurs. + + + + Deletes a directory and optionally all its contents. + + The path of the directory to delete. + True to delete the directory, its subdirectories, and all files; otherwise, false. + "Success" if the operation was successful; otherwise, an error message. + + + + Retrieves the file name and extension of a file path. + + The path of the file to retrieve the name from. + The file name and extension, or an error message if an exception occurs. + + + + Provides General Utilities Functions For Small Basic. + + + + + Sends a left mouse click at the specified screen coordinates. + + The x-coordinate of the screen position. + The y-coordinate of the screen position. + + + + Sends a right mouse click at the specified screen coordinates. + + The x-coordinate of the screen position. + The y-coordinate of the screen position. + + + + Sets the cursor position to the specified screen coordinates. + + The x-coordinate of the screen position. + The y-coordinate of the screen position. + + + + Returns the current system time as a string. + + The current system time in HH:mm:ss format. + + + + Returns the current system date as a string. + + The current system date in yyyy-MM-dd format. + + + + Generates a random number between the specified minimum and maximum values. + + The minimum value. + The maximum value. + A random number between min and max. + + + + Converts the given string to uppercase. + + The string to convert. + The uppercase version of the input string. + + + + Converts the given string to lowercase. + + The string to convert. + The lowercase version of the input string. + + + + Throws an exception with the specified message. + + The message for the exception. + + + + Calculates the square root of a number. + + The number. + The square root of a. + + + + Gets the machine name of the current computer. + + The machine name. + + + + Gets the operating system version of the current computer. + + The operating system version. + + + + Gets the value of an environment variable. + + The name of the environment variable. + The value of the environment variable. + + + + Opens the specified URL in the default web browser. + + The URL to open. + + + + Gets the current working directory. + + The current working directory. + + + + Gets the user name of the currently logged-in user. + + The user name. + + + + Gets the current culture name. + + The name of the current culture. + + + + Generates a random GUID (Globally Unique Identifier). + + A random GUID as a string. + + + + Plays a simple beep sound. + + + + + Checks if a file exists at the specified path. + + The path of the file. + True if the file exists, otherwise false. + + + + Gets the path of the temporary folder. + + The path of the temporary folder. + + + + Gets a list of all drive names on the current computer. + + A comma-separated list of drive names. + + + + Creates a directory at the specified path. + + The path of the directory to create. + + + + Gets the process ID of the current process. + + The process ID of the current process. + + + + Gets the path of the system directory. + + The path of the system directory. + + + + Gets the path of the user profile directory. + + The path of the user profile directory. + + + + Gets the current UTC date and time. + + The current UTC date and time in yyyy-MM-dd HH:mm:ss format. + + + + Gets the number of currently running processes on the system. + + The number of running processes. + + + + Gets the ID of the current thread. + + The ID of the current thread. + + + + Gets the current local date and time. + + The current local date and time in yyyy-MM-dd HH:mm:ss format. + + + + Gets the number of milliseconds elapsed since the system started. + + The number of milliseconds since the system started. + + + + Checks if the current operating system is 64-bit. + + True if the operating system is 64-bit, otherwise false. + + + + Checks if the current process is running in 64-bit mode. + + True if the process is 64-bit, otherwise false. + + + + Gets the number of logical processors on the current machine. + + The number of logical processors. + + + + Gets the name of the current application domain. + + The name of the current application domain. + + + + Gets the version of the currently executing assembly. + + The version of the current assembly. + + + + Checks if the application is running with administrative privileges. + + True if running as an administrator, otherwise false. + + + + Gets the current system time zone. + + The name of the current time zone. + + + + Gets a list of all logical drives on the system. + + A comma-separated list of drive names. + + + + Gets the title of the currently active window. + + The title of the active window. + + + + Captures a segment of the screen and saves it as an image file. + + The x-coordinate of the upper-left corner of the segment. + The y-coordinate of the upper-left corner of the segment. + The width of the segment. + The height of the segment. + The path where the image file will be saved. + + + + Checks if a debugger is attached to the process. + + True if a debugger is attached, otherwise false. + + + + Gets the ID of the current managed thread. + + The ID of the current managed thread. + + + + Gets the path of the system directory. + + The path of the system directory. + + + + Gets the domain name associated with the current user. + + The domain name of the current user. + + + + Gets the version of the operating system. + + The version of the operating system. + + + + Checks if the current process is running in user-interactive mode. + + True if the process is running in user-interactive mode, otherwise false. + + + + Gets the system uptime in seconds. + + The system uptime in seconds. + + + + Gets the current UI culture of the operating system. + + The name of the current UI culture. + + + + Gets a list of installed font names on the system. + + A comma-separated list of installed font names. + + + + Gets a list of network interface names on the system. + + A comma-separated list of network interface names. + + + + Gets a list of running process names on the system. + + A comma-separated list of running process names. + + + + Gets the battery charge status. + + The battery charge status as a percentage. + + + + Gets the current text content from the clipboard. + + The text content from the clipboard, or an empty string if the clipboard is empty or does not contain text. + + + + Sets the specified text content to the clipboard. + + The text content to set to the clipboard. + + + + Gets the current CPU usage percentage. + + The current CPU usage percentage. + + + + Gets the MAC address of the first operational network interface. + + The MAC address as a string, or an empty string if no operational network interface is found. + + + + Gets the local IP address of the machine. + + The local IP address, or an empty string if no network connection is found. + + + + Gets the system drive letter (e.g., "C"). + + The system drive letter. + + + + Gets the name of the current user. + + The name of the current user. + + + + Gets the size of the system's memory page in bytes. + + The size of the memory page in bytes. + + + + Gets the memory usage of the current process in bytes. + + The memory usage of the current process in bytes. + + + + Downloads a file from the specified URL to the specified destination path. + + The URL of the file to download. + The path where the file will be saved. + + + + Gets the external IP address of the machine. + + The external IP address as a string. + + + + Gets the machine GUID (Globally Unique Identifier). + + The machine GUID as a string. + + + + Gets a list of running services on the machine. + + A comma-separated list of running service names. + + + + Captures a screenshot of the active window and saves it as an image file. + + The path where the image file will be saved. + + + + Starts a process with the specified arguments. + + The name of the process to start. + The arguments to pass to the process. + + + + Kills a process by its name. + + The name of the process to kill. + + + + Gets a list of all files in the current directory. + + A comma-separated list of file names in the current directory. + + + + Sends an email using SMTP. + + The recipient email address. + The email subject. + The email body. + The SMTP server address. + The SMTP server port. + The SMTP server username. + The SMTP server password. + + + + Generates a unique identifier (UUID) as a string. + + A UUID string. + + + + Converts a number from one base to another base. + + The number to convert. + The base of the input number. + The base to convert the number to. + The converted number as a string. + + + + Gets a random item from an array of items. + + An array of items. + A random item from the array. + + + + Checks if a given string is a palindrome. + + The string to check. + True if the string is a palindrome, otherwise false. + + + + Calculates the sum of the digits of a given number. + + The number whose digits are to be summed. + The sum of the digits. + + + + Generates a Fibonacci sequence of a given length. + + The length of the Fibonacci sequence. + An array containing the Fibonacci sequence. + + + + Checks if a given number is a prime number. + + The number to check. + True if the number is prime, otherwise false. + + + + Calculates the Levenshtein distance between two strings. + + The source string. + The target string. + The Levenshtein distance between the two strings. + + + + Converts a given string to title case (each word starts with a capital letter). + + The text to convert. + The text in title case. + + + + Calculates the factorial of a given number. + + The number to calculate the factorial for. + The factorial of the number. + + + + Finds the median value in a given array of numbers. + + The array of numbers. + The median value of the array. + + + + Checks if a given number is an Armstrong number (Narcissistic number). + + The number to check. + True if the number is an Armstrong number, otherwise false. + + + + Counts the number of words in a given string. + + The text to count words in. + The number of words in the text. + + + + Generates a list of prime numbers up to a specified number. + + The upper limit to generate prime numbers up to. + An array of prime numbers up to the specified limit. + + + + Calculates the length of the hypotenuse in a right triangle given the lengths of the other two sides. + + The length of one side. + The length of the other side. + The length of the hypotenuse. + + + + Counts the number of vowels in a given string. + + The text to count vowels in. + The number of vowels in the text. + + + + Finds all substrings of a specified length from a given string. + + The text to extract substrings from. + The length of each substring. + An array of substrings of the specified length. + + + + Converts RGB color values to a hex color code. + + The red component (0-255). + The green component (0-255). + The blue component (0-255). + The hex color code as a string. + + + + Checks if a given string represents a numeric value. + + The string to check. + True if the string is numeric, otherwise false. + + + + Removes duplicate values from an array. + + The array with possible duplicate values. + An array with duplicates removed. + + + + Gets the name of the day of the week for a given date. + + The date to get the day of the week for. + The name of the day of the week. + + + + Sorts an array of numbers in descending order. + + The array to sort. + The sorted array in descending order. + + + + Calculates the age of a person given their birthdate. + + The birthdate to calculate the age from. + The age in years. + + + + Checks if a given string contains only letters. + + The string to check. + True if the string contains only letters, otherwise false. + + + + Calculates compound interest over a specified number of periods. + + The principal amount. + The annual interest rate (as a decimal). + The number of periods per year. + The number of years the money is invested for. + The compound interest amount. + + + + Converts a given string to Base64 encoding. + + The string to encode. + The Base64 encoded string. + + + + Finds the maximum value in an array of numbers. + + The array to search. + The maximum value in the array. + + + + Finds the minimum value in an array of numbers. + + The array to search. + The minimum value in the array. + + + + Calculates the greatest common divisor (GCD) of two integers using the Euclidean algorithm. + + The first integer. + The second integer. + The GCD of the two integers. + + + + Generates a random password of a specified length containing letters and digits. + + The length of the password. + The generated password. + + + + Converts a DateTime object to ISO 8601 format (yyyy-MM-ddTHH:mm:ssZ). + + The DateTime object to convert. + The ISO 8601 formatted date string. + + + + Merges two arrays into a single array. + + The first array. + The second array. + The merged array. + + + + Checks if a given number is even. + + The number to check. + True if the number is even, otherwise false. + + + + Checks if a given number is odd. + + The number to check. + True if the number is odd, otherwise false. + + + + Converts a Base64 encoded string back to its original string representation. + + The Base64 encoded string. + The decoded string. + + + + Gets a color from its RGB components. + + The red component (0-255). + The green component (0-255). + The blue component (0-255). + The color in string format. + + + + Converts a color from its RGB components to a hexadecimal string. + + The color in RGB string format. + The color in hexadecimal format. + + + + Converts a hexadecimal color string to an RGB color. + + The hexadecimal color string (e.g., "#RRGGBB"). + An array containing the RGB values. + + + + Provides System.Environment Functions For Small Basic. + + + + + Terminates the process and gives the exit code to the operating system. + + The exit code to pass to the operating system. + + + + Returns the command-line arguments for the process. + + An array of strings representing the command-line arguments. + + + + Retrieves the value of an environment variable. + + The name of the environment variable. + The value of the environment variable. + + + + Retrieves the value of an environment variable, using the specified target. + + The name of the environment variable. + The target for the environment variable. + The value of the environment variable. + + + + Returns the names of the logical drives on the current machine. + + An array of strings representing the names of the logical drives. + + + + Retrieves the value of a resource string by its key.Currently WILL Give Nothing + + The key of the resource string. + The value of the resource string. + + + + Sets the value of an environment variable. + + The name of the environment variable. + The value to set for the environment variable. + + + + Sets the value of an environment variable, using the specified target. + + The name of the environment variable. + The value to set for the environment variable. + The target for the environment variable. + + + + Gets the command line for the application. + + The command line arguments for the application. + + + + Gets or sets the fully qualified path of the current working directory. + + The path of the current working directory. + + + + Gets the name of the machine on which the application is running. + + The name of the machine. + + + + Gets a string representing the newline character(s) used by the current environment. + + The newline characters used by the current environment. + + + + Gets an OperatingSystem object that describes the current platform. + + The current platform as a string. + + + + Gets the number of processors on the current machine. + + The number of processors. + + + + Gets a string representation of the current call stack. + + The current call stack as a string. + + + + Gets the full path of the system directory. + + The path to the system directory. + + + + Gets the number of milliseconds elapsed since the system started. + + The number of milliseconds since the system started. + + + + Gets the domain name of the current user. + + The domain name of the current user. + + + + Gets the user name of the current thread. + + The user name of the current thread. + + + + Gets the version of the common language runtime (CLR) that is installed on the operating system. + + The version of the CLR. + + + + Gets the amount of physical memory allocated for the process. + + The amount of physical memory allocated for the process, in bytes. + + + + Provides System.Math Functions For Small Basic. + + + + + Returns the absolute value of a specified number. + + A number whose absolute value is to be found. + The absolute value of the specified number. + + + + Returns the angle whose cosine is the specified number. + + A number representing a cosine, where d must be greater than or equal to -1, but less than or equal to 1. + The angle, measured in radians, whose cosine is the specified number. + + + + Returns the angle whose sine is the specified number. + + A number representing a sine, where d must be greater than or equal to -1, but less than or equal to 1. + The angle, measured in radians, whose sine is the specified number. + + + + Returns the angle whose tangent is the specified number. + + A number representing a tangent. + The angle, measured in radians, whose tangent is the specified number. + + + + Returns the angle whose tangent is the quotient of two specified numbers. + + The y-coordinate of a point. + The x-coordinate of a point. + The angle, measured in radians, whose tangent is the quotient of two specified numbers. + + + + Returns the smallest integer greater than or equal to the specified number. + + A number. + The smallest integer greater than or equal to the specified number. + + + + Returns the cosine of the specified angle. + + An angle, measured in radians. + The cosine of the specified angle. + + + + Returns the hyperbolic cosine of the specified angle. + + An angle, measured in radians. + The hyperbolic cosine of the specified angle. + + + + Returns e raised to the specified power. + + A number specifying a power. + The number e raised to the specified power. + + + + Returns the largest integer less than or equal to the specified number. + + A number. + The largest integer less than or equal to the specified number. + + + + Returns the remainder resulting from the division of a specified number by another specified number. + + A dividend. + A divisor. + A number equal to x - (y * Q), where Q is the quotient of x / y rounded to the nearest integer. + + + + Returns the natural (base e) logarithm of a specified number. + + A number whose logarithm is to be found. + The natural (base e) logarithm of the specified number. + + + + Returns the base 10 logarithm of a specified number. + + A number whose logarithm is to be found. + The base 10 logarithm of the specified number. + + + + Returns the larger of two specified numbers. + + The first of two numbers to compare. + The second of two numbers to compare. + The larger of the two numbers. + + + + Returns the smaller of two specified numbers. + + The first of two numbers to compare. + The second of two numbers to compare. + The smaller of the two numbers. + + + + Returns a specified number raised to the specified power. + + A double-precision floating-point number to be raised to a power. + A double-precision floating-point number that specifies a power. + The number x raised to the power y. + + + + Rounds a specified number to the nearest integer. + + A number to be rounded. + The integer nearest to the specified number. + + + + Returns a value indicating the sign of a number. + + A signed number. + A number indicating the sign of the specified number. + + + + Returns the sine of the specified angle. + + An angle, measured in radians. + The sine of the specified angle. + + + + Returns the hyperbolic sine of the specified angle. + + An angle, measured in radians. + The hyperbolic sine of the specified angle. + + + + Returns the square root of a specified number. + + A number. + The square root of the specified number. + + + + Returns the tangent of the specified angle. + + An angle, measured in radians. + The tangent of the specified angle. + + + + Returns the hyperbolic tangent of the specified angle. + + An angle, measured in radians. + The hyperbolic tangent of the specified angle. + + + + Calculates the integral part of a specified number. + + A number to truncate. + The integral part of the specified number. + + + + Represents the natural logarithmic base, specified by the constant, e. + + + + + Represents the ratio of the circumference of a circle to its diameter, specified by the constant, PI. + + + + + Provides methods and properties for managing processes. + This class allows you to start new processes, manage process information, and interact with running processes. + It includes functionalities for: + - Starting processes with or without arguments + - Retrieving process IDs and names + - Getting and setting process-related information such as file path, arguments, priority, and more + + + + + Starts a new process with the specified executable file path. + + The path of the executable file to start. Example: "C:\\Windows\\System32\\notepad.exe" + + + + Starts a new process with the specified executable file path and arguments. + + The path of the executable file to start. Example: "C:\\Windows\\System32\\cmd.exe" + The arguments to pass to the executable file. Example: "/c echo Hello World" + + + + Starts a new process with the specified ProcessStartInfo. + + The path of the executable file to start. Example: "C:\\Windows\\System32\\notepad.exe" + The arguments to pass to the executable file. Example: "" + + + + Gets a list of process IDs for all running processes on the local machine. + + A comma-separated string of process IDs. Example: "1234,5678" + + + + Gets the process name for a specified process ID. + + The process ID. Example: 1234 + The process name. Example: "notepad" + + + + Gets the process ID of the currently managed process. + + The process ID. Example: 1234 + + + + Gets the start time of the currently managed process. + + The start time of the process. Example: "2024-07-24 14:30:00" + + + + Gets the exit time of the currently managed process. + + The exit time of the process. Example: "2024-07-24 15:00:00" + + + + Gets a value indicating whether the currently managed process has exited. + + true if the process has exited; otherwise, false. + + + + Gets the title of the main window of the currently managed process. + + The main window title. Example: "Untitled - Notepad" + + + + Gets a value indicating whether the currently managed process is responding. + + true if the process is responding; otherwise, false. + + + + Gets the total processor time for the currently managed process. + + The total processor time. Example: "00:00:01.2345678" + + + + Gets or sets the file path of the application to start. + + + To set the file path:
+ ZSProcess.FilePath = "C:\\Windows\\System32\\notepad.exe" +
+
+ + + Gets or sets the arguments to pass to the executable file. + + + To set arguments:
+ ZSProcess.Arguments = "/c echo Hello World" +
+
+ + + Gets or sets a value that indicates whether to use the operating system shell to start the process. + + + To enable shell execution:
+ ZSProcess.UseShellExecute = true +
+
+ + + Gets or sets a value that determines whether to redirect standard input, output, and error streams. + + + To enable redirection:
+ ZSProcess.RedirectStandardOutput = true +
+
+ + + Gets or sets the value of the process priority. + + + To set priority class:
+ ZSProcess.PriorityClass = "High" +
+
+ + + Gets or sets a value that indicates whether to create a new window for the process. + + + To disable window creation:
+ ZSProcess.CreateNoWindow = true +
+
+ + + Provides methods and properties for working with globalization, including culture information, date and time formatting, number formatting, and text information. + This class also includes support for various calendars such as Gregorian, Hijri, Chinese, and Korean. + + + + + Gets or sets the current culture. Example: "en-US" + + + Get the current culture:
+ currentCulture = ZSGlobalization.CurrentCulture
+ Set the current culture to French (France):
+ ZSGlobalization.CurrentCulture = "fr-FR" +
+
+ + + Gets the name of the calendar used by the current culture. Example: "GregorianCalendar" + + + + + Gets or sets the date and time pattern for short dates. Example: "MM/dd/yyyy" + + + Get the short date pattern:
+ shortDatePattern = ZSGlobalization.ShortDatePattern
+ Set the short date pattern to day/month/year:
+ ZSGlobalization.ShortDatePattern = "dd/MM/yyyy" +
+
+ + + Gets or sets the date and time pattern for long dates. Example: "dddd, MMMM dd, yyyy" + + + Get the long date pattern:
+ longDatePattern = ZSGlobalization.LongDatePattern
+ Set the long date pattern to day of week, day month year:
+ ZSGlobalization.LongDatePattern = "dddd, dd MMMM yyyy" +
+
+ + + Gets or sets the number decimal separator. Example: "." + + + Get the number decimal separator:
+ decimalSeparator = ZSGlobalization.NumberDecimalSeparator
+ Set the number decimal separator to a comma:
+ ZSGlobalization.NumberDecimalSeparator = "," +
+
+ + + Gets or sets the currency symbol. Example: "$" + + + Get the currency symbol:
+ currencySymbol = ZSGlobalization.CurrencySymbol
+ Set the currency symbol to Euro:
+ ZSGlobalization.CurrencySymbol = "€" +
+
+ + + Gets the text information (casing) of the current culture. Example: "Invariant" + + + Get the text info:
+ textInfo = ZSGlobalization.TextInfo +
+
+ + + Gets the ISO 639-1 two-letter code for the language of the current culture. Example: "en" + + + + + Gets the ISO 639-2 three-letter code for the language of the current culture. Example: "eng" + + + + + Gets the Windows three-letter code for the language of the current culture. Example: "ENU" + + + + + Gets the native name of the language of the current culture. Example: "English" + + + + + Gets the current date in the Hijri calendar. + + + + + Gets the current date in the Chinese calendar. + + + + + Gets the current date in the Gregorian calendar. + + + + + Gets the current date in the Korean calendar. + + diff --git a/ZS/obj/Debug/ZS.csprojResolveAssemblyReference.cache b/ZS/obj/Debug/ZS.csprojResolveAssemblyReference.cache index 4671d5d..c37764a 100644 Binary files a/ZS/obj/Debug/ZS.csprojResolveAssemblyReference.cache and b/ZS/obj/Debug/ZS.csprojResolveAssemblyReference.cache differ diff --git a/ZS/obj/Debug/ZS.dll b/ZS/obj/Debug/ZS.dll index 625d6de..d6ce5f5 100644 Binary files a/ZS/obj/Debug/ZS.dll and b/ZS/obj/Debug/ZS.dll differ