| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 | using OTS.WinFormsUI.Docking;using SpectrumSTDEditor.BaseClass;using System;using System.Drawing;using System.Windows.Forms;namespace SpectrumSTDEditor{    public partial class Attributes : DockContent    {        public Form_Main m_MainForm = null;                private void clickEvent_Click(object sender, EventArgs e)        {            SourceGrid.CellContext context = (SourceGrid.CellContext)sender;            int i = context.Position.Row;            int j = context.Position.Column;            /// 保证鼠标点击的GRID行和列是有效的            if (i >= 0 && j >= 0)            {                ColorDialog cd = new ColorDialog();                cd.FullOpen = true;//自定义颜色界面打开                DialogResult result = cd.ShowDialog();                if (result == DialogResult.OK)                {                    SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();                    view.BackColor = cd.Color;                    Grid_Attributes[i, j].View = view;                    m_MainForm.ChangeSTDRulesLISTBackColor();                }            }            Grid_Attributes.Refresh();        }        private void EditorEvent_EditEnded(object sender, EventArgs e)        {            SourceGrid.CellContext context = (SourceGrid.CellContext)sender;            //if(Grid_Attributes[context.Position.Row, context.Position.Column].Value==null)            //{            //    MessageBox.Show("The name of rule cannot be null!", "warnning");            //    return;            //}            m_MainForm.ChangeSTDRuleName(Convert.ToString( Grid_Attributes[context.Position.Row, context.Position.Column].Value));        }        private class MyHeader : SourceGrid.Cells.ColumnHeader        {            public MyHeader(object value) : base(value)            {                SourceGrid.Cells.Views.ColumnHeader view = new SourceGrid.Cells.Views.ColumnHeader();                view.Font = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold);                view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft;                //view.BackColor = Color.Green;                //view.ForeColor= Color.Red;                View = view;                //自带排序true;不实现排序false                AutomaticSortEnabled = false;            }        }        public Attributes(Form_Main mainForm)        {            InitializeComponent();            m_MainForm = mainForm;        }        private void Attributes_Load(object sender, EventArgs e)        {            m_MainForm.lan = new Language(this);            Grid_Attributes.Redim(10, 2);            if (m_MainForm.lan.GetNameTable("Form_Main")["language"].ToString() == "ZH")            {                //SourceGrid.Cells.ColumnHeader head1 = new SourceGrid.Cells.ColumnHeader("通用属性");                Grid_Attributes[0, 0] = new SourceGrid.Cells.Cell("通用属性 ", typeof(string));                //head1.AutomaticSortEnabled = false;                Grid_Attributes[1, 0] = new SourceGrid.Cells.Cell("STDId ", typeof(string));                Grid_Attributes[2, 0] = new SourceGrid.Cells.Cell("规则名称 ", typeof(string));                Grid_Attributes[3, 0] = new SourceGrid.Cells.Cell("中文名称 ", typeof(string));                Grid_Attributes[4, 0] = new SourceGrid.Cells.Cell("颜色", typeof(string));                Grid_Attributes[5, 0] = new SourceGrid.Cells.Cell("硬度(HV)", typeof(string));                Grid_Attributes[6, 0] = new SourceGrid.Cells.Cell("密度(g/m³)", typeof(string));                Grid_Attributes[7, 0] = new SourceGrid.Cells.Cell("Video", typeof(string));                Grid_Attributes[8, 0] = new SourceGrid.Cells.Cell("化学式", typeof(string));                Grid_Attributes[9, 0] = new SourceGrid.Cells.Cell("元素", typeof(string));            }            else            {                Grid_Attributes[0, 0] = new SourceGrid.Cells.Cell("General Properties", typeof(string));                Grid_Attributes[1, 0] = new SourceGrid.Cells.Cell("STDId ", typeof(string));                Grid_Attributes[2, 0] = new SourceGrid.Cells.Cell("RuleName ", typeof(string));                Grid_Attributes[3, 0] = new SourceGrid.Cells.Cell("ChineseName ", typeof(string));                Grid_Attributes[4, 0] = new SourceGrid.Cells.Cell("Color", typeof(string));                Grid_Attributes[5, 0] = new SourceGrid.Cells.Cell("Hardness", typeof(string));                Grid_Attributes[6, 0] = new SourceGrid.Cells.Cell("Density", typeof(string));                Grid_Attributes[7, 0] = new SourceGrid.Cells.Cell("Video", typeof(string));                Grid_Attributes[8, 0] = new SourceGrid.Cells.Cell("Formula", typeof(string));                Grid_Attributes[9, 0] = new SourceGrid.Cells.Cell("Element", typeof(string));            }            Grid_Attributes[1, 1] = new SourceGrid.Cells.Cell(" ", typeof(int));            Grid_Attributes[2, 1] = new SourceGrid.Cells.Cell(" ", typeof(string));            Grid_Attributes[3, 1] = new SourceGrid.Cells.Cell("", typeof(string));            Grid_Attributes[4, 1] = new SourceGrid.Cells.Cell("", typeof(string));            Grid_Attributes[5, 1] = new SourceGrid.Cells.Cell("", typeof(string));            Grid_Attributes[6, 1] = new SourceGrid.Cells.Cell("", typeof(string));            Grid_Attributes[7, 1] = new SourceGrid.Cells.Cell("", typeof(string));            Grid_Attributes[8, 1] = new SourceGrid.Cells.Cell("", typeof(string));            Grid_Attributes[9, 1] = new SourceGrid.Cells.Cell("", typeof(string));            Grid_Attributes[0, 0].ColumnSpan = 2;            Grid_Attributes.AutoStretchColumnsToFitWidth = true;            Grid_Attributes.Columns[0].Width = this.Width / 2 - 30;            Grid_Attributes.Columns[1].Width = this.Width / 2 + 30;            for (int i=0;i<10;i++)            {                Grid_Attributes.Rows[i].Height = 25;            }            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();            view.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);            view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;            view.BackColor = Color.LightGray;            Grid_Attributes[0, 0].View = view;            SourceGrid.Cells.Controllers.CustomEvents EditorEvent = new SourceGrid.Cells.Controllers.CustomEvents();            EditorEvent.EditEnded += new EventHandler(EditorEvent_EditEnded);            Grid_Attributes[2, 1].AddController(EditorEvent);            SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();            clickEvent.Click += new EventHandler(clickEvent_Click);            Grid_Attributes[4,1].AddController(clickEvent);            Grid_Attributes[0, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[1, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[4, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[0, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[1, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[2, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[3, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[4, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[5, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[6, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[7, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[8, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes[9, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);            Grid_Attributes.Selection.FocusStyle = SourceGrid.FocusStyle.None;            //SourceGrid.Position po = new SourceGrid.Position(1, 0);            //Grid_Attributes[1, 0].Grid.Select();            //Grid_Attributes.Selection.Focus(po, true);        }        public void SetDatatoGrid_Attributes(int STDId)        {            Grid_Attributes[1, 1].Value = STDId;            Grid_Attributes[2, 1].Value = m_MainForm.STDDictionary[STDId].StrName;            Grid_Attributes[3, 1].Value = m_MainForm.STDDictionary[STDId].ChineseName;            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();            view.BackColor = shareFunction.string10ToColor(m_MainForm.STDDictionary[STDId].Color);            Grid_Attributes[4, 1].View = view;            Grid_Attributes[5, 1].Value = m_MainForm.STDDictionary[STDId].Hardness;            Grid_Attributes[6, 1].Value = m_MainForm.STDDictionary[STDId].Density;            Grid_Attributes[7, 1].Value = m_MainForm.STDDictionary[STDId].BSE;            Grid_Attributes[8, 1].Value = m_MainForm.STDDictionary[STDId].Formula;            Grid_Attributes[9, 1].Value = m_MainForm.STDDictionary[STDId].Element;            //SourceGrid.Position po = new SourceGrid.Position(1, 0);            //Grid_Attributes[1, 0].Grid.Select();            //Grid_Attributes.Selection.Focus(po, true);            Grid_Attributes.Refresh();        }        public void SetDatatoGrid_Attributes(STDdata sTDdata)        {            Grid_Attributes[1, 1].Value = "";            Grid_Attributes[2, 1].Value = sTDdata.StrName;            Grid_Attributes[3, 1].Value = sTDdata.ChineseName;            SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();            view.BackColor = shareFunction.string10ToColor(sTDdata.Color);            Grid_Attributes[4, 1].View = view;            Grid_Attributes[5, 1].Value = sTDdata.Hardness;            Grid_Attributes[6, 1].Value = sTDdata.Density;            Grid_Attributes[7, 1].Value = sTDdata.BSE;            Grid_Attributes[8, 1].Value = sTDdata.Formula;            Grid_Attributes[9, 1].Value = sTDdata.Element;            Grid_Attributes.Refresh();        }    }}
 |