예제 #1
0
        private void editButton_Click(object sender, EventArgs e)
        {
            ListViewItem listViewItem = lvGlobalParameters.SelectedItem;

            try
            {
                if (listViewItem != null)
                {
                    SolidEdgeFramework.ApplicationGlobalConstants globalConstant = (SolidEdgeFramework.ApplicationGlobalConstants)listViewItem.Tag;
                    Type   valueType       = listViewItem.SubItems[2].Tag as Type;
                    object globalValue     = null;
                    Type   globalValueType = null;

                    if (typeof(bool).Equals(valueType))
                    {
                        globalValue = booleanToolStripComboBox.SelectedItem;
                    }
                    else if (typeof(string).Equals(valueType))
                    {
                        globalValue = _textToolStripTextBox.Text;
                    }
                    else if (typeof(int).Equals(valueType))
                    {
                        globalValue = int.Parse(_textToolStripTextBox.Text);
                    }

                    if (globalValue != null)
                    {
                        _application.SetGlobalParameter(globalConstant, globalValue);

                        globalValueType = globalValue.GetType();

                        listViewItem.SubItems[1].Text = String.Format("{0}", globalValue);
                        listViewItem.SubItems[1].Tag  = globalValue;
                        listViewItem.SubItems[2].Text = String.Format("{0}", globalValueType);
                        listViewItem.SubItems[2].Tag  = globalValueType;
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            lvGlobalParameters.SelectedItem = listViewItem;
        }