internal override void EventListenStart() { _callback = (IntPtr sensorHandle, IntPtr eventPtr, uint events_count, IntPtr data) => { updateBatchEvents(eventPtr, events_count); Interop.SensorEventStruct sensorData = latestEvent(); TimeSpan = new TimeSpan((Int64)sensorData.timestamp); X = sensorData.values[0]; Y = sensorData.values[1]; Z = sensorData.values[2]; BiasX = sensorData.values[3]; BiasY = sensorData.values[4]; BiasZ = sensorData.values[5]; DataUpdated?.Invoke(this, new UncalibratedMagnetometerDataUpdatedEventArgs(sensorData.values)); }; int error = Interop.SensorListener.SetEventsCallback(ListenerHandle, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for uncalibrated magnetometer sensor"); throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for uncalibrated magnetometer"); } }
public void Reset() { stack.Clear(); _current = 1; _count = 0; DataUpdated?.Invoke(); }
internal override void EventListenStart() { _callback = (IntPtr sensorHandle, IntPtr eventPtr, uint events_count, IntPtr data) => { updateBatchEvents(eventPtr, events_count); Interop.SensorEventStruct sensorData = latestEvent(); TimeSpan = new TimeSpan((Int64)sensorData.timestamp); StepCount = (uint)sensorData.values[0]; WalkStepCount = (uint)sensorData.values[1]; RunStepCount = (uint)sensorData.values[2]; MovingDistance = sensorData.values[3]; CalorieBurned = sensorData.values[4]; LastSpeed = sensorData.values[5]; LastSteppingFrequency = sensorData.values[6]; LastStepStatus = (PedometerState)sensorData.values[7]; DataUpdated?.Invoke(this, new PedometerDataUpdatedEventArgs(sensorData.values)); }; int error = Interop.SensorListener.SetEventsCallback(ListenerHandle, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for pedometer sensor"); throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for pedometer"); } }
/// <summary> /// Aplica os dados do aplicativo para: Language /// </summary> /// <param name="dataUpdatedNotification">Notificação de atualização de dados.</param> /// <param name="cancellationToken">Token de cancelamento.</param> /// <returns>Task</returns> private async Task ApplyDataApplicationLanguage(DataUpdated dataUpdatedNotification, CancellationToken cancellationToken) { var request = dataUpdatedNotification.Request; var dataApplicationLanguage = request.Data.Application.Language; if (CultureInfo.DefaultThreadCurrentCulture?.TwoLetterISOLanguageName != dataApplicationLanguage) { var fromLanguage = CultureInfo.DefaultThreadCurrentUICulture != null ? CultureInfo.DefaultThreadCurrentUICulture : CultureInfo.InstalledUICulture; var toLanguage = dataApplicationLanguage.ToCultureInfo(); if (fromLanguage.TwoLetterISOLanguageName != toLanguage.TwoLetterISOLanguageName) { CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture = toLanguage; Log.Debug("Changed application language from {fromLanguage} to {toLanguage}.", $"{fromLanguage.TwoLetterISOLanguageName}, {fromLanguage.DisplayName},", $"{toLanguage.TwoLetterISOLanguageName}, {toLanguage.DisplayName}"); await _messageBus.Send( new UserNotificationPost( new NotificationMessage(Resources.Notification_LanguageChanged.QueryString( fromLanguage.TwoLetterISOLanguageName.ToLanguageName().ToLower(), toLanguage.TwoLetterISOLanguageName.ToLanguageName().ToLower() )), request), cancellationToken); } } }
// HACK: This should not be here and solved differently, because it messes up the internal state public virtual void SetDimensionAtIndex(int dataIndex, int dimensionIndex) { _dataDimensionsIndices[dimensionIndex] = dataIndex; var e = new DataPresenterEventArgs(); DataUpdated?.Invoke(this, e); }
/// <summary> /// Aplica os dados do aplicativo para: LockScreen /// </summary> /// <param name="dataUpdatedNotification">Notificação de atualização de dados.</param> /// <param name="cancellationToken">Token de cancelamento.</param> /// <returns>Task</returns> private async Task ApplyDataApplicationLockScreen(DataUpdated dataUpdatedNotification, CancellationToken cancellationToken) { var request = dataUpdatedNotification.Request; var dataApplicationLockScreen = request.Data.Application.LockScreen; if (_lockScreen.IsLocked != dataApplicationLockScreen) { if (dataApplicationLockScreen) { _lockScreen.Lock(); } else { _lockScreen.Unlock(); } Log.Debug("Lock screen activated: {Mode}", dataApplicationLockScreen); await _messageBus.Send( new UserNotificationPost( new NotificationMessage(Resources.Notification_LockScreenDefined.QueryString( dataApplicationLockScreen ? Resources.Name_Term_Active : Resources.Name_Term_Inactive )), request), cancellationToken); } }
internal override void EventListenStart() { _callback = (IntPtr sensorHandle, IntPtr eventPtr, uint events_count, IntPtr data) => { updateBatchEvents(eventPtr, events_count); Interop.SensorEventStruct sensorData = latestEvent(); Timestamp = sensorData.timestamp; if (sensorData.values[0] == 0) { Rotation = AutoRotationState.Degree_0; } else { Rotation = (AutoRotationState)sensorData.values[0]; } Accuracy = sensorData.accuracy; DataUpdated?.Invoke(this, new AutoRotationSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); }; int error = Interop.SensorListener.SetEventsCallback(ListenerHandle, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for auto-rotation sensor"); throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for auto-rotation"); } }
/// <summary> /// Aplica os dados do aplicativo para: Shortcut /// </summary> /// <param name="dataUpdatedNotification">Notificação de atualização de dados.</param> /// <param name="cancellationToken">Token de cancelamento.</param> /// <returns>Task</returns> private async Task ApplyDataApplicationShortcut(DataUpdated dataUpdatedNotification, CancellationToken cancellationToken) { var request = dataUpdatedNotification.Request; var dataApplicationShortcut = request.Data.Application.Shortcut; var shortcut = dataApplicationShortcut.ToShortcutDescription(); try { var registered = _shortcut.Register(dataApplicationShortcut); Log.Debug("Shortcut key \"{Shortcut}\" registered: {Registered}", shortcut, registered); await _messageBus.Send(new UserNotificationPost( new NotificationMessage( (registered ? Resources.Notification_ShortcutDefined : dataApplicationShortcut != Keys.None ? Resources.Notification_ShortcutInvalid : Resources.Notification_ShortcutRemoved).QueryString(shortcut), registered || dataApplicationShortcut == Keys.None), request), cancellationToken); } catch (Exception exception) { Log.Error(exception, "Error registering shortcut key: {Shortcut}", shortcut); await _messageBus.Send(new UserNotificationPost( new NotificationMessage(exception.Message, false), request), cancellationToken); } }
public async void Refresh() { await refreshLock.WaitAsync(); if (!IsValid || DateTime.UtcNow - lastRefresh > TimeSpan.FromMinutes(15)) { try { await GetCurrentConditions(); await GetForecast(); lastRefresh = DateTime.UtcNow; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } } refreshLock.Release(); if (DataUpdated != null) { DataUpdated.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Запустить бесконечный цикл прослушивания /// </summary> /// <returns></returns> private async Task RunListen() { try { while (isRunListen) { string messageReceive = await myPipeClientServer.Listen(); if (messageReceive == COMMAND_STOP) { isRunListen = false; return; } DataUpdated?.Invoke(this, new DataUpdatedEventArgs <string>(new NetworkVariableData <string>(messageReceive))); } } catch (Exception ex) { // ошибка возникает при закрытии слушающего ожидающего подключения, // которая перехватывается здесь Debug.WriteLine("ERROR: {0}", ex.ToString()); WriteCompleted?.Invoke(this, new WriteCompletedEventArgs(ex, false, this)); } }
public void OnNext(AFDataPipeEvent value) { if (value.Action != AFDataPipeAction.Delete) { DataUpdated?.Invoke(this, new EventArgs <AFValue>(value.Value)); } }
public GameDoubler(int finish) { this._finish = finish; _current = 1; _count = 0; DataUpdated?.Invoke(); //minCount=? }
/// <summary> /// Clear the highlight flags for all indices. /// </summary> public void ClearHighlights() { for (int i = 0; i < _highlightedItems.Length; i++) { _highlightedItems[i] = false; } DataUpdated?.Invoke(this, new DataPresenterEventArgs()); }
public void Undo() { if (stack.Count > 0) { _current = stack.Pop(); _count--; } DataUpdated?.Invoke(); }
private void OnDataUpdated(FirebaseEvent <BattleData> evt) { currentBattle = evt.Object; if (currentBattle.LastPlayingPlayerId != ApplicationData.PlayerId) { DataUpdated?.Invoke(evt.Object); } }
private void NotifyIfExpired() { if (DataUpdated.Add(DatabaseExpiry) > DateTime.UtcNow) { return; } DatabaseExpired?.Invoke(this, EventArgs.Empty); }
public void ForceRenew() { if (UpdateInfo()) { DeleteImages(); DecodeData(); DataUpdated?.Invoke(this); } }
// periodically raise gui update event private void updateGui() { if ((DateTime.Now - this.lastGuiUpdate).TotalSeconds >= guiUpdatePeriod) { lastGuiUpdate = DateTime.Now; GuiUpdateEvent?.Invoke(); } DataUpdated?.Invoke(); }
/// <summary> /// Toggles the highlight flag for the specified index. /// </summary> /// <param name="index">The index for which the highlight should be toggled.</param> public virtual void ToogleItemHighlight(int index) { _highlightedItems[index] = !_highlightedItems[index]; HighlightChanged?.Invoke(this, index); if (index >= _selectedMinItem || index < _selectedMaxItem) { DataUpdated?.Invoke(this, new DataPresenterEventArgs()); } }
/// <summary> /// Called whenever the data of the DataProvider has changed. /// </summary> /// <param name="sender">The DataProvider which data has changed.</param> /// <param name="e">The event arguments.</param> protected virtual void Provider_DataUpdated(object sender, EventArgs e) { if (_highlightedItems.Length != _dataProvider.Data.NumOfItems) { _highlightedItems = new bool[_dataProvider.Data.NumOfItems]; } //TODO: Check dataSet dimensions, items count, etc. DataUpdated?.Invoke(this, new DataPresenterEventArgs(_selectedMinItem, _selectedMaxItem)); }
public async Task ResetCardDataAsync() { CachedCards = null; ActiveDataSource = DataSources[0]; CardDataInfoUrl = string.Format(DefaultCardInfoUrl, ActiveDataSource); Settings.ActiveCardDataVersion = null; Settings.HighestNotifiedCardDataVersion = Settings.ActiveCardDataVersion; DataUpdated?.Invoke(this, await GetCachedCardsAsync()); }
public async Task dothis() { EventStreamResponse response = await client.OnAsync("DavesTrain/passengers", (sender, args, context) => { if (DataUpdated != null) { DataUpdated.Invoke(this, EventArgs.Empty); } }); }
public async void Delete(Entry EntryToDelete) { await Task.Run(() => { Entrys.Remove(EntryToDelete); Data.Save(Entrys, Sellers, Assortment); }); DataUpdated?.Invoke(null, null); }
protected virtual void HandleEvent(IncomingMessage message) { switch (message.e) { case "shutdown": Console.WriteLine($"Server is going to close this connection: {message.d}"); break; case "props": string eventType = "", entityType = ""; JObject entity = null; object entityObject = null; foreach (var prop in (message.d as JContainer).Values <JProperty>()) { switch (prop.Name) { case "eventType": eventType = prop.Value.ToString(); break; case "entityType": entityType = prop.Value.ToString(); break; case "entity": entity = prop.Value as JObject; break; default: Log.Write($"Unrecognized event property: {prop}"); break; } } NotificationTaskQueue.Enqueue(() => { if (entity != null) { Cache.Update(eventType, entityType, entity); try { var typeName = entityType[0].ToString().ToUpper() + entityType.Substring(1); typeName = $"Tradovate.Services.Model.{typeName}"; var type = Type.GetType(typeName, true); entityObject = JsonConvert.DeserializeObject(entity.ToString(), type); } catch (Exception ex) { Console.Error.WriteLine($"Cannot deserialize event's entity: {entityType}, {entity}, {ex}"); } } DataUpdated?.Invoke(this, new DataUpdate(eventType, entityType, entityObject)); }); break; } }
public void SetServerListFromConfig(IReadOnlyCollection <ServerConfigItem> configServers) { itemsList.Clear(); itemsList.AddRange(configServers.Select(x => new ServerListDataItem { Address = x.Url, Id = x.Id, })); DataUpdated?.Invoke(); }
public void SetList(List <ClientFolderEndpoint> folders) { _items.Clear(); _items.AddRange(folders.Select(x => new FolderListDataItem { DisplayName = x.DisplayName, Id = x.Id, })); DataUpdated?.Invoke(); }
public void SetServerListFromConfig(IEnumerable <FolderConfigItem> configServers) { _items.Clear(); _items.AddRange(configServers.Select(x => new FolderListDataItem { DisplayName = x.DisplayName, LocalPath = x.LocalPath, Id = x.Id, })); DataUpdated?.Invoke(); }
/// <summary> /// Adds a new data log record to this table. /// </summary> /// <param name="dataLog">The <see cref="ActivityDataLog" /> to add.</param> internal void Add(ActivityDataLog dataLog) { ValidateType(dataLog); if (Records.ContainsKey(dataLog.RecordId)) { throw new DataLoggerMockException(string.Format("The {0} table received a record with a duplicate key.", TableName)); } Records.Add(dataLog.RecordId, new DataLoggerMockRecord(dataLog)); DataUpdated?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Updates the specified data log in this table. /// </summary> /// <param name="dataLog">The <see cref="ActivityDataLog" /> to update.</param> internal void Update(ActivityDataLog dataLog) { ValidateType(dataLog); if (!Records.ContainsKey(dataLog.RecordId)) { throw new DataLoggerMockException($"The {TableName} table received an Update command for a record that does not exist."); } Records[dataLog.RecordId].Update(dataLog); DataUpdated?.Invoke(this, EventArgs.Empty); }
private void DataUpdatedEvent() { while (Stopwatch.GetTimestamp() - _lastUpdateTime < 100 * TickResolMs) { if (AbortEdiabasJob()) { break; } Thread.Sleep(100); } _lastUpdateTime = Stopwatch.GetTimestamp(); DataUpdated?.Invoke(this, EventArgs.Empty); }