namespace Yw.WinFrmUI.Phart
|
{
|
public partial class UniversalChartExcelImportCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public UniversalChartExcelImportCtrl()
|
{
|
InitializeComponent();
|
this.gridView1.SetDefaultEditView();
|
this.gridView1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
this.repImgCmbFeatType.Items.Add("三次拟合", Yw.Ahart.eFeatType.Cubic, -1);
|
this.repImgCmbFeatType.Items.Add("不拟合", Yw.Ahart.eFeatType.Through2d, -1);
|
|
}
|
|
|
private Yw.Ahart.eFeatType _feat_type;
|
private List<Yw.Geometry.Point2d> _def_pt_list = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Ahart.eCurveType curve_type, List<Yw.Geometry.Point2d> def_pt_list)
|
{
|
_def_pt_list = def_pt_list;
|
_def_pt_list ??= new List<Geometry.Point2d>();
|
_feat_type = Yw.Ahart.eFeatType.Cubic;
|
|
var (axis_x_title, axis_y_title) = AxisTitleHelper.Get(curve_type);
|
this.colX.Caption = axis_x_title;
|
this.colY.Caption = axis_x_title;
|
|
this.universalEditChart1.AxisXTitle = axis_x_title;
|
this.universalEditChart1.AxisYTitle = axis_y_title;
|
|
this.bindingSource1.DataSource = _def_pt_list;
|
this.bindingSource1.ResetBindings(false);
|
|
}
|
|
|
//设置图表
|
private void SetChart(Yw.Ahart.eFeatType feat_type, List<Yw.Geometry.Point2d> def_pt_list)
|
{
|
if (def_pt_list == null || def_pt_list.Count < 4)
|
{
|
this.universalEditChart1.Clear();
|
return;
|
}
|
var fit_pt_list = def_pt_list.GetFitPointList(feat_type);
|
this.universalEditChart1.SetBindingData(def_pt_list, fit_pt_list);
|
}
|
|
|
//值变换
|
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
{
|
SetChart(_feat_type, _def_pt_list);
|
}
|
|
//拟合
|
private void barFeatType_EditValueChanged(object sender, EventArgs e)
|
{
|
_feat_type = (Yw.Ahart.eFeatType)this.barFeatType.EditValue;
|
SetChart(_feat_type, _def_pt_list);
|
}
|
|
/// <summary>
|
/// 获取数据
|
/// </summary>
|
public bool Get(out Yw.Ahart.eFeatType feat_type, out List<Yw.Geometry.Point2d> pt_list)
|
{
|
feat_type = _feat_type;
|
pt_list = _def_pt_list;
|
if (_def_pt_list == null || !_def_pt_list.Any())
|
return false;
|
return true;
|
}
|
|
|
|
}
|
|
}
|