Beispiel #1
0
        public static ConfigureResult2 Edit(IColorScheme scheme, IConversationNodeData data, AudioGenerationParameters audioContext, Func <ParameterType, ParameterEditorSetupData, IParameterEditor> config, ILocalizationEngine localizer, IAudioParameterEditorCallbacks audioProvider, AutoCompleteSuggestionsDelegate autoCompleteSuggestions)
        {
            using (Form f = new Form())
            {
                NodeEditor editor = new NodeEditor(scheme, data, audioContext, config, localizer, audioProvider, autoCompleteSuggestions);

                f.Text = editor.Title;
                bool oked = false;
                editor.Ok += () =>
                {
                    var invalid = editor.m_parameterEditors.Select(e => new { Name = e.Item2.Name, Message = e.Item1.IsValid() }).Where(e => e.Message != null);
                    if (!invalid.Any())
                    {
                        oked = true;
                        f.Close();
                    }
                    else
                    {
                        string message = "Invalid values specified for the following parameters:";
                        foreach (var i in invalid)
                        {
                            message += "\n";
                            message += i.Name + ": ";
                            message += i.Message;
                        }

                        MessageBox.Show(message);
                    }
                };
                editor.Cancel += () => { oked = false; f.Close(); };
                editor.Dock    = DockStyle.Fill;
                int maxHeight = editor.MaximumHeight + f.Height - f.ClientSize.Height;
                int minHeight = editor.MinimumHeight + f.Height - f.ClientSize.Height;
                f.MaximumSize       = new Size(999999, maxHeight);
                f.MinimumSize       = new Size(0, minHeight);
                editor.NeedsResize += () =>
                {
                    bool resize = false;
                    if (f.Size.Height == f.MaximumSize.Height || f.Size.Height == f.MinimumSize.Height)
                    {
                        resize = true;
                    }
                    int max = editor.MaximumHeight + f.Height - f.ClientSize.Height;
                    int min = editor.MinimumHeight + f.Height - f.ClientSize.Height;
                    f.MaximumSize = new Size(999999, max);
                    f.MinimumSize = new Size(0, min);
                    if (resize)
                    {
                        f.Size = new Size(f.Size.Width, max);
                    }
                };
                f.Size = new Size(500, 478);
                f.Controls.Add(editor);
                f.ShowDialog();

                if (oked)
                {
                    var updates = editor.m_parameterEditors.Select(e => e.Item1.UpdateParameterAction());
                    return(new ConfigureResult2(updates.ToArray()));
                }
                else
                {
                    return(ConfigureResult.Cancel);
                }
            }
        }
Beispiel #2
0
        public NodeEditor(IColorScheme scheme, IConversationNodeData data, AudioGenerationParameters audioContext, Func <ParameterType, ParameterEditorSetupData, IParameterEditor> config, ILocalizationEngine localizer, IAudioParameterEditorCallbacks audioProvider, AutoCompleteSuggestionsDelegate autoCompleteSuggestions)
            : this()
        {
            Scheme = scheme;
            m_data = data;

            this.SuspendLayout();
            flowLayoutPanel1.SuspendLayout();
            flowLayoutPanel2.SuspendLayout();

            if (!string.IsNullOrEmpty(data.Description))
            {
                int padding = 8;
                m_descriptionBox      = new MyTextBox(panel1, () => new RectangleF(panel1.Location.Plus(padding, padding), new SizeF(panel1.Width - padding * 2, panel1.Height - padding * 2)), MyTextBox.InputFormEnum.None, null, x => new SimpleTextBoxBorderDrawer(x), 8, Fonts.Default);
                m_descriptionBox.Text = data.Description;
                MyTextBox.SetupCallbacks(panel1, m_descriptionBox);
                panel1.Size         = m_descriptionBox.RequestedArea.ToSize();
                panel1.SizeChanged += (object sender, EventArgs e) =>
                {
                    var requested = m_descriptionBox.RequestedArea.ToSize();
                    panel1.Size = new Size(requested.Width + padding * 2, requested.Height + padding * 2);
                };
            }
            else
            {
                panel1.Height = 0;
            }

            //Make the panels really tall so they can visibly contain all the parameter editors.
            //Note the whole control won't be visible as we'll scroll them by shifting them in Y.
            flowLayoutPanel1.Height = 10000;
            flowLayoutPanel2.Height = 10000;

            Title = m_data.Name;

            foreach (Parameter p in m_data.Parameters.OrderByDescending(p => p.Name))
            {
                var editorData = new ParameterEditorSetupData(p, localizer, audioProvider, audioContext, (s) => autoCompleteSuggestions(p, s));
                if (p is UnknownParameter unknown)
                {
                    UnknownParameterEditor ed = null;
                    Label label = null;
                    ed = UnknownParameterEditor.Make(Scheme, editorData, m_data.RemoveUnknownParameter(unknown),
                                                     () =>
                    {
                        flowLayoutPanel2.Controls.Remove(ed);
                        flowLayoutPanel1.Controls.Remove(label);
                        SetupScrollbar();
                    });
                    label = AddParameter(p, ed);
                }
                else
                {
                    AddParameter(p, config(p.TypeId, editorData));
                }
            }

            flowLayoutPanel1.ResumeLayout();
            flowLayoutPanel2.ResumeLayout();

            SetupScrollbar();

            if (flowLayoutPanel1.Controls.Count > 0)
            {
                EventHandler SizeChanged = (a, b) =>
                {
                    NeedsResize.Execute();
                    DoResize();
                };
                flowLayoutPanel2.Controls[0].LocationChanged += SizeChanged;
                flowLayoutPanel2.Controls[0].SizeChanged     += SizeChanged;
                panel1.SizeChanged += SizeChanged;
            }
            ;

            this.ResumeLayout();

            this.splitContainer1.Panel2.SizeChanged += Panel2_SizeChanged;

            if (flowLayoutPanel2.Controls.Count > 0)
            {
                for (int i = flowLayoutPanel2.Controls.Count - 1; i >= 0; i--)
                {
                    (flowLayoutPanel2.Controls[i] as Panel).TabStop  = true;
                    (flowLayoutPanel2.Controls[i] as Panel).TabIndex = flowLayoutPanel2.Controls.Count - i - 1;
                }
            }
        }
Beispiel #3
0
 public override ConfigureResult2 Edit(IColorScheme scheme, IConversationNodeData node, AudioGenerationParameters audioContext, Func <ParameterType, ParameterEditorSetupData, IParameterEditor> config, ILocalizationEngine localizer, IAudioParameterEditorCallbacks audioProvider, AutoCompleteSuggestionsDelegate autoCompleteSuggestions)
 {
     if (node.Parameters.Any())
     {
         return(NodeEditor.Edit(scheme, node, audioContext, config, localizer, audioProvider, autoCompleteSuggestions));
     }
     else
     {
         return(ConfigureResult2.NotApplicable);
     }
 }
Beispiel #4
0
 public abstract ConfigureResult2 Edit(IColorScheme scheme, IConversationNodeData node, AudioGenerationParameters audioContext, Func <ParameterType, ParameterEditorSetupData, IParameterEditor> config, ILocalizationEngine localizer, IAudioParameterEditorCallbacks audioProvider, AutoCompleteSuggestionsDelegate autoCompleteSuggestions);