예제 #1
0
        /// <summary>
        /// Adds all context menu items based on the given variable names.
        /// </summary>
        private void RebuildContextMenu()
        {
            if (m_Customiser == null)
            {
                return;
            }

            m_Customiser.MenuItems.Clear();

            // No options for read only text boxes
            if (ReadOnly)
            {
                return;
            }

            if (m_VariableNames.Length > 0)
            {
                List <string> vars = new List <string>(m_VariableNames);
                vars.Sort();
                // We insert in reverse order
                vars.Reverse();

                // Add final separator
                m_Customiser.MenuItems.Add(new ContextMenuItem(string.Empty, 0));

                foreach (string var in vars)
                {
                    ContextMenuItem newItem = new ContextMenuItem("{" + var + "}", 0)
                    {
                        EventHandler = this.OnVariableSelected
                    };
                    m_Customiser.MenuItems.Add(newItem);
                }
            }

            // Add context menu item for multiline editor
            if (Multiline && m_EnableEditor)
            {
                // Add final separator
                m_Customiser.MenuItems.Add(new ContextMenuItem(string.Empty, 0));

                ContextMenuItem newItem = new ContextMenuItem("Editor...", 0)
                {
                    EventHandler = delegate
                    {
                        using (MultilineEditorDialog dialog = new MultilineEditorDialog())
                        {
                            dialog.Value = this.Text;
                            dialog.SetVariableNames(m_VariableNames);

                            if (dialog.ShowDialog(this) == DialogResult.OK)
                            {
                                this.Text = dialog.Value;
                            }
                        }
                    }
                };
                m_Customiser.MenuItems.Add(newItem);
            }
        }
예제 #2
0
        /// <summary>
        /// Inserts the selected variable at the current cursor position.
        /// </summary>
        private void OnVariableSelected(ContextMenuItem menuItem)
        {
            int selStart = SelectionStart;

            Text           = Text.Insert(selStart, menuItem.Text);
            SelectionStart = selStart + menuItem.Text.Length;
        }
예제 #3
0
        /// <summary>
        /// Adds all context menu items based on the given variable names.
        /// </summary>
        private void RebuildContextMenu()
        {
            if (m_Customiser == null) return;

            m_Customiser.MenuItems.Clear();

            // No options for read only text boxes
            if (ReadOnly) return;

            if (m_VariableNames.Length > 0)
            {

                List<string> vars = new List<string>(m_VariableNames);
                vars.Sort();
                // We insert in reverse order
                vars.Reverse();

                // Add final separator
                m_Customiser.MenuItems.Add(new ContextMenuItem(string.Empty, 0));

                foreach (string var in vars)
                {
                    ContextMenuItem newItem = new ContextMenuItem("{" + var + "}", 0);
                    newItem.EventHandler = OnVariableSelected;
                    m_Customiser.MenuItems.Add(newItem);
                }
            }

            // Add context menu item for multiline editor
            if (Multiline && m_EnableEditor)
            {
                // Add final separator
                m_Customiser.MenuItems.Add(new ContextMenuItem(string.Empty, 0));

                ContextMenuItem newItem = new ContextMenuItem("Editor...", 0);
                newItem.EventHandler = delegate(ContextMenuItem item)
                {
                    using (MultilineEditorDialog dialog = new MultilineEditorDialog())
                    {
                        dialog.Value = this.Text;
                        dialog.SetVariableNames(m_VariableNames);

                        if (dialog.ShowDialog(this) == DialogResult.OK)
                        {
                            this.Text = dialog.Value;
                        }
                    }
                };
                m_Customiser.MenuItems.Add(newItem);
            }
        }
예제 #4
0
 /// <summary>
 /// Inserts the selected variable at the current cursor position.
 /// </summary>
 private void OnVariableSelected(ContextMenuItem menuItem)
 {
     int selStart = SelectionStart;
     Text = Text.Insert(selStart, menuItem.Text);
     SelectionStart = selStart + menuItem.Text.Length;
 }