mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-22 11:01:28 +03:00
v2.0
SmartThreadPool v2.0
This commit is contained in:
Generated
+316
@@ -0,0 +1,316 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace STPCEDemo
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private UsageControl.UsageHistoryControl usageHistoryControl1;
|
||||
private Button btnStartStop;
|
||||
private Label label1;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu();
|
||||
this.btnStartStop = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.lblThreadsInUse = new System.Windows.Forms.Label();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.lblThreadsInPool = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.spnMinThreads = new System.Windows.Forms.NumericUpDown();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.spnMaxThreads = new System.Windows.Forms.NumericUpDown();
|
||||
this.spnIdleTimeout = new System.Windows.Forms.NumericUpDown();
|
||||
this.spnWorkItemsPerSecond = new System.Windows.Forms.NumericUpDown();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.spnWorkItemDuration = new System.Windows.Forms.NumericUpDown();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.usageControl1 = new UsageControl.UsageControl();
|
||||
this.usageHistoryControl1 = new UsageControl.UsageHistoryControl();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnStartStop
|
||||
//
|
||||
this.btnStartStop.Location = new System.Drawing.Point(148, 10);
|
||||
this.btnStartStop.Name = "btnStartStop";
|
||||
this.btnStartStop.Size = new System.Drawing.Size(72, 20);
|
||||
this.btnStartStop.TabIndex = 0;
|
||||
this.btnStartStop.Text = "Start";
|
||||
this.btnStartStop.Click += new System.EventHandler(this.btnStartStop_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
|
||||
this.label1.Location = new System.Drawing.Point(10, 10);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(143, 20);
|
||||
this.label1.Text = "Smart Thread Pool";
|
||||
//
|
||||
// lblThreadsInUse
|
||||
//
|
||||
this.lblThreadsInUse.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.lblThreadsInUse.Location = new System.Drawing.Point(148, 106);
|
||||
this.lblThreadsInUse.Name = "lblThreadsInUse";
|
||||
this.lblThreadsInUse.Size = new System.Drawing.Size(72, 24);
|
||||
this.lblThreadsInUse.Text = "0";
|
||||
this.lblThreadsInUse.TextAlign = System.Drawing.ContentAlignment.TopCenter;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.label7.Location = new System.Drawing.Point(10, 106);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(124, 24);
|
||||
this.label7.Text = "Used threads (Green)";
|
||||
//
|
||||
// lblThreadsInPool
|
||||
//
|
||||
this.lblThreadsInPool.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.lblThreadsInPool.Location = new System.Drawing.Point(148, 88);
|
||||
this.lblThreadsInPool.Name = "lblThreadsInPool";
|
||||
this.lblThreadsInPool.Size = new System.Drawing.Size(72, 24);
|
||||
this.lblThreadsInPool.Text = "0";
|
||||
this.lblThreadsInPool.TextAlign = System.Drawing.ContentAlignment.TopCenter;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.label2.Location = new System.Drawing.Point(10, 88);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(124, 24);
|
||||
this.label2.Text = "Threads in pool (Red)";
|
||||
//
|
||||
// spnMinThreads
|
||||
//
|
||||
this.spnMinThreads.Location = new System.Drawing.Point(148, 125);
|
||||
this.spnMinThreads.Maximum = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.spnMinThreads.Name = "spnMinThreads";
|
||||
this.spnMinThreads.Size = new System.Drawing.Size(72, 24);
|
||||
this.spnMinThreads.TabIndex = 3;
|
||||
this.spnMinThreads.ValueChanged += new System.EventHandler(this.spnMinThreads_ValueChanged);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.label4.Location = new System.Drawing.Point(10, 173);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(120, 24);
|
||||
this.label4.Text = "Idle timeout (Seconds)";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.label3.Location = new System.Drawing.Point(10, 149);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(104, 24);
|
||||
this.label3.Text = "Maximum Threads";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.label5.Location = new System.Drawing.Point(10, 125);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(104, 24);
|
||||
this.label5.Text = "Minimum Threads";
|
||||
//
|
||||
// spnMaxThreads
|
||||
//
|
||||
this.spnMaxThreads.Location = new System.Drawing.Point(148, 149);
|
||||
this.spnMaxThreads.Maximum = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.spnMaxThreads.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.spnMaxThreads.Name = "spnMaxThreads";
|
||||
this.spnMaxThreads.Size = new System.Drawing.Size(72, 24);
|
||||
this.spnMaxThreads.TabIndex = 4;
|
||||
this.spnMaxThreads.Value = new decimal(new int[] {
|
||||
5,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.spnMaxThreads.ValueChanged += new System.EventHandler(this.spnMaxThreads_ValueChanged);
|
||||
//
|
||||
// spnIdleTimeout
|
||||
//
|
||||
this.spnIdleTimeout.Location = new System.Drawing.Point(148, 173);
|
||||
this.spnIdleTimeout.Maximum = new decimal(new int[] {
|
||||
60,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.spnIdleTimeout.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.spnIdleTimeout.Name = "spnIdleTimeout";
|
||||
this.spnIdleTimeout.Size = new System.Drawing.Size(72, 24);
|
||||
this.spnIdleTimeout.TabIndex = 5;
|
||||
this.spnIdleTimeout.Value = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// spnWorkItemsPerSecond
|
||||
//
|
||||
this.spnWorkItemsPerSecond.Location = new System.Drawing.Point(148, 203);
|
||||
this.spnWorkItemsPerSecond.Name = "spnWorkItemsPerSecond";
|
||||
this.spnWorkItemsPerSecond.Size = new System.Drawing.Size(72, 24);
|
||||
this.spnWorkItemsPerSecond.TabIndex = 6;
|
||||
this.spnWorkItemsPerSecond.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.label6.Location = new System.Drawing.Point(10, 203);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(120, 24);
|
||||
this.label6.Text = "Work items/sec";
|
||||
//
|
||||
// spnWorkItemDuration
|
||||
//
|
||||
this.spnWorkItemDuration.Increment = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.spnWorkItemDuration.Location = new System.Drawing.Point(148, 227);
|
||||
this.spnWorkItemDuration.Maximum = new decimal(new int[] {
|
||||
6000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.spnWorkItemDuration.Name = "spnWorkItemDuration";
|
||||
this.spnWorkItemDuration.Size = new System.Drawing.Size(72, 24);
|
||||
this.spnWorkItemDuration.TabIndex = 7;
|
||||
this.spnWorkItemDuration.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.label8.Location = new System.Drawing.Point(10, 227);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(132, 24);
|
||||
this.label8.Text = "Work item duration (ms)";
|
||||
//
|
||||
// usageControl1
|
||||
//
|
||||
this.usageControl1.BackColor = System.Drawing.Color.Black;
|
||||
this.usageControl1.Location = new System.Drawing.Point(10, 33);
|
||||
this.usageControl1.Maximum = 10;
|
||||
this.usageControl1.Name = "usageControl1";
|
||||
this.usageControl1.Size = new System.Drawing.Size(41, 52);
|
||||
this.usageControl1.TabIndex = 1;
|
||||
this.usageControl1.Value1 = 0;
|
||||
this.usageControl1.Value2 = 0;
|
||||
//
|
||||
// usageHistoryControl1
|
||||
//
|
||||
this.usageHistoryControl1.BackColor = System.Drawing.Color.Black;
|
||||
this.usageHistoryControl1.Location = new System.Drawing.Point(66, 33);
|
||||
this.usageHistoryControl1.Maximum = 10;
|
||||
this.usageHistoryControl1.Name = "usageHistoryControl1";
|
||||
this.usageHistoryControl1.Size = new System.Drawing.Size(154, 52);
|
||||
this.usageHistoryControl1.TabIndex = 2;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.AutoScroll = true;
|
||||
this.ClientSize = new System.Drawing.Size(240, 258);
|
||||
this.Controls.Add(this.btnStartStop);
|
||||
this.Controls.Add(this.spnWorkItemDuration);
|
||||
this.Controls.Add(this.label8);
|
||||
this.Controls.Add(this.spnWorkItemsPerSecond);
|
||||
this.Controls.Add(this.label6);
|
||||
this.Controls.Add(this.spnIdleTimeout);
|
||||
this.Controls.Add(this.spnMaxThreads);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.spnMinThreads);
|
||||
this.Controls.Add(this.lblThreadsInUse);
|
||||
this.Controls.Add(this.label7);
|
||||
this.Controls.Add(this.lblThreadsInPool);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.usageControl1);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.usageHistoryControl1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "Form1";
|
||||
this.Text = "Smart Thread Pool";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private UsageControl.UsageControl usageControl1;
|
||||
private Label lblThreadsInUse;
|
||||
private Label label7;
|
||||
private Label lblThreadsInPool;
|
||||
private Label label2;
|
||||
private NumericUpDown spnMinThreads;
|
||||
private Label label4;
|
||||
private Label label3;
|
||||
private Label label5;
|
||||
private NumericUpDown spnMaxThreads;
|
||||
private NumericUpDown spnIdleTimeout;
|
||||
private NumericUpDown spnWorkItemsPerSecond;
|
||||
private Label label6;
|
||||
private NumericUpDown spnWorkItemDuration;
|
||||
private Label label8;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Amib.Threading;
|
||||
using System.Threading;
|
||||
|
||||
namespace STPCEDemo
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private bool running;
|
||||
private readonly System.Windows.Forms.Timer uiTimer;
|
||||
private SmartThreadPool _stp;
|
||||
private readonly System.Windows.Forms.Timer wiTimer;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
running = false;
|
||||
InitializeComponent();
|
||||
|
||||
uiTimer = new System.Windows.Forms.Timer();
|
||||
uiTimer.Interval = 1000;
|
||||
uiTimer.Tick += new EventHandler(uiTimer_Tick);
|
||||
|
||||
wiTimer = new System.Windows.Forms.Timer();
|
||||
wiTimer.Interval = 1000;
|
||||
wiTimer.Tick += new EventHandler(wiTimer_Tick);
|
||||
//Debug.WriteLine("Form Thread Priority is " + (int)GetCurrentThreadPriority());
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
SetRunningState(false);
|
||||
}
|
||||
|
||||
void uiTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (null == _stp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
int inUse = _stp.InUseThreads;
|
||||
int inPool = _stp.ActiveThreads;
|
||||
|
||||
this.usageHistoryControl1.AddValues(inUse, inPool);
|
||||
this.usageControl1.Value1 = inUse;
|
||||
this.usageControl1.Value2 = inPool;
|
||||
this.lblThreadsInUse.Text = inUse.ToString();
|
||||
this.lblThreadsInPool.Text = inPool.ToString();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void wiTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
int count = Convert.ToInt32(spnWorkItemsPerSecond.Value);
|
||||
int sleepDuration = Convert.ToInt32(spnWorkItemDuration.Value);
|
||||
Debug.WriteLine(string.Format("{0}: C = {1}, S = {2}", DateTime.Now.ToString("HH:mm:ss"), count, sleepDuration));
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_stp.QueueWorkItem(DoWork, sleepDuration);
|
||||
}
|
||||
}
|
||||
|
||||
private void DoWork(int sleepDuration)
|
||||
{
|
||||
//Debug.WriteLine("DoWork Thread Priority is " + (int)GetCurrentThreadPriority());
|
||||
|
||||
DateTime start = DateTime.Now;
|
||||
//int sleepDuration = Convert.ToInt32(state);
|
||||
Thread.Sleep(sleepDuration);
|
||||
TimeSpan duration = DateTime.Now - start;
|
||||
|
||||
Debug.WriteLine(string.Format("{0}: Duration = {1}", DateTime.Now.ToString("HH:mm:ss"), duration.TotalMilliseconds));
|
||||
|
||||
//return null;
|
||||
}
|
||||
|
||||
void btnStartStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetRunningState(!running);
|
||||
}
|
||||
|
||||
private void SetRunningState(bool newRunningState)
|
||||
{
|
||||
btnStartStop.Text = newRunningState ? "Stop" : "Start";
|
||||
if (newRunningState)
|
||||
{
|
||||
_stp = new SmartThreadPool(
|
||||
Convert.ToInt32(spnIdleTimeout.Value) * 1000,
|
||||
Convert.ToInt32(spnMaxThreads.Value),
|
||||
Convert.ToInt32(spnMinThreads.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (null != _stp)
|
||||
{
|
||||
_stp.Shutdown();
|
||||
}
|
||||
_stp = null;
|
||||
}
|
||||
spnIdleTimeout.Enabled = !newRunningState;
|
||||
uiTimer.Enabled = newRunningState;
|
||||
wiTimer.Enabled = newRunningState;
|
||||
running = newRunningState;
|
||||
}
|
||||
|
||||
private void spnMinThreads_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (null != _stp)
|
||||
{
|
||||
_stp.MinThreads = Convert.ToInt32(spnMinThreads.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void spnMaxThreads_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (null != _stp)
|
||||
{
|
||||
_stp.MaxThreads = Convert.ToInt32(spnMaxThreads.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetCurrentThreadPriority()
|
||||
{
|
||||
IntPtr hThread = GetCurrentThread();
|
||||
int priority = CeGetThreadPriority(hThread);
|
||||
return priority;
|
||||
}
|
||||
|
||||
[DllImport("coredll.dll", SetLastError = true)]
|
||||
public static extern int CeGetThreadPriority(IntPtr hThread);
|
||||
|
||||
[DllImport("coredll.dll")]
|
||||
public static extern IntPtr GetCurrentThread();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.FormFactorShadowProperty" xml:space="preserve">
|
||||
<value>WEBPAD</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace STPCEDemo
|
||||
{
|
||||
public static class Pens
|
||||
{
|
||||
private static Pen _red = new Pen(Color.Red);
|
||||
private static Pen _lawnGreen = new Pen(Color.LawnGreen);
|
||||
|
||||
private static Pen _green = new Pen(Color.Green);
|
||||
private static Pen _darkGray = new Pen(Color.DarkGray);
|
||||
private static Pen _white = new Pen(Color.White);
|
||||
|
||||
|
||||
public static Pen Red
|
||||
{
|
||||
get { return _red; }
|
||||
}
|
||||
|
||||
|
||||
public static Pen LawnGreen
|
||||
{
|
||||
get { return _lawnGreen; }
|
||||
}
|
||||
|
||||
public static Pen Green
|
||||
{
|
||||
get { return _green; }
|
||||
}
|
||||
|
||||
public static Pen DarkGray
|
||||
{
|
||||
get { return _darkGray; }
|
||||
}
|
||||
|
||||
public static Pen White
|
||||
{
|
||||
get { return _white; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace STPCEDemo
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[MTAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("STPCEDemo")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("STPCEDemo")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2008")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a9f7d57c-9b87-4b5e-81a5-9d4b2719b5b5")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.1433
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace STPCEDemo.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("STPCEDemo.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,115 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{356114BA-5F10-4DB6-9971-987CE11F765F}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>STPCEDemo</RootNamespace>
|
||||
<AssemblyName>STPCEDemo</AssemblyName>
|
||||
<ProjectTypeGuids>{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PlatformFamilyName>WindowsCE</PlatformFamilyName>
|
||||
<PlatformID>E2BECB1F-8C8C-41ba-B736-9BE7D946A398</PlatformID>
|
||||
<OSVersion>5.0</OSVersion>
|
||||
<DeployDirSuffix>STPCEDemo</DeployDirSuffix>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FormFactorID>
|
||||
</FormFactorID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;$(PlatformFamilyName)</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;$(PlatformFamilyName)</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pens.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UsageControl.resx">
|
||||
<DependentUpon>UsageControl.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UsageHistoryControl.resx">
|
||||
<DependentUpon>UsageHistoryControl.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="UsageControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UsageHistoryControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SmartThreadPool\SmartThreadPoolCE.csproj">
|
||||
<Project>{D81DD596-C71F-4AC2-816C-63C19589E7E0}</Project>
|
||||
<Name>SmartThreadPoolCE</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Condition="'$(TargetFrameworkVersion)' == 'v1.0'" Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.v1.targets" />
|
||||
<Import Condition="'$(TargetFrameworkVersion)' == 'v2.0'" Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}">
|
||||
<HostingProcess disable="1" />
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,328 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
using STPCEDemo;
|
||||
|
||||
namespace UsageControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for UsageControl.
|
||||
/// </summary>
|
||||
public class UsageControl : System.Windows.Forms.UserControl
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
private const int ovalWidth = 18;
|
||||
private const int columns = 2;
|
||||
|
||||
private int fixedWidth;
|
||||
private int rows = 1;
|
||||
|
||||
private int min = 0; // Minimum value for progress range
|
||||
private int max = 100; // Maximum value for progress range
|
||||
private int val1 = 0; // Current progress
|
||||
private int val2 = 0; // Current progress
|
||||
|
||||
public UsageControl()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
|
||||
EnableDoubleBuffering();
|
||||
fixedWidth = 2 + (ovalWidth+1)*columns + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
private void EnableDoubleBuffering()
|
||||
{
|
||||
// Set the value of the double-buffering style bits to true.
|
||||
//this.SetStyle(ControlStyles.DoubleBuffer |
|
||||
// ControlStyles.UserPaint |
|
||||
// ControlStyles.AllPaintingInWmPaint,
|
||||
// true);
|
||||
//this.UpdateStyles();
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
//
|
||||
// UsageControl
|
||||
//
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.Name = "UsageControl";
|
||||
this.Size = new System.Drawing.Size(192, 160);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
Width = fixedWidth;
|
||||
rows = (ClientRectangle.Height / 4) - 1;
|
||||
// Invalidate the control to get a repaint.
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
int percent1 = ((val1 - min) * 100) / (max - min);
|
||||
int percent2 = ((val2 - min) * 100) / (max - min);
|
||||
|
||||
int filledCount1 = (rows * percent1) / 100;
|
||||
int filledCount2 = (rows * percent2) / 100;
|
||||
int diff = Math.Abs(filledCount1 - filledCount2);
|
||||
|
||||
int emptyCount = rows - Math.Max(filledCount1, filledCount2);
|
||||
|
||||
int i = 0;
|
||||
|
||||
for(i = 0; i < filledCount1; ++i)
|
||||
{
|
||||
for(int j = 0; j < columns; ++j)
|
||||
{
|
||||
DrawOval(
|
||||
g,
|
||||
Pens.LawnGreen,
|
||||
2 + j*(1+ovalWidth),
|
||||
ClientRectangle.Bottom - 5 - i*4);
|
||||
}
|
||||
}
|
||||
|
||||
for(; i < filledCount2; ++i)
|
||||
{
|
||||
for(int j = 0; j < columns; ++j)
|
||||
{
|
||||
DrawOval(
|
||||
g,
|
||||
Pens.Red,
|
||||
2 + j*(1+ovalWidth),
|
||||
ClientRectangle.Bottom - 5 - i*4);
|
||||
}
|
||||
}
|
||||
|
||||
for(; i < rows; ++i)
|
||||
{
|
||||
for(int j = 0; j < columns; ++j)
|
||||
{
|
||||
DrawOval(
|
||||
g,
|
||||
Pens.Green,
|
||||
2 + j*(1+ovalWidth),
|
||||
ClientRectangle.Bottom - 5 - i*4);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw a three-dimensional border around the control.
|
||||
Draw3DBorder(g);
|
||||
|
||||
// Clean up.
|
||||
//g.Dispose();
|
||||
base.OnPaint (e);
|
||||
}
|
||||
|
||||
private void DrawOval(Graphics g, Pen pen, int x, int y)
|
||||
{
|
||||
g.DrawLine(pen, x+1 , y, x+ovalWidth-2, y);
|
||||
g.DrawLine(pen, x, y+1, x+ovalWidth-1, y+1);
|
||||
g.DrawLine(pen, x+1, y+2, x+ovalWidth-2, y+2);
|
||||
}
|
||||
|
||||
public int Maximum
|
||||
{
|
||||
get
|
||||
{
|
||||
return max;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
// Make sure that the maximum value is never set lower than the minimum value.
|
||||
if (value < min)
|
||||
{
|
||||
min = value;
|
||||
}
|
||||
|
||||
max = value;
|
||||
|
||||
// Make sure that value is still in range.
|
||||
if (val1 > max)
|
||||
{
|
||||
val1 = max;
|
||||
}
|
||||
|
||||
// Invalidate the control to get a repaint.
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public int Value1
|
||||
{
|
||||
get
|
||||
{
|
||||
return val1;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
int oldValue = val1;
|
||||
|
||||
// Make sure that the value does not stray outside the valid range.
|
||||
if (value < min)
|
||||
{
|
||||
val1 = min;
|
||||
}
|
||||
else if (value > max)
|
||||
{
|
||||
val1 = max;
|
||||
}
|
||||
else
|
||||
{
|
||||
val1 = value;
|
||||
}
|
||||
Invalidate();
|
||||
/*
|
||||
// Invalidate only the changed area.
|
||||
float percent;
|
||||
|
||||
Rectangle newValueRect = this.ClientRectangle;
|
||||
Rectangle oldValueRect = this.ClientRectangle;
|
||||
|
||||
// Use a new value to calculate the rectangle for progress.
|
||||
percent = (float)(val1 - min) / (float)(max - min);
|
||||
newValueRect.Width = (int)((float)newValueRect.Width * percent);
|
||||
|
||||
// Use an old value to calculate the rectangle for progress.
|
||||
percent = (float)(oldValue - min) / (float)(max - min);
|
||||
oldValueRect.Width = (int)((float)oldValueRect.Width * percent);
|
||||
|
||||
Rectangle updateRect = new Rectangle();
|
||||
|
||||
// Find only the part of the screen that must be updated.
|
||||
if (newValueRect.Width > oldValueRect.Width)
|
||||
{
|
||||
updateRect.X = oldValueRect.Size.Width;
|
||||
updateRect.Width = newValueRect.Width - oldValueRect.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
updateRect.X = newValueRect.Size.Width;
|
||||
updateRect.Width = oldValueRect.Width - newValueRect.Width;
|
||||
}
|
||||
|
||||
updateRect.Height = this.Height;
|
||||
|
||||
// Invalidate the intersection region only.
|
||||
this.Invalidate(updateRect);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
public int Value2
|
||||
{
|
||||
get
|
||||
{
|
||||
return val2;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
int oldValue = val2;
|
||||
|
||||
// Make sure that the value does not stray outside the valid range.
|
||||
if (value < min)
|
||||
{
|
||||
val2 = min;
|
||||
}
|
||||
else if (value > max)
|
||||
{
|
||||
val2 = max;
|
||||
}
|
||||
else
|
||||
{
|
||||
val2 = value;
|
||||
}
|
||||
Invalidate();
|
||||
|
||||
/*
|
||||
// Invalidate only the changed area.
|
||||
float percent;
|
||||
|
||||
Rectangle newValueRect = this.ClientRectangle;
|
||||
Rectangle oldValueRect = this.ClientRectangle;
|
||||
|
||||
// Use a new value to calculate the rectangle for progress.
|
||||
percent = (float)(val1 - min) / (float)(max - min);
|
||||
newValueRect.Width = (int)((float)newValueRect.Width * percent);
|
||||
|
||||
// Use an old value to calculate the rectangle for progress.
|
||||
percent = (float)(oldValue - min) / (float)(max - min);
|
||||
oldValueRect.Width = (int)((float)oldValueRect.Width * percent);
|
||||
|
||||
Rectangle updateRect = new Rectangle();
|
||||
|
||||
// Find only the part of the screen that must be updated.
|
||||
if (newValueRect.Width > oldValueRect.Width)
|
||||
{
|
||||
updateRect.X = oldValueRect.Size.Width;
|
||||
updateRect.Width = newValueRect.Width - oldValueRect.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
updateRect.X = newValueRect.Size.Width;
|
||||
updateRect.Width = oldValueRect.Width - newValueRect.Width;
|
||||
}
|
||||
|
||||
updateRect.Height = this.Height;
|
||||
|
||||
// Invalidate the intersection region only.
|
||||
this.Invalidate(updateRect);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private void Draw3DBorder(Graphics g)
|
||||
{
|
||||
int PenWidth = (int)Pens.White.Width;
|
||||
|
||||
g.DrawLine(Pens.DarkGray,
|
||||
this.ClientRectangle.Left, this.ClientRectangle.Top,
|
||||
this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Top);
|
||||
g.DrawLine(Pens.DarkGray,
|
||||
this.ClientRectangle.Left, this.ClientRectangle.Top,
|
||||
this.ClientRectangle.Left, this.ClientRectangle.Height - PenWidth);
|
||||
g.DrawLine(Pens.White,
|
||||
this.ClientRectangle.Left, this.ClientRectangle.Height - PenWidth,
|
||||
this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Height - PenWidth);
|
||||
g.DrawLine(Pens.White,
|
||||
this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Top,
|
||||
this.ClientRectangle.Width - PenWidth, this.ClientRectangle.Height - PenWidth);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used forserialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>80</value>
|
||||
</data>
|
||||
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>(Default)</value>
|
||||
</data>
|
||||
<data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>UsageControl</value>
|
||||
</data>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>8, 8</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
using STPCEDemo;
|
||||
|
||||
namespace UsageControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for UsageHistoryControl.
|
||||
/// </summary>
|
||||
public class UsageHistoryControl : System.Windows.Forms.UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
private const int squareWidth = 12;
|
||||
private const int maxLastValuesCount = 2000;
|
||||
private const int shiftStep = 3;
|
||||
|
||||
private int shift = 0;
|
||||
|
||||
private int [] lastValues1 = new int[maxLastValuesCount];
|
||||
private int [] lastValues2 = new int[maxLastValuesCount];
|
||||
private int nextValueIndex;
|
||||
private int lastValuesCount;
|
||||
|
||||
private int max = 100;
|
||||
private int min = 0;
|
||||
|
||||
public UsageHistoryControl()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
|
||||
EnableDoubleBuffering();
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
lastValues1.Initialize();
|
||||
lastValues2.Initialize();
|
||||
nextValueIndex = 0;
|
||||
lastValuesCount = 0;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
//
|
||||
// UsageHistoryControl
|
||||
//
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.Name = "UsageHistoryControl";
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void EnableDoubleBuffering()
|
||||
{
|
||||
// Set the value of the double-buffering style bits to true.
|
||||
//this.SetStyle(ControlStyles.DoubleBuffer |
|
||||
// ControlStyles.UserPaint |
|
||||
// ControlStyles.AllPaintingInWmPaint,
|
||||
// true);
|
||||
//this.UpdateStyles();
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
// Invalidate the control to get a repaint.
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
for(int i = 0; i <= ClientRectangle.Width+squareWidth; i += squareWidth)
|
||||
{
|
||||
g.DrawLine(Pens.Green, i-shift, 0, i-shift, ClientRectangle.Height);
|
||||
}
|
||||
|
||||
for(int i = 0; i < ClientRectangle.Height; i += squareWidth)
|
||||
{
|
||||
g.DrawLine(Pens.Green, 0, i, ClientRectangle.Width, i);
|
||||
}
|
||||
|
||||
int startValueIndex = (nextValueIndex-1+maxLastValuesCount)%maxLastValuesCount;
|
||||
|
||||
int prevVal1 = GetRelativeValue(lastValues1[startValueIndex]);
|
||||
int prevVal2 = GetRelativeValue(lastValues2[startValueIndex]);
|
||||
|
||||
for(int i = 1; i < lastValuesCount; ++i)
|
||||
{
|
||||
int index = nextValueIndex - 1 - i;
|
||||
if (index < 0)
|
||||
{
|
||||
index += maxLastValuesCount;
|
||||
}
|
||||
|
||||
int val1 = GetRelativeValue(lastValues1[index]);
|
||||
int val2 = GetRelativeValue(lastValues2[index]);
|
||||
|
||||
g.DrawLine(
|
||||
Pens.Red,
|
||||
ClientRectangle.Width-(i-1)*shiftStep, ClientRectangle.Height-prevVal2,
|
||||
ClientRectangle.Width-i*shiftStep, ClientRectangle.Height-val2);
|
||||
|
||||
g.DrawLine(
|
||||
Pens.LawnGreen,
|
||||
ClientRectangle.Width-(i-1)*shiftStep, ClientRectangle.Height-prevVal1,
|
||||
ClientRectangle.Width-i*shiftStep, ClientRectangle.Height-val1);
|
||||
|
||||
prevVal1 = val1;
|
||||
prevVal2 = val2;
|
||||
}
|
||||
}
|
||||
|
||||
private int GetRelativeValue(int val)
|
||||
{
|
||||
int result = val * (ClientRectangle.Height-2) / max + 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
public void AddValues(int val1, int val2)
|
||||
{
|
||||
lastValues1[nextValueIndex] = val1;
|
||||
lastValues2[nextValueIndex] = val2;
|
||||
|
||||
nextValueIndex++;
|
||||
nextValueIndex %= maxLastValuesCount;
|
||||
lastValuesCount++;
|
||||
if (lastValuesCount > maxLastValuesCount)
|
||||
{
|
||||
lastValuesCount = maxLastValuesCount;
|
||||
}
|
||||
|
||||
shift += shiftStep;
|
||||
shift %= squareWidth;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public int Maximum
|
||||
{
|
||||
get
|
||||
{
|
||||
return max;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
// Make sure that the maximum value is never set lower than the minimum value.
|
||||
if (value < min)
|
||||
{
|
||||
min = value;
|
||||
}
|
||||
|
||||
max = value;
|
||||
|
||||
// Invalidate the control to get a repaint.
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used forserialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>UsageHistoryControl</value>
|
||||
</data>
|
||||
<data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>80</value>
|
||||
</data>
|
||||
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>(Default)</value>
|
||||
</data>
|
||||
<data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>8, 8</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user