Exemple #1
0
        internal static async Task <string> getHardwareInfo()
        {
            return(await Task.Run(() =>
            {
                hardwareInfo.RefreshMemoryStatus();
                hardwareInfo.RefreshDriveList();
                StringBuilder sb = new StringBuilder();
                sb.Append(((hardwareInfo.MemoryStatus.AvailablePhysical / 1024.0) / 1024.0).ToString("0.00"));
                sb.Append(" MB freier RAM\r\n");
                foreach (var drive in hardwareInfo.DriveList)
                {
                    foreach (var partition in drive.PartitionList)
                    {
                        foreach (var volume in partition.VolumeList)
                        {
                            sb.Append(volume.Name);
                            sb.Append(" hat ");
                            sb.Append(((volume.FreeSpace / 1024.0) / 1024.0).ToString("0.0"));
                            sb.Append(" MB freien Platz");
                            sb.Append("\r\n");
                        }
                    }
                }

                SystemMetrics systemMetrics = new SystemMetrics();
                Metrics result = systemMetrics.GetMetrics();
                sb.Append(result.TotalCpuUsage.ToString("0.0"));
                sb.Append(" % CPU-Last");
                return sb.ToString();
            }));
        }
Exemple #2
0
        private async Task <EmbedBuilder> GetMessageEmbed(SystemMetrics system)
        {
            var embed = new EmbedBuilder
            {
                Title       = ":small_orange_diamond: System Metrics",
                Description = $"Server name: {Environment.MachineName}",
                Color       = Color.Blue
            };

            embed.AddField("CPU", GetProgressBar(await Task.Run(() => system.GetCPUUsage())), true);
            double ramUsage = await Task.Run(() => system.GetRAMUsage());

            embed.AddField("Memory: " + SystemMetrics.GetMemoryRatioString(ramUsage, system.RAMTotalSize), GetProgressBar(ramUsage), true);
            double diskUsage = await Task.Run(() => system.GetDiskUsage());

            embed.AddField("Disk: " + SystemMetrics.GetDiskRatioString(diskUsage, system.DiskTotalSize), GetProgressBar(diskUsage), true);

            (int serverCount, int startedCount, int activePlayers) = await GetGameServerDashBoardDetails();

            embed.AddField($"Servers: {serverCount}/{MainWindow.MAX_SERVER}", GetProgressBar(serverCount * 100 / MainWindow.MAX_SERVER), true);
            embed.AddField($"Online: {startedCount}/{serverCount}", GetProgressBar((serverCount == 0) ? 0 : startedCount * 100 / serverCount), true);
            embed.AddField("Active Players", GetActivePlayersString(activePlayers), true);

            embed.WithFooter(new EmbedFooterBuilder().WithIconUrl("https://github.com/WindowsGSM/WindowsGSM/raw/master/WindowsGSM/Images/WindowsGSM.png").WithText($"WindowsGSM {MainWindow.WGSM_VERSION} | System Metrics"));
            embed.WithCurrentTimestamp();

            return(embed);
        }
Exemple #3
0
        /// <summary>
        /// Retrieves the specified system metric or system configuration setting.
        /// </summary>
        /// <param name="metric">The system metric or configuration setting to be retrieved.</param>
        /// <returns>The return value is the requested system metric or configuration setting.</returns>
        public static int GetSystemMetrics(SystemMetrics metric)
        {
            var ret = NativeMethods.GetSystemMetrics(metric);

            if (ret != 0)
                return ret;

            throw new Win32Exception("The call of GetSystemMetrics failed. Unfortunately, GetLastError code doesn't provide more information.");
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static Point GetVirtualScreenTopLeftPoint()
        {
            int x = SystemMetrics.GetSystemMetric(SystemMetric.VirtualScreenX);
            int y = SystemMetrics.GetSystemMetric(SystemMetric.VirtualScreenY);

            Point point = new Point(x, y);

            return(point);
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static Size GetVirtualScreenSize()
        {
            int width  = SystemMetrics.GetSystemMetric(SystemMetric.VirtualScreenWidth);
            int height = SystemMetrics.GetSystemMetric(SystemMetric.VirtualScreenHeight);

            Size size = new Size(width, height);

            return(size);
        }
Exemple #6
0
        private async Task Action_Stats(SocketMessage message)
        {
            var system = new SystemMetrics();
            await Task.Run(() => system.GetCPUStaticInfo());

            await Task.Run(() => system.GetRAMStaticInfo());

            await Task.Run(() => system.GetDiskStaticInfo());

            await message.Channel.SendMessageAsync(embed : (await GetMessageEmbed(system)).Build());
        }
Exemple #7
0
        /// <summary>
        /// Retrieves the specified system metric or system configuration setting.
        /// </summary>
        /// <param name="metric">The system metric or configuration setting to be retrieved.</param>
        /// <returns>The return value is the requested system metric or configuration setting.</returns>
        public static int GetSystemMetrics(SystemMetrics metric)
        {
            var ret = NativeMethods.GetSystemMetrics(metric);

            if (ret != 0)
            {
                return(ret);
            }

            throw new Win32Exception("The call of GetSystemMetrics failed. Unfortunately, GetLastError code doesn't provide more information.");
        }
 /// <summary>
 /// Returns the desired system metric, or -1 if the call fails
 /// </summary>
 /// <param name="metric">Metric to be queried</param>
 /// <returns>Metric</returns>
 public static int GetMetric(SystemMetrics metric)
 {
     try
     {
         var result = GetSystemMetrics(metric);
         return(result);
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemple #9
0
        private static int MaxWidth(Font font, IEnumerable <String> labels)
        {
            var result = 0;

            if (labels != null)
            {
                foreach (var label in labels)
                {
                    result = Math.Max(result, SystemMetrics.GetTextHeight(font, label));
                }
            }
            return(result);
        }
Exemple #10
0
 public static extern int GetSystemMetrics(SystemMetrics metric);
Exemple #11
0
 public static extern int GetSystemMetrics(SystemMetrics metric);
Exemple #12
0
 public static extern int GetSystemMetrics(
     [MarshalAs(UnmanagedType.I4)] SystemMetrics metric);
 private static extern int GetSystemMetrics(SystemMetrics smIndex);
Exemple #14
0
 /// <summary>
 /// Returns the number of display monitors available
 /// </summary>
 /// <returns></returns>
 public static int GetDisplayCount()
 {
     return(SystemMetrics.GetSystemMetric(SystemMetric.Monitors));
 }
Exemple #15
0
 private static extern int GetSystemMetrics(SystemMetrics smIndex);
Exemple #16
0
 public static extern int GetSystemMetricsForDpi(SystemMetrics nIndex, uint dpi);
Exemple #17
0
		private extern static int Win32GetSystemMetrics(SystemMetrics nIndex);
Exemple #18
0
 public static extern int GetSystemMetrics(SystemMetrics nIndex);
Exemple #19
0
 public static extern int GetSystemMetrics(SystemMetrics smIndex);
 protected static extern int GetSystemMetrics(SystemMetrics deviceMode);