I am working to derive an ASCOM driver for an DIY astronomical dome from an example of a focuser.
Here the original for a focuser device:
ASCOM.EQFocuser.Focuser focuser;
public MainWindow(Focuser focuser)
{
this.focuser = focuser;
this.focuser.FocuserValueChanged += FocuserValueChanged;
this.focuser.FocuserStateChanged += FocuserStateChanged;
this.focuser.FocuserHumidityChanged += FocuserHumidityChanged;
this.focuser.FocuserTemperatureChanged += FocuserTemperatureChanged;
this.focuser.FocuserMotorChanged += FocuserMotorChanged;
InitializeComponent();
InitControls();
this.FormBorderStyle = FormBorderStyle.FixedSingle;
}
delegate void SetCurrentPositionCallBack(int position);
delegate void SetCurrentStateCallBack(bool isMoving);
delegate void SetCurrentTemperatureCallBack(string temperature);
delegate void SetCurrentHumidityCallBack(string humidity);
delegate void SetCurrentMotorCallBack(int motorNumber);
private void SetCurrentTemperature(string temperature)
{
txtBoxTemperature.InvokeIfRequired(txtBoxTemperature => { txtBoxTemperature.Text = temperature; });
}
private void SetCurrentHumidity(string humidity)
{
txtBoxHumidity.InvokeIfRequired(txtBoxHumidity => { txtBoxHumidity.Text = humidity; });
}
private void SetCurrentPosition(int position)
{
textBoxCurrentPosition.InvokeIfRequired(textBoxCurrentPosition => { textBoxCurrentPosition.Text = position.ToString(); });
}
private void FocuserValueChanged(object sender, FocuserValueChangedEventArgs e)
{
//this.textBoxCurrentPosition.Text = e.NewValue.ToString();
SetCurrentPosition(e.NewValue);
}
Now my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
namespace ASCOM.SensDome
{
public partial class MainWindow : Form
{
ASCOM.SensDome.Dome dome;
public MainWindow(Dome dome)
{
this.dome = dome;
this.dome.DomeStateChanged += DomeStateChanged;
this.dome.DomeValueChanged += DomeValueChanged;
// Eventhandler einbauen !!!!!!!
InitializeComponent();
InitControls();
this.FormBorderStyle = FormBorderStyle.FixedSingle;
}
delegate void SetCurrentPositionCallBack(int position);
delegate void SetCurrentStateCallBack(bool isMoving);
private void DomeValueChanged(object sender, DomeValueChangedEventArgs e)
{
SetCurrentPosition(e.NewValue);
}
private void SetCurrentPosition(int position)
{
textBoxCurrentPosition.I
}
Screenshot showing that the method is not offered
In the original the InvokeIfRequired is available for the textbox object. In my project I do not get it offered. The settings, the EventArgs are of identical structure.
What am i doing wrong?
I kindly ask for advice. Christian
reprogramming of eventhanlers and eventargs. Comparing to the original on differences in the code and the used forms and the project properties. No differences found. Checking on stackoverflow for similar problems and solutions.