public MainViewModel() { #if DEBUG if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { #endif cfg = new Config("EFBConnect.xml", new List <Type> { typeof(ConnectionType) }); _connection = cfg.Get <ConnectionType>("ConnectionType", ConnectionType.Broadcast, true); _deviceIp = cfg.Get <string>("IPAddress", null, true); if (!string.IsNullOrEmpty(_deviceIp)) { SetIP(_deviceIp); } ConnectionStatus = "Disconnected from flight simulator."; efbConnect = new EFBConnectClient(); efbConnect.PropertyChanged += Simulator_PropertyChanged; efbConnect.Initialize(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(10); timer.Tick += timer_Tick; timer.Start(); #if DEBUG } #endif }
public MainViewModel() { #if DEBUG if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { #endif cfg = new Config("EFBConnect.xml", new List <Type> { typeof(ConnectionType) }); _connection = cfg.Get <ConnectionType>("ConnectionType", ConnectionType.Broadcast, true); _deviceIp = cfg.Get <string>("IPAddress", null, true); switch (_connection) { case ConnectionType.IPAddress: SetIP(string.IsNullOrWhiteSpace(_deviceIp) ? null : _deviceIp); break; case ConnectionType.Broadcast: SetIP(null); break; default: var message = $"Unknown ConnectionType '{Enum.GetName( typeof( ConnectionType ), _connection )}'"; Log.Instance.Error(message); throw new InvalidOperationException(message); } ConnectionStatus = "Disconnected from flight simulator."; efbConnect = new EFBConnectClient(); efbConnect.PropertyChanged += Simulator_PropertyChanged; efbConnect.Initialize(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(10); timer.Tick += timer_Tick; timer.Start(); #if DEBUG } #endif }
void timer_Tick(object sender, EventArgs e) { efbConnect.Initialize(); }