From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I get the actual position (pixel) of the Waveform graph caption?

MStudio 7.1 .NET
XP SP2
MS VS .NET 2003
 
Thanks, ScottyO
0 Kudos
Message 1 of 7
(3,910 Views)

There are no properties/methods available to give you this information at any arbirtrary time. However, depending on what you're trying to do, you may find the BeforeDrawCaption and AfterDrawCaption events useful. You can use these events to implement custom drawing within the bounds of the caption. The arguments of these events have a Bounds property, which provides the coordinates and dimensions of the caption in pixels.

Just out of curiosity, what are you trying to do and how would this information help with doing it?

- Elton

0 Kudos
Message 2 of 7
(3,904 Views)
What I want to do is place a vertical scrollbar directly over the top of the caption (caption placement is Left) when the user wants to review past data on disk.  The scrollbar scrolls through the file.
 
It was never a problem because when I placed the scrollbar in the form designer it always appeared over the caption.  But now I offer the user to change the appearance of the graph; ThickFrame3D, ThinFrame3D, Sunken, etc.  The caption moves to a different place depending on the appearance selected and the scrollbar is not always directly over it.  So therefore, I need to know the location of the caption so that when the user decides to scroll through data, I can place the scrollbar precisely.
 
ScottyO

Message Edited by Sof on 10-26-2005 05:17 PM

Message Edited by Sof on 10-26-2005 05:18 PM

0 Kudos
Message 3 of 7
(3,907 Views)

Are you using the caption to reserve space within the bounds of the graph so that you can fit the scrollbar within the bounds of the graph? If so, here's another approach:

  1. Add a Y axis to the graph. See the Position property to Right.
  2. Set MajorDivisions.LabelVisible and MajorDivisions.TickVisible to false to hide the labels and ticks in the axis.
  3. Set MinimumWidth to however much space you want for the scrollbar (i.e., 25). Now you have space reserved within the bounds of the graph for the scrollbar.
  4. Write code to dynamically size and position the scrollbar in relation to the plot area. The graphs provide a PlotAreaBounds property that will give you the bounds of the plot area. Make the scrollbar the same height as the plot area, and position the scrollbar to the right of the plot area within the space that you reserved.
  5. Add event handlers for BorderChanged, SizeChanged, and whatever else may affect this. Call the code above from within the event handlers.

Does this achieve the same end result as what you were doing before? If not, what is different?

- Elton

0 Kudos
Message 4 of 7
(3,897 Views)

Well, no.  The caption actually serves a fundamental use.  It displays the "Sensor name" that is being graphed from real-time continuous data.  When the user presses a toolbar button to look at history, I place the scrollbar over the caption.  The only reason I placed it there was it was clean and convienient.

I like your idea, however, if I fully understand you, I don't think it will work for my app.  I have to place the scroll bar on the left side somewhere.   I could do as you suggest with another yaxis but it's location would not be immediately obvious because of the already existing YAxis located next to the PlotArea.

Maybe your first suggestion will work when the caption is drawn.

ScottyO 

0 Kudos
Message 5 of 7
(3,895 Views)
That worked perfectly.  Here's the code!
 

private void OnAfterDrawCaption(object sender, NationalInstruments.UI.AfterDrawCaptionEventArgs e)

{

if( _FileView )

this.HistorySlider.Bounds = e.Bounds;

}

 

Very nice, very simple.  Thanks Elton for the assistance.

 

ScottyO

0 Kudos
Message 6 of 7
(3,892 Views)

This only seems to work when the dock property of the graph is set to fill.  Hum??

I have multiple graphs on the same form, so I would like to use a different layout.

 

0 Kudos
Message 7 of 7
(3,733 Views)