IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Chart graphique et ram


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Technicien
    Inscrit en
    Juillet 2020
    Messages
    141
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Technicien

    Informations forums :
    Inscription : Juillet 2020
    Messages : 141
    Par défaut Chart graphique et ram
    Bonjour le Forum,

    Je souhaiterez récupérer la valeur de la Ram utilisée afin de la mettre dans un Chart.
    La première partie du code fonctionne
    Pouvez-vous m'aider pour le code de la second partie
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            Dim RamLibre As Long = CLng(My.Computer.Info.AvailablePhysicalMemory)
            Dim RamTotal As Long = CLng(My.Computer.Info.TotalPhysicalMemory)
            Dim RamUtilisée As Long = CLng((RamTotal - My.Computer.Info.AvailablePhysicalMemory))
            Dim Pourcentage As Integer = CInt((RamUtilisée * 100) / RamTotal)
            Dim Pourcentage2 As Integer = CInt((RamLibre * 100) / RamTotal)
            ProgressBar1.Maximum = 100
            ProgressBar2.Maximum = 100
            ProgressBar1.Value = Pourcentage
            ProgressBar2.Value = Pourcentage2
            LabelProgressBarValue1.Text = ProgressBar1.Value & "%"  '14
            LabelProgressBarValue2.Text = ProgressBar2.Value & "%"  '20
     
            Application.DoEvents()
            Dim Giga As Long = 1024 * 1024 * 1024
            Dim TotaleRam As Long = CLng(My.Computer.Info.TotalPhysicalMemory)
            Dim TotalRamEnGiga As Double = CDbl(TotaleRam / Giga)
            LabelTotalRam.Text = TotalRamEnGiga.ToString(".00") & " Go"
     
            ' Dim RamLibre As Long = CLng(My.Computer.Info.AvailablePhysicalMemory)
            Dim RamLibreEnGiga As Double = RamLibre / Giga
            LabelRamlibre.Text = RamLibreEnGiga.ToString(".00") & " Go"
     
            Dim RamUtilisée2 As Long = TotaleRam - RamLibre
            Dim RamUtiliséeEnGiga As Double = RamUtilisée2 / Giga
            LabelRamUtilise.Text = RamUtiliséeEnGiga.ToString(".00") & " Go"
        End Sub
    Merci pour votre aide.

  2. #2
    Membre éprouvé
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2018
    Messages
    323
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2018
    Messages : 323
    Par défaut
    Bonsoir,

    Voici un exemple que vous pouvez faire avec ram et cpu avec un chart.
    Nom : Animation.gif
Affichages : 151
Taille : 79,1 Ko

    voici mon code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    Public Class Form1
        Private WithEvents CPU As New PerformanceCounter
        Private WithEvents Ram As New PerformanceCounter
        Private WithEvents Timer As New Timer With {.Interval = 500}
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Me.CPU.CategoryName = "Processor"
            Me.CPU.CounterName = "% Processor Time"
            Me.CPU.InstanceName = "_Total"
     
            Me.Ram.CategoryName = "Memory"
            Me.Ram.CounterName = "% Committed Bytes In Use"
     
            Me.Chart1.Series.Clear()
            Me.Chart1.Series.Add("CPU")
            Me.Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
     
            Me.Chart1.Series.Add("RAM")
            Me.Chart1.Series(1).ChartType = DataVisualization.Charting.SeriesChartType.Line
     
            AddHandler Timer.Tick, AddressOf Timer1_Tick
            Timer.Start()
        End Sub
     
        Private Sub Timer1_Tick(sender As Object, e As EventArgs)
            Me.MyProgressbar1.Value = CPU.NextValue
            Me.MyProgressbar2.Value = Ram.NextValue
            Label3.Text = MyProgressbar1.Value & " %"
            Label4.Text = MyProgressbar2.Value & " %"
            Chart1.Series("CPU").Points.AddY(MyProgressbar1.Value)
            Chart1.Series("RAM").Points.AddY(MyProgressbar2.Value)
        End Sub
     
    End Class
    Cordialement

  3. #3
    Membre confirmé
    Homme Profil pro
    Technicien
    Inscrit en
    Juillet 2020
    Messages
    141
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Technicien

    Informations forums :
    Inscription : Juillet 2020
    Messages : 141
    Par défaut
    Bonjour Miska59,

    Merci pour votre aide, c'est super !, cela fonctionne parfaitement, avez-vous une idée de comment enlever du chart les anciens points du CPU , en gros de ne garder par exemple que les 100 dernières valeurs.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
     Private WithEvents CPU As New PerformanceCounter
        Private WithEvents Ram As New PerformanceCounter
        Private WithEvents Timer As New Windows.Forms.Timer With {.Interval = 500}  
     
    Me.Chart1.Series.Clear()
            Me.Chart1.Series.Add("CPU")
            Me.Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
     
            Me.Chart1.Series.Add("RAM")
            Me.Chart1.Series(1).ChartType = DataVisualization.Charting.SeriesChartType.Line
     
            AddHandler Timer.Tick, AddressOf Timeressai_Tick
            Timer.Start()
        End Sub
        Private Sub Timeressai_Tick(sender As Object, e As EventArgs)
            Me.ProgressBar3.Value = CInt(CPU.NextValue)
            Me.ProgressBar4.Value = CInt(Ram.NextValue)
            Label3.Text = ProgressBar3.Value & " %"
            Label4.Text = ProgressBar4.Value & " %"
            Chart1.Series("CPU").Points.AddY(ProgressBar3.Value)
            Chart1.Series("RAM").Points.AddY(ProgressBar4.Value)
        End Sub
    Encore merci,

  4. #4
    Membre éprouvé
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2018
    Messages
    323
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2018
    Messages : 323
    Par défaut
    bonjour,

    j'ai pas bien compris a votre question ?
    avez-vous une idée de comment enlever du chart les anciens points du CPU , en gros de ne garder par exemple que les 100 dernières valeurs.
    voici un exemple pour avoir les les 100 dernières valeurs :
    Nom : Animation.gif
Affichages : 127
Taille : 111,8 Ko

    mon code à jour :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    Public Class Form1
        Private WithEvents CPU As New PerformanceCounter
        Private WithEvents Ram As New PerformanceCounter
        Private WithEvents Timer As New Timer With {.Interval = 500}
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Me.CPU.CategoryName = "Processor"
            Me.CPU.CounterName = "% Processor Time"
            Me.CPU.InstanceName = "_Total"
     
            Me.Ram.CategoryName = "Memory"
            Me.Ram.CounterName = "% Committed Bytes In Use"
     
     
            Me.Chart1.Series.Clear()
            Me.Chart1.Series.Add("CPU")
            Me.Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
            Me.Chart1.Legends(0).BackColor = Color.FromArgb(224, 224, 224, 224)
            Me.Chart1.ChartAreas(0).BackColor = Color.FromArgb(224, 224, 224, 224)
            Me.Chart1.ChartAreas(0).AxisX.LabelStyle.Font = New Font("Times New Roman", 14, FontStyle.Bold)
            Me.Chart1.ChartAreas(0).AxisX.LabelStyle.ForeColor = Color.Red
            Me.Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.Red
            Me.Chart1.Series(0).Color = Color.Red
            Me.Chart1.Series(0).BorderWidth = 3
            Me.Chart1.ChartAreas(0).AxisX.Maximum = 100
            Me.Chart1.ChartAreas(0).AxisX.Minimum = 0
     
            Me.Chart1.Series.Add("RAM")
            Me.Chart1.Series(1).ChartType = DataVisualization.Charting.SeriesChartType.Line
            Me.Chart1.Series(1).Color = Color.Blue
            Me.Chart1.Series(1).BorderWidth = 3
            Me.Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = Color.Blue
            Me.Chart1.ChartAreas(0).AxisY.LabelStyle.Font = New Font("Times New Roman", 14, FontStyle.Bold)
            Me.Chart1.ChartAreas(0).AxisY.LabelStyle.ForeColor = Color.Blue
            Me.Chart1.ChartAreas(0).AxisY.Maximum = 100
            Me.Chart1.ChartAreas(0).AxisY.Minimum = 0
     
            AddHandler Timer.Tick, AddressOf Timer1_Tick
            Timer.Start()
        End Sub
     
        Private Sub Timer1_Tick(sender As Object, e As EventArgs)
            Me.MyProgressbar1.Value = CPU.NextValue
            Me.MyProgressbar2.Value = Ram.NextValue
            Label3.Text = MyProgressbar1.Value & " %"
            Label4.Text = MyProgressbar2.Value & " %"
            Chart1.Series("CPU").Points.AddY(MyProgressbar1.Value)
            Chart1.Series("RAM").Points.AddY(MyProgressbar2.Value)
            For i = 0 To Chart1.Series.Count - 1
                If Chart1.Series(0).Points.Count = 100 Then
                    Chart1.Series(0).Points.RemoveAt(i)
                    Chart1.Series(1).Points.RemoveAt(i)
                End If
            Next
        End Sub
     
    End Class
    cordialement,

  5. #5
    Membre confirmé
    Homme Profil pro
    Technicien
    Inscrit en
    Juillet 2020
    Messages
    141
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Technicien

    Informations forums :
    Inscription : Juillet 2020
    Messages : 141
    Par défaut
    Bonsoir Miska59,

    Merci pour votre code, il fonctionne parfaitement avec les 100 valeurs maxi.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Charte Graphique Web ?
    Par Sceener dans le forum Webdesign & Ergonomie
    Réponses: 9
    Dernier message: 10/09/2007, 10h41
  2. MOSS2007 Charte graphique et accès anonyme
    Par @melie dans le forum SharePoint
    Réponses: 3
    Dernier message: 23/08/2007, 18h56
  3. cherche charte graphique
    Par MortDansLAme dans le forum Webdesign & Ergonomie
    Réponses: 2
    Dernier message: 26/04/2007, 17h04
  4. Réponses: 14
    Dernier message: 15/10/2006, 11h22
  5. [CSS] logiciel pour dev sa propre charte graphique...
    Par luta dans le forum Mise en page CSS
    Réponses: 8
    Dernier message: 14/11/2005, 11h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo