I do have a way to do this, but I was wondering if there a better, simpler way to do this?
Basically I wish to turn a FixedText into a switch button. To do that I need mouseclick event, then a way to check if the cursor has clicked on the drawing object.
alertStatusSwitch flips between true/false
The magic happens here:
Cursor tfCursor = tfAlertStatus.GetCursor(this.ChartControl, this.ChartPanel, this.ChartPanel.Scales[0], cursorPoint);
Since the indicator creates this TextFixed drawing object, is there a better way to detect clicks on this drawing object?
Thanks in advance.
Here is my code:
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
// OMMITTED //
}
else if (State == State.Configure)
{
alertStatusSwitch = true;
tfAlertStatus = Draw.TextFixed(// OMMITTED //);
tfAlertStatus.YPixelOffset = ChartAlertStatusYPixelOffset;
if (ChartControl != null) {
ChartControl.MouseLeftButtonUp += MouseClicked;
}
}
else if (State == State.Terminated) {
if (ChartControl != null) {
ChartControl.MouseLeftButtonUp -= MouseClicked;
}
}
}
protected void MouseClicked(object sender, MouseButtonEventArgs e)
{
Point cursorPoint = this.ChartControl.MouseDownPoint;
Cursor tfCursor = tfAlertStatus.GetCursor(this.ChartControl, this.ChartPanel, this.ChartPanel.Scales[0], cursorPoint);
if (tfCursor != null) {
if (alertStatusSwitch) {
tfAlertStatus = Draw.TextFixed(// OMMITTED //);
tfAlertStatus.YPixelOffset = ChartAlertStatusYPixelOffset;
alertStatusSwitch = false;
ForceRefresh();
} else {
tfAlertStatus = Draw.TextFixed(// OMMITTED //);
tfAlertStatus.YPixelOffset = ChartAlertStatusYPixelOffset;
alertStatusSwitch = true;
ForceRefresh();
}
}
}

Comment