#region
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Windows.Forms;
|
using CSFrameworkV5.Core;
|
using CSFrameworkV5.Interfaces.InterfaceModels;
|
using DevExpress.XtraEditors;
|
|
#endregion
|
|
namespace CSFrameworkV5.Library
|
{
|
public partial class frmFormConfigDetail : Form
|
{
|
private int i;
|
|
private frmFormConfigDetail()
|
{
|
InitializeComponent();
|
}
|
|
private void BindingObject(BaseEdit edit, object o, string fieldName)
|
{
|
edit.DataBindings.Clear();
|
edit.DataBindings.Add("EditValue", o, fieldName);
|
}
|
|
private void btnBottom_Click(object sender, EventArgs e)
|
{
|
if (listFields.SelectedIndex < listFields.ItemCount - 1)
|
MoveItem(listFields.ItemCount - 1);
|
}
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
{
|
Close();
|
}
|
|
private void btnDown_Click(object sender, EventArgs e)
|
{
|
i = listFields.SelectedIndex;
|
if (i < listFields.ItemCount - 1)
|
{
|
i++;
|
MoveItem(i);
|
}
|
}
|
|
private void btnHideAll_Click(object sender, EventArgs e)
|
{
|
listFields.UnCheckAll();
|
}
|
|
private void btnOK_Click(object sender, EventArgs e)
|
{
|
btnOK.Tag = "OK";
|
Close();
|
}
|
|
private void btnShowAll_Click(object sender, EventArgs e)
|
{
|
listFields.CheckAll();
|
}
|
|
private void btnTop_Click(object sender, EventArgs e)
|
{
|
MoveItem(0);
|
}
|
|
private void btnUp_Click(object sender, EventArgs e)
|
{
|
i = listFields.SelectedIndex;
|
if (i > 0)
|
{
|
i--;
|
MoveItem(i);
|
}
|
}
|
|
public static void Execute(List<FieldConfig> fields, bool isViewMode)
|
{
|
var form = new frmFormConfigDetail();
|
form.listFields.DisplayMember = "CaptionCustom";
|
form.listFields.ValueMember = "FieldName";
|
form.listFields.DataSource = fields;
|
form.btnOK.Visible = !isViewMode;
|
form.panelControl1.Enabled = !isViewMode;
|
form.groupControl1.Enabled = !isViewMode;
|
form.ShowDialog();
|
}
|
|
private void frmFormConfigDetail_Load(object sender, EventArgs e)
|
{
|
//
|
}
|
|
private void listFields_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
if (listFields.SelectedItem != null)
|
{
|
var item = listFields.SelectedItem as FieldConfig;
|
ShowConfig(item);
|
}
|
}
|
|
private void MoveItem(int index)
|
{
|
var item = listFields.SelectedItem as FieldConfig;
|
var list = listFields.DataSource as IList;
|
list.Remove(item);
|
list.Insert(index, item);
|
listFields.Refresh();
|
listFields.SelectedIndex = index;
|
}
|
|
private void ShowConfig(FieldConfig item)
|
{
|
if (string.IsNullOrEmpty(item.CaptionCustom))
|
item.CaptionCustom = item.Caption;
|
|
BindingObject(txtCustomCaption, item, "CaptionCustom");
|
BindingObject(txtDefaultCaption, item, "Caption");
|
BindingObject(txtFieldName, item, "FieldName");
|
BindingObject(txtNoBlank, item, "NoBlank");
|
BindingObject(txtPoint, item, "Point");
|
BindingObject(txtReadOnly, item, "ReadOnly");
|
BindingObject(txtWidth, item, "Width");
|
}
|
|
private void txtPoint_EditValueChanged(object sender, EventArgs e)
|
{
|
var len = (int)txtPoint.Value;
|
|
lblExample.Text = "20170808";
|
var point = new StringBuilder("");
|
|
for (var i = 1; i <= len; i++) point.Append(i.ToStringEx());
|
|
if (point.Length > 0)
|
{
|
lblExample.Text = lblExample.Text + "." + point.ToStringEx();
|
lblExample.Refresh();
|
}
|
}
|
}
|
}
|