|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
using GeoSigma.SigmaDrawerStyle;
|
|
|
using GeoSigmaDrawLib;
|
|
|
using SigmaDrawerElement;
|
|
|
using SymbolLibManager;
|
|
|
using UCDraw;
|
|
|
|
|
|
namespace WellGroupEditor
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 井组编辑窗体类
|
|
|
/// </summary>
|
|
|
public partial class FormWellGroupEditor : Form
|
|
|
{
|
|
|
public string WellGroupData
|
|
|
{
|
|
|
get;set;
|
|
|
}
|
|
|
public WellGroupItemEdit GroupItemEdit { get; set; }
|
|
|
public GeoSigmaXY ParentGeo { get; set; }
|
|
|
public bool IsEdited { get; set; } = false;
|
|
|
private GeoSigma.UCDraw.MainView mainView;
|
|
|
private DrawViewer viewControl;
|
|
|
private WellGroupSetting groupSetting;
|
|
|
private WellGroupParameter sourceParameter;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 井符号
|
|
|
/// </summary>
|
|
|
//[Category("整体参数"), DisplayName("井符号"), PropertyOrder(7)]
|
|
|
//[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
|
public DrawerPointStyle WellSymbol { get; set; } = new DrawerPointStyle();
|
|
|
/// <summary>
|
|
|
/// 入靶点符号
|
|
|
/// </summary>
|
|
|
//[Category("整体参数"), DisplayName("入靶点符号"), PropertyOrder(8)]
|
|
|
//[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
|
public DrawerPointStyle StartSymbol { get; set; } = new DrawerPointStyle();
|
|
|
/// <summary>
|
|
|
/// 出靶点符号
|
|
|
/// </summary>
|
|
|
//[Category("整体参数"), DisplayName("出靶点符号"), PropertyOrder(9)]
|
|
|
public DrawerPointStyle EndSymbol { get; set; } = new DrawerPointStyle();
|
|
|
private Drawer parentDrawer;
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="FormWellGroupEditor"/> class.
|
|
|
/// </summary>
|
|
|
public FormWellGroupEditor()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
//tableLayoutPanel1.GetType().GetProperty(
|
|
|
// "DoubleBuffered"
|
|
|
// , System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
|
|
|
// .SetValue(tableLayoutPanel1, true, null);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="FormWellGroupEditor"/> class.
|
|
|
/// </summary>
|
|
|
/// <param name="wellGroupData">The well group data.</param>
|
|
|
public FormWellGroupEditor(string wellGroupData, GeoSigmaDrawLib.GeoSigmaXY geo, object parent)
|
|
|
: this()
|
|
|
{
|
|
|
if (parent is Control ucParent)
|
|
|
{
|
|
|
parentDrawer = (Drawer)ucParent;
|
|
|
}
|
|
|
this.ParentGeo = geo;
|
|
|
this.WellGroupData = wellGroupData;
|
|
|
|
|
|
groupSetting = new WellGroupSetting();
|
|
|
GroupItemEdit = new WellGroupItemEdit();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Form1_S the load.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private async void Form1_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
mainView = new GeoSigma.UCDraw.MainView();
|
|
|
this.Controls.Add(mainView.ToolstripElements);
|
|
|
viewControl = mainView.ViewControl;
|
|
|
AddEditorToolItem();
|
|
|
//设置窗体最大化
|
|
|
viewControl.Dock = DockStyle.Fill;
|
|
|
//指定当前子窗体显示的容器
|
|
|
viewControl.Parent = splitContainer1.Panel1;
|
|
|
viewControl.BringToFront();
|
|
|
viewControl.Show();
|
|
|
|
|
|
mainView.PropertyControl.Dock = DockStyle.Fill;
|
|
|
mainView.PropertyControl.Parent = splitContainer2.Panel2;
|
|
|
mainView.PropertyControl.Show();
|
|
|
|
|
|
mainView.PropertyVisible = true;
|
|
|
//mainView.LayerVisible = false;
|
|
|
//mainView.StatisticVisble = false;
|
|
|
//mainView.ToolstripView.Visible = false;
|
|
|
mainView.BeforeSaveFileEvent += saveElementData;
|
|
|
mainView.AutoReleaseView = true;
|
|
|
mainView.NewFile("");
|
|
|
viewControl.ElementMovedEvent += (pos) =>
|
|
|
{
|
|
|
//viewControl.Geo.WellGroupEditMovePoint(pos);
|
|
|
viewControl.Geo.WellGroupEditMoveElementS();
|
|
|
};
|
|
|
viewControl.SelectedElementChanged += (view, eleArgs) => {
|
|
|
if(eleArgs == null)
|
|
|
{
|
|
|
GroupItemEdit = null;
|
|
|
ppgEdit.SelectedObject = GroupItemEdit;
|
|
|
ppgEdit.Refresh();
|
|
|
return;
|
|
|
}
|
|
|
DrawerElementProperty property = eleArgs.Data;
|
|
|
if( property.ElementType == DrawElementType.ELEMENT_CURVE)
|
|
|
{
|
|
|
if(GroupItemEdit == null)
|
|
|
{
|
|
|
GroupItemEdit = new WellGroupItemEdit();
|
|
|
ppgEdit.SelectedObject = GroupItemEdit;
|
|
|
}
|
|
|
long pos = eleArgs.Position;
|
|
|
GroupItemEdit.HorizonLength = viewControl.Geo.GetCurveLength(pos);
|
|
|
GroupItemEdit.Position = eleArgs.Position;
|
|
|
ppgEdit.Refresh();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GroupItemEdit = null;
|
|
|
ppgEdit.SelectedObject = GroupItemEdit;
|
|
|
ppgEdit.Refresh();
|
|
|
}
|
|
|
};
|
|
|
//viewControl.DrawerOnMouseMoveEvent += async (drawer, mx, my) => {
|
|
|
// //await Task.Run(() => { parentDrawer.SetMouseLocation(mx, my); });
|
|
|
//};
|
|
|
//viewControl.DrawerChangedViewWindowEvent += async (drawer, left, top, scaleX, scaleY) => {
|
|
|
// await Task.Run(() => {
|
|
|
// //parentDrawer.SetViewStatus(left, top, scaleX, scaleY);
|
|
|
// });
|
|
|
//};
|
|
|
viewControl.Geo.SetZoomMode(1);
|
|
|
|
|
|
if(!string.IsNullOrEmpty(this.WellGroupData))
|
|
|
{
|
|
|
//viewControl.Geo.AddElementByBuffer(
|
|
|
// this.WellGroupData
|
|
|
// , (int)DrawElementType.ELEMENT_WELL_GROUP
|
|
|
// , 3);
|
|
|
//tsbSelect_Click(null, null);
|
|
|
// 进入编辑状态
|
|
|
mainView.ToolWellGroupEdit();
|
|
|
viewControl.Geo.WellGroupEditSetData(this.WellGroupData);
|
|
|
// 获得父级图件中的符号
|
|
|
GeoSigmaXY.DrawerCopyAllSymbol(this.ParentGeo.GetDrawerXy(), viewControl.Geo.GetDrawerXy(), false);
|
|
|
|
|
|
viewControl.ViewAll();
|
|
|
|
|
|
DrawerElementProperty eleProperty = DrawerElementHelp.Deserialize(WellGroupData);
|
|
|
DrawerWellGroup wellGroup = eleProperty.Element as DrawerWellGroup;
|
|
|
|
|
|
sourceParameter = wellGroup.Parameter;
|
|
|
if (sourceParameter != null)
|
|
|
{
|
|
|
groupSetting.BranchCountRight = sourceParameter.BranchCountRight;
|
|
|
groupSetting.BranchDistanceRight = sourceParameter.BranchDistanceRight;
|
|
|
|
|
|
groupSetting.BranchCountLeft = sourceParameter.BranchCountLeft;
|
|
|
groupSetting.BranchDistanceLeft = sourceParameter.BranchDistanceLeft;
|
|
|
|
|
|
groupSetting.BranchAngle = sourceParameter.BranchAngle;
|
|
|
groupSetting.HoriLength = sourceParameter.BranchLength;
|
|
|
groupSetting.BranchSpace = sourceParameter.BranchSpace;
|
|
|
}
|
|
|
//ppgSettingBase.SelectedObject = groupSetting;
|
|
|
//WellSymbol.Geo = viewControl.Geo;
|
|
|
//this.ppgWell.SelectedObject = this.WellSymbol;
|
|
|
//StartSymbol.Geo = viewControl.Geo;
|
|
|
//this.ppgStartSymbol.SelectedObject = this.StartSymbol;
|
|
|
//EndSymbol.Geo = viewControl.Geo;
|
|
|
//this.ppgEndSymbol.SelectedObject = this.EndSymbol;
|
|
|
ppgEdit.SelectedObject = this.GroupItemEdit;
|
|
|
}
|
|
|
viewControl.Geo.SaveActionPosition();
|
|
|
}
|
|
|
private void UpdateGroupSetting(bool isToShow)
|
|
|
{
|
|
|
//groupSetting.WellSymbol
|
|
|
}
|
|
|
private void AddEditorToolItem()
|
|
|
{
|
|
|
ToolStripButton tsbtnEdit = new ToolStripButton();
|
|
|
|
|
|
tsbtnEdit.CheckOnClick = true;
|
|
|
tsbtnEdit.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
|
|
tsbtnEdit.Image = Properties.Resources.curSelect;
|
|
|
tsbtnEdit.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
|
|
|
tsbtnEdit.ImageTransparentColor = System.Drawing.Color.Magenta;
|
|
|
tsbtnEdit.Name = "tsbSelect";
|
|
|
tsbtnEdit.Size = new System.Drawing.Size(23, 24);
|
|
|
tsbtnEdit.Text = "编辑";
|
|
|
tsbtnEdit.Click += new System.EventHandler(this.tsbSelect_Click);
|
|
|
mainView.ToolstripElements.Items[11].Visible = false;
|
|
|
mainView.ToolstripElements.Items.Insert(11, tsbtnEdit);
|
|
|
|
|
|
mainView.ButtonStatusChangeEvent += (DrawToolType toolType, bool bChecked) => {
|
|
|
if (toolType == DrawToolType.WellGroupEdit||
|
|
|
toolType == DrawToolType.EditWellGroupBranchCurveNode)
|
|
|
{
|
|
|
tsbtnEdit.Checked = bChecked;
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
private void tsbSelect_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (mainView.ToolWellGroupEdit() == false)
|
|
|
{
|
|
|
((ToolStripButton)sender).Checked = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void CreateIndex()
|
|
|
{
|
|
|
List<Tuple<int,int, int>> lstWellGroupData = new List<Tuple<int, int, int>>();
|
|
|
DrawerElementProperty propertyEdited = DrawerElementHelp.Deserialize(this.WellGroupData);
|
|
|
DrawerWellGroup wellGroup = propertyEdited.Element as DrawerWellGroup;
|
|
|
for(int i=0;i< wellGroup.WellBranches.Count;i++)
|
|
|
{
|
|
|
WellBranch branch = wellGroup.WellBranches[i];
|
|
|
|
|
|
DrawerPline plineOffset = new DrawerPline();
|
|
|
string strLine = $"{wellGroup.X},{wellGroup.Y}\r\n" +
|
|
|
$"{branch.PointStart.X},{branch.PointStart.Y}\r\n";
|
|
|
plineOffset.Coordinate = strLine;
|
|
|
|
|
|
DrawerElementProperty propertyOffset = new DrawerElementProperty();
|
|
|
propertyOffset.Element = plineOffset;
|
|
|
propertyOffset.CurveStyle = branch.LineStyles?.First(it=>it.Name== "offset");
|
|
|
string strLineData = DrawerElementHelp.Serialize(propertyOffset);
|
|
|
|
|
|
int nPos = viewControl.Geo.AddElementByBuffer(
|
|
|
strLineData
|
|
|
, (int)DrawElementType.ELEMENT_CURVE
|
|
|
, 3);
|
|
|
|
|
|
lstWellGroupData.Add(new Tuple<int, int, int>(i, 0, nPos));
|
|
|
|
|
|
DrawerPline plineHori = new DrawerPline();
|
|
|
strLine = $"{branch.PointStart.X},{branch.PointStart.Y}\r\n" +
|
|
|
$"{branch.PointEnd.X},{branch.PointEnd.Y}\r\n";
|
|
|
plineHori.Coordinate = strLine;
|
|
|
|
|
|
DrawerElementProperty propertyHori = new DrawerElementProperty();
|
|
|
propertyHori.Element = plineHori;
|
|
|
propertyHori.CurveStyle = branch.LineStyles?.First(it => it.Name == "horizon"); ;
|
|
|
strLineData = DrawerElementHelp.Serialize(propertyHori);
|
|
|
|
|
|
nPos = viewControl.Geo.AddElementByBuffer(
|
|
|
strLineData
|
|
|
, (int)DrawElementType.ELEMENT_CURVE
|
|
|
, 3);
|
|
|
lstWellGroupData.Add(new Tuple<int,int, int>(i, 1, nPos));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
private void saveElementData(CancelEventArgs e)
|
|
|
{
|
|
|
WellGroupData = viewControl.Geo.WellGroupEditGetData();
|
|
|
GeoSigmaXY.DrawerCopyAllSymbol(viewControl.Geo.GetDrawerXy(), this.ParentGeo.GetDrawerXy(), true);
|
|
|
viewControl.Geo.SaveActionPosition();
|
|
|
|
|
|
e.Cancel = true;
|
|
|
IsEdited = true;
|
|
|
}
|
|
|
|
|
|
//private void btnWellSymbol_Click(object sender, EventArgs e)
|
|
|
//{
|
|
|
// GeoSigmaXY geo = viewControl.Geo;
|
|
|
// string strLibraryPath = string.Empty;
|
|
|
// geo.GetLibraryPath(ref strLibraryPath);
|
|
|
// string strSelectedSymbolName = string.Empty;
|
|
|
// FrmSymbolSelect frm = new FrmSymbolSelect(geo, strLibraryPath, ref strSelectedSymbolName);
|
|
|
// if(frm.ShowDialog() == DialogResult.OK)
|
|
|
// {
|
|
|
// strSelectedSymbolName = frm.SelectedSymbolName;
|
|
|
// }
|
|
|
//}
|
|
|
/// <summary>
|
|
|
/// 应用样式
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void tsbtnApplyStyle_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
string strWellGroupData = viewControl.Geo.WellGroupEditGetData();
|
|
|
DrawerElementProperty eleProperty = DrawerElementHelp.Deserialize(strWellGroupData);
|
|
|
DrawerWellGroup wellGroup = eleProperty.Element as DrawerWellGroup;
|
|
|
WellGroupParameter para = new WellGroupParameter();
|
|
|
para.BranchCountRight = groupSetting.BranchCountRight;
|
|
|
para.BranchDistanceRight = groupSetting.BranchDistanceRight;
|
|
|
para.BranchCountLeft = groupSetting.BranchCountLeft;
|
|
|
para.BranchDistanceLeft = groupSetting.BranchDistanceLeft;
|
|
|
|
|
|
para.BranchAngle = groupSetting.BranchAngle;
|
|
|
para.BranchLength = groupSetting.HoriLength;
|
|
|
para.BranchSpace = groupSetting.BranchSpace;
|
|
|
wellGroup.Parameter = para;
|
|
|
|
|
|
for (int i = 0; i < wellGroup.WellBranches.Count; i++)
|
|
|
{
|
|
|
WellBranch branch = wellGroup.WellBranches[i];
|
|
|
if (branch.LineStyles == null)
|
|
|
{
|
|
|
branch.LineStyles = new List<DrawerCurveStyle>();
|
|
|
}
|
|
|
// 靶前位移线颜色
|
|
|
if (branch.LineStyles.Count < 1)
|
|
|
{
|
|
|
DrawerCurveStyle drawerCurveStyle = new DrawerCurveStyle();
|
|
|
drawerCurveStyle.Name = "offset";
|
|
|
branch.LineStyles.Add(drawerCurveStyle);
|
|
|
}
|
|
|
DrawerCurveStyle curveStyleOffset = branch.LineStyles[0];
|
|
|
if (curveStyleOffset.Properties.Count == 0)
|
|
|
{
|
|
|
CurveProperty curveProperty = new CurveProperty();
|
|
|
curveStyleOffset.Properties.Add(curveProperty);
|
|
|
}
|
|
|
CurveProperty curvePropertyOffset = curveStyleOffset.Properties.Find(it=>it is CurveProperty) as CurveProperty;
|
|
|
curvePropertyOffset.LineColor = groupSetting.WellOffsetColor;
|
|
|
// 水平段线颜色
|
|
|
if(branch.LineStyles.Count < 2)
|
|
|
{
|
|
|
DrawerCurveStyle drawerCurveStyle = new DrawerCurveStyle();
|
|
|
drawerCurveStyle.Name = "horizon";
|
|
|
branch.LineStyles.Add(drawerCurveStyle);
|
|
|
}
|
|
|
DrawerCurveStyle curveStyleHori = branch.LineStyles[1];
|
|
|
if (curveStyleHori.Properties.Count == 0)
|
|
|
{
|
|
|
CurveProperty curveProperty = new CurveProperty();
|
|
|
curveStyleHori.Properties.Add(curveProperty);
|
|
|
}
|
|
|
CurveProperty curvePropertyHori = curveStyleHori.Properties.Find(it => it is CurveProperty) as CurveProperty;
|
|
|
curvePropertyHori.LineColor = groupSetting.WellHoriColor;
|
|
|
// 入靶点符号
|
|
|
}
|
|
|
|
|
|
// 保存数据
|
|
|
eleProperty.Element = wellGroup;
|
|
|
string strData = DrawerElementHelp.Serialize(eleProperty);
|
|
|
viewControl.Geo.WellGroupEditSetData(strData);
|
|
|
|
|
|
viewControl.Redraw();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 重新生成
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void tsbtnRebuilt_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// ppgs the edit_ property value changed.
|
|
|
/// </summary>
|
|
|
/// <param name="s">The s.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void ppgEdit_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
|
|
{
|
|
|
object obj = e.ChangedItem.Value;
|
|
|
if(e.ChangedItem.PropertyDescriptor.Name == "HorizonLength")
|
|
|
{
|
|
|
double dLength = (double)obj;
|
|
|
if (dLength <= 0)
|
|
|
{
|
|
|
e.ChangedItem.PropertyDescriptor.SetValue(ppgEdit.SelectedObject, e.OldValue);
|
|
|
return;
|
|
|
}
|
|
|
WellGroupItemEdit groupItemEdit = ppgEdit.SelectedObject as WellGroupItemEdit;
|
|
|
if (groupItemEdit.Position <= 0 )
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
viewControl.Geo.SetBranchHorizonLength(dLength, groupItemEdit.Position);
|
|
|
viewControl.Redraw();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 窗体关闭事件.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void FormWellGroupEditor_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
{
|
|
|
bool bModified = false;
|
|
|
if (mainView != null && mainView.IsDocumentModified())
|
|
|
{
|
|
|
bModified = true;
|
|
|
}
|
|
|
if (bModified)
|
|
|
{
|
|
|
switch (MessageBox.Show(
|
|
|
"是否保存修改并退出?请选择:\r\n是,保存并退出;\r\n否,放弃修改退出;\r\n取消,不退出。", "关闭",
|
|
|
MessageBoxButtons.YesNoCancel,
|
|
|
MessageBoxIcon.Question))
|
|
|
{
|
|
|
case DialogResult.Cancel:
|
|
|
e.Cancel = true;
|
|
|
break;
|
|
|
case DialogResult.Yes:
|
|
|
WellGroupData = viewControl.Geo.WellGroupEditGetData();
|
|
|
if(sourceParameter !=null)
|
|
|
{
|
|
|
sourceParameter.BranchCountRight = groupSetting.BranchCountRight;
|
|
|
sourceParameter.BranchDistanceRight = groupSetting.BranchDistanceRight;
|
|
|
|
|
|
sourceParameter.BranchCountLeft = groupSetting.BranchCountLeft;
|
|
|
sourceParameter.BranchDistanceLeft = groupSetting.BranchDistanceLeft;
|
|
|
|
|
|
sourceParameter.BranchAngle = groupSetting.BranchAngle;
|
|
|
sourceParameter.BranchLength = groupSetting.HoriLength;
|
|
|
sourceParameter.BranchSpace = groupSetting.BranchSpace;
|
|
|
|
|
|
DrawerElementProperty eleProperty = DrawerElementHelp.Deserialize(WellGroupData);
|
|
|
DrawerWellGroup wellGroup = eleProperty.Element as DrawerWellGroup;
|
|
|
wellGroup.Parameter = sourceParameter;
|
|
|
|
|
|
WellGroupData = DrawerElementHelp.Serialize(eleProperty);
|
|
|
}
|
|
|
|
|
|
GeoSigmaXY.DrawerCopyAllSymbol(viewControl.Geo.GetDrawerXy(), this.ParentGeo.GetDrawerXy(), false);
|
|
|
IsEdited = true;
|
|
|
e.Cancel = false;
|
|
|
break;
|
|
|
case DialogResult.No:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|