DynamicDataDisplay.dll is a visual control that adds dynamic data to your Silverlight or WPF application interaction. It allows the creation of line graphs, bubble charts, heat maps and other complex two-dimensional graphs, which are very common in scientific software.
Dynamicdatadisplay Sample Charts:
As follows:
http://dynamicdatadisplay.codeplex.com/
First, create a WPF project, right-click on the reference and select "Add Reference" to find the downloaded DynamicDataDisplay.dll;
Next, add the reference set in the. cs file:
Microsoft.Research.DynamicDataDisplay; Microsoft.Research.DynamicDataDisplay.DataSources;
private Observabledatasource dataSource = new Observabledatasource (); dynamically store chart coordinate points
Private PerformanceCounter cpuperformance = new PerformanceCounter (); Represents the performance component of Windows NT
Private DispatcherTimer timer = new DispatcherTimer ();//Create a Timer
Define a function to get the data for CPU and memory:
private void Animatedplot (object sender, EventArgs e)
{
Cpuperformance.categoryname = "Processor";
Cpuperformance.countername = "% Processor time";
Cpuperformance.instancename = "_total";
D ouble x = i;
//When debugging, cannot call NextValue () function, need to assign Y to a fixed value
Double y = cpuperformance.nextvalue ();
if (Maxcpu < y)
{
Maxcpu = y;
}
Double y = 12;
Double memoryuse = process.getcurrentprocess (). privatememorysize64/1024.0/1024.0; Get use memory
Point point = new Point (x, y);
Datasource.appendasync (base. Dispatcher, point);
C Puusagetext.text = String.Format ("{0:0}%", y);//Cpuusagetext for TextBlock control, showing CPU utilization
Cpumaxtext.text = String.Format ("{0:0}%", maxcpu);//Cpumaxtext for TextBlock control, showing maximum CPU usage
Memoryusagetext.text = memoryuse.tostring ("F02");//Memoryusagetext for TextBlock control, display memory size
i++;
}
Note: the NextValue () function will error during the VS Debug Code!! You need to assign a value of Y to a constant.
The next step is to display the image:
public void Startcpushow ()
{
Plotter. Addlinegraph (DataSource, Colors.green, 2, "Percentage"); Set information about the centerline of the image
Timer. Interval = Timespan.fromseconds (1);
Timer. Tick + = new EventHandler (animatedplot);
Timer. IsEnabled = true; Plotter. Viewport.fittoview ();
}
To add a namespace to a XAML file:
xmlns : D3 = "http://research.microsoft.com/DynamicDataDisplay/1.0"
Create a chart frame with <d3:ChartPlotter>;
Add two integer axes to it:
X-Axis:<d3:horizontalintegeraxis>
Y-Axis:<d3:verticalintegeraxis>
<d3:Header> to set the chart name
<d3:VerticalAxisTitle> used to set the y-axis name.
<d3:chartplotter x:name= "plotter" margin= "10,10,33,10" grid.row= "1" background= "Transparent" foreground= "# Ff00dbe7 ">
<d3:ChartPlotter.VerticalAxis>
<d3:verticalintegeraxis foreground= "#FF00DBE7"/>
</d3:ChartPlotter.VerticalAxis>
<d3:chartplotter.horizontalaxis >
<d3:horizontalintegeraxis foreground= "#FF00DBE7"/>
</d3:ChartPlotter.HorizontalAxis>
<d3:header content= "CPU performance History" foreground= "#FF00DBE7"/>
</d3:ChartPlotter>
Finally, it is important to note that many systems cannot run the program. Note that you need to rebuild the performance counters before you can use features such as viewing CPUs
The Rebuild method is as follows:
Run the cmd command line
Input LODCTR/R
Waiting to rebuild performance counters
The Last:
If you have questions [email protected]
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
WPF uses DynamicDataDisplay.dll to display CPU and memory usage curves