首页 > 代码库 > silverlight visifire控件图表制作——silverlight 后台方法ControlChart.xaml.cs
silverlight visifire控件图表制作——silverlight 后台方法ControlChart.xaml.cs
一、构造方法ControlChart
1、前台页面控件赋值
//时间下拉框赋值,下拉框赋选定值
for (int ii = DateTime.Today.Year; ii >= 1980; ii--)
{
string item = string.Format("{0}年", ii.ToString());
this.dateYear.Items.Add(item);
if (item == sClickReportDate)
{
this.dateYear.SelectedValue = http://www.mamicode.com/sClickReportDate;//下拉框赋选定值
}
}
2、页面地名下拉框绑定数据,下拉框赋选定值
string str = "大庆,吉林,辽河,华北,大港,冀东,浙江,新疆";
string[] address = str.Split(‘,‘);
for (int i = 0; i < address.Length; i++)
{
this.addressNameList.Items.Add(address[i]);
if (address[i] == ChartTitle)
{
this.addressNameList.SelectedValue = http://www.mamicode.com/ChartTitle;//下拉框赋选定值
}
}
3、调整页面布局
this.dateStart.Visibility = Visibility.Collapsed;//不显示控件
this.dateYear.Visibility = Visibility.Visible;//显示控件
this.addressName.Margin = new Thickness(167, 16, 0, 0);//位置
this.addressNameList.Margin = new Thickness(212, 12, 0, 0);
this.btnDown.Margin = new Thickness(322, 12, 0, 0);
this.dtName.Margin = new Thickness(412, 16, 0, 0);
this.showData.Margin = new Thickness(470, 18, 0, 0);
4、查询方法(调用wcf获取画图信息)
Query();
private void Query()
{
DBServiceClient svc = new DBServiceClient(); //调用wcf
//委托
svc.GetSingleChartDataCompleted += new EventHandler<GetSingleChartDataCompletedEventArgs>(svc_GetSingleChartDataCompleted);
//调用wcf的GetSingleChartData 方法
//(详细方法请参考博文:silverlight visifire控件图表制作——wcf)
svc.GetSingleChartDataAsync(strReportDate, strEndReportDate, sTNameClick, sXName);
}
5、打印
(详细请参考博文:silverlight visifire控件图表制作——silverlight 后台方法打印 http://www.cnblogs.com/xuxin-1989/p/3819686.html)
6、委托方法
private void svc_GetSingleChartDataCompleted(object sender, GetSingleChartDataCompletedEventArgs e)
{
//获得wcf 返回值
ObservableCollection<ListItem> lBaseOilBar = e.Result;
//画图
CreateChart(this.gridVisifire, lBaseOilBar);
}
7、画图方法(详细请参考博文:silverlight visifire控件图表制作——silverlight 后台方法画图方法)
8、页面事件
(详细请参考博文:silverlight visifire控件图表制作——silverlight 后台方法页面事件 http://www.cnblogs.com/xuxin-1989/p/3819773.html)