mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-22 09:01:19 +03:00
Added support for Silverlight and Mono (And more)
Also added: * Join, Choice, and Pipe to SmartThreadPool. * Local performance counters (for Mono, Silverlight, and WindowsCE)
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace STPSLDemo
|
||||
{
|
||||
public partial class UsageControl : UserControl
|
||||
{
|
||||
private int _rows = 25;
|
||||
private int _columns = 2;
|
||||
|
||||
private int _max = 100; // Maximum value for progress range
|
||||
private int _value1 = 30; // Current progress
|
||||
private int _value2 = 60; // Current progress
|
||||
|
||||
|
||||
public int Value1
|
||||
{
|
||||
get { return _value1; }
|
||||
set
|
||||
{
|
||||
_value1 = value;
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public int Value2
|
||||
{
|
||||
get { return _value2; }
|
||||
set
|
||||
{
|
||||
_value2 = value;
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public int Maximum
|
||||
{
|
||||
get { return _max; }
|
||||
set
|
||||
{
|
||||
_max = value;
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public UsageControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LayoutRoot.Height = _rows * 4;
|
||||
LayoutRoot.Width = _columns * 18;
|
||||
|
||||
LayoutRoot.RowDefinitions.Clear();
|
||||
|
||||
for (int i = 0; i < _rows; i++)
|
||||
{
|
||||
LayoutRoot.RowDefinitions.Add(new RowDefinition());
|
||||
}
|
||||
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
private void UpdateDisplay()
|
||||
{
|
||||
LayoutRoot.Children.Clear();
|
||||
|
||||
for (int j = 0; j < _columns; j++)
|
||||
{
|
||||
for (int i = 0; i < _rows; i++)
|
||||
{
|
||||
Brush brush = EmptyCell;
|
||||
|
||||
int percent = i * _max / _rows;
|
||||
|
||||
if (percent <= _value2)
|
||||
{
|
||||
brush = RedCell;
|
||||
}
|
||||
|
||||
if (percent <= _value1)
|
||||
{
|
||||
brush = GreenCell;
|
||||
}
|
||||
|
||||
Border border = new Border { Background = brush };
|
||||
|
||||
Grid.SetRow(border, _rows - i - 1);
|
||||
Grid.SetColumn(border, j);
|
||||
LayoutRoot.Children.Add(border);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user