private void PhysicalMemoryTimer_Tick(object sender, EventArgs e)
{
try
{
decimal memory = (PhysicalMemory - FreePhysicalMemory) / PhysicalMemory;
textBlock.Text = memory.ToString("p0");
if (memory < lv
&& File.Exists(System.Windows.Forms.Application.StartupPath + @"\Image\green.png"))
{
var uriSource = new Uri(System.Windows.Forms.Application.StartupPath + @"\Image\green.png", UriKind.Absolute);
imgBackground.Source = new BitmapImage(uriSource);
}
else if (memory >= lv
&& memory < huang
&& File.Exists(System.Windows.Forms.Application.StartupPath + @"\Image\yellow.png"))
{
var uriSource = new Uri(System.Windows.Forms.Application.StartupPath + @"\Image\yellow.png", UriKind.Absolute);
imgBackground.Source = new BitmapImage(uriSource);
}
else if (File.Exists(System.Windows.Forms.Application.StartupPath + @"\Image\red.png"))
{
var uriSource = new Uri(System.Windows.Forms.Application.StartupPath + @"\Image\red.png", UriKind.Absolute);
imgBackground.Source = new BitmapImage(uriSource);
}
}
catch
{
}
}