You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.8 KiB
C#
123 lines
3.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
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 DevExpress.XtraEditors;
|
|
using DevExpress.XtraTreeList.Nodes;
|
|
using GeoSigma.SigmaDrawerUtil;
|
|
using UCDraw;
|
|
|
|
namespace PcgDrawR
|
|
{
|
|
public partial class FrmOptions : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
private DrawerConfig sysConfig;
|
|
public FrmOptions()
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.LoadData();
|
|
}
|
|
/// <summary>
|
|
/// 加载配置数据.
|
|
/// </summary>
|
|
private void LoadData()
|
|
{
|
|
this.sysConfig = DrawerConfig.Instance.Clone();
|
|
this.trlDataItem.Nodes.Clear();
|
|
|
|
// 系统设置节点
|
|
foreach (var node in this.sysConfig.ConfigNodes)
|
|
{
|
|
if (node.Display == true)
|
|
{
|
|
TreeListNode tln = this.trlDataItem.Nodes.Add(new object[] { node.Caption, node.Name });
|
|
tln.ImageIndex = 1;
|
|
tln.Tag = node.ConfigItems;
|
|
}
|
|
}
|
|
trlDataItem.ExpandAll();
|
|
}
|
|
|
|
/// <summary>
|
|
/// trls the data item_ focused node changed.
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
private void trlDataItem_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
|
|
{
|
|
if (e.Node == null)
|
|
{
|
|
return;
|
|
}
|
|
object obj = e.Node.Tag;
|
|
if (obj != null)
|
|
{
|
|
this.propertyGridControl1.SelectedObject = (CustomProperties)obj;
|
|
}
|
|
else
|
|
{
|
|
this.propertyGridControl1.SelectedObject = null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// btns the o k_ click.
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
this.sysConfig.Save();
|
|
DrawerConfig.Instance = this.sysConfig;
|
|
this.DialogResult = DialogResult.OK;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Frms the options_ load.
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
private void FrmOptions_Load(object sender, EventArgs e)
|
|
{
|
|
if (this.trlDataItem.Nodes.Count > 0)
|
|
{
|
|
trlDataItem_FocusedNodeChanged(
|
|
this.trlDataItem
|
|
, new DevExpress.XtraTreeList.FocusedNodeChangedEventArgs(null, this.trlDataItem.Nodes[0]));
|
|
}
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
private void propertyGridControl1_CustomPropertyDescriptors(object sender, DevExpress.XtraVerticalGrid.Events.CustomPropertyDescriptorsEventArgs e)
|
|
{
|
|
if (e.Context.PropertyDescriptor == null)
|
|
{
|
|
e.Properties = e.Properties.Sort(new PropertyOrderComparer());
|
|
}
|
|
}
|
|
public class PropertyOrderComparer : IComparer
|
|
{
|
|
/// <inheritdoc/>
|
|
int IComparer.Compare(object a, object b)
|
|
{
|
|
if ((a is CustomPropDescriptor) && (b is CustomPropDescriptor))
|
|
{
|
|
return ((CustomPropDescriptor)a).PropertyOrder.CompareTo(((CustomPropDescriptor)b).PropertyOrder);
|
|
}
|
|
return new CaseInsensitiveComparer().Compare(a, b);
|
|
}
|
|
}
|
|
}
|
|
} |