Exemplo n.º 1
0
 protected override void OnDocumentDefaults()
 {
     base.OnDocumentDefaults();
     mTextStyle = Document.ActiveTextStyle;
     if (mTextStyle == null)
     {
         mTextStyle = Document.TextStyles.Standard;
     }
 }
Exemplo n.º 2
0
        public static void CreateTextStyle(vdDocument activeDocument, string txtStyleName, double txtSize, double widthFactor, string fontFile, string bigFontFile)
        {
            vdTextstyle txt = new vdTextstyle();

            txt.Name        = txtStyleName;
            txt.FontFile    = fontFile;
            txt.BigFontFile = bigFontFile;
            txt.Height      = txtSize;
            txt.WidthFactor = widthFactor;
            activeDocument.TextStyles.AddItem(txt);
        }
Exemplo n.º 3
0
        public override bool DeSerialize(DeSerializer deserializer, string fieldname, object value)
        {
            if (base.DeSerialize(deserializer, fieldname, value))
            {
                return(true);
            }
            else if (fieldname == "NumSides")
            {
                mNumSides = (int)value;
            }
            else if (fieldname == "Radius")
            {
                mRadius = (double)value;
            }
            else if (fieldname == "TextString")
            {
                mText = (string)value;
            }
            else if (fieldname == "TextStyle")
            {
                mTextStyle = (vdTextstyle)value;
            }
            else if (fieldname == "TextHeight")
            {
                mTextHeight = (double)value;
            }
            else if (fieldname == "PipeHeight")
            {
                dPipeHeight = (double)value;
            }
            else if (fieldname == "StartCircle")
            {
                cirStart = value as vdCircle;
            }
            else if (fieldname == "EndCircle")
            {
                cirEnd = value as vdCircle;
            }
            else if (fieldname == "StartPoint")
            {
                gpStartPoint = value as gPoint;
            }
            else if (fieldname == "EndPoint")
            {
                gpEndPoint = value as gPoint;
            }

            else
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        public static ulong AddMText(vdDocument activeDocument, double txtSize, string txtStyle, string textContent, gPoint insertPoint, VdConstVerJust verJust, VdConstHorJust horJust, string fontFile)
        {
            //We will create a vdMText object and add it to the Active Layout which is the basic Model Layout always existing in a Document.
            VectorDraw.Professional.vdFigures.vdMText onemtext = new VectorDraw.Professional.vdFigures.vdMText();
            //We set the document where the Mtext is going to be added.This is important for the vdMText in order to obtain initial properties with setDocumentDefaults.
            onemtext.SetUnRegisterDocument(activeDocument);
            onemtext.setDocumentDefaults();

            //The two previus steps are important if a vdFigure object is going to be added to a document.
            //Now we will change some properties of the text.
            onemtext.InsertionPoint = insertPoint;
            onemtext.HorJustify     = horJust;

            vdTextstyle txtStyleObj = GetTextStyleByName(activeDocument, txtStyle);

            if (!string.IsNullOrEmpty(fontFile))
            {
                txtStyleObj.FontFile = fontFile;
            }
            if (txtSize > 0.00001)
            {
                txtStyleObj.Height = txtSize;
            }
            onemtext.Style = txtStyleObj;
            //   onemtext.PenColor.SystemColor = Color.FromArgb(TextColor);
            onemtext.HorJustify = horJust;
            onemtext.VerJustify = verJust;
            onemtext.TextString = textContent;



            /*
             \0...\o             Turns overline on and off
             * \L...\l               Turns underline on and off
             \\                      Inserts a backslash
             \{...\}                Inserts an opening and closing brace
             \\\Cindex;        Changes to the  specified color
             \\\Hvalue;       Changes to the text height specified in drawing units
             \\\Hvaluex;     Changes the text height  to a multiple of the current text height
             \\\Tvalue;       Adjusts the space between characters, from .75 to 4 times
             \\\Qangle;      Changes obliquing angle
             \\\Wvalue;     Changes width factor to produce wide text
             \\\Ffile name; Changes to the specified font file
             \\\A                   Sets the alignment value; valid values: 0, 1, 2
             \\\P                   Ends paragraph
             \\\S...^...;         Stacks the subsequent text at the \, #, or ^ symbol
             */

            //Now we will add this object to the Entities collection of the Model Layout(ActiveLayout).
            activeDocument.ActiveLayOut.Entities.AddItem(onemtext);
            return(onemtext.Handle.Value);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 处理车位编号
        /// </summary>
        /// <returns></returns>
        void ProCarNum(vdDocument doc, string PropName, double width, double height)
        {
            foreach (vdFigure vdf in doc.ActiveLayOut.Entities)
            {
                if (vdf is vdInsert)
                {
                    vdInsert vdi = vdf as vdInsert;

                    vdXProperty vdx = vdi.XProperties.FindName(PropName);
                    if (vdx != null)
                    {
                        //删除原来的文字
                        vdBlock vdb = vdi.Block;
                        for (int i = vdb.Entities.Count - 1; i >= 0; i--)
                        {
                            if (vdb.Entities[i] is vdText)
                            {
                                vdb.Entities.RemoveAt(i);
                            }
                        }
                        //文字样式
                        vdTextstyle vdts = doc.TextStyles.FindName("车位编号");
                        if (vdts == null)
                        {
                            vdts        = new vdTextstyle(doc);
                            vdts.Height = height / 5.0;
                        }
                        //字体
                        vdText vdt = new vdText(doc);
                        vdt.Style      = vdts;
                        vdt.TextString = vdx.PropValue.ToString();
                        vdt.HorJustify = VectorDraw.Professional.Constants.VdConstHorJust.VdTextHorCenter;
                        vdt.VerJustify = VectorDraw.Professional.Constants.VdConstVerJust.VdTextVerCen;


                        Box bb = vdb.BoundingBox();
                        vdt.InsertionPoint = new gPoint(bb.MidPoint.x, bb.Min.y + height / 2.0, bb.Min.z);
                        vdb.Entities.Add(vdt);
                    }
                }
            }
        }
Exemplo n.º 6
0
        public override void InitializeProperties()
        {
            gpStartPoint = new gPoint();
            gpEndPoint   = new gPoint();
            dPipeHeight  = 0.0;
            cirStart     = new vdCircle();
            cirEnd       = new vdCircle();


            mNumSides   = 4;
            mText       = "";
            mTextHeight = 1.0d;
            mTextStyle  = null;
            if (Document != null)
            {
                mTextStyle = Document.TextStyles.Standard;
            }
            mRadius = 1.0d;
            base.InitializeProperties();
        }
Exemplo n.º 7
0
        public static vdTextstyle GetTextStyleByName(vdDocument activeDocument, string txtStyleName)
        {
            vdTextstyle defaulttxt = new vdTextstyle();

            defaulttxt.FontFile = "Times New Roman";

            if (string.IsNullOrEmpty(txtStyleName))
            {
                return(defaulttxt);
            }
            else
            {
                vdTextstyle txt = activeDocument.TextStyles.FindName(txtStyleName);
                if (null != txt)
                {
                    return(txt);
                }
                else
                {
                    return(defaulttxt);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 替换字体
        /// </summary>
        /// <param name="vdbs"></param>
        private void ReplaceText(vdBlocks vdbs, vdDocument doc, double width, double height, string PropName)
        {
            //doc.Purge();
            Dictionary <string, string> BlksMap    = new Dictionary <string, string>();
            Dictionary <string, string> BlksMapTmp = new Dictionary <string, string>();

            //删除车位编号
            foreach (vdFigure vdf in doc.ActiveLayOut.Entities)
            {
                if (vdf is vdInsert)
                {
                    vdInsert    vdi = vdf as vdInsert;
                    vdXProperty vdx = vdi.XProperties.FindName(PropName);
                    if (vdx != null)
                    {
                        string  strName = vdx.PropValue.ToString();
                        vdBlock vdb     = vdi.Block;
                        Box     box     = vdb.BoundingBox();

                        Box textbox            = new Box(new gPoint(box.MidPoint.x - width / 2.0, box.Min.y), new gPoint(box.MidPoint.x + width / 2.0, box.Min.y + height));
                        vdArray <vdFigure> vda = new vdArray <vdFigure>();
                        foreach (vdFigure vdff in vdb.Entities)
                        {
                            if (vdff is vdPolyface)
                            {
                                if (vdff.BoundingBox.BoxInBox(textbox))
                                {
                                    vda.AddItem(vdff);
                                }
                            }
                        }

                        Box b = new Box();
                        foreach (vdFigure vdf1 in vda)
                        {
                            b.AddBox(vdf1.BoundingBox);
                            vdb.Entities.RemoveItem(vdf1);
                        }

                        //文字样式
                        vdTextstyle vdts = doc.TextStyles.FindName("车位编号");
                        if (vdts == null)
                        {
                            vdts        = new vdTextstyle(doc);
                            vdts.Name   = "车位编号";
                            vdts.Height = b.Height;
                            //MessageBox.Show(b.Height.ToString());
                            doc.TextStyles.Add(vdts);
                        }

                        //文字
                        vdText vdt = new vdText(doc);
                        vdt.Style          = vdts;
                        vdt.TextString     = vdx.PropValue.ToString();
                        vdt.HorJustify     = VectorDraw.Professional.Constants.VdConstHorJust.VdTextHorCenter;
                        vdt.VerJustify     = VectorDraw.Professional.Constants.VdConstVerJust.VdTextVerCen;
                        vdt.InsertionPoint = b.MidPoint;
                        vdb.Entities.AddItem(vdt);

                        vdf.Invalidate();
                        vdf.Update();
                        string ssss = GetBlkMd5(vdi.Block);

                        if (!BlksMap.ContainsKey(vdi.Block.Name))
                        {
                            BlksMap.Add(vdi.Block.Name, ssss);
                        }
                        else
                        {
                            MessageBox.Show("可能存在重复编号的车位,请仔细查看!");
                        }
                    }
                }
            }

            //查找md5的计数

            Dictionary <string, int> md5count = new Dictionary <string, int>();

            foreach (KeyValuePair <string, string> kv in BlksMap)
            {
                if (!md5count.ContainsKey(kv.Value))
                {
                    md5count.Add(kv.Value, 1);
                }
                else
                {
                    md5count[kv.Value]++;
                }
            }

            foreach (KeyValuePair <string, string> kv in BlksMap)
            {
                if (md5count[kv.Value] > 1)
                {
                    vdBlock vdb2 = doc.Blocks.FindName(kv.Value);
                    vdBlock vdb  = doc.Blocks.FindName(kv.Key);
                    if (vdb2 == null)  //md5码的块不存在的话
                    {
                        if (vdb != null)
                        {
                            vdBlock vdb1 = vdb.Clone(doc) as vdBlock;
                            for (int i = vdb1.Entities.Count - 1; i >= 0; i--)
                            {
                                if (vdb1.Entities[i] is vdText)
                                {
                                    vdb1.Entities.RemoveItem(vdb1.Entities[i]);
                                }
                            }
                            vdb1.Name = kv.Value;
                            doc.Blocks.Add(vdb1);
                        }
                    }
                    //原来的内容作为一个块,加进去

                    for (int i = vdb.Entities.Count - 1; i >= 0; i--)
                    {
                        if (!(vdb.Entities[i] is vdText))
                        {
                            vdb.Entities.RemoveItem(vdb.Entities[i]);
                        }
                    }

                    //vdb.Entities.RemoveAll();
                    vdInsert vdi = new vdInsert(doc);
                    vdi.Block = doc.Blocks.FindName(kv.Value);  //
                    vdb.Entities.Add(vdi);

                    //将字体加上去

                    vdb.Update();
                }
            }

            //ProCarNum(doc, PropName, width, height);  //处理车位编号
        }