예제 #1
0
        private void EditMI_Click(object sender, EventArgs e)
        {
            try {
                if (ItemsLV.SelectedItems.Count != 1)
                {
                    return;
                }

                ValueState state = ItemsLV.SelectedItems[0].Tag as ValueState;

                if (!IsEditableType(state.Component))
                {
                    return;
                }

                object value = null;
                if (state.Component is LocalizedText)
                {
                    value = new StringValueEditDlg().ShowDialog(state.Component.ToString());
                    if (value != null)
                    {
                        value = new LocalizedText(((LocalizedText)state.Component).Key,
                                                  ((LocalizedText)state.Component).Locale, value.ToString());
                    }
                }
                else
                {
                    value = new SimpleValueEditDlg().ShowDialog(state.Component, state.Component.GetType());
                }

                if (value == null)
                {
                    return;
                }

                if (state.Value is IEncodeable)
                {
                    PropertyInfo property = (PropertyInfo)state.ComponentId;

                    MethodInfo[] accessors = property.GetAccessors();

                    for (int ii = 0; ii < accessors.Length; ii++)
                    {
                        if (accessors[ii].ReturnType == typeof(void))
                        {
                            accessors[ii].Invoke(state.Value, new object[] { value });
                            state.Component = value;
                            break;
                        }
                    }
                }

                DataValue datavalue = state.Value as DataValue;

                if (datavalue != null)
                {
                    int component = (int)state.ComponentId;

                    switch (component)
                    {
                    case 0: {
                        datavalue.Value = value;
                        break;
                    }
                    }
                }

                if (state.Value is IList)
                {
                    int ii = (int)state.ComponentId;
                    ((IList)state.Value)[ii] = value;
                    state.Component          = value;
                }

                m_expanding = false;
                int index       = (int)state.ComponentIndex;
                int indentCount = ItemsLV.Items[index].IndentCount;

                while (ItemsLV.Items[index - 1].IndentCount == indentCount)
                {
                    --index;
                }

                bool overwrite = true;
                ShowValue(ref index, ref overwrite, state.Value);
            } catch (Exception exception) {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
예제 #2
0
        private void EditMI_Click(object sender, EventArgs e)
        {
            try
            {
                if (ItemsLV.SelectedItems.Count != 1)
                {
                    return;
                }

                ValueState state = ItemsLV.SelectedItems[0].Tag as ValueState;

                if (!IsEditableType(state.Component))
                {
                    return;
                }

                object value = null;
                if (state.Component is LocalizedText)
                {
                    value = new StringValueEditDlg().ShowDialog(state.Component.ToString());
                    if (value != null)
                    {
                        value = new LocalizedText(((LocalizedText)state.Component).Key, ((LocalizedText)state.Component).Locale, value.ToString());
                    }
                }
                else
                {
                    value = new SimpleValueEditDlg().ShowDialog(state.Component, state.Component.GetType());
                }

                if (value == null)
                {
                    return;
                }

                if (state.Value is IEncodeable)
                {
                    PropertyInfo property = (PropertyInfo)state.ComponentId;
                    
                    MethodInfo[] accessors = property.GetAccessors();

                    for (int ii = 0; ii < accessors.Length; ii++)
                    {
                        if (accessors[ii].ReturnType == typeof(void))
                        {
                            accessors[ii].Invoke(state.Value, new object[] { value });
                            state.Component = value;
                            break;
                        }
                    }
                }
                
                DataValue datavalue = state.Value as DataValue;

                if (datavalue != null)
                {
                    int component = (int)state.ComponentId;

                    switch (component)
                    {
                        case 0: { datavalue.Value = value; break; }
                    }
                }

                if (state.Value is IList)
                {
                    int ii = (int)state.ComponentId;
                    ((IList)state.Value)[ii] = value;
                    state.Component = value;
                }
                
                m_expanding = false;
                int index = (int)state.ComponentIndex;
                int indentCount = ItemsLV.Items[index].IndentCount;

                while (ItemsLV.Items[index - 1].IndentCount == indentCount)
                {
                    --index;
                }

                bool overwrite = true;
                ShowValue(ref index, ref overwrite, state.Value);                
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }