|
|
|
|
|
// <copyright file="PanelProperty.cs" company="PlaceholderCompany">
|
|
|
|
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
|
|
|
|
// </copyright>
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
//using StyleLibManager;
|
|
|
|
|
|
namespace UCDraw
|
|
|
|
|
|
{
|
|
|
|
|
|
//public delegate void SymbolSigma(GeoSigmaDrawLib.GeoSigmaXY geoSigma);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 属性面板
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class WellPolePanelProperty : UserControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 图元属性发生了变化
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public event EventHandler<EventArgs> ElementChanged;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="WellPolePanelProperty"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public WellPolePanelProperty()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
|
|
propertyGrid1.PropertyValueChanged += (s, e) => ElementChanged?.Invoke(this, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object SelectedObject
|
|
|
|
|
|
{
|
|
|
|
|
|
get => propertyGrid1.SelectedObject;
|
|
|
|
|
|
set => propertyGrid1.SelectedObject = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ExpandPropertyGridValueColumn()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (propertyGrid1 == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
// 获取内部 PropertyGridView
|
|
|
|
|
|
var gridViewField = typeof(PropertyGrid).GetField("gridView",
|
|
|
|
|
|
BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
|
|
if (gridViewField?.GetValue(propertyGrid1) is Control gridView)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 方法 A:启用 LargeButtons 模式(值列变宽)
|
|
|
|
|
|
var largeButtonsProp = gridView.GetType().GetProperty("LargeButtons");
|
|
|
|
|
|
largeButtonsProp?.SetValue(gridView, true);
|
|
|
|
|
|
|
|
|
|
|
|
// 方法 B(更直接):设置固定值列宽度
|
|
|
|
|
|
// 注意:不同 .NET 版本字段名可能不同
|
|
|
|
|
|
var valueCellWidthField = gridView.GetType().GetField("valueCellWidth",
|
|
|
|
|
|
BindingFlags.Instance | BindingFlags.NonPublic);
|
|
|
|
|
|
if (valueCellWidthField != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
valueCellWidthField.SetValue(gridView, 200); // 设置为 200 像素
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 触发重绘
|
|
|
|
|
|
propertyGrid1.Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|