Page 1 of 1

Update RectangleTool to support edit annotation.

Posted: Wed Oct 07, 2009 2:10 pm
by 13048148
Good morning,

I am using the RectangleTool to put annotations on charts. I set the AllowEdit property to true so users can edit the text in the annotation. I would like to save the updated RectangleTool text. Can you add events that are fired when the rectangletool goes into edit mode and when it exits edit mode.

Without that, it is difficult for me to know when the user has finished editing the text.

I noticed that the rectangletool goes into drag mode whenever the user presses the escape key to exit editing. This doesn't follow normal user interface patterns. Could you remove that behavior or make it configurable? I think dragging should be independant of editing.

Finally, it seems the only way to exit edit mode is by pressing escape. Normally, escape would cancel edit mode and revert to the original text. Also, normally, clicking anywhere outside the rectangletool would exit edit mode. Can you make clicking outside the rectangletool end edit mode and pressing escape cancel edit mode? I tried implementing this myself using rectangletool.EndEdit, but can't implement this 100% correctly without being able to detect if a rectangletool is in edit mode or not.

Best regards
Len

Re: Update RectangleTool to support edit annotation.

Posted: Thu Oct 08, 2009 10:18 am
by 10050769
Hello LT411,

I think that found a solution that solve your problem to detect if a rectangletool is in edit mode or not and save text of rectangletool to document .txt:

Please see next code and check that works as you want:

Code: Select all

 Steema.TeeChart.Styles.Bar bar;
        Steema.TeeChart.Tools.RectangleTool rectangletool1;
        System.IO.StreamWriter Tex;
        bool temp;
        bool finishedit;
        private void InitializeChart()
        {
            bar = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
            bar.FillSampleValues();
            rectangletool1 = new Steema.TeeChart.Tools.RectangleTool(tChart1.Chart);
            rectangletool1.AllowDrag = false;// Option solve problem drag.
            tChart1.MouseClick += new MouseEventHandler(tChart1_MouseClick);
            rectangletool1.KeyDown += new KeyEventHandler(rectangletool1_KeyDown);
        }
        void rectangletool1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Escape)
            {
                rectangletool1.EndEdit();
                rectangletool1.AllowEdit = false;
                temp = true;
            }
            SaveText();
        }
        void tChart1_MouseClick(object sender, MouseEventArgs e)
        {
            if (!rectangletool1.Bounds.Contains(e.X, e.Y))
            {
                rectangletool1.EndEdit();
                rectangletool1.AllowEdit = false;
                finishedit = true;
            }
            else
            {
                rectangletool1.StartEdit();
                rectangletool1.AllowEdit = true;
            }

            SaveText();
        }

        private void SaveText()
        {
            if (finishedit || temp)
                {
                    //previously you could make a file!
                    Tex = System.IO.File.CreateText("C:/test.txt");
                    Tex.WriteLine(rectangletool1.Text);
                    Tex.Write(Tex.NewLine);
                    Tex.Close();
                }
            }   
I hope will help.

Thanks,