コード例 #1
0
 public FieldEditAction(FieldEditState state0, FieldEditState state1, EditorIndex index, int fieldIndex, bool canCombime)
     : base(state0, state1)
 {
     state0.Edit     = state1.Edit = this;
     this.index      = index;
     this.fieldIndex = fieldIndex;
     this.canCombime = canCombime;
 }
コード例 #2
0
        private void ApplyEdit(FieldEditState state)
        {
            if (state == null)
            {
                return;
            }
            int fieldIndex = state.Edit.fieldIndex;

            if (fieldIndex >= 0 && fieldIndex < editors.Count)
            {
                // Console.WriteLine(editors[fieldIndex].accessor.Get() + " -> " + state.value);
                editors[fieldIndex].GetControl().Focus();
                editors[fieldIndex].SetValue(state.value, false);
                editors[fieldIndex].SelectedIndex = state.selection;
            }
        }
コード例 #3
0
        private void AddRow(Accessor accessor, TableLayoutPanel tableLayout)
        {
            if (accessor.GetTags().Any(x => x.flag == FieldTags.Inline))
            {
                AddInlineRow(accessor, tableLayout);
                return;
            }

            FieldEditor editor = FieldEditor.CreateEditor(accessor, this);

            if (editor == null)
            {
                return;
            }

            tableLayout.RowCount++;
            Label label = new Label();

            label.AutoSize = true;
            label.Text     = GetHumanReadableField(accessor.GetName());
            FieldTag comment = accessor.GetTags().Where(tag => tag.flag == FieldTags.Comment).FirstOrDefault();

            if (comment != null)
            {
                ToolTip tooltip = new ToolTip();
                tooltip.SetToolTip(label, comment.arg);
            }
            tableLayout.Controls.Add(label, 0, tableLayout.RowCount - 1);

            Control content = editor.GetControl();

            content.Enabled = !editor.accessor.GetTags().Any((tag) => tag.flag == FieldTags.Readonly);
            tableLayout.Controls.Add(content, 1, tableLayout.RowCount - 1);
            int fieldIndex = editors.Count;

            editors.Add(editor);
            editor.OnEdited += (sender, args) =>
            {
                if (OnObjectEdited != null)
                {
                    EditorIndex    index  = Index;
                    FieldEditState state0 = new FieldEditState(args.valueBefore, editor.LastSelectedIndex);
                    FieldEditState state1 = new FieldEditState(args.valueAfter, editor.SelectedIndex);
                    OnObjectEdited(sender, new FieldEditAction(state0, state1, index.RemoveNext(), fieldIndex, editor.EditsCanCombine));
                }
            };
        }