Ejemplo n.º 1
0
        public GenEntryForm(GenEntry entry)
        {
            this.entry = entry;
            groups     = new List <GenEntryFormGroup>();

            InitFormLayout();
            ShowInTaskbar = false;
            StartPosition = FormStartPosition.CenterParent;
            MaximizeBox   = false;
            MinimizeBox   = false;
            Width         = 400;
            Height        = 600;

            AddGroup(CreateCommonGroup());

            var generators = Generator.Available()
                             .OrderBy(generator => generator.Title);

            foreach (var generator in generators)
            {
                var groupControl = generator.CreateOptionGroup(entry);
                if (groupControl != null)
                {
                    AddGroup(groupControl);
                }
            }
        }
Ejemplo n.º 2
0
        private void ShowEntryForm(int index)
        {
            GenEntry entry;

            if (index < currentSettings.entries.Count)
            {
                entry = currentSettings.entries[index].Clone();
            }
            else
            {
                entry      = new GenEntry();
                entry.guid = Guid.NewGuid().ToString();
            }

            using (var form = new GenEntryForm(entry))
            {
                form.Saved += (s, e) => {
                    if (index < currentSettings.entries.Count)
                    {
                        currentSettings.entries[index] = entry;
                    }
                    else
                    {
                        currentSettings.entries.Add(entry);
                    }
                    Update(currentSettings);
                };

                form.ShowDialog(this.form);
            }
        }
Ejemplo n.º 3
0
        public override UI.GenEntryFormGroup CreateOptionGroup(GenEntry entry)
        {
            var group = UI.GenEntryForm.CreateGroup(Title);

            group.Controls.Add(new UI.GenEntryFormRow("Command", new Control[] { UI.GenEntryForm.CreateTextBox(entry, "wt.command") }));

            return(group);
        }
Ejemplo n.º 4
0
        public static TextBox CreateTextBox(GenEntry entry, string field)
        {
            var ctrl     = new TextBox();
            var property = entry.GetType().GetProperty(field);
            var initial  = property != null?property.GetValue(entry) : entry.Get(field, "");

            ctrl.Text = initial != null?initial.ToString() : "";

            ctrl.TextChanged += (a, e) => {
                if (property != null)
                {
                    property.SetValue(entry, ctrl.Text);
                }
                else
                {
                    entry.Set(field, ctrl.Text);
                }
            };

            return(ctrl);
        }
Ejemplo n.º 5
0
 public override UI.GenEntryFormGroup CreateOptionGroup(GenEntry entry)
 {
     return(null);
 }