using DPumpHydr.WinFrmUI.RLT.Child.Crown;
|
using DPumpHydr.WinFrmUI.RLT.Docking.Crown;
|
using System.Drawing;
|
using System.Windows.Forms;
|
using System.Collections.Generic;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
using System;
|
using System.ComponentModel;
|
|
namespace DPumpHydr.WinFrmUI.Volute
|
{
|
public partial class SectAreaDockPanel : CrownToolWindow
|
{
|
|
public SectAreaDockPanel()
|
{
|
InitializeComponent();
|
|
this.DefaultDockArea = RLT.Enum.Crown.DockArea.Bottom;
|
this.DockText = "截面面积";
|
this.SerializationKey = "SectAreaDockPanel";
|
|
}
|
private ViewModel.SectionBundleInfo _bundle = null;
|
private ViewModel.SectionShapePara _para = null;
|
public Action<ViewModel.SectionBundleInfo , int> OnRefreshSingleSectBundle = null;
|
public void RefreshControl()
|
{
|
_selectedPointIndex = -1;
|
chart.RefreshControl();
|
}
|
|
public void SetBindingData(ViewModel.SectionBundleInfo bundle)
|
{
|
if (bundle == null) return;
|
_bundle = bundle;
|
List<double> Data = new List<double>();
|
for (int i = 0; i < 9; i++)
|
{
|
Data.Add(bundle.Area[i]);
|
}
|
chart.SetBindingData(Data);
|
}
|
public void SetBindingData(ViewModel.SectionShapePara para)
|
{
|
if(para == null) return;
|
_para = para;
|
chart.SetBindingData(para);
|
}
|
public ViewModel.SectionBundleInfo GetBindingData(out string error)
|
{
|
error = "";
|
if (_bundle == null)
|
{
|
error = "_bundle为空";
|
return null;
|
}
|
return _bundle;
|
}
|
protected override bool ProcessDialogKey(Keys keyData)
|
{
|
if (keyData == Keys.Up || keyData == Keys.Down || keyData == Keys.Left || keyData == Keys.Right)
|
{
|
return false;
|
}
|
else
|
{
|
return base.ProcessDialogKey(keyData);
|
}
|
}
|
private int _selectedPointIndex = -1;
|
private void chart_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
|
{
|
if (_selectedPointIndex == -1)
|
{
|
return;
|
}
|
var data = chart.GetBindingData();
|
if (data == null)
|
{
|
return;
|
}
|
//根据按键增加或减少Y值
|
if (e.KeyCode == Keys.Up)
|
{
|
data[_selectedPointIndex] += data[_selectedPointIndex] * 0.01; // 增加Y值
|
chart.SetBindingData(data);
|
_bundle.Area[_selectedPointIndex] = data[_selectedPointIndex];
|
OnRefreshSingleSectBundle.Invoke(_bundle, _selectedPointIndex);
|
}
|
else if (e.KeyCode == Keys.Down)
|
{
|
data[_selectedPointIndex] -= data[_selectedPointIndex] * 0.01; // 减少Y值
|
chart.SetBindingData(data);
|
_bundle.Area[_selectedPointIndex] = data[_selectedPointIndex];
|
OnRefreshSingleSectBundle.Invoke(_bundle, _selectedPointIndex);
|
}
|
}
|
//int _sequence = 0;
|
private void chart_MouseClick(object sender, MouseEventArgs e)
|
{
|
int pointIndex = chart.Judgment_point(e.X, e.Y);
|
if (pointIndex == -1)
|
{
|
return;
|
}
|
if (_para != null)
|
{
|
if(_para.Index != pointIndex)
|
{
|
return;
|
}
|
}
|
_selectedPointIndex = pointIndex;
|
}
|
|
|
}
|
}
|