private void EditHandler(object sender, EventArgs e) { if (_mouseLocation.RowIndex < 0 || _mouseLocation.RowIndex > _devices.Rows.Count - 1) { return; } string oldName = _devices.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString(); string newName = InvokeDeviceEditor(oldName); if (string.IsNullOrEmpty(newName)) { return; } _devices.Rows[_mouseLocation.RowIndex].Cells[0].Value = newName; for (int i = 0; i < _recipeDevicesValues.Count; i++) { if (_recipeDevicesValues[i].Item1 != oldName) { continue; } _recipeDevicesValues[i] = Tuple.Create(newName, _recipeDevicesValues[i].Item2); break; } OnDataChange?.Invoke(new[] { _deviceNames, _recipeDevicesValues }); OnLock?.Invoke(); }
private void DeleteHandler(object sender, EventArgs e) { if (_mouseLocation.RowIndex < 0 || _mouseLocation.RowIndex > _devices.Rows.Count - 1) { return; } string name = _devices.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString(); if (ConfirmationForm.Invoke(name) != DialogResult.OK) { return; } _devices.Rows.RemoveAt(_mouseLocation.RowIndex); for (int i = 0; i < _recipeDevicesValues.Count; i++) { if (_recipeDevicesValues[i].Item1 != name) { continue; } _recipeDevicesValues[i] = Tuple.Create("", _recipeDevicesValues[i].Item2); break; } OnDataChange?.Invoke(new[] { _deviceNames, _recipeDevicesValues }); OnLock?.Invoke(); }
private async Task SetElementsAsync() { if (_entity == null) { return; } _eventHandle?.Dispose(); _eventHandle = _repository.ChangeToken.RegisterChangeCallback(async x => { await SetElementsAsync(); OnDataChange?.Invoke(this, new EventArgs()); }, null); var parentId = _repositoryParentIdProperty?.Getter.Invoke(_entity) as string; var entities = await _memoryCache.GetOrCreateAsync(new { _repository, parentId }, (entry) => { entry.AddExpirationToken(_repository.ChangeToken); return(_repository.InternalGetAllAsync(parentId, Query.Default())); }); _elements = entities .Select(entity => (IElement) new ElementDTO { Id = _idProperty.Getter(entity), Labels = _labelProperties.Select(x => x.StringGetter(entity)) }) .ToList(); }
private void DeleteHandler(object sender, EventArgs e) { if (_mouseLocation.RowIndex < 0 || _mouseLocation.RowIndex > _dgv.Rows.Count - 1) { return; } string name = _dgv.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString(); if (ConfirmationForm.Invoke(name) != DialogResult.OK) { return; } _dgv.Rows.RemoveAt(_mouseLocation.RowIndex); for (int i = 0; i < _data.Count; i++) { if (_data[i].Item1 != name) { continue; } _data[i] = Tuple.Create("", _data[i].Item2); break; } OnDataChange?.Invoke(_data); _state = State.Deleted; }
private void AddHandler(object sender, EventArgs e) { string newName = RenameForm.Invoke(); _dgv.Rows.Add(newName); _data.Add(Tuple.Create(newName, "")); OnDataChange?.Invoke(_data); _state = State.Added; }
private async Task OnRepositoryChangeAsync(object?sender, CollectionRepositoryEventArgs args) { if (args.RepositoryAlias == _setup.RepositoryAlias) { await SetElementsAsync(refreshCache : true); OnDataChange?.Invoke(sender, EventArgs.Empty); } }
private void AddHandler(object sender, EventArgs e) { string newName = InvokeDeviceEditor("Отсутствует"); _devices.Rows.Add(newName); _recipeDevicesValues.Add(Tuple.Create(newName, "")); OnDataChange?.Invoke(new[] { _deviceNames, _recipeDevicesValues }); OnLock?.Invoke(); }
private Task OnRepositoryChangeAsync(object?sender, CollectionRepositoryEventArgs args) { if ((!string.IsNullOrEmpty(_repositoryAlias) && args.RepositoryAlias == _repositoryAlias) || (string.IsNullOrEmpty(_repositoryAlias) && args.CollectionAlias == _collectionAlias)) { OnDataChange?.Invoke(sender, EventArgs.Empty); } return(Task.CompletedTask); }
public async void SubscribeDataChange <T>() { ListenDataChange = true; DataCache.OnCacheChanged += (sender, e) => OnDataChange?.Invoke(this, e); while (ListenDataChange) { T obj = await client.Get <T>(FullyQualifiedJsonURL); DataCache.CompareCache(obj); } }
private void UserCallbackDataChange(List <CacheChangeData> updates) { foreach (var update in updates) { try { OnDataChange?.Invoke(update); } catch (Exception e) { _Logger.Log(e); } } }
private void AddHandler(object sender, EventArgs e) { var lst = InvokeIngredEditor(new List <string> { "Ничто", "Нисколько", "Никакие" }); _dgv.Rows.Add(lst[0], lst[1], lst[2]); _data.Add(Tuple.Create( Tuple.Create(lst[0], ""), Tuple.Create(lst[1], ""), Tuple.Create(lst[2], ""))); OnDataChange?.Invoke(_data); OnLock?.Invoke(); }
private void SetData(object value, SignalChangeType changeType) { data = value; if (Data != null) { SignalLogItem logItem = new SignalLogItem(this, changeType, Data); Log.Add(logItem); if (Log.Count > 1000) { Log.RemoveAt(0); } ProcessDataChange(); OnDataChange?.Invoke(this, true); } }
private async Task SetElementsAsync() { if (_entity == null) { return; } _eventHandle?.Dispose(); _eventHandle = _repository.ChangeToken.RegisterChangeCallback(async x => { await SetElementsAsync(); OnDataChange?.Invoke(this, new EventArgs()); }, null); var parent = default(IParent?); if (_repositoryParentSelector != null) { // a bit weird (see CollectionRelationConfig) if (_repositoryParentSelector.ObjectType == typeof(ValueTuple <IParent?, IEntity>)) { parent = _repositoryParentSelector.Getter.Invoke((_parent, _entity)) as IParent; } else if (_parent != null) { parent = _repositoryParentSelector.Getter.Invoke(_parent) as IParent; } } var entities = await _memoryCache.GetOrCreateAsync(new { _repository, parent }, (entry) => { entry.AddExpirationToken(_repository.ChangeToken); return(_repository.InternalGetAllAsync(parent, Query.Default())); }); _elements = entities .Select(entity => (IElement) new ElementDTO { Id = _idProperty.Getter(entity), Labels = _labelProperties.Select(x => x.StringGetter(entity)) }) .ToList(); }
private void EditHandler(object sender, EventArgs e) { if (_mouseLocation.RowIndex < 0 || _mouseLocation.RowIndex > _dgv.Rows.Count - 1) { return; } string oldName = _dgv.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString(); var lst = InvokeIngredEditor(new List <string> { _dgv.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString(), _dgv.Rows[_mouseLocation.RowIndex].Cells[1].Value.ToString(), _dgv.Rows[_mouseLocation.RowIndex].Cells[2].Value.ToString() }); if (string.IsNullOrEmpty(lst[0]) || string.IsNullOrEmpty(lst[1]) || string.IsNullOrEmpty(lst[2])) { return; } for (int i = 0; i < 3; i++) { _dgv.Rows[_mouseLocation.RowIndex].Cells[i].Value = lst[i]; } for (int i = 0; i < _data.Count; i++) { if (_data[i].Item1.Item1 != oldName) { continue; } _data[i] = Tuple.Create( Tuple.Create(lst[0], _data[i].Item1.Item2), Tuple.Create(lst[1], _data[i].Item2.Item2), Tuple.Create(lst[2], _data[i].Item3.Item2)); break; } OnDataChange?.Invoke(_data); OnLock?.Invoke(); }
private async Task SetElementsAsync() { if (_editContext == null) { return; } _eventHandle?.Dispose(); _eventHandle = _repository.ChangeToken.RegisterChangeCallback(async x => { await SetElementsAsync(); OnDataChange?.Invoke(this, new EventArgs()); }, null); var parent = default(IParent?); if (_entityAsParent && _editContext.EntityState != EntityState.IsNew) { parent = new ParentEntity(_editContext.Parent, _editContext.Entity, _editContext.RepositoryAlias); } if (_repositoryParentSelector != null && _parent != null) { parent = _repositoryParentSelector.Getter.Invoke(_parent) as IParent; } var entities = await _memoryCache.GetOrCreateAsync(new { _repository, parent }, async (entry) => { entry.AddExpirationToken(_repository.ChangeToken); return(await _repository.GetAllAsync(parent, Query.Default(_editContext.CollectionAlias))); }); _elements = entities .Select(entity => (IElement) new Element { Id = _idProperty.Getter(entity), Labels = _labelProperties.Select(x => x.StringGetter(entity)).ToList() }) .ToList(); }
public void LoadData(string name) { if (name == null) { return; } DataTable dt = Connector.GetTable( QueryFactory.Queries.SelectDevicesByRecipeName, Tuple.Create("@Name", name)); _devices.Rows.Clear(); _devices.Columns.Clear(); _devices.ColumnCount = 1; _recipeDevicesValues.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { string text = dt.Rows[i].ItemArray[0].ToString(); _devices.Rows.Add(text); _recipeDevicesValues.Add(Tuple.Create(text, text)); } OnDataChange?.Invoke(new[] { _deviceNames, _recipeDevicesValues }); }
private void EditHandler(object sender, EventArgs e) { if (_mouseLocation.RowIndex < 0 || _mouseLocation.RowIndex > _dgv.Rows.Count - 1) { return; } string name = _dgv.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString(); string newName = RenameForm.Invoke(false, name); _dgv.Rows[_mouseLocation.RowIndex].Cells[0].Value = newName; for (int i = 0; i < _data.Count; i++) { if (_data[i].Item1 != name) { continue; } _data[i] = Tuple.Create(newName, _data[i].Item2); break; } OnDataChange?.Invoke(_data); _state = State.Edited; }
public void LoadData(string recipeName) { DataTable dt = Connector.GetTable(QueryFactory.Queries.SelectIngredsByRecipeName, Tuple.Create("@Name", recipeName)); _dgv.Rows.Clear(); _dgv.ColumnCount = 3; _data = new DataStructure(); foreach (DataRow row in dt.Rows) { _data.Add(Tuple.Create( Tuple.Create(row.ItemArray[0].ToString(), row.ItemArray[0].ToString()), Tuple.Create(row.ItemArray[1].ToString(), row.ItemArray[1].ToString()), Tuple.Create(row.ItemArray[2].ToString(), row.ItemArray[2].ToString()))); _dgv.Rows.Add( row.ItemArray[0].ToString(), row.ItemArray[1].ToString(), row.ItemArray[2].ToString()); } OnDataChange?.Invoke(_data); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (e.Button != MouseButtons.Left) { drag = false; handle = -1; return; } if (drag && Selected.Count > 0) { var pt = TransformPoint(e.Location, Title.Resolution, Size); int dx = pt.X - p1.X; int dy = pt.Y - p1.Y; foreach (var el in Selected) { int x = el.Bounds.X, y = el.Bounds.Y, w = el.Bounds.Width, h = el.Bounds.Height; switch (handle) { default: x += dx; y += dy; break; case 0: x += dx; y += dy; w -= dx; h -= dy; break; case 7: w += dx; h += dy; break; case 1: y += dy; h -= dy; break; case 6: h += dy; break; case 2: y += dy; w += dx; h -= dy; break; case 5: x += dx; w -= dx; h += dy; break; case 3: x += dx; w -= dx; break; case 4: w += dx; break; } x = Math.Min(x + w, x); y = Math.Min(y + w, y); w = Math.Abs(w); h = Math.Abs(h); //if (keepAspect) { // var img = el.GetPreferredSize(); // var rs = (float)w / h; // var ri = (float)img.Width / img.Height; // w = rs > ri ? (int)(img.Width * ((float)h / img.Height)) : w; // h = rs > ri ? h : (int)(img.Height * ((float)w / img.Width)); //} el.Bounds = new Rectangle(x, y, w, h); OnDataChange?.Invoke(); } p1 = new Point(pt.X, pt.Y); Invalidate(); } }
public void NotifyObservers() { OnDataChange?.Invoke(Temperature, Humidity, Pressure); }
internal void UDPReciever() { try { timerforchecklogin = new System.Timers.Timer(); timerforchecklogin.Interval = 30000; timerforchecklogin.Start(); timerforchecklogin.Elapsed += timerforchecklogin_Elapsed; Task.Factory.StartNew(() => { while (true) { // string address = subscriber.Receive (Encoding.Unicode); // byte[] buffer = new byte[512]; // int bufferSize = subscriber.Receive (buffer); var buffer = subscriber.Receive(); if (buffer == null) { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("STOP")); continue; } //Data = (INTERACTIVE_ONLY_MBP)DataPacket.RawDeserialize(buffer.Skip(4).ToArray(), typeof(INTERACTIVE_ONLY_MBP)); long TokenName = BitConverter.ToInt64(buffer, 0); Data = (INTERACTIVE_ONLY_MBP)DataPacket.RawDeserialize(buffer.Skip(8).ToArray(), typeof(INTERACTIVE_ONLY_MBP)); OnDataChange.Raise(OnDataChange, OnDataChange.CreateReadOnlyArgs(Data)); //if (Global.Instance.Data_With_Nano.ContainsKey(TokenName)) //{ // switch(Global.Instance.Data_With_Nano[TokenName]) // { // case ClassType.MARKETWTCH: // Data = (INTERACTIVE_ONLY_MBP)DataPacket.RawDeserialize(buffer.Skip(8).ToArray(), typeof(INTERACTIVE_ONLY_MBP)); // OnDataChange.Raise(OnDataChange, OnDataChange.CreateReadOnlyArgs(Data)); // break; // case ClassType.SPREAD: // SpreadData_7211 = (MS_SPD_MKT_INFO_7211)DataPacket.RawDeserialize(buffer.Skip(8).ToArray(), typeof(MS_SPD_MKT_INFO_7211)); // OnSpreadDataChange.Raise(OnSpreadDataChange, OnSpreadDataChange.CreateReadOnlyArgs(SpreadData_7211)); // break; // } //} } }); } catch (OperationCanceledException e) { Console.WriteLine("Cancellation invoked"); } catch (AggregateException e) { Console.WriteLine("Some unexpected exception "); } catch (Exception Ex) { Console.WriteLine("Exception Raised " + Ex.StackTrace); } }
public void Unsubscribe(OnDataChange dataChangeSubscriber) { dataChangeEvent -= dataChangeSubscriber; }
public void Subscribe(OnDataChange dataChangeSubscriber) { dataChangeEvent += dataChangeSubscriber; }
public void TriggerDataChange() { OnDataChange?.Invoke(); }
private void EditContext_OnFieldChanged(object?sender, FieldChangedEventArgs e) { OnDataChange?.Invoke(this, new EventArgs()); }
protected void RaiseOnDataChange(TModel model, TEntity entity) { OnDataChange?.Invoke(model, entity); }
internal void HandleDataChange(string key, string value) { OnDataChange?.Invoke(key, value); }
public void Subscribe(OnDataChange func) { DataChangeSubscribers += func; }
public void SetOnDataChange(OnDataChange onDataChange) { this.onDataChange = onDataChange; }