/// <summary> /// An order has been received an update containing critical modification of its information, /// so handle this here and show to user. /// </summary> void management_OrdersCriticalInformationChangedEvent(ITradeEntityManagement provider, AccountInfo account, Order order, OrderInfo updateInfo) { // Compose the critical update message instantly, as otherwise it is wrong since the order gets instantly updated after this call. string criticalUpdateMessage = string.Empty; if (order.OpenPrice.HasValue && updateInfo.OpenPrice.HasValue && order.OpenPrice.Value != updateInfo.OpenPrice.Value) { criticalUpdateMessage = string.Format("Open Price Difference [{0}], Existing [{1}], New [{2}].", order.OpenPrice - updateInfo.OpenPrice, order.OpenPrice.ToString(), updateInfo.OpenPrice) + Environment.NewLine; } if (order.ClosePrice.HasValue && updateInfo.ClosePrice.HasValue && order.ClosePrice.Value != updateInfo.ClosePrice.Value) { criticalUpdateMessage += string.Format("Close Price Difference [{0}], Existing [{1}], New [{2}].", order.ClosePrice - updateInfo.ClosePrice, order.ClosePrice.ToString(), updateInfo.ClosePrice) + Environment.NewLine; } WinFormsHelper.BeginManagedInvoke(this, delegate() { if (toolStripButtonPopupNotifications.Checked == false) { return; } if (string.IsNullOrEmpty(criticalUpdateMessage) == false) { MessageBox.Show("Account [" + account.Name + "] Order Id[" + order.Id + "] Critical Information Updated" + Environment.NewLine + criticalUpdateMessage, "Critical Order Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } }); }
private void toolStripButtonStartAdapter_Click(object sender, EventArgs e) { foreach (ListViewItem item in listViewIntegrations.SelectedItems) { GeneralHelper.FireAndForget(delegate(ListViewItem itemValue) { string operationMessage = string.Empty; IIntegrationAdapter adapter = (IIntegrationAdapter)itemValue.Tag; string operationResultMessage; if (adapter.Start(out operationResultMessage) == false) { operationMessage += "Adapter [" + adapter.Name + "] failed to start [" + operationResultMessage + "]." + Environment.NewLine; } WinFormsHelper.BeginManagedInvoke(this, delegate() { if (string.IsNullOrEmpty(operationMessage) == false) { MessageBox.Show(operationMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } UpdateUI(); }); }, item); } }
void source_DataDownloadedEventToDataStore(OnlineEntrySource source) { source.DataDownloadedEvent -= new OnlineEntrySource.EntrySourceUpdateDelegate(source_DataDownloadedEventToDataStore); if (source.DownloadSucceeded) { foreach (string filePath in source.DownloadedTempFilesPaths) { Manager.AddEntryFromLocalFile(filePath); } WinFormsHelper.BeginManagedInvoke(this, delegate() { toolStripStatusLabel1.DisplayStyle = ToolStripItemDisplayStyle.Text; toolStripStatusLabel1.Text = "Download of [" + source.Uri.ToString() + "] successful."; }); } else { WinFormsHelper.BeginManagedInvoke(this, delegate() { toolStripStatusLabel1.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; toolStripStatusLabel1.Text = "Download of [" + source.Uri.ToString() + "] failed."; }); } source.EndDownload(true); WinFormsHelper.BeginFilteredManagedInvoke(this, UpdateUI); }
void _component_OperationalStateChangedEvent(IOperational operational, OperationalStateEnum previousOperationState) { WinFormsHelper.BeginManagedInvoke(this, delegate { labelStatus.Text = UserFriendlyNameAttribute.GetTypeAttributeName(operational.GetType()) + " is " + operational.OperationalState.ToString(); }); }
public void UpdateUI() { ListView listView = _listView; if (listView != null) { WinFormsHelper.BeginManagedInvoke(_listView, DoUpdateUI); } }
void _ownerControl_Paint(object sender, PaintEventArgs e) { if (e.ClipRectangle.Width >= _ownerControl.Width && e.ClipRectangle.Height >= _ownerControl.Height) { _drawnHorizontal = false; _drawnVertical = false; WinFormsHelper.BeginManagedInvoke(_ownerControl, delegate() { Redraw(); }); } }
private void toolStripButtonStopAdapter_Click(object sender, EventArgs e) { foreach (ListViewItem item in listViewIntegrations.SelectedItems) { // Make sure to pass item as parameter, otherwise the value is in foreach and chages before the thread starts. GeneralHelper.FireAndForget(delegate(ListViewItem itemValue) { IIntegrationAdapter adapter = (IIntegrationAdapter)itemValue.Tag; System.Diagnostics.Trace.WriteLine(adapter.Name); string operationResultMessage; adapter.Stop(out operationResultMessage); WinFormsHelper.BeginManagedInvoke(this, UpdateUI); }, item); } }
void expertManager_AddedExpertContainerEvent(ExpertInformation container) { WinFormsHelper.BeginFilteredManagedInvoke(this, TimeSpan.FromMilliseconds(250), new GeneralHelper.GenericDelegate <bool>(UpdateUI), true); GeneralHelper.DefaultDelegate newDelegate = delegate() { // Select the newly created expert. this.listViewExperts.SelectedIndices.Clear(); if (listViewExperts.VirtualListSize > 0) { this.listViewExperts.SelectedIndices.Add(listViewExperts.VirtualListSize - 1); } }; WinFormsHelper.BeginManagedInvoke(this, newDelegate); }
void _session_OperationalStatusChangedEvent(IOperational session, OperationalStateEnum previousState) {// Session has changed operation mode - show in the chart name. if (_session == null) { SystemMonitor.Warning("Control session already cleared."); return; } WinFormsHelper.BeginManagedInvoke(this, delegate() { if (session == _session) { UpdateMasterChart(); } else { SystemMonitor.CheckError(_session == null || session == null, "Session mismatch."); } }); // We can not afford delayed execution here, since on closing the application, persisting is needed // and by than Invoke requests are not handled any more. if (previousState == OperationalStateEnum.Operational) {// All coming out of operation state must be persisted. // Save UI dataDelivery to sessionInformation object. if (_session.ChartControlPersistence != null) { _session.ChartControlPersistence.Clear(); } else { _session.ChartControlPersistence = new SerializationInfoEx(); } chartControl.SaveState(_session.ChartControlPersistence); } }
void _platform_ComponentDeserializationFailedEvent(long componentId, string componentTypeName) { WinFormsHelper.BeginManagedInvoke(this, new GeneralHelper.GenericDelegate <long, string>( uiThread_ComponentDeSerializationFailed), componentId, componentTypeName); }
void platform_ActiveComponentRemovedEvent(PlatformComponent component, bool isInitial) { WinFormsHelper.BeginManagedInvoke(this, new GeneralHelper.GenericDelegate <PlatformComponent, bool, bool>( uiThread_ActiveComponentUpdateEvent), component, false, isInitial); }