コード例 #1
0
        /// <summary>
        /// Fills context prompt menu.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editControl1_ContextPromptOpen(object sender, Syncfusion.Windows.Forms.Edit.ContextPromptUpdateEventArgs e)
        {
            // First of all we should get lexem(if it is one),
            // which opens current region that supports context prompt dropping.
            ILexem lex = GetCurrentContextPromptDropper();

            if (lex == null)
            {
                // If there is no such lexem, than we should not show context prompt.
                e.CloseForm = true;
                return;
            }

            IConfigLexem conf = lex.Config.ParentConfig;

            // If there is no prompts assigned to the found complex lexem, than we should exit.
            if (!m_MethodPrompts.Contains(conf.ID))
            {
                return;
            }

            DictionaryEntry[] prompts = ( DictionaryEntry[] )m_MethodPrompts[conf.ID];
            e.List.Clear();
            // add prompts
            foreach (DictionaryEntry entry in prompts)
            {
                // Creates new context prompt item and adds it to the list of the prompts.
                ContextPromptItem itemNew = e.List.Add((string)entry.Key, (string)entry.Value);
                // Parses subject of the item, splits it to the set of method parameters
                // and adds every parameter as boldable item to the context prompt item.
                ParseContectPromptSubject(itemNew);
            }
        }
コード例 #2
0
        /// <summary>
        /// Fills context prompt menu.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editControl1_ContextPromptUpdate(object sender, Syncfusion.Windows.Forms.Edit.ContextPromptUpdateEventArgs e)
        {
            if (e.List.SelectedItem == null)
            {
                return;
            }

            ConfigStack stack;

            // Gets information about region, that supports context prompt dropping, we are currently in.
            IStackData dropper = GetCurrentDropperLexemConfigPair(out stack);

            if (dropper != null)
            {
                // If we have found start start of the region which is context prompt dropper,
                // than we should get list of lexems inside that region that are before current cursor position.
                IList list = editControl1.GetLexemsInsideCurrentStack(false);

                if (list == null)
                {
                    // If something is wrong than close context prompt.
                    e.CloseForm = true;
                    return;
                }

                int iIndex = 0;

                // Count all commas that are before that cursor position.
                // Doing that we can find index of the subject part we should make bolded.
                foreach (ILexem lexem in list)
                {
                    if (lexem.Text == ",")
                    {
                        iIndex++;
                    }
                }

                // If we have found index of the bolded item in currently selected context prompt,
                // than select it.
                if (iIndex >= e.List.SelectedItem.BoldedItems.Count || iIndex < 0)
                {
                    e.List.SelectedItem.BoldedItems.SelectedItem = null;
                }
                else
                {
                    e.List.SelectedItem.BoldedItems.SelectedItem = e.List.SelectedItem.BoldedItems[iIndex];
                }
            }
            else
            {
                // If we have moved out of the region that supports context prompt dropping, than close context prompt.
                e.CloseForm = true;
            }
        }