private decimal Add_to(string Name, string Btext, string Rtext, decimal x, decimal y, decimal w, decimal h, decimal pts = 8)
    {
        UltraMapper.Mapper mapper = new UltraMapper.Mapper();
        TextSpan           S      = null;

        Dymodkl.TextObject Newto = mapper.Map(Dlab.GetRto());

        Newto.Name = Name;

        Newto.ObjectLayout.DPOINT.X = x.ToString();
        Newto.ObjectLayout.DPOINT.Y = y.ToString();

        Newto.ObjectLayout.Size.Width  = w.ToString();
        Newto.ObjectLayout.Size.Height = h.ToString();

        if (Newto.FMTTEXT.LTSS.Count > 0)
        {
            Newto.FMTTEXT.LTSS.Clear();
        }

        Newto.FMTTEXT.LTSS.Add(new LineTextSpan());

        if (!string.IsNullOrEmpty(Btext))
        {
            S = new TextSpan
            {
                FONT = mapper.Map(Dlab.GetRfont())
            };
            S.FONT.FontSize = pts.ToString();
            S.FONT.IsBold   = "true";
            S.Text          = Btext;
            Newto.FMTTEXT.LTSS[0].TSPANS.Add(S);
        }

        if (!string.IsNullOrEmpty(Rtext))
        {
            S = new TextSpan
            {
                FONT = mapper.Map(Dlab.GetRfont())
            };
            S.FONT.FontSize = pts.ToString();
            S.FONT.IsBold   = "false";
            S.Text          = Rtext;
            Newto.FMTTEXT.LTSS[0].TSPANS.Add(S);
        }

        Lt.Add(Newto);
        return(y + h);
    }
    private decimal Setlo(string Name, string Val = "", int Ltnum = 0, int Tnum = 0)
    {
        Dymodkl.TextObject T0 = Get_to(Name);

        if (T0 != null)
        {
            T0.FMTTEXT.LTSS[Ltnum].TSPANS[Tnum].Text = Val;

            decimal x = Convert.ToDecimal(T0.ObjectLayout.DPOINT.Y) + Convert.ToDecimal(T0.ObjectLayout.Size.Height);

            return(x);
        }

        return(0);
    }
    private DesktopLabel Openlabel(string LabelName)
    {
        IDymoLabel D1 = DymoLabel.Instance;

        Dymodkl.TextObject T = null;
        D1.LoadLabelFromFilePath(LabelName);
        DesktopLabel D2 = Dlab.FromXml(D1.XMLContent);

        Lt = D2.DYMOLabel.DLM.LOS.LTOS;
        List <string> Ln = (List <string>)(from DymoSDK.Interfaces.ILabelObject d in D1.GetLabelObjects() select d.Name as string).ToList();

        if (Ln.Contains("dob"))
        {
            Setlo("dob", "DOB: " + DOB);
        }

        if (Ln.Contains("printed"))
        {
            Setlo("printed", DateTime.Now.ToString("MM/dd/yyyy"), 0, 1);
        }

        if (Ln.Contains("Date_Printed"))
        {
            Setlo("Date_Printed", "Printed: " + DateTime.Now.ToString("MM/dd/yyyy"), 0, 0);
        }

        Dcy = Setlo("name", Patient);

        if (Ln.Contains("firstline"))
        {
            T    = Get_to("firstline");
            Ltop = Convert.ToDecimal(T.ObjectLayout.DPOINT.Y);
            Dcy  = Ltop;
            Lt.Remove(T);
        }

        if (Ln.Contains("lastline"))
        {
            T       = Get_to("lastline");
            Lbottom = Convert.ToDecimal(T.ObjectLayout.DPOINT.Y);
            Lt.Remove(T);
        }

        return(D2);
    }