public bool OnConfirmEx(IntPtr title, IntPtr text, DialogButtonFlags flags, IntPtr title0, IntPtr title1, IntPtr title2, IntPtr chkMsg, ref bool chkState, out Int32 retVal) { #if debug OnGeneric("OnConfirmEx"); Console.Error.WriteLine("OnConfirmEx"); #endif retVal = -1; AlertEventHandler eh = (AlertEventHandler)(owner.Events[WebBrowser.AlertEvent]); if (eh != null) { AlertEventArgs e = new AlertEventArgs(); e.Type = DialogType.ConfirmEx; if (title != IntPtr.Zero) { e.Title = Marshal.PtrToStringUni(title); } if (text != IntPtr.Zero) { e.Text = Marshal.PtrToStringUni(text); } if (chkMsg != IntPtr.Zero) { e.CheckMessage = Marshal.PtrToStringUni(chkMsg); } e.CheckState = chkState; eh(this, e); chkState = e.CheckState; return(e.BoolReturn); } return(false); }
/// <summary> /// Actions to take when an alert fires an event. /// </summary> /// <param name="args"></param> private void OnAlertEvent(AlertEventArgs args) { string message; switch (args.EventType) { case AlertEventType.CloserToTarget: message = string.Format("{0}:{1} - {2} - Nearing to price {3}", args.Instrument.Market, args.Instrument.Symbol, args.Price, args.Alert.PriceTarget); break; case AlertEventType.TargetReached: message = string.Format("{0}:{1} - {2} - Target reached at {3}!", args.Instrument.Market, args.Instrument.Symbol, args.Price, args.Alert.PriceTarget); break; default: message = "Unknown message type " + args.EventType; break; } AddTextOutput(message); }
public bool OnPrompt(IntPtr title, IntPtr text, ref IntPtr retVal) { #if debug OnGeneric("OnPrompt"); Console.Error.WriteLine("OnPrompt"); #endif AlertEventHandler eh = (AlertEventHandler)(owner.Events[WebBrowser.AlertEvent]); if (eh != null) { AlertEventArgs e = new AlertEventArgs(); e.Type = DialogType.Prompt; if (title != IntPtr.Zero) { e.Title = Marshal.PtrToStringUni(title); } if (text != IntPtr.Zero) { e.Text = Marshal.PtrToStringUni(text); } if (retVal != IntPtr.Zero) { e.Text2 = Marshal.PtrToStringUni(retVal); } eh(this, e); retVal = Marshal.StringToHGlobalUni(e.StringReturn); return(e.BoolReturn); } return(false); }
public bool OnSelect(IntPtr title, IntPtr text, uint count, IntPtr list, out int retVal) { #if debug OnGeneric("OnSelect"); Console.Error.WriteLine("OnSelect"); #endif retVal = 0; AlertEventHandler eh = (AlertEventHandler)(owner.Events[WebBrowser.AlertEvent]); if (eh != null) { AlertEventArgs e = new AlertEventArgs(); e.Type = DialogType.Select; if (title != IntPtr.Zero) { e.Title = Marshal.PtrToStringUni(title); } if (text != IntPtr.Zero) { e.Text = Marshal.PtrToStringUni(text); } eh(this, e); return(e.BoolReturn); } return(false); }
/// <summary> /// Broadcast alert /// </summary> public void BroadcastAlert(AlertMessage msg) { try { this.m_tracer.TraceVerbose("Broadcasting alert {0}", msg); // Broadcast alert // TODO: Fix this, this is bad var args = new AlertEventArgs(msg); this.Received?.Invoke(this, args); if (args.Ignore) { return; } if (msg.Flags == AlertMessageFlags.Transient) { ApplicationContext.Current.ShowToast(msg.Subject); } else { this.Save(msg); } // Committed this.Committed?.BeginInvoke(this, args, null, null); } catch (Exception e) { this.m_tracer.TraceError("Error broadcasting alert: {0}", e); } }
private void Instance_AlertReported(object sender, AlertEventArgs e) { if (AlertMatches(e)) { HandleUpdate(e.Alert); } }
public bool OnPromptPassword(IntPtr title, IntPtr text, IntPtr chkMsg, ref bool chkState, out IntPtr password) { #if debug OnGeneric("OnPromptPassword"); Console.Error.WriteLine("OnPromptPassword"); #endif password = IntPtr.Zero; AlertEventHandler eh = (AlertEventHandler)(owner.Events[WebBrowser.AlertEvent]); if (eh != null) { AlertEventArgs e = new AlertEventArgs(); e.Type = DialogType.PromptPassword; if (title != IntPtr.Zero) { e.Title = Marshal.PtrToStringUni(title); } if (text != IntPtr.Zero) { e.Text = Marshal.PtrToStringUni(text); } if (chkMsg != IntPtr.Zero) { e.CheckMessage = Marshal.PtrToStringUni(chkMsg); } e.CheckState = chkState; eh(this, e); return(e.BoolReturn); } return(false); }
public void TestAlertEventArgs() { var args = new AlertEventArgs("Klingons on the starboard bow!"); Assert.AreEqual("Klingons on the starboard bow!", args.Message); Assert.Throws <ArgumentNullException> (() => new AlertEventArgs(null)); }
async void Popup_AlertEvent(AlertEventArgs _args) { alertDialog.AlertEvent -= Popup_AlertEvent; if (!_args.IsCancel) { } await Page.Navigation.PopPopupAsync(); }
/// <summary> /// This method iterates through all known report types and generates alerts for them. It is then up to the /// consumer of said alerts as to how the alerts will be handled. /// </summary> private async Task IterateReportedValues() { this.Started?.Invoke(this, EventArgs.Empty); var token = this._cancellationTokenSource.Token; while (!token.IsCancellationRequested) { using IServiceScope scope = OrbitServiceProvider.Instance.CreateScope(); var provider = scope.ServiceProvider; // Task.WhenAll allows each of these to run concurrently, effectively making this loop run in parallel await Task.WhenAll(this.ReportTypes.Select(async reportType => { try { Logger.Debug("Iterating type {reportType}", reportType); Type componentType = this._componentByReportType.GetOrAdd(reportType, ExplicitlyMappedComponent); var component = (IMonitoredComponent)provider.GetRequiredService(componentType); token.ThrowIfCancellationRequested(); // TODO: Should we check here that the value is actually new? IModel?report = await component.GetLatestReportAsync(token); if (report == null) { return; } token.ThrowIfCancellationRequested(); await this.OnNewValueRead(component, new ValueReadEventArgs(report)).ConfigureAwait(true); if (report is IAlertableModel a) { foreach (var alert in a.GenerateAlerts()) { var args = new AlertEventArgs(a, alert); await OnAlertReported(component, args).ConfigureAwait(true); } } } catch (OperationCanceledException) { // Ignore cancellation errors } catch (Exception ex) { Logger.Error(ex, "Error in EventMonitor loop"); } })); await Task.Delay(TimeSpan.FromSeconds(SecondsDelay), token).ConfigureAwait(false); } this.Stopped?.Invoke(this, EventArgs.Empty); }
void OnAlert(object sender, AlertEventArgs e) { var handler = Alert; if (handler != null) { handler(this, e); } }
async void Popup_AlertConfirmationEvent(AlertEventArgs _args) { alertDialog.AlertEvent -= Popup_AlertConfirmationEvent; if (!_args.IsCancel) { ConfrimationAlert_Result(_args.IsCancel); } await Page.Navigation.PopPopupAsync(); }
private void Engine_AlertRaised(object sender, AlertEventArgs args) { if (args.DisplayPopup) { AlertBase alert = args.Alert; this._playSound = args.PlaySound; this.Alerts.Insert(0, alert); this.StartTimer(); } }
private async void OnAlertEvent(AlertEventArgs args) { if (string.IsNullOrEmpty(args.Accept)) { await DisplayAlert(args.Title, args.Message, args.Cancel); } else { await DisplayAlert(args.Title, args.Message, args.Accept, args.Cancel); } }
protected override bool AlertMatches(AlertEventArgs alert) { try { bool matches = alert.Query <OxygenGenerator>().Matches(a => a.OxygenLevel); if (matches) { MakePercentage(alert.Alert); } return(matches); } catch (Exception e) { Debug.LogError(e, this); return(false); } }
public void MainLoop() { while (true) { Decision = Refreash(); if (Trader.CheckTrad(Decision, Ticker.CurrentValue) == ExchangeStatus.buy && firstBuyFlag) { firstBuyFlag = false; } RefreashedEventArgs refreashEA = new RefreashedEventArgs(Ticker.CurrentValue, Ticker.LastValue, Ticker.Status, Decision, Trader.CurrentBitcoinNum, Trader.CurrentCashNum); onRefreash(refreashEA); if (IsAlert && ((AlertUpper != 0 && Ticker.CurrentValue >= AlertUpper) || (AlertLower != 0 && Ticker.CurrentValue <= AlertLower))) { AlertEventArgs alertEA = new AlertEventArgs(Ticker.CurrentValue, AlertUpper, AlertLower); alerted(alertEA); } Thread.Sleep((int)SleepTime); } }
// This is like the last two but for miscellaneous generic alerts that kill a colonist. It just displays // the strings that come in for the button and alert text. void OnAlertStarted(object sender, AlertEventArgs args) { alertType = AlertType.Misc; int happinessDiff = args.happinessDiff; OpenGameOverUI(); gameOverText.text = args.alertString; if (happinessDiff <= 0) { dayDisplay.text = "Happiness " + happinessDiff; } else { dayDisplay.text = "Happiness +" + happinessDiff; } GameEvents.InvokeHappinessChanged(happinessDiff); restartButton.transform.GetChild(0).gameObject.GetComponent <Text>().text = args.buttonString; }
public void OnAlert(IntPtr title, IntPtr text) { #if debug OnGeneric("OnAlert"); Console.Error.WriteLine("OnAlert"); #endif AlertEventHandler eh = (AlertEventHandler)(owner.Events[WebBrowser.AlertEvent]); if (eh != null) { AlertEventArgs e = new AlertEventArgs(); e.Type = DialogType.Alert; if (title != IntPtr.Zero) { e.Title = Marshal.PtrToStringUni(title); } if (text != IntPtr.Zero) { e.Text = Marshal.PtrToStringUni(text); } eh(this, e); } }
public bool OnConfirm(IntPtr title, IntPtr text) { #if debug OnGeneric("OnConfirm"); Console.Error.WriteLine("OnConfirm"); #endif AlertEventHandler eh = (AlertEventHandler)(owner.Events[WebBrowser.AlertEvent]); if (eh != null) { AlertEventArgs e = new AlertEventArgs(); e.Type = DialogType.Confirm; if (title != IntPtr.Zero) { e.Title = Marshal.PtrToStringUni(title); } if (text != IntPtr.Zero) { e.Text = Marshal.PtrToStringUni(text); } eh(this, e); return(e.BoolReturn); } return(false); }
// If the big alert box is on the screen don't click the day. void OnAlertStarted(object sender, AlertEventArgs args) { advanceDayButton.interactable = false; }
void OnEngineAlert (object sender, AlertEventArgs e) { OnAlert (e); }
//If an alert is given I don't want you to click stuff, that would be weird. void OnAlertStarted(object sender, AlertEventArgs args) { inMenu = true; }
public Matcher(AlertEventArgs args) { this._args = args; }
void OnAlert(object sender, AlertEventArgs e) { var handler = Alert; if (handler != null) handler (this, e); }
private void alert_OnAlert(object sender, AlertEventArgs e) { _FireAlert = true; }
public void alerted(AlertEventArgs e) { alert?.Invoke(this, e); }
/// <summary> /// Use this to query <see cref="AlertEventArgs"/> using Expressions for readability. /// </summary> public static Matcher <TModel> Query <TModel>(this AlertEventArgs args) where TModel : class, IAlertableModel => new Matcher <TModel>(args);
private void Client_Alert(object sender, AlertEventArgs e) { NewLogMessage?.Invoke(this, $"{DateTime.Now}: {e.Message}"); }
private Task OnAlertReported(object sender, AlertEventArgs args) { return(this.RunInCorrectSynchronizationContext(() => this.AlertReported?.Invoke(sender, args))); }
void CameraWindow_AlertHandler(object sender, AlertEventArgs eventArgs) { if (Camera.Plugin != null) { var a = (String) Camera.Plugin.GetType().GetMethod("ProcessAlert").Invoke(Camera.Plugin, new object[] { eventArgs.Description }); if (!String.IsNullOrEmpty(a)) { string[] actions = a.ToLower().Split(','); foreach (var action in actions) { if (!String.IsNullOrEmpty(action)) { switch (action) { case "alarm": CameraAlarm(eventArgs.Description, EventArgs.Empty); break; case "flash": FlashCounter = 10; break; } if (action.StartsWith("border:") && action.Length>7) { string col = action.Substring(7); try { _customColor = Color.FromArgb(Convert.ToInt32(col)); Custom = true; } catch (Exception e) { Log.Error("",e);//MainForm.LogExceptionToFile(e); } } } } } } }
static void ResetAlert(AlertEventArgs args) { nextAlert = nextAlert.AddDays(1); }
void communicator_OnAlert(object source, AlertEventArgs e) { //Предупреждние }
protected abstract bool AlertMatches(AlertEventArgs alert);