Prod.: Engine, ver.: 6, ID: 60001413, HowTo : How can I set the text's Height before cmdText starts

HowTo : How can I set the text's Height before cmdText starts

Article60001413
TypeHowTo
ProductEngine
Version6
Date Added6/9/2011
Submitted byGizem Basturk
Keywords

Subject

How can I set the text's Height before cmdText starts

Summary

Is there a global/default text height of document ? I want this because when I want to enter height value from user, it does not effect current vdtext while the user is creating this vdtext. The height effects when the user finishes the command as you suggest in previous mail. But I want that the user can see new height while she/he is writing the text.

Solution

You can set the height of the text before the cmdText starts. See the code below and the remarks :

        private void button3_Click(object sender, EventArgs e)
        {
            vdDocument doc = vdFramedControl1.BaseControl.ActiveDocument;
            doc.New();
            cmdTextWithHeight(doc, null, null, null, 5.0);
            cmdTextWithHeight(doc, "VDF version6", new gPoint(30,30), null, 15.0);
            cmdTextWithHeight(doc, null, new gPoint(10,10), 0.0d, 25.0);
            cmdTextWithHeight(doc, "hi", null, 30.0, 35.0);
        }

        private bool cmdTextWithHeight(vdDocument document, object TextString, object InsertionPoint, object RotationAngle, double TextHeight)
        {
            bool ret = false;
            double oldheight = document.ActiveTextStyle.Height; // store the old value to set this back after this finishes
            document.ActiveTextStyle.Height = TextHeight;// set the Height that is needed to activetextstyle
            if (document.CommandAction.CmdText(TextString, InsertionPoint, RotationAngle))
            {
                vdText txt = document.ActiveLayOut.Entities[document.ActiveLayOut.Entities.Count - 1] as vdText; // get the text that was just created
                if (txt != null)
                {
                    //... do other things there with the just-created-vdText if you like !!
                    txt.Height = TextHeight; // see it to the Height so evene if activeTextStyle changes this remains.
                    ret = true;
                }

            }
            document.ActiveTextStyle.Height = oldheight; // set the original value back.
            return ret;
        }