Draw text and rectangle!

May 3, 2016 at 6:38 PM
Edited May 4, 2016 at 6:57 AM
Hi!

Please for help!
I am working with MapWindow 5 and like to draw text in rectangle in the map or on the specific layer at point p.
How to fire this action from MW5.Views.MainView.cs? How to define graphics object in this MainView.cs?

Here is what I have found:
        var font = new Font("Arial", 8);
        var gr = _contex.Map.CreateGraphics();        <<<<<< ?????
    var pen = new Pen(Color.Blue);

        var p = new Point();
        p.X = 518000;
        p.Y = 125500;

        var rect = new Rectangle(
        p.X - 16,
        p.Y - 14,
        36,
        28);

    string text = "This is my text!";     

        var brush = new SolidBrush(Color.Red);
        gr.FillRectangle(brush, rect);
        gr.DrawRectangle(pen, rect);
    gr.DrawText(text, rect, font);
Coordinator
May 12, 2016 at 9:30 AM
I'm not sure if that is the easiest workflow.
Why don't you use labels, they are intended for this purpose.
You can create a point shapefile to position your labels very specific.
Marked as answer by pmeems on 9/27/2016 at 6:30 AM