|
|
// <copyright file="PanelProperty.cs" company="PlaceholderCompany">
|
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
|
// </copyright>
|
|
|
|
|
|
using GeoSigma.SigmaDrawerStyle;
|
|
|
using GeoSigma.SigmaDrawerUtil;
|
|
|
using GeoSigma.UCDraw.Drawtool;
|
|
|
using GeoSigmaDrawLib;
|
|
|
using SigmaDrawerElement;
|
|
|
using StyleLibManager;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Reflection;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace UCDraw
|
|
|
{
|
|
|
public delegate void SymbolSigma(GeoSigmaDrawLib.GeoSigmaXY geoSigma);
|
|
|
|
|
|
/// <summary>
|
|
|
/// 属性面板
|
|
|
/// </summary>
|
|
|
public partial class PanelEleProperty : UserControl
|
|
|
{
|
|
|
public WellBaseDrawView Viewer { get; set; }
|
|
|
public string LayerName { get; set; }
|
|
|
private int propertyType = 0; // 0-层位属性;1-元素属性
|
|
|
private int propertyIndex = -1;
|
|
|
private int elementPropertyIndex = -1;
|
|
|
public SymbolSigma GetSigmaEvent { get; set; } = null;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 图元属性发生了变化
|
|
|
/// </summary>
|
|
|
public event EventHandler<EventArgs> ElementChanged;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 图层属性发生了变化
|
|
|
/// </summary>
|
|
|
public event EventHandler<EventArgs> LayerChanged;
|
|
|
|
|
|
public PanelEleProperty()
|
|
|
{
|
|
|
this.InitializeComponent();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 属性控件绘制事件.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void propertyGrid_Paint(object sender, PaintEventArgs e)
|
|
|
{
|
|
|
PropertyGrid propertyGrid = sender as PropertyGrid;
|
|
|
Type objectType = propertyGrid.SelectedObject?.GetType();
|
|
|
FieldInfo categorysinfo = objectType?.GetField("categorys", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
if (categorysinfo != null)
|
|
|
{
|
|
|
List<string> categorys = categorysinfo.GetValue(propertyGrid.SelectedObject) as List<String>;
|
|
|
propertyGrid.CollapseAllGridItems();
|
|
|
GridItemCollection currentPropEntries = typeof(PropertyGrid).GetField("currentPropEntries", BindingFlags.NonPublic | BindingFlags.Instance)
|
|
|
.GetValue(propertyGrid) as GridItemCollection;
|
|
|
GridItem[] newarray = currentPropEntries.Cast<GridItem>().OrderBy((t) => categorys.IndexOf(t.Label)).ToArray();
|
|
|
currentPropEntries.GetType().GetField("entries", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(currentPropEntries, newarray);
|
|
|
|
|
|
propertyGrid.ExpandAllGridItems();
|
|
|
// 获取顶层分类节点
|
|
|
GridItem rootItem = propertyGrid.SelectedGridItem;
|
|
|
while (rootItem?.Parent != null)
|
|
|
{
|
|
|
rootItem = rootItem.Parent;
|
|
|
}
|
|
|
// 展开第一级分类
|
|
|
foreach (GridItem item in rootItem?.GridItems)
|
|
|
{
|
|
|
item.Expanded = true;
|
|
|
}
|
|
|
}
|
|
|
propertyGrid.Paint -= this.propertyGrid_Paint;
|
|
|
}
|
|
|
|
|
|
private DrawerStyle currentStyle;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 图层属性
|
|
|
/// </summary>
|
|
|
public DrawerStyle CurrentStyle
|
|
|
{
|
|
|
get => this.currentStyle;
|
|
|
set
|
|
|
{
|
|
|
this.currentStyle = value;
|
|
|
this.ppgLayer.SelectedObject = null;
|
|
|
this.lsvLayer.Items.Clear();
|
|
|
// lsvElement.Items.Clear();
|
|
|
if (this.currentStyle == null)
|
|
|
{
|
|
|
this.SetElementUI();
|
|
|
return;
|
|
|
}
|
|
|
if (this.currentStyle.CurveStyle != null)
|
|
|
{
|
|
|
List<CurveView> lstCurve = this.currentStyle.CurveStyle.Properties;
|
|
|
if (lstCurve != null && lstCurve.Count > 0)
|
|
|
{
|
|
|
int nIndex = 0;
|
|
|
foreach (CurveView curve in lstCurve)
|
|
|
{
|
|
|
if (curve is CurveStyleBase)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
nIndex++;
|
|
|
ListViewItem lvi = new ListViewItem(string.Empty + nIndex);
|
|
|
lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, curve.TypeName));
|
|
|
lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, GeoSigma.UCDraw.Properties.Resources.PanelProperty_Curve_TypeName));
|
|
|
lvi.Tag = curve;
|
|
|
this.lsvLayer.Items.Add(lvi);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (this.currentStyle.PontStyle != null)
|
|
|
{
|
|
|
AddPointStyleItem(this.currentStyle.PontStyle, this.lsvLayer);
|
|
|
}
|
|
|
if (this.lsvLayer.Items.Count > 0)
|
|
|
{
|
|
|
// CurveProperty property = lsvCurve.Items[0].Tag as CurveProperty;
|
|
|
this.lsvLayer.Items[0].Selected = true;
|
|
|
// propertyGrid.SelectedObject = lsvLayer.Items[0].Tag;
|
|
|
}
|
|
|
this.lsvLayer.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
|
|
|
|
|
|
this.SetElementUI();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private DrawerElementProperty elementProperty;
|
|
|
/// <summary>
|
|
|
/// 图元属性
|
|
|
/// </summary>
|
|
|
public DrawerElementProperty ElementProperty
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return this.elementProperty;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
this.elementProperty = value;
|
|
|
this.ppgElement.SelectedObject = null;
|
|
|
this.ppgData.SelectedObject = null;
|
|
|
this.lsvElement.Items.Clear();
|
|
|
if (this.elementProperty == null || this.elementProperty.Element == null)
|
|
|
{
|
|
|
this.SetElementUI();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (this.Viewer.SelectGetLayerName(out string layer))
|
|
|
{
|
|
|
this.elementProperty.Element.Layer = layer;
|
|
|
}
|
|
|
|
|
|
this.ppgData.SelectedObject = this.elementProperty.Element;
|
|
|
|
|
|
if (this.IsPointType(this.elementProperty.Element.ElementType))
|
|
|
{
|
|
|
if (this.elementProperty.PointStyle != null)
|
|
|
{
|
|
|
AddPointStyleItem(this.elementProperty.PointStyle, this.lsvElement);
|
|
|
}
|
|
|
}
|
|
|
else if (this.elementProperty.Element.ElementType == DrawElementType.ELEMENT_CURVE)
|
|
|
{
|
|
|
this.lsvElement.Visible = true;
|
|
|
this.ppgElement.Visible = true;
|
|
|
|
|
|
if (this.elementProperty.CurveStyle != null)
|
|
|
{
|
|
|
List<CurveView> lstCurve = this.elementProperty.CurveStyle.Properties;
|
|
|
if (lstCurve != null && lstCurve.Count > 0)
|
|
|
{
|
|
|
int nIndex = 1;
|
|
|
foreach (CurveView curve in lstCurve)
|
|
|
{
|
|
|
if (curve is CurveStyleBase)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
ListViewItem lvi = new ListViewItem(string.Empty + nIndex);
|
|
|
lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, curve.TypeName));
|
|
|
lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, GeoSigma.UCDraw.Properties.Resources.PanelProperty_Curve_TypeName));
|
|
|
lvi.Tag = curve;
|
|
|
this.lsvElement.Items.Add(lvi);
|
|
|
|
|
|
nIndex++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (this.elementProperty.Element.ElementType == DrawElementType.ELEMENT_MESH)
|
|
|
{
|
|
|
DrawerSurface surface = this.elementProperty.Element as DrawerSurface;
|
|
|
// surface.Items.DrawerUpdateEvent +=new DrawerUpdateEventHandler( Items_DrawerUpdateEvent);
|
|
|
if (surface.Items.DrawerUpdateEvent == null)
|
|
|
{
|
|
|
surface.Items.DrawerUpdateEvent += (GradientColors colors) =>
|
|
|
{
|
|
|
surface.SetColors(colors);
|
|
|
string strData = DrawerElementHelp.Serialize(this.elementProperty);
|
|
|
if (this.Viewer.SetElementProperty(strData) == true) //ggff
|
|
|
{
|
|
|
this.Viewer.Redraw();
|
|
|
}
|
|
|
// MessageBox.Show("Need Redraw");
|
|
|
// Viewer.Redraw();
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
if (this.lsvElement.Items.Count > 0)
|
|
|
{
|
|
|
this.lsvElement.Items[0].Selected = true;
|
|
|
}
|
|
|
this.lsvElement.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
|
|
|
|
|
|
this.SetElementUI();
|
|
|
|
|
|
this.SetDataPropertyStatus(this.ppgData);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public long ElementPosition { get; set; } = 0;
|
|
|
/// <inheritdoc/>
|
|
|
protected override void OnHandleCreated(EventArgs e)
|
|
|
{
|
|
|
float fDpixRatio = AutoResizeForm.GetWindowsZoomRatio(this.CreateGraphics());
|
|
|
if (fDpixRatio != 1.0f)
|
|
|
{
|
|
|
this.tsElementToolBar.ImageScalingSize = new Size(
|
|
|
(int)(this.tsElementToolBar.ImageScalingSize.Width * fDpixRatio)
|
|
|
, (int)(this.tsElementToolBar.ImageScalingSize.Height * fDpixRatio));
|
|
|
foreach (ToolStripItem item in this.tsElementToolBar.Items)
|
|
|
{
|
|
|
if (item.Image != null)
|
|
|
{
|
|
|
Image imgDest = AutoResizeForm.ImageBicubicResize(
|
|
|
item.Image, fDpixRatio);
|
|
|
item.Image.Dispose();
|
|
|
item.Image = imgDest;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.tsLayerToolBar.ImageScalingSize = new Size(
|
|
|
(int)(this.tsLayerToolBar.ImageScalingSize.Width * fDpixRatio)
|
|
|
, (int)(this.tsLayerToolBar.ImageScalingSize.Height * fDpixRatio));
|
|
|
foreach (ToolStripItem item in this.tsLayerToolBar.Items)
|
|
|
{
|
|
|
if (item.Image != null)
|
|
|
{
|
|
|
Image imgDest = AutoResizeForm.ImageBicubicResize(
|
|
|
item.Image, fDpixRatio);
|
|
|
item.Image.Dispose();
|
|
|
item.Image = imgDest;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 设置属性的状态
|
|
|
/// </summary>
|
|
|
/// <param name="ppg">图元属性</param>
|
|
|
private void SetPropertyStatus(PropertyGrid ppg)
|
|
|
{
|
|
|
object varElement = ppg.SelectedObject;
|
|
|
if (varElement is CurveProperty curveProperty)
|
|
|
{
|
|
|
bool bReadOnly = !IsWaveCurve(curveProperty);
|
|
|
{
|
|
|
PropertyHelp.SetPropertyReadOnly(ppg.SelectedObject, "WaveT", bReadOnly);
|
|
|
PropertyHelp.SetPropertyReadOnly(varElement, "WaveA", bReadOnly);
|
|
|
PropertyHelp.SetPropertyReadOnly(curveProperty, "WaveNum", bReadOnly);
|
|
|
}
|
|
|
|
|
|
PropertyHelp.SetPropertyReadOnly(curveProperty, nameof(CurveProperty.Alpha), (curveProperty.Base.Style & (int)LineType.PLINE_HS) != 0);
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// Sets 数据属性的只读或可视状态.
|
|
|
/// </summary>
|
|
|
/// <param name="ppg">The PPG.</param>
|
|
|
private void SetDataPropertyStatus(PropertyGrid ppg)
|
|
|
{
|
|
|
object varElement = ppg.SelectedObject;
|
|
|
if (varElement is SigmaDrawerElement.DrawerSurface surface)
|
|
|
{
|
|
|
PropertyHelp.SetPropertyReadOnly(varElement, "Point", surface.AutoUpdate);
|
|
|
PropertyHelp.SetPropertyReadOnly(varElement, "RulerSize", surface.AutoUpdate);
|
|
|
PropertyHelp.SetPropertyReadOnly(varElement, "RulerTextHeight", surface.AutoUpdate);
|
|
|
PropertyHelp.SetPropertyReadOnly(varElement, "RulerNumber", surface.AutoUpdate);
|
|
|
PropertyHelp.SetPropertyReadOnly(varElement, "RulerDF", surface.AutoUpdate);
|
|
|
PropertyHelp.SetPropertyReadOnly(varElement, "RulerStyleReverse", surface.AutoUpdate);
|
|
|
PropertyHelp.SetPropertyReadOnly(varElement, "RulerRangeZ", surface.AutoUpdate);
|
|
|
}
|
|
|
ppg.Refresh();
|
|
|
}
|
|
|
|
|
|
// 图元变更后, UI处理逻辑
|
|
|
/// <summary>
|
|
|
/// Sets the element u i.
|
|
|
/// </summary>
|
|
|
private void SetElementUI()
|
|
|
{
|
|
|
this.tsbLayerPropAddPoint.Enabled = !this.lsvLayer.Items.OfType<ListViewItem>()
|
|
|
.Any(r => this.IsPointStyle(r.Tag));
|
|
|
|
|
|
if (this.elementProperty != null && this.elementProperty.Element != null)
|
|
|
{
|
|
|
bool isCurve = this.elementProperty.Element.ElementType == DrawElementType.ELEMENT_CURVE;
|
|
|
bool isPoint = this.IsPointType(this.elementProperty.Element.ElementType);
|
|
|
|
|
|
this.tsbElementPropAddLine.Enabled = isCurve;
|
|
|
|
|
|
this.tsbElementPropAddPoint.Enabled = isPoint && (!this.ElementHasPointItems() || this.elementProperty.PointStyle == null);
|
|
|
|
|
|
this.tsbtnElementStyleLibrary.Enabled = this.tsbElementPropAddPoint.Enabled | this.tsbElementPropAddLine.Enabled;
|
|
|
|
|
|
this.tsbElementPropMoveUp.Enabled = isCurve;
|
|
|
this.tsbElementPropMoveDown.Enabled = isCurve;
|
|
|
this.tsbElementPropDel.Enabled = isCurve;
|
|
|
|
|
|
if (isPoint)
|
|
|
{
|
|
|
this.splitElement.Panel1Collapsed = false;
|
|
|
this.splitElementGrid.Panel1Collapsed = false;
|
|
|
// this.splitElement.Panel1Collapsed = true;
|
|
|
// this.splitElementGrid.Panel1Collapsed = this.elementProperty.PointStyle == null;
|
|
|
// this.tsbElementPropDel.Enabled = this.elementProperty.PointStyle != null;
|
|
|
}
|
|
|
else if (isCurve)
|
|
|
{
|
|
|
this.splitElement.Panel1Collapsed = false;
|
|
|
this.splitElementGrid.Panel1Collapsed = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.splitElement.Panel1Collapsed = true;
|
|
|
this.splitElementGrid.Panel1Collapsed = true;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.splitElement.Panel1Collapsed = true;
|
|
|
this.splitElementGrid.Panel1Collapsed = true;
|
|
|
|
|
|
this.tsbElementPropAddLine.Enabled = false;
|
|
|
this.tsbElementPropAddPoint.Enabled = false;
|
|
|
this.tsbtnElementStyleLibrary.Enabled = false;
|
|
|
this.tsbElementPropMoveUp.Enabled = false;
|
|
|
this.tsbElementPropMoveDown.Enabled = false;
|
|
|
this.tsbElementPropDel.Enabled = false;
|
|
|
}
|
|
|
|
|
|
this.OnClipboardChanged();
|
|
|
}
|
|
|
|
|
|
private bool ElementHasPointItems()
|
|
|
{
|
|
|
return this.lsvElement.Items.OfType<ListViewItem>().Any(r => this.IsPointStyle(r.Tag));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 是否是点类数据
|
|
|
/// </summary>
|
|
|
/// <param name="elementType">数据类型</param>
|
|
|
/// <returns>是否点类数据</returns>
|
|
|
private bool IsPointType(DrawElementType elementType)
|
|
|
{
|
|
|
return (elementType == DrawElementType.ELEMENT_POINT
|
|
|
|| elementType == DrawElementType.ELEMENT_XYZ
|
|
|
|| elementType == DrawElementType.ELEMENT_TWOPOINT
|
|
|
|| elementType == DrawElementType.ELEMENT_CROSSPOINT);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 显示图层属性
|
|
|
/// </summary>
|
|
|
/// <param name="layerStyle">图层属性</param>
|
|
|
public void ShowLayerProperty(DrawerStyle layerStyle)
|
|
|
{
|
|
|
this.CurrentStyle = layerStyle;
|
|
|
this.tabControl1.SelectTab(0);
|
|
|
this.LayerChanged?.Invoke(this, new EventArgs());
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// Shows the element property.
|
|
|
/// </summary>
|
|
|
/// <param name="elementProperty">The element property.</param>
|
|
|
/// <param name="position">The position.</param>
|
|
|
public void ShowElementProperty(DrawerElementProperty elementProperty, long position)
|
|
|
{
|
|
|
this.ElementPosition = position;
|
|
|
this.ElementProperty = elementProperty;
|
|
|
this.tabControl1.SelectTab(1);
|
|
|
this.ElementChanged?.Invoke(this, new EventArgs());
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 选择图层属性
|
|
|
/// </summary>
|
|
|
/// <param name="sender">sender</param>
|
|
|
/// <param name="e">e</param>
|
|
|
private void lsvCurve_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
if (this.lsvLayer.SelectedItems.Count > 0)
|
|
|
{
|
|
|
this.ppgLayer.SelectedObject = this.lsvLayer.SelectedItems[0].Tag;
|
|
|
this.propertyType = 0;
|
|
|
this.propertyIndex = this.lsvLayer.SelectedItems[0].Index;
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 选择图元属性
|
|
|
/// </summary>
|
|
|
/// <param name="sender">sender</param>
|
|
|
/// <param name="e">e</param>
|
|
|
private void lsvElement_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
if (this.lsvElement.SelectedItems.Count > 0)
|
|
|
{
|
|
|
this.ppgElement.SelectedObject = this.lsvElement.SelectedItems[0].Tag;
|
|
|
// propertyType=0;
|
|
|
this.elementPropertyIndex = this.lsvElement.SelectedItems[0].Index;
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 属性修改事件
|
|
|
/// </summary>
|
|
|
/// <param name="s">sender</param>
|
|
|
/// <param name="e">e</param>
|
|
|
private void ppgLayer_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
|
|
{
|
|
|
object varStyle = this.ppgLayer.SelectedObject;
|
|
|
if (varStyle is DrawerPointStyle)
|
|
|
{
|
|
|
if (!this.needResetDraw(e.ChangedItem))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
string strPointStyle = ((DrawerPointStyle)varStyle).SerialXml();
|
|
|
if (this.Viewer.SetLayerHowtoViewPoint(this.LayerName, strPointStyle, true) == true)
|
|
|
{
|
|
|
this.Viewer.Redraw();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (e.ChangedItem.Label.IndexOf("步长|数目") >= 0)
|
|
|
{
|
|
|
this.ppgLayer.SelectedObject = varStyle;
|
|
|
}
|
|
|
string strCurveStyle = ((CurveView)varStyle).SerialXml();
|
|
|
// Console.WriteLine(strCurveStyle);
|
|
|
strCurveStyle = strCurveStyle.Replace("true", "1");
|
|
|
strCurveStyle = strCurveStyle.Replace("false", "0");
|
|
|
|
|
|
if (this.Viewer.SetLayerHowtoViewCurve(this.LayerName, strCurveStyle, this.propertyIndex) == true)
|
|
|
{
|
|
|
this.Viewer.Redraw();
|
|
|
}
|
|
|
this.SetPropertyStatus(s as PropertyGrid);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// needs the reset draw.
|
|
|
/// </summary>
|
|
|
/// <param name="item">The item.</param>
|
|
|
/// <returns>A bool.</returns>
|
|
|
private bool needResetDraw(GridItem item)
|
|
|
{
|
|
|
if (item.Label.IndexOf("固定比例") >= 0)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// ppgs the element_ property value changed.
|
|
|
/// </summary>
|
|
|
/// <param name="s">The s.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void ppgElement_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
|
|
{
|
|
|
if (this.elementProperty == null || this.elementProperty.Element == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
object varElement = this.ppgData.SelectedObject;
|
|
|
if (varElement is DrawerWellGroup)
|
|
|
{
|
|
|
DrawerWellGroup wellGroup = varElement as DrawerWellGroup;
|
|
|
WellGroupParameter groupPara = wellGroup.Parameter;
|
|
|
WellGroupCreateParameter drawerPara = new WellGroupCreateParameter(groupPara);
|
|
|
drawerPara.WellX = wellGroup.X;
|
|
|
drawerPara.WellY = wellGroup.Y;
|
|
|
drawerPara.WellName = wellGroup.Name;
|
|
|
WellGroupCaculator caculator = new WellGroupCaculator();
|
|
|
DrawerWellGroup wellGroupNew = caculator.CreateWellGroup(drawerPara);
|
|
|
|
|
|
this.elementProperty.Element = wellGroupNew;
|
|
|
// ppgElement.SelectedObject = elementProperty.Element;
|
|
|
}
|
|
|
|
|
|
bool state = true;
|
|
|
if (varElement is DrawerSurface)
|
|
|
{
|
|
|
DrawerSurface surfaces = varElement as DrawerSurface;
|
|
|
state = surfaces.AutoUpdate;
|
|
|
}
|
|
|
string strData = DrawerElementHelp.Serialize(this.elementProperty);
|
|
|
if (this.Viewer.SetElementProperty(strData/*, state*/) == true) //ggff
|
|
|
{
|
|
|
this.Viewer.Redraw();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (varElement is DrawerFrame)
|
|
|
{
|
|
|
this.ppgData.SelectedObject = this.elementProperty.Element;
|
|
|
}
|
|
|
if (e.ChangedItem.Label.IndexOf("步长|数目") >= 0)
|
|
|
{
|
|
|
this.ppgElement.SelectedObject = this.ppgElement.SelectedObject;
|
|
|
}
|
|
|
this.SetDataPropertyStatus(this.ppgData);
|
|
|
|
|
|
this.SetPropertyStatus(s as PropertyGrid);
|
|
|
|
|
|
// (s as PropertyGrid).Refresh();
|
|
|
}
|
|
|
|
|
|
public class ReadOnlyPropertyDescriptor : PropertyDescriptor
|
|
|
{
|
|
|
private PropertyDescriptor innerDescriptor;
|
|
|
private bool isReadOnly = true;
|
|
|
|
|
|
public ReadOnlyPropertyDescriptor(PropertyDescriptor innerDescriptor, bool isReadOnly)
|
|
|
: base(innerDescriptor)
|
|
|
{
|
|
|
this.innerDescriptor = innerDescriptor;
|
|
|
this.isReadOnly = isReadOnly;
|
|
|
}
|
|
|
|
|
|
public override bool IsReadOnly
|
|
|
{
|
|
|
get { return true; }
|
|
|
}
|
|
|
|
|
|
public override Type ComponentType => this.innerDescriptor.ComponentType;
|
|
|
|
|
|
public override Type PropertyType => this.innerDescriptor.PropertyType;
|
|
|
|
|
|
/// <summary>
|
|
|
/// Cans the reset value.
|
|
|
/// </summary>
|
|
|
/// <param name="component">The component.</param>
|
|
|
/// <returns>A bool.</returns>
|
|
|
public override bool CanResetValue(object component)
|
|
|
{
|
|
|
return this.innerDescriptor.CanResetValue(component);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Gets the value.
|
|
|
/// </summary>
|
|
|
/// <param name="component">The component.</param>
|
|
|
/// <returns>An object.</returns>
|
|
|
public override object GetValue(object component)
|
|
|
{
|
|
|
return this.innerDescriptor.GetValue(component);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Resets the value.
|
|
|
/// </summary>
|
|
|
/// <param name="component">The component.</param>
|
|
|
public override void ResetValue(object component)
|
|
|
{
|
|
|
this.innerDescriptor.ResetValue(component);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Sets the value.
|
|
|
/// </summary>
|
|
|
/// <param name="component">The component.</param>
|
|
|
/// <param name="value">The value.</param>
|
|
|
public override void SetValue(object component, object value)
|
|
|
{
|
|
|
if (!this.isReadOnly)
|
|
|
{
|
|
|
this.innerDescriptor.SetValue(component, value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Shoulds the serialize value.
|
|
|
/// </summary>
|
|
|
/// <param name="component">The component.</param>
|
|
|
/// <returns>A bool.</returns>
|
|
|
public override bool ShouldSerializeValue(object component)
|
|
|
{
|
|
|
return this.innerDescriptor.ShouldSerializeValue(component);
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 向上移动曲线样式
|
|
|
/// </summary>
|
|
|
/// <param name="ppg">ppg</param>
|
|
|
/// <param name="lsv">lsv</param>
|
|
|
/// <param name="pred">pred</param>
|
|
|
private void MoveUpCurveStyle(PropertyGrid ppg, ListView lsv, Func<int, bool> pred)
|
|
|
{
|
|
|
object varStyle = ppg.SelectedObject;
|
|
|
|
|
|
if (!(varStyle is DrawerPointStyle))
|
|
|
{
|
|
|
List<ListViewItem> list = lsv.Items.OfType<ListViewItem>().Where(r => r.Tag is CurveView).ToList();
|
|
|
|
|
|
int index = list.FindIndex(r => r.Tag is CurveView && r.Tag == varStyle);
|
|
|
|
|
|
if (index > 0)
|
|
|
{
|
|
|
if (pred(index))
|
|
|
{
|
|
|
int i = lsv.Items.IndexOf(list[index]);
|
|
|
|
|
|
ListViewItem item = lsv.Items[i];
|
|
|
|
|
|
lsv.Items.RemoveAt(i);
|
|
|
|
|
|
lsv.Items.Insert(i - 1, item);
|
|
|
|
|
|
this.Viewer.Redraw();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 向下移动曲线样式
|
|
|
/// </summary>
|
|
|
/// <param name="ppg">ppg</param>
|
|
|
/// <param name="lsv">lsv</param>
|
|
|
/// <param name="pred">pred</param>
|
|
|
private void MoveDownCurveStyle(PropertyGrid ppg, ListView lsv, Func<int, bool> pred)
|
|
|
{
|
|
|
object varStyle = ppg.SelectedObject;
|
|
|
|
|
|
if (!(varStyle is DrawerPointStyle))
|
|
|
{
|
|
|
List<ListViewItem> list = lsv.Items.OfType<ListViewItem>().Where(r => r.Tag is CurveView).ToList();
|
|
|
|
|
|
int index = list.FindIndex(r => r.Tag is CurveView && r.Tag == varStyle);
|
|
|
|
|
|
if (index < list.Count - 1)
|
|
|
{
|
|
|
if (pred(index))
|
|
|
{
|
|
|
int i = lsv.Items.IndexOf(list[index]);
|
|
|
|
|
|
ListViewItem item = lsv.Items[i];
|
|
|
|
|
|
lsv.Items.RemoveAt(i);
|
|
|
|
|
|
lsv.Items.Insert(i + 1, item);
|
|
|
|
|
|
this.Viewer.Redraw();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除选择的样式
|
|
|
/// </summary>
|
|
|
/// <param name="ppg">属性面板</param>
|
|
|
/// <param name="lsv">修饰列表</param>
|
|
|
/// <param name="element">是否是元素属性</param>
|
|
|
/// <param name="predCurve">删除曲线样式委托</param>
|
|
|
/// <param name="predPoint">删除点样式委托</param>
|
|
|
private void DeleteStyle(PropertyGrid ppg, ListView lsv, bool element, Func<int, bool> predCurve, Func<bool> predPoint)
|
|
|
{
|
|
|
if (lsv.SelectedItems.Count == 0)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 从数据对象中移除修饰
|
|
|
DeleteCurveStyles(lsv, element, predCurve);
|
|
|
DeletePointStyles(lsv, element, predPoint);
|
|
|
|
|
|
if (lsv.Items.Count == 0)
|
|
|
{
|
|
|
ppg.SelectedObject = null;
|
|
|
}
|
|
|
if (lsv.Items.Count > 0)
|
|
|
{
|
|
|
lsv.Items[0].Selected = true;
|
|
|
}
|
|
|
|
|
|
// Reset listview Index;
|
|
|
int n = 1;
|
|
|
for (int i = 0; i < lsv.Items.Count; i++)
|
|
|
{
|
|
|
ListViewItem item = lsv.Items[i];
|
|
|
if (item.Tag is CurveView)
|
|
|
{
|
|
|
item.Text = string.Empty + n++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.SetElementUI();
|
|
|
}
|
|
|
|
|
|
private void DeletePointStyles(ListView lsv, bool element, Func<bool> predPoint)
|
|
|
{
|
|
|
bool needRemovePointStyle = GetSelectedTags(lsv).Any(tag => IsPointStyle(tag));
|
|
|
if (!needRemovePointStyle)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!predPoint())
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
for (int idx = lsv.Items.Count - 1; idx >= 0; idx--)
|
|
|
{
|
|
|
if (IsPointStyle(lsv.Items[idx].Tag))
|
|
|
{
|
|
|
lsv.Items[idx].Remove();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (element && this.elementProperty != null)
|
|
|
{
|
|
|
this.elementProperty.PointStyle = null;
|
|
|
}
|
|
|
else if (!element && this.currentStyle != null)
|
|
|
{
|
|
|
this.currentStyle.PontStyle = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void DeleteCurveStyles(ListView lsv, bool element, Func<int, bool> predCurve)
|
|
|
{
|
|
|
List<object> tagList = GetSelectedTags(lsv);
|
|
|
|
|
|
foreach (object item in tagList)
|
|
|
{
|
|
|
if (item is CurveView cv)
|
|
|
{
|
|
|
for (int idx = 0; idx < lsv.Items.Count; idx++)
|
|
|
{
|
|
|
if (ReferenceEquals(item, lsv.Items[idx].Tag))
|
|
|
{
|
|
|
if (predCurve(idx))
|
|
|
{
|
|
|
this.Viewer.Redraw();
|
|
|
lsv.Items[idx].Remove();
|
|
|
if (element)
|
|
|
{
|
|
|
this.elementProperty?.CurveStyle.Properties.Remove(cv);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.currentStyle?.CurveStyle.Properties.Remove(cv);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private List<object> GetSelectedTags(ListView listView)
|
|
|
{
|
|
|
return listView.SelectedItems.Cast<ListViewItem>()
|
|
|
.Select(item => item.Tag)
|
|
|
.ToList();
|
|
|
}
|
|
|
|
|
|
private bool IsPointStyle(object style)
|
|
|
{
|
|
|
return style is DrawerPointStyle || style is DrawerPointStyleText || style is DrawerPointStyleSymbol || style is DrawerPointStyleZValue;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 清除修饰
|
|
|
/// </summary>
|
|
|
/// <param name="ppg">属性面板控件</param>
|
|
|
/// <param name="lsv">列表控件</param>
|
|
|
/// <param name="curveStyle">清除线样式</param>
|
|
|
/// <param name="pointStyle">清除点样式</param>
|
|
|
/// <param name="element">元素样式</param>
|
|
|
/// <param name="predCurve">删除曲线样式函数</param>
|
|
|
/// <param name="predPoint">删除点样式函数</param>
|
|
|
private void ClearStyle(PropertyGrid ppg, ListView lsv, bool curveStyle, bool pointStyle, bool element, Func<int, bool> predCurve, Func<bool> predPoint)
|
|
|
{
|
|
|
if (lsv.Items.Count == 0)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
List<object> tagList = new List<object>();
|
|
|
for (int idx = 0; idx < lsv.Items.Count; idx++)
|
|
|
{
|
|
|
tagList.Add(lsv.Items[idx].Tag);
|
|
|
}
|
|
|
// 从数据对象中移除修饰
|
|
|
foreach (object item in tagList)
|
|
|
{
|
|
|
if (item is CurveView cv && curveStyle)
|
|
|
{
|
|
|
for (int idx = 0; idx < lsv.Items.Count; idx++)
|
|
|
{
|
|
|
if (ReferenceEquals(item, lsv.Items[idx].Tag))
|
|
|
{
|
|
|
if (predCurve(idx))
|
|
|
{
|
|
|
this.Viewer.Redraw();
|
|
|
lsv.Items[idx].Remove();
|
|
|
if (element)
|
|
|
{
|
|
|
this.elementProperty?.CurveStyle.Properties.Remove(cv);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.currentStyle?.CurveStyle.Properties.Remove(cv);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (item is DrawerPointStyle && pointStyle)
|
|
|
{
|
|
|
if (predPoint())
|
|
|
{
|
|
|
this.Viewer.Redraw();
|
|
|
for (int idx = 0; idx < lsv.Items.Count; idx++)
|
|
|
{
|
|
|
if (ReferenceEquals(item, lsv.Items[idx].Tag))
|
|
|
{
|
|
|
lsv.Items[idx].Remove();
|
|
|
}
|
|
|
}
|
|
|
if (element && this.elementProperty != null)
|
|
|
{
|
|
|
this.elementProperty.PointStyle = null;
|
|
|
}
|
|
|
else if (!element && this.currentStyle != null)
|
|
|
{
|
|
|
this.currentStyle.PontStyle = null;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (lsv.Items.Count == 0)
|
|
|
{
|
|
|
ppg.SelectedObject = null;
|
|
|
}
|
|
|
if (lsv.Items.Count > 0)
|
|
|
{
|
|
|
lsv.Items[0].Selected = true;
|
|
|
}
|
|
|
// Reset listview Index;
|
|
|
int n = 1;
|
|
|
for (int i = 0; i < lsv.Items.Count; i++)
|
|
|
{
|
|
|
ListViewItem item = lsv.Items[i];
|
|
|
if (item.Tag is CurveView)
|
|
|
{
|
|
|
item.Text = string.Empty + n++;
|
|
|
}
|
|
|
}
|
|
|
this.SetElementUI();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加曲线样式
|
|
|
/// </summary>
|
|
|
/// <param name="lsv">lsv</param>
|
|
|
/// <param name="curve">curve</param>
|
|
|
private void AddCurveStyle(ListView lsv, CurveView curve)
|
|
|
{
|
|
|
{
|
|
|
this.Viewer.Redraw();
|
|
|
|
|
|
int curveCount = lsv.Items.OfType<ListViewItem>().Count(r => r.Tag is CurveView);
|
|
|
|
|
|
ListViewItem lvi = new ListViewItem(string.Empty + (curveCount + 1));
|
|
|
lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, curve.TypeName));
|
|
|
lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, GeoSigma.UCDraw.Properties.Resources.PanelProperty_Curve_TypeName));
|
|
|
curve.Geo = this.Viewer.Geo;
|
|
|
lvi.Tag = curve;
|
|
|
|
|
|
if (lsv.Items.Count > 0 && lsv.Items[lsv.Items.Count - 1] is ListViewItem lastItem && lastItem.Tag is DrawerPointStyle)
|
|
|
{
|
|
|
lastItem.Remove();
|
|
|
|
|
|
lsv.Items.Add(lvi);
|
|
|
lsv.Items.Add(lastItem);
|
|
|
lsv.SelectedItems.Clear();
|
|
|
lvi.Selected = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
lsv.Items.Add(lvi);
|
|
|
lsv.SelectedItems.Clear();
|
|
|
lvi.Selected = true;
|
|
|
}
|
|
|
lsv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
|
|
|
this.SetElementUI();
|
|
|
}
|
|
|
|
|
|
this.OnClipboardChanged();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Configs the curve fill symbol.
|
|
|
/// </summary>
|
|
|
/// <param name="curve">The curve.</param>
|
|
|
private void ConfigCurveFillSymbol<T>(T curve)
|
|
|
where T : CurveView
|
|
|
{
|
|
|
CurveFillSymbol curveFill = new CurveFillSymbol();
|
|
|
curveFill.Geo = this.Viewer.Geo;
|
|
|
PropertyInfo[] props = curveFill.GetType().GetProperties();
|
|
|
foreach (PropertyInfo pi in props)
|
|
|
{
|
|
|
if (pi.Name == "SymbolEditor")
|
|
|
{
|
|
|
// curveFill = new CurveFillSymbol();
|
|
|
curveFill.Geo = this.Viewer.Geo;
|
|
|
pi.SetValue(curve, curveFill.SymbolEditor, null);
|
|
|
}
|
|
|
|
|
|
if (pi.PropertyType.Equals(typeof(PropertyPoint)))
|
|
|
{
|
|
|
PropertyPoint symbol = new PropertyPoint();
|
|
|
if (pi.Name == "Delt")
|
|
|
{
|
|
|
symbol = curveFill.Delt;
|
|
|
}
|
|
|
else if (pi.Name == "Grid")
|
|
|
{
|
|
|
symbol = curveFill.Grid;
|
|
|
}
|
|
|
else if (pi.Name == "Scale")
|
|
|
{
|
|
|
symbol = curveFill.Scale;
|
|
|
}
|
|
|
pi.SetValue(curve, symbol, null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加曲线样式(图元)
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T">T</typeparam>
|
|
|
private void AddElementCurveStyle<T>()
|
|
|
where T : CurveView
|
|
|
{
|
|
|
if (this.elementProperty == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
if (this.elementProperty.ElementType != DrawElementType.ELEMENT_CURVE)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
Type t = typeof(T);
|
|
|
T curve = Activator.CreateInstance(t) as T;
|
|
|
|
|
|
// CurveStyleType cst = (CurveStyleType)Enum.Parse(typeof(CurveStyleType), t.Name);
|
|
|
CurveStyleType styleType = curve.StyleType;
|
|
|
// AddCurveStyle(lsvElement, curve, true, () => Viewer.SelectCreateCurveStyle(cst, curve.SerialXml()));
|
|
|
this.Viewer.SelectCreateCurveStyle(styleType, curve.SerialXml());
|
|
|
|
|
|
if (this.elementProperty != null)
|
|
|
{
|
|
|
if (this.elementProperty.CurveStyle == null)
|
|
|
{
|
|
|
this.elementProperty.CurveStyle = new DrawerCurveStyle();
|
|
|
}
|
|
|
this.elementProperty.CurveStyle.Properties.Add(curve);
|
|
|
}
|
|
|
|
|
|
if (typeof(T) == typeof(CurveFillSymbol))
|
|
|
{
|
|
|
this.ConfigCurveFillSymbol(curve);
|
|
|
}
|
|
|
|
|
|
this.AddCurveStyle(this.lsvElement, curve);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加曲线样式(图层)
|
|
|
/// </summary>
|
|
|
/// <typeparam name="T">CurveView</typeparam>
|
|
|
private void AddLayerCurveStyle<T>()
|
|
|
where T : CurveView
|
|
|
{
|
|
|
// CurveLocation curveLocation = new CurveLocation();
|
|
|
Type t = typeof(T);
|
|
|
T curve = Activator.CreateInstance(t) as T;
|
|
|
|
|
|
if (typeof(T) == typeof(CurveFillSymbol))
|
|
|
{
|
|
|
this.ConfigCurveFillSymbol(curve);
|
|
|
}
|
|
|
else if (typeof(T) == typeof(CurveTwoMark))
|
|
|
{
|
|
|
CurveTwoMark curveTwoMark = new CurveTwoMark();
|
|
|
curveTwoMark.Geo = this.Viewer.Geo;
|
|
|
PropertyInfo[] props = t.GetProperties();
|
|
|
foreach (PropertyInfo pi in props)
|
|
|
{
|
|
|
if (pi.Name == "SymbolEditor")
|
|
|
{
|
|
|
curveTwoMark.Geo = this.Viewer.Geo;
|
|
|
pi.SetValue(curve, curveTwoMark.SymbolEditor, null);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (typeof(T) == typeof(CurveScaleSymbol))
|
|
|
{
|
|
|
CurveScaleSymbol curveStyle = new CurveScaleSymbol();
|
|
|
curveStyle.Geo = this.Viewer.Geo;
|
|
|
PropertyInfo[] props = t.GetProperties();
|
|
|
foreach (PropertyInfo pi in props)
|
|
|
{
|
|
|
if (pi.Name == "SymbolEditor")
|
|
|
{
|
|
|
curveStyle.Geo = this.Viewer.Geo;
|
|
|
pi.SetValue(curve, curveStyle.SymbolEditor, null);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// CurveStyleType cst = (CurveStyleType)Enum.Parse(typeof(CurveStyleType), t.Name);
|
|
|
// CurveStyleType curveStyle = curve.StyleType;
|
|
|
if (this.lsvLayer.Items.Count == 0)
|
|
|
{
|
|
|
this.Viewer.CreateLayerCurveStyle(this.LayerName, curve.StyleType, curve.SerialXml());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.Viewer.AddLayerCurveStyle(this.LayerName, curve.StyleType, curve.SerialXml());
|
|
|
}
|
|
|
if (this.currentStyle != null)
|
|
|
{
|
|
|
if (this.currentStyle.CurveStyle == null)
|
|
|
{
|
|
|
this.currentStyle.CurveStyle = new DrawerCurveStyle();
|
|
|
}
|
|
|
this.currentStyle.CurveStyle.Properties.Add(curve);
|
|
|
}
|
|
|
this.AddCurveStyle(this.lsvLayer, curve);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Adds the point style.
|
|
|
/// </summary>
|
|
|
/// <param name="dps">The dps.</param>
|
|
|
/// <param name="lsv">The lsv.</param>
|
|
|
/// <param name="element">If true, element.</param>
|
|
|
/// <param name="pred">The pred.</param>
|
|
|
private void AddPointStyle(DrawerPointStyle dps, ListView lsv, bool element, Func<DrawerPointStyle, bool> pred)
|
|
|
{
|
|
|
if (pred(dps))
|
|
|
{
|
|
|
this.Viewer.Redraw();
|
|
|
|
|
|
if (element && this.elementProperty != null)
|
|
|
{
|
|
|
this.elementProperty.PointStyle = dps;
|
|
|
|
|
|
this.ppgElement.SelectedObject = dps;
|
|
|
}
|
|
|
else if (!element && this.currentStyle != null)
|
|
|
{
|
|
|
this.currentStyle.PontStyle = dps;
|
|
|
this.currentStyle.PontStyle.Geo = this.Viewer.Geo;
|
|
|
}
|
|
|
|
|
|
ListViewItem lvi2 = AddPointStyleItem(dps, lsv);
|
|
|
|
|
|
lsv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
|
|
|
if (lsv.Visible != true)
|
|
|
{
|
|
|
lsv.Visible = true;
|
|
|
}
|
|
|
this.SetElementUI();
|
|
|
lvi2.Selected = true;
|
|
|
}
|
|
|
|
|
|
this.OnClipboardChanged();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 添加点样式,点样式一次要添加三个 Item
|
|
|
/// </summary>
|
|
|
/// <param name="dps">点样式</param>
|
|
|
/// <param name="lsv">被添加的列表</param>
|
|
|
/// <returns>返回第一个 Item</returns>
|
|
|
private static ListViewItem AddPointStyleItem(DrawerPointStyle dps, ListView lsv)
|
|
|
{
|
|
|
ListViewItem lvi2 = new ListViewItem("1");
|
|
|
lvi2.SubItems.Add(new ListViewItem.ListViewSubItem(lvi2, "文本"));
|
|
|
lvi2.SubItems.Add(new ListViewItem.ListViewSubItem(lvi2, "点"));
|
|
|
lvi2.Tag = new DrawerPointStyleText(dps);
|
|
|
lsv.Items.Add(lvi2);
|
|
|
|
|
|
ListViewItem lvi3 = new ListViewItem("2");
|
|
|
lvi3.SubItems.Add(new ListViewItem.ListViewSubItem(lvi3, "符号"));
|
|
|
lvi3.SubItems.Add(new ListViewItem.ListViewSubItem(lvi3, "点"));
|
|
|
lvi3.Tag = new DrawerPointStyleSymbol(dps);
|
|
|
lsv.Items.Add(lvi3);
|
|
|
|
|
|
ListViewItem lvi4 = new ListViewItem("3");
|
|
|
lvi4.SubItems.Add(new ListViewItem.ListViewSubItem(lvi4, "Z值"));
|
|
|
lvi4.SubItems.Add(new ListViewItem.ListViewSubItem(lvi4, "点"));
|
|
|
lvi4.Tag = new DrawerPointStyleZValue(dps);
|
|
|
lsv.Items.Add(lvi4);
|
|
|
|
|
|
return lvi2;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Adds the point style.
|
|
|
/// </summary>
|
|
|
/// <param name="lsv">The lsv.</param>
|
|
|
/// <param name="element">If true, element.</param>
|
|
|
/// <param name="pred">The pred.</param>
|
|
|
private void AddPointStyle(ListView lsv, bool element, Func<DrawerPointStyle, bool> pred)
|
|
|
{
|
|
|
DrawerPointStyle styleNew = new DrawerPointStyle();
|
|
|
styleNew.Text.Height = 30;
|
|
|
styleNew.Text.Width = 12;
|
|
|
styleNew.Symbol.Height = 30;
|
|
|
styleNew.Symbol.Width = 30;
|
|
|
styleNew.Geo = this.Viewer.Geo;
|
|
|
this.AddPointStyle(styleNew, lsv, element, pred);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the element prop move up_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbElementPropMoveUp_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.MoveUpCurveStyle(this.ppgElement, this.lsvElement, idx => this.Viewer.SelectMoveUpCurveStyle(idx));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the element prop move down_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbElementPropMoveDown_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.MoveDownCurveStyle(this.ppgElement, this.lsvElement, idx => this.Viewer.SelectMoveDownCurveStyle(idx));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the layer prop move up_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbLayerPropMoveUp_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.MoveUpCurveStyle(this.ppgLayer, this.lsvLayer, idx => this.Viewer.SetLayerMoveUpCurveStyle(this.LayerName, idx));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the layer prop move down_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbLayerPropMoveDown_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.MoveDownCurveStyle(this.ppgLayer, this.lsvLayer, idx => this.Viewer.SetLayerMoveDownCurveStyle(this.LayerName, idx));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the layer prop del_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbLayerPropDel_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.DeleteStyle(this.ppgLayer, this.lsvLayer, false,
|
|
|
idx => this.Viewer.RemoveCurveStyle(this.LayerName, idx),
|
|
|
() => this.Viewer.RemovePointStyle(this.LayerName));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the element prop del_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbElementPropDel_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (this.elementProperty.ElementType == DrawElementType.ELEMENT_POINT)
|
|
|
{
|
|
|
if (this.lsvElement.Items.Count > 0)
|
|
|
{
|
|
|
this.lsvElement.Items[0].Selected = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.DeleteStyle(this.ppgElement, this.lsvElement, true,
|
|
|
idx => this.Viewer.SelectRemoveCurveStyle(idx),
|
|
|
() => this.Viewer.SelectRemovePointStyle());
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the element prop add point_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbElementPropAddPoint_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddPointStyle(this.lsvElement, true, s => this.Viewer.SelectCreatePointStyle(s.SerialXml()));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the layer prop add point_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbLayerPropAddPoint_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddPointStyle(this.lsvLayer, false, s => this.Viewer.CreateLayerPointStyle(this.LayerName, s.SerialXml()));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve property_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveProperty_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveProperty>();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// tsmis the layer arrow head_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerArrowHead_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveArrowHead>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer arrow tail_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerArrowTail_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveArrowTail>();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve location_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveLocation_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveLocation>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve scale symbol_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveScaleSymbol_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveScaleSymbol>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve name_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveName_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveName>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve two mark_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveTwoMark_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveTwoMark>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve fill symbol_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveFillSymbol_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveFillSymbol>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve in name_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveInName_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveInName>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve in name any_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveInNameAny_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveInNameAny>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve effect_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveEffect_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveEffect>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the layer prop add curve center name_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiLayerPropAddCurveCenterName_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveCenterName>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve property_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveProperty_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveProperty>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve location_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveLocation_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveLocation>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve scale symbol_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveScaleSymbol_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveScaleSymbol>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve name_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveName_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveName>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve two mark_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveTwoMark_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveTwoMark>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve fill symbol_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveFillSymbol_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveFillSymbol>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve in name_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveInName_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveInName>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve in name any_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveInNameAny_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveInNameAny>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve effect_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveEffect_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveEffect>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsmis the element prop add curve center name_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsmiElementPropAddCurveCenterName_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddElementCurveStyle<CurveCenterName>();
|
|
|
}
|
|
|
|
|
|
// 当前复制对象变更后, 更新界面
|
|
|
/// <summary>
|
|
|
/// Ons the clipboard changed.
|
|
|
/// </summary>
|
|
|
/// <param name="clear">If true, clear.</param>
|
|
|
private void OnClipboardChanged(bool clear = false)
|
|
|
{
|
|
|
if (clear)
|
|
|
{
|
|
|
Clipboard.Clear();
|
|
|
}
|
|
|
if (this.lsvLayer.SelectedItems.Count == 0)
|
|
|
{
|
|
|
this.tsbLayerPropCopy.Enabled = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.tsbLayerPropCopy.Enabled = true;
|
|
|
}
|
|
|
|
|
|
if (this.lsvElement.SelectedItems.Count == 0)
|
|
|
{
|
|
|
this.tsbElementPropCopy.Enabled = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.tsbElementPropCopy.Enabled = true;
|
|
|
}
|
|
|
this.tsbLayerPropPaste.Enabled = this.canPaste();
|
|
|
if (this.elementProperty != null && this.canPaste())
|
|
|
{
|
|
|
this.tsbElementPropPaste.Enabled = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// cans the paste.
|
|
|
/// </summary>
|
|
|
/// <returns>A bool.</returns>
|
|
|
private bool canPaste()
|
|
|
{
|
|
|
return ClipboardHelper.Check(ClipboardHelper.CfDrawStyleXml);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the layer prop copy_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbLayerPropCopy_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
Clipboard.Clear();
|
|
|
if (this.lsvLayer.SelectedItems.Count == 0)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
object obj = null;
|
|
|
DrawerStyle drawStyle = null;
|
|
|
DrawerCurveStyle curveStyle = null;
|
|
|
DrawerPointStyle pointStyle = null;
|
|
|
for (int i = 0; i < this.lsvLayer.SelectedItems.Count; i++)
|
|
|
{
|
|
|
obj = this.lsvLayer.SelectedItems[i].Tag;
|
|
|
if (obj is CurveView cv)
|
|
|
{
|
|
|
if (curveStyle == null)
|
|
|
{
|
|
|
curveStyle = new DrawerCurveStyle();
|
|
|
}
|
|
|
curveStyle.Properties.Add(cv.Clone());
|
|
|
}
|
|
|
else if (obj is DrawerPointStyle dps)
|
|
|
{
|
|
|
if (pointStyle == null)
|
|
|
{
|
|
|
pointStyle = new DrawerPointStyle();
|
|
|
}
|
|
|
pointStyle = dps.Clone();
|
|
|
}
|
|
|
}
|
|
|
if (curveStyle != null || pointStyle != null)
|
|
|
{
|
|
|
drawStyle = new DrawerStyle();
|
|
|
drawStyle.CurveStyle = curveStyle;
|
|
|
drawStyle.PontStyle = pointStyle;
|
|
|
ClipboardHelper.SaveObjectToClipboard<string>(ClipboardHelper.CfDrawStyleXml, drawStyle.SerialXml());
|
|
|
}
|
|
|
this.OnClipboardChanged();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the element copy_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbElementCopy_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
Clipboard.Clear();
|
|
|
|
|
|
if (!this.lsvElement.Visible && this.lsvElement.SelectedItems.Count == 0)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (this.elementProperty?.Element == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (this.elementProperty.ElementType != DrawElementType.ELEMENT_POINT
|
|
|
&& this.elementProperty.ElementType != DrawElementType.ELEMENT_CURVE)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
DrawerCurveStyle curveStyle = null;
|
|
|
DrawerPointStyle pointStyle = null;
|
|
|
for (int i = 0; i < this.lsvElement.SelectedItems.Count; i++)
|
|
|
{
|
|
|
object obj = this.lsvElement.SelectedItems[i].Tag;
|
|
|
if (obj is CurveView cv)
|
|
|
{
|
|
|
if (curveStyle == null)
|
|
|
{
|
|
|
curveStyle = new DrawerCurveStyle();
|
|
|
}
|
|
|
curveStyle.Properties.Add(cv.Clone());
|
|
|
}
|
|
|
else if (obj is DrawerPointStyle dps)
|
|
|
{
|
|
|
if (pointStyle == null)
|
|
|
{
|
|
|
pointStyle = new DrawerPointStyle();
|
|
|
}
|
|
|
pointStyle = dps.Clone();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (curveStyle != null || pointStyle != null)
|
|
|
{
|
|
|
DrawerStyle drawStyle = new DrawerStyle
|
|
|
{
|
|
|
CurveStyle = curveStyle,
|
|
|
PontStyle = pointStyle,
|
|
|
};
|
|
|
ClipboardHelper.SaveObjectToClipboard(ClipboardHelper.CfDrawStyleXml, drawStyle.SerialXml());
|
|
|
}
|
|
|
|
|
|
this.OnClipboardChanged();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the layer prop paste_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbLayerPropPaste_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
DrawerStyle drawStyle = null;
|
|
|
DrawerCurveStyle curveStyle = null;
|
|
|
DrawerPointStyle pointStyle = null;
|
|
|
|
|
|
string drawStyleXml = ClipboardHelper.LoadObjectFromClipboard<string>(ClipboardHelper.CfDrawStyleXml);
|
|
|
if (!string.IsNullOrEmpty(drawStyleXml))
|
|
|
{
|
|
|
drawStyle = new DrawerStyle();
|
|
|
drawStyle = drawStyle.DeserialXml(drawStyleXml);
|
|
|
curveStyle = drawStyle.CurveStyle;
|
|
|
pointStyle = drawStyle.PontStyle;
|
|
|
}
|
|
|
if (curveStyle != null)
|
|
|
{
|
|
|
// 清除曲线样式
|
|
|
this.ClearStyle(this.ppgLayer, this.lsvLayer, true, false, false,
|
|
|
idx => this.Viewer.RemoveCurveStyle(this.LayerName, idx),
|
|
|
() => this.Viewer.RemovePointStyle(this.LayerName));
|
|
|
for (int i = 0; i < curveStyle.Properties.Count; i++)
|
|
|
{
|
|
|
CurveView cv = curveStyle.Properties[i];
|
|
|
if (this.lsvLayer.Items.Count == 0)
|
|
|
{
|
|
|
this.Viewer.CreateLayerCurveStyle(this.LayerName, cv.StyleType, curveStyle.SerialXml());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.Viewer.AddLayerCurveStyle(this.LayerName, cv.StyleType, curveStyle.SerialXml());
|
|
|
}
|
|
|
if (this.CurrentStyle != null)
|
|
|
{
|
|
|
if (this.currentStyle.CurveStyle == null)
|
|
|
{
|
|
|
this.currentStyle.CurveStyle = new DrawerCurveStyle();
|
|
|
}
|
|
|
this.CurrentStyle.CurveStyle.Properties.Add(cv);
|
|
|
}
|
|
|
this.AddCurveStyle(this.lsvLayer, cv);
|
|
|
}
|
|
|
}
|
|
|
if (pointStyle != null)
|
|
|
{
|
|
|
// 清除点样式
|
|
|
this.ClearStyle(this.ppgLayer, this.lsvLayer, false, true, false,
|
|
|
idx => this.Viewer.RemoveCurveStyle(this.LayerName, idx),
|
|
|
() => this.Viewer.RemovePointStyle(this.LayerName));
|
|
|
ListViewItem lviPoint = this.lsvLayer.Items.OfType<ListViewItem>().FirstOrDefault(it => it.Tag is DrawerPointStyle);
|
|
|
if (lviPoint != null)
|
|
|
{
|
|
|
if (MessageBox.Show("是否替换现有点修饰?", "粘贴", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
|
{
|
|
|
this.lsvLayer.Items.Remove(lviPoint);
|
|
|
pointStyle.Clone();
|
|
|
pointStyle.Geo = this.Viewer.Geo;
|
|
|
this.AddPointStyle(pointStyle, this.lsvLayer, false, s => this.Viewer.CreateLayerPointStyle(this.LayerName, s.SerialXml()));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
pointStyle.Clone();
|
|
|
pointStyle.Geo = this.Viewer.Geo;
|
|
|
this.AddPointStyle(pointStyle, this.lsvLayer, false, s => this.Viewer.CreateLayerPointStyle(this.LayerName, s.SerialXml()));
|
|
|
}
|
|
|
}
|
|
|
this.OnClipboardChanged();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbs the element prop paste_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbElementPropPaste_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (this.elementProperty == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (this.elementProperty.ElementType != DrawElementType.ELEMENT_POINT
|
|
|
&& this.elementProperty.ElementType != DrawElementType.ELEMENT_CURVE)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
DrawerStyle drawStyle = null;
|
|
|
DrawerCurveStyle curveStyle = null;
|
|
|
DrawerPointStyle pointStyle = null;
|
|
|
|
|
|
string drawStyleXml = ClipboardHelper.LoadObjectFromClipboard<string>(ClipboardHelper.CfDrawStyleXml);
|
|
|
if (!string.IsNullOrEmpty(drawStyleXml))
|
|
|
{
|
|
|
drawStyle = new DrawerStyle();
|
|
|
drawStyle = drawStyle.DeserialXml(drawStyleXml);
|
|
|
curveStyle = drawStyle.CurveStyle;
|
|
|
pointStyle = drawStyle.PontStyle;
|
|
|
}
|
|
|
if (curveStyle != null && this.elementProperty.ElementType == DrawElementType.ELEMENT_CURVE)
|
|
|
{
|
|
|
// 清除曲线样式
|
|
|
this.ClearStyle(this.ppgElement, this.lsvElement, true, false, false,
|
|
|
idx => this.Viewer.RemoveCurveStyle(this.LayerName, idx),
|
|
|
() => this.Viewer.RemovePointStyle(this.LayerName));
|
|
|
for (int i = 0; i < curveStyle.Properties.Count; i++)
|
|
|
{
|
|
|
CurveView cv = curveStyle.Properties[i];
|
|
|
this.Viewer.SelectCreateCurveStyle(cv.StyleType, cv.SerialXml());
|
|
|
if (this.elementProperty != null)
|
|
|
{
|
|
|
if (this.elementProperty.CurveStyle == null)
|
|
|
{
|
|
|
this.elementProperty.CurveStyle = new DrawerCurveStyle();
|
|
|
}
|
|
|
this.elementProperty.CurveStyle.Properties.Add(cv);
|
|
|
}
|
|
|
this.AddCurveStyle(this.lsvElement, cv);
|
|
|
}
|
|
|
}
|
|
|
if (pointStyle != null && this.elementProperty.ElementType == DrawElementType.ELEMENT_POINT)
|
|
|
{
|
|
|
pointStyle.Clone();
|
|
|
pointStyle.Geo = this.Viewer.Geo;
|
|
|
this.AddPointStyle(pointStyle, this.lsvElement, true, s => this.Viewer.SelectCreatePointStyle(s.SerialXml()));
|
|
|
}
|
|
|
|
|
|
this.OnClipboardChanged();
|
|
|
}
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
protected override void WndProc(ref Message m)
|
|
|
{
|
|
|
const int WM_CLIPBOARDUPDATE = 0x031D;
|
|
|
if (m.Msg == WM_CLIPBOARDUPDATE)
|
|
|
{
|
|
|
this.OnClipboardChanged();
|
|
|
}
|
|
|
|
|
|
base.WndProc(ref m);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Panels the property_ load.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void PanelProperty_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
GeoSigmaLib.AddClipboardFormatListener(this.Handle);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// ppgs the element_ selected objects changed.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void ppgElement_SelectedObjectsChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
this.SetPropertyStatus(this.ppgElement);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// ppgs the data_ selected objects changed.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void ppgData_SelectedObjectsChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
if (this.ppgData.SelectedObject == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// ppgs the layer_ selected objects changed.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void ppgLayer_SelectedObjectsChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
this.SetPropertyStatus(this.ppgLayer);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 使用样式库为图层设置样式
|
|
|
/// </summary>
|
|
|
/// <param name="sender">按钮</param>
|
|
|
/// <param name="e">事件参数</param>
|
|
|
private void tsbtnLayerStyleLibrary_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.loadStylesLibrary((string group, string style) =>
|
|
|
{
|
|
|
this.Viewer.Geo.StyleLibraryApplyStyleTo(group, style, this.LayerName);
|
|
|
this.Viewer.Redraw();
|
|
|
|
|
|
string strCurveData = string.Empty;
|
|
|
string strPointData = string.Empty;
|
|
|
this.Viewer.GetLayerStyleData(this.LayerName, ref strCurveData, ref strPointData);
|
|
|
// 当前层位设置事件
|
|
|
DrawerStyle drawerStyle = new DrawerStyle();
|
|
|
if (strCurveData != string.Empty)
|
|
|
{
|
|
|
drawerStyle.DeserializeCurve(strCurveData);
|
|
|
for (int i = 0; i < drawerStyle.CurveStyle.Properties.Count; i++)
|
|
|
{
|
|
|
drawerStyle.CurveStyle.Properties[i].Geo = this.Viewer.Geo;
|
|
|
}
|
|
|
}
|
|
|
if (strPointData != string.Empty)
|
|
|
{
|
|
|
drawerStyle.DeserializePoint(strPointData);
|
|
|
drawerStyle.PontStyle.Geo = this.Viewer.Geo;
|
|
|
}
|
|
|
if (drawerStyle.CurveStyle != null || drawerStyle.PontStyle != null)
|
|
|
{
|
|
|
this.ShowLayerProperty(drawerStyle);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.ShowLayerProperty(null);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// tsbtns the element style library_ click.
|
|
|
/// </summary>
|
|
|
/// <param name="sender">The sender.</param>
|
|
|
/// <param name="e">The e.</param>
|
|
|
private void tsbtnElementStyleLibrary_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.loadStylesLibrary((string group, string style) =>
|
|
|
{
|
|
|
bool bSuccess = this.Viewer.Geo.StyleLibraryApplyStyleToElement(group, style, this.ElementPosition);
|
|
|
if (bSuccess == false)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
this.Viewer.Redraw();
|
|
|
|
|
|
string strElementData = string.Empty;
|
|
|
long lPosition = 0;
|
|
|
bool isElementFind = this.Viewer.Geo.SelectGetElement(ref strElementData, ref lPosition);
|
|
|
if (isElementFind && lPosition == this.ElementPosition)
|
|
|
{
|
|
|
DrawerElementProperty property = DrawerElementHelp.Deserialize(strElementData);
|
|
|
if (property != null && property.ElementType == DrawElementType.ELEMENT_MESH)
|
|
|
{
|
|
|
double zMin = 0;
|
|
|
double zMax = 0;
|
|
|
this.Viewer.Geo.SurfaceGetZRange(lPosition, ref zMin, ref zMax);
|
|
|
DrawerSurface surface = property.Element as DrawerSurface;
|
|
|
surface.RangeZ.Zmin = zMin;
|
|
|
surface.RangeZ.Zmax = zMax;
|
|
|
}
|
|
|
this.ShowElementProperty(property, lPosition);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// loads the styles library.
|
|
|
/// </summary>
|
|
|
/// <param name="applyStyleHandler">The apply style handler.</param>
|
|
|
private void loadStylesLibrary(ApplyStyleHandler applyStyleHandler)
|
|
|
{
|
|
|
string styleLibPath = Path.Combine(Directory.GetParent(Application.StartupPath).FullName, "Style");
|
|
|
if (!Directory.Exists(styleLibPath))
|
|
|
{
|
|
|
Directory.CreateDirectory(styleLibPath);
|
|
|
}
|
|
|
|
|
|
FrmStyleMain dialog = new FrmStyleMain(styleLibPath);
|
|
|
dialog.ApplyStyle += applyStyleHandler;
|
|
|
dialog.ShowDialog(this.Viewer);
|
|
|
}
|
|
|
|
|
|
private void NormalToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveProperty>();
|
|
|
}
|
|
|
|
|
|
private void HeadTailNameToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveName>();
|
|
|
}
|
|
|
|
|
|
private void CenterLineToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveInName>();
|
|
|
}
|
|
|
|
|
|
private void CenterAreaToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveCenterName>();
|
|
|
}
|
|
|
|
|
|
private void AnyPositionToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveInNameAny>();
|
|
|
}
|
|
|
|
|
|
private void ChainageToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveLocation>();
|
|
|
}
|
|
|
|
|
|
private void HeadSymbolToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveArrowHead>();
|
|
|
}
|
|
|
|
|
|
private void TailSymbolToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveArrowTail>();
|
|
|
}
|
|
|
|
|
|
private void DoubleSymbolToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveTwoMark>();
|
|
|
}
|
|
|
|
|
|
private void ManySymbolToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveScaleSymbol>();
|
|
|
}
|
|
|
|
|
|
private void SymbolFillToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveFillSymbol>();
|
|
|
}
|
|
|
|
|
|
private void GradientColorToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.AddLayerCurveStyle<CurveEffect>();
|
|
|
}
|
|
|
|
|
|
private bool IsWaveCurve(CurveProperty curveProperty)
|
|
|
{
|
|
|
return (curveProperty.Base.Style & (int)LineType.PLINE_WAVE) != 0;
|
|
|
}
|
|
|
|
|
|
private void ElementNormalToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveProperty>();
|
|
|
}
|
|
|
|
|
|
private void ElementHeadTailToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveName>();
|
|
|
}
|
|
|
|
|
|
private void ElementCenterLineToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveInName>();
|
|
|
}
|
|
|
|
|
|
private void ElementCenterAreaToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveCenterName>();
|
|
|
}
|
|
|
|
|
|
private void ElementAnyPositionToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveInNameAny>();
|
|
|
}
|
|
|
|
|
|
private void ElementChainageToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveLocation>();
|
|
|
}
|
|
|
|
|
|
private void ElementHeadSymbolToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveArrowHead>();
|
|
|
}
|
|
|
|
|
|
private void ElementTailSymbolToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveArrowTail>();
|
|
|
}
|
|
|
|
|
|
private void ElementDoubleSymbolToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveTwoMark>();
|
|
|
}
|
|
|
|
|
|
private void ElementManySymbolToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveScaleSymbol>();
|
|
|
}
|
|
|
|
|
|
private void ElementSymbolFillToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveFillSymbol>();
|
|
|
}
|
|
|
|
|
|
private void ElementGradientColorToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
AddElementCurveStyle<CurveEffect>();
|
|
|
}
|
|
|
}
|
|
|
}
|