Prod.: Engine, ver.: 6017, ID: 60001139, Wish : A method to get the AcceptedStringValues for the active action

Wish : A method to get the AcceptedStringValues for the active action

Article60001139
TypeWish
ProductEngine
Version6017
Date Added5/3/2010
FixedYes [5/3/2010]
Submitted byYannis Makarounis
Keywords

Subject

A method to get the AcceptedStringValues for the active action

Summary

A method to get the AcceptedStringValues for the active action

Solution


In 6018 a new method GetAcceptedStringValues was added in BaseAction objects.

comments: Returns a clone of the Accepted strings array.

remarks: String values are translated by the vdres.txt resources file.

You can use this property to get the active action acceptedstring values and display them into a popup menu.

When the user select an item from the popup , using the SendCommandString method with selected string value,the active action will parse that value.


Example in C#


private void Form1_Load(object sender, EventArgs e)
{
        vdFramedControl.BaseControl.vdMouseDown += new VectorDraw.Professional.Control.MouseDownEventHandler(BaseControl_vdMouseDown);
}


        void BaseControl_vdMouseDown(MouseEventArgs e, ref bool cancel)
        {
            //If the user press the Right mouse button with Shift key pressed


            if (e.Button == MouseButtons.Right && (System.Windows.Forms.Control.ModifierKeys & Keys.Shift) != 0 && doc.ActiveLayOut.OverAllActiveActions != null  )
            {
                //If a user action is active
                if (doc.ActiveLayOut.OverAllActiveActions.Count > 1)
                {


                    BaseAction action = doc.ActiveLayOut.ActiveAction;
                    string [] acceptedvalues = action.GetAcceptedStringValues();
                    //If the action has accepted string values
                    if (acceptedvalues != null)
                    {
                        //cancel the default right mouse button implementation
                        cancel = true;
                        //create and show a popup menu with accepted values
                        ContextMenu popUpMenu = new ContextMenu();
                        foreach (string item in acceptedvalues)
                        {
                            string []values = item.Split(new char[] { ';' });
                            if (values.Length == 0) continue;
                            popUpMenu.MenuItems.Add(values[0], new EventHandler(pop_Clicked));   
                        }
                        popUpMenu.Show(this, e.Location);
                    }


                }
            }
        }


       //when the user press a menu item from popup menu with accepted values send the menu item text to active action for parse.
       void pop_Clicked(object sender,EventArgs args)
        {
            MenuItem mitem = sender as MenuItem;
            if (mitem == null) return;
            doc.SendCommandActionString(mitem.Text);
        }