Ejemplo n.º 1
0
        internal static UnknownParameterEditor Make(IColorScheme scheme, ParameterEditorSetupData data, SimpleUndoPair removeParameter, Action remove)
        {
            UnknownParameterEditor x = null;

            try
            {
                x        = new UnknownParameterEditor();
                x.Scheme = scheme;
                x.Setup(data);
                x.m_removeParameter = removeParameter;
                x.Remove           += remove;
                var result = x;
                x = null;
                return(result);
            }
            finally
            {
                if (x != null)
                {
                    x.Dispose();
                }
            }
        }
Ejemplo n.º 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;
                }
            }
        }