Devexpress中的实时Grid和precessBar的学习笔记
2014-05-06 17:31
274 查看
正在实现一个调度界面,本身用到了TreeList示例。
用的是11版的:WinForms\XtraTreeList\CS\TreeListMainDemo
现在,我想了解一下最新的技术,特别是实时变更工具条的部分。
DevExpress-13.2.6 中,找到一个grid的实时示例:
C:\Users\Public\Documents\DevExpress Demos 13.2\Components\WinForms\CS\GridMainDemo\bin\Debug
我们这次分析,两个重点:
1. 如何在gridview中加入一列,显示进度条。
2. 进度条如何动态改变
启动后,我们先来看看,如何填加后面的工具条:
editorProgressBar = new RepositoryItemProgressBar { Minimum = 300, Maximum = 1000, ShowTitle = true, PercentView = false };
gridView1.GridControl.RepositoryItems.AddRange(new RepositoryItem[] { editorProgressBar });
column.ColumnEdit = editorProgressBar;
在这里下断,因为可以肯定,是需要改变这个值的。
找到:
public void Do() {
Random rndRow = new Random();
int postedOperation = 0;
do {
Stopwatch watch = Stopwatch.StartNew();
int row = rndRow.Next(0, collection.Count);
lock(lockObj) {
if(!useRealtimeSource) {
Interlocked.Increment(ref postedOperation);
context.Post((x) => {
collection[row].Update();
collection.ResetItem(row);
Interlocked.Decrement(ref postedOperation);
}, null);
} else {
collection[row].Update();
collection.ResetItem(row);
}
}
把这句注释掉后,启动,发现界面果然静止了。
那么,这里也就是我们要调研的第二个重点。
最难懂的就是这句:
realTimeSource.DataSource = chtr.List;
后面没看明白。
[DXToolboxItem(true)]
[ToolboxBitmap(typeof(ResFinder), "Bitmaps256.RealTimeSource.bmp")]
[Designer("DevExpress.Xpo.Design.RealtimeSourceDesigner, DevExpress.Xpo.v13.2.Design")]
[ToolboxTabName("DX.13.2: Data & Analytics")]
public class RealTimeSource : Component, IListSource, IDXCloneable
{
public static int SendQueueTimeout;
public RealTimeSource();
[RefreshProperties(RefreshProperties.All)]
[Category("Data")]
[AttributeProvider(typeof(IListSource))]
[DefaultValue("")]
public object DataSource { get; set; }
[RefreshProperties(RefreshProperties.All)]
[Editor("DevExpress.Design.RealTimeSourcePropertiesEditor, DevExpress.Design.v13.2", "System.Drawing.Design.UITypeEditor, System.Drawing")]
public string DisplayableProperties { get; set; }
[DefaultValue(false)]
public bool IgnoreItemEvents { get; set; }
[Browsable(false)]
public bool UseWeakEventHandler { get; set; }
public void CatchUp();
protected override void Dispose(bool disposing);
protected virtual object DXClone();
protected virtual RealTimeSource DXCloneCreate();
public static IEnumerable<string> GetDisplayableProperties(object source);
public IList GetList();
public TimeSpan GetQueueDelay();
public void Resume();
public void Suspend();
}
chtr = new ChangeThread(syncContext);
RealTimeSource rts = new RealTimeSource();
realTimeSource.DataSource = chtr.List;
这个就是那个list
readonly BindingList<MarketData> collection = new BindingList<MarketData>();
public class MarketData {
readonly static Random rnd = new Random();
const double MAX = 950;
const double MIN = 350;
public string Ticker { get; private set; }
double last;
public double Last {
get { return Math.Round(last, 1); }
private set { last = value; }
}
double chgPercent;
public double ChgPercent {
get { return Math.Round(chgPercent * 100, 2); }
private set { chgPercent = value; }
}
double open;
public double Open {
get { return Math.Round(open, 1); }
private set { open = value; }
}
double high;
public double High {
get { return Math.Round(high, 1); }
private set { high = value; }
}
double low;
public double Low {
get { return Math.Round(low, 1); }
private set { low = value; }
}
public DateTime Date;
public string Time {
get { return Date.ToLongTimeString(); }
}
double dayVal;
public double DayVal {
get { return Math.Round(dayVal, 1); }
private set { dayVal = value; }
}
没有完全看明白。但它就是能工作。
上面的属性,最终是如何映射到界面上的。
用的是11版的:WinForms\XtraTreeList\CS\TreeListMainDemo
现在,我想了解一下最新的技术,特别是实时变更工具条的部分。
DevExpress-13.2.6 中,找到一个grid的实时示例:
C:\Users\Public\Documents\DevExpress Demos 13.2\Components\WinForms\CS\GridMainDemo\bin\Debug
我们这次分析,两个重点:
1. 如何在gridview中加入一列,显示进度条。
2. 进度条如何动态改变
启动后,我们先来看看,如何填加后面的工具条:
namespace DevExpress.XtraGrid.Demos { public partial class RealTimeSourceDemo : TutorialControl { public RealTimeSourceDemo() { InitializeComponent(); TutorialInfo.WhatsThisCodeFile = "CS\\GridMainDemo\\Modules\\RealTimeSource.cs"; TutorialInfo.WhatsThisXMLFile = "DevExpress.XtraGrid.Demos.CodeInfo.RealTimeSource.xml"; editorProgressBar = new RepositoryItemProgressBar { Minimum = 300, Maximum = 1000, ShowTitle = true, PercentView = false }; }
editorProgressBar = new RepositoryItemProgressBar { Minimum = 300, Maximum = 1000, ShowTitle = true, PercentView = false };
protected override void DoShow() { base.DoShow(); isHide = false; syncContext = SynchronizationContext.Current; chtr = new ChangeThread(syncContext); trackBar1.Value = 10; PatchInterval(); //<gridControl1> realTimeSource = CreateRealTimeSource(); gridControl1.DataSource = realTimeSource; //</gridControl1> timerShow = new Timer(TimerShowCallback, null, 0, 500); backgroundTimer = new Timer(chtr.OnIdle, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(10)); this.Disposed += RealTimeSourceDemo_Disposed; chartControl1.Series["UPSDiagram"].Points.Clear(); tr = new Thread(chtr.Do); tr.IsBackground = true; tr.Start(); //<gridControl1> realTimeSource.DataSource = chtr.List; //</gridControl1> gridView1.GridControl.RepositoryItems.AddRange(new RepositoryItem[] { editorProgressBar }); }
gridView1.GridControl.RepositoryItems.AddRange(new RepositoryItem[] { editorProgressBar });
private void gridView1_DataSourceChanged(object sender, EventArgs e) { GridColumn column = gridView1.Columns["DayVal"]; if(column == null || editorProgressBar == null) return; column.ColumnEdit = editorProgressBar; }
column.ColumnEdit = editorProgressBar;
在这里下断,因为可以肯定,是需要改变这个值的。
public class MarketData { double dayVal; public double DayVal { get { return Math.Round(dayVal, 1); } private set { dayVal = value; } } }
找到:
public void Do() {
Random rndRow = new Random();
int postedOperation = 0;
do {
Stopwatch watch = Stopwatch.StartNew();
int row = rndRow.Next(0, collection.Count);
lock(lockObj) {
if(!useRealtimeSource) {
Interlocked.Increment(ref postedOperation);
context.Post((x) => {
collection[row].Update();
collection.ResetItem(row);
Interlocked.Decrement(ref postedOperation);
}, null);
} else {
collection[row].Update();
collection.ResetItem(row);
}
}
把这句注释掉后,启动,发现界面果然静止了。
那么,这里也就是我们要调研的第二个重点。
最难懂的就是这句:
realTimeSource.DataSource = chtr.List;
后面没看明白。
[DXToolboxItem(true)]
[ToolboxBitmap(typeof(ResFinder), "Bitmaps256.RealTimeSource.bmp")]
[Designer("DevExpress.Xpo.Design.RealtimeSourceDesigner, DevExpress.Xpo.v13.2.Design")]
[ToolboxTabName("DX.13.2: Data & Analytics")]
public class RealTimeSource : Component, IListSource, IDXCloneable
{
public static int SendQueueTimeout;
public RealTimeSource();
[RefreshProperties(RefreshProperties.All)]
[Category("Data")]
[AttributeProvider(typeof(IListSource))]
[DefaultValue("")]
public object DataSource { get; set; }
[RefreshProperties(RefreshProperties.All)]
[Editor("DevExpress.Design.RealTimeSourcePropertiesEditor, DevExpress.Design.v13.2", "System.Drawing.Design.UITypeEditor, System.Drawing")]
public string DisplayableProperties { get; set; }
[DefaultValue(false)]
public bool IgnoreItemEvents { get; set; }
[Browsable(false)]
public bool UseWeakEventHandler { get; set; }
public void CatchUp();
protected override void Dispose(bool disposing);
protected virtual object DXClone();
protected virtual RealTimeSource DXCloneCreate();
public static IEnumerable<string> GetDisplayableProperties(object source);
public IList GetList();
public TimeSpan GetQueueDelay();
public void Resume();
public void Suspend();
}
chtr = new ChangeThread(syncContext);
RealTimeSource rts = new RealTimeSource();
realTimeSource.DataSource = chtr.List;
这个就是那个list
readonly BindingList<MarketData> collection = new BindingList<MarketData>();
public class MarketData {
readonly static Random rnd = new Random();
const double MAX = 950;
const double MIN = 350;
public string Ticker { get; private set; }
double last;
public double Last {
get { return Math.Round(last, 1); }
private set { last = value; }
}
double chgPercent;
public double ChgPercent {
get { return Math.Round(chgPercent * 100, 2); }
private set { chgPercent = value; }
}
double open;
public double Open {
get { return Math.Round(open, 1); }
private set { open = value; }
}
double high;
public double High {
get { return Math.Round(high, 1); }
private set { high = value; }
}
double low;
public double Low {
get { return Math.Round(low, 1); }
private set { low = value; }
}
public DateTime Date;
public string Time {
get { return Date.ToLongTimeString(); }
}
double dayVal;
public double DayVal {
get { return Math.Round(dayVal, 1); }
private set { dayVal = value; }
}
没有完全看明白。但它就是能工作。
上面的属性,最终是如何映射到界面上的。
相关文章推荐
- Devexpress 12.2.8.0 部分学习笔记1 【pivot grid】
- cortex_m3_stm32嵌入式学习笔记(十四):RTC实时时钟(秒中断)
- Ext第一周 史上最强学习笔记---GridPanel(基础篇)
- <一>Strom实时计算学习笔记
- QtQuick学习笔记之QML布局定位器Row/Column/Grid/Flow
- extjs学习笔记(四)带分页的grid
- extjs 学习笔记(三) 最基本的grid
- 操作系统学习笔记:实时系统
- Ext.Net学习笔记11:Ext.Net GridPanel的用法
- Devexpress 12.2.8.0 部分学习笔记1 WebChartControl
- QNX实时操作系统学习笔记之嵌入式系统(二)
- Grid++Report 学习笔记1-重复的行抑制显示
- Ext JS4 学习笔记之发送表单(Form)时也将表单下的表格(Grid)数据一同发送的方法
- Ext.Net学习笔记17:Ext.Net GridPanel Selection
- QNX实时操作系统学习笔记之嵌入式系统(一)
- ExtJs学习笔记(2)_Basic GridPanel[基本网格]
- extjs 学习笔记(三) 最基本的grid
- Zeroc Ice 学习笔记--IceGrid服务部署
- 操作系统学习笔记:实时系统
- 【Ext.Net学习笔记】06:Ext.Net GridPanel的用法(GridPanel 折叠/展开行、GridPanel Selection、 可编辑的GridPanel)