Relative border

Hello!

In the following code snippet, I want the ‘border’ to be always visible; i.e. if I keep moving the quip object to the right, ‘border’ is not visible after a few mouse moves. What I want is, the ‘border’ should always be at a fixed position, relative to the left margin in the visible region. How can I achieve this?

public partial class Form1 : Form
{
private GoView view;
private GoDocument model;

    public Form1()
    {
          InitializeComponent();
          InitGoObjects();
          view.Dock = DockStyle.Fill;
          Controls.Add(view);
    }

    private void InitGoObjects()
    {
          view = new GoView();
          model = view.Document;

          GoComment quip = new GoComment();
          quip.Text = "42";
          quip.Position = new PointF(50, 50);
          model.Add(quip);

          GoRectangle border = new GoRectangle();
          border.Size = new SizeF(20, 100);
          model.Add(border);
    }
}

Thanks,

Pradip

Do you want users to be able to select that “border” object? What do you want to happen when the GoView.DocScale changes, i.e. the user zooms in or out? Do you have multiple GoViews displaying that GoDocument?
Depending on the answers, you might either implement a GoView.PropertyChanged event handler to change the Bounds of the “border”, or you might implement an override of either GoView.OnPaint or GoView.PaintBackgroundDecoration.

No, the user can’t select the border object. When the DocScale changes, we would like the border to still span the entire length of the view. We would also like the border to be displayed with the new DocScale.

What we have in mind is something like a floating-control.

What events should I implement?

Thanks in advance.

Pradip

caulagi, you are trying to implement something I’m also working on it, though mine is slightly different from yours.
It seems for you that GoView.PaintBackgroundDecoration suits your need best.