Font issue in Rectangle tool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Font issue in Rectangle tool

Post by amol » Sat Nov 15, 2014 9:20 am

Hi Steema Support,

I am using rectangle tool in my application for showing data and using font "Consolas".With this font data plotted(shown) with proper alignment . But when we use font type "Times New Roman" it changes the alignment of the data and it is shown unmanaged in Rectangle tool.
Is there any way to set the proper alignment using "Times New Roman" font. Please find the attched application to see the changes in alignment.
Please provide any solution for the same asap.
Thanks in advance

Thanks & Regards
PlanoResearch
RectangleToolDemo.rar
Rectangle tool demo
(34.11 KiB) Downloaded 594 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Font issue in Rectangle tool

Post by Christopher » Mon Nov 17, 2014 11:38 am

Hello,

As this video shows, the behaviour in this case is expected.

Do you get the same results as in the video above? Which version are you using?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: Font issue in Rectangle tool

Post by amol » Wed Nov 19, 2014 10:52 am

Hi Steema Support,

Thanks for your reply.
Yes, we got the same result as shown in the vedio.I am using Teechart version 4.1.2011.4191.
Please suggest any solution.

Thanks&Regards
PlanoResearch

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Font issue in Rectangle tool

Post by Christopher » Wed Nov 19, 2014 10:56 am

amol wrote: Yes, we got the same result as shown in the vedio.I am using Teechart version 4.1.2011.4191.
Please suggest any solution.
As I said, this is expected behaviour - I do not see what the problem is, therefore, I cannot suggest a solution.

Can you please tell me the behaviour you would like to see that is different to the default behaviour?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Re: Font issue in Rectangle tool

Post by amol » Wed Nov 19, 2014 11:36 am

Hi Christoper,

As shown in video that is previously given by you. In this video it is clearly shown when we press button "Change Font to Times New Roman" then data inside the rectangle tool shows unmanaged this is the issue that we do not want. And when we press button"Change Font to Consolas" then rectangle tool data shows managed or with proper alignment. It look good.
So we want to manage the rectangle tool data alignment with "Times New Roman" also.
Hoping it will help you to clarify the issue.
Please provide any solution for the same.

Thanks&Regards
PlanoResearch

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Font issue in Rectangle tool

Post by Christopher » Wed Nov 19, 2014 2:26 pm

amol wrote: Hoping it will help you to clarify the issue.
Please provide any solution for the same.
Try using a standard System.Windows.Forms.TextBox to compare behaviour, e.g.

Code: Select all

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        Points point;
        public RectangleTool rect;

        TextBox textBox;
        public Form1()
        {
            InitializeComponent();
            point = new Points(tChart1.Chart);
            point.FillSampleValues(30);
            tChart1.Aspect.View3D = false;
            rect = new RectangleTool(tChart1.Chart);
            rect.Top = 100;
            rect.Left = 200;
            rect.Active = true;
            rect.Shape.Font.Name = "Consolas";
            rect.AutoSize = true;
            List<string> lstResultName = new List<string>();
            lstResultName.Add("First Element");
            lstResultName.Add("Second Element");
            lstResultName.Add("Third Element");
            lstResultName.Add("Fourth Element");
            List<string> lstResultUnit = new List<string>();
            lstResultUnit.Add("aaa");
            lstResultUnit.Add("bbbbrer");
            lstResultUnit.Add("cc");
            lstResultUnit.Add("dddd");
            List<string> lstResultValue = new List<string>();
            lstResultValue.Add("29111");
            lstResultValue.Add("2221");
            lstResultValue.Add("12123233");
            lstResultValue.Add("3333434");
            SetResults(lstResultName,lstResultUnit,lstResultValue);

            textBox = new TextBox();
            textBox.Multiline = true;
            textBox.Width = 300;
            textBox.Height = 100;

            tChart1.Controls.Add(textBox);
            textBox.Text = rect.Text;

        }
        public void SetResults(List<string> lstResultName, List<string> lstResultUnit, List<string> lstResultValue)
        {
           string strResults = string.Empty;

            int max = 0;
            int index1 = 0;
            int total = 0;
            for (int i = 0; i < lstResultName.Count; i++)
            {
                if (lstResultUnit[i] != string.Empty)
                {
                    if (max < lstResultName[i].Length + lstResultUnit[i].Length)
                    {
                        max = lstResultName[i].Length + lstResultUnit[i].Length;
                    }
                }
            }

            for (int i = 0; i < lstResultName.Count; i++)
            {
                if (lstResultUnit[i] != string.Empty)
                {
                    total = lstResultName[i].Length + lstResultUnit[i].Length;
                    if (max == total)
                    {
                        string str = lstResultName[i];
                        str = str + "   ";
                        lstResultName[i] = str;
                    }
                    else
                    {
                        string str = lstResultName[i];

                        for (int j = 0; j < max - (total); j++)
                        {
                            str = str + " ";
                        }
                        str = str + "   ";
                        lstResultName[i] = str;
                    }
                }
            }



            for (int i = 0; i < lstResultUnit.Count; i++)
            {
                if (lstResultUnit[i] != string.Empty)
                {
                    string str = lstResultUnit[i];
                    str = "[" + str + "] " + "=" + " ";
                    lstResultUnit[i] = str;
                }
            }

            for (int i = 0; i < lstResultName.Count; i++)
            {
                if (lstResultUnit[i] != string.Empty)
                {
                    strResults = strResults + lstResultName[i] + lstResultUnit[i] + lstResultValue[i] + "\r\n";
                    index1++;
                }
                else
                {
                    strResults = strResults + lstResultName[i] + lstResultUnit[i] + lstResultValue[i] + "\r\n";
                }
            }
           
            if (index1 == 0)
            {
                rect.Active = false;
            }
            rect.Text = strResults;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            rect.Shape.Font.Name = "Times New Roman";
            textBox.Font = new Font(rect.Shape.Font.Name, 8);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            rect.Shape.Font.Name = "Consolas";
            textBox.Font = new Font(rect.Shape.Font.Name, 8);
        }
    }
}
Here, exactly the same thing happens ... the spacing is different when the font changes. Therefore I don't see this as a specific TeeChart issue, but as a generic issue related to the behaviour of different fonts and spaces in the .NET framework.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply