private void OnResponse(object o, ResponseArgs args) { if (args.ResponseId == ResponseType.Apply) { Process.Start(_downloader.LocalFile); return; } if (args.ResponseId == ResponseType.Ok) { SaveChanges(); } Destroy(); }
// ============================================ // PRIVATE (Methods) Event Handlers // ============================================ private void OnLoginResponse(object sender, ResponseArgs args) { if (args.ResponseId == ResponseType.Ok) { DoLogin((GUI.Dialogs.Login)sender); if (myInfo != null) { RunMainWindow(); } } else { Gtk.Application.Quit(); } }
public override void Parse(ParserContext ctx, ResponseMessage resMsg) { var regex = new Regex($@"^42{ctx.Namespace}\d*\[(.+)\]$"); if (regex.IsMatch(resMsg.Text)) { var groups = regex.Match(resMsg.Text).Groups; string text = groups[1].Value; var formatter = new DataFormatter(); var data = formatter.Format(text); var eventHandlerArg = new ResponseArgs { RawText = resMsg.Text }; string eventName = JsonConvert.DeserializeObject <string>(data[0]); if (data.Count > 1) { eventHandlerArg.Text = data[1]; } if (ctx.EventHandlers.ContainsKey(data[0])) { var handlerBox = ctx.EventHandlers[data[0]]; handlerBox.EventHandler?.Invoke(eventHandlerArg); if (handlerBox.EventHandlers != null) { for (int i = 0; i < handlerBox.EventHandlers.Count; i++) { var arg = new ResponseArgs { RawText = resMsg.Text }; if (i + 2 <= data.Count - 1) { arg.Text = data[i + 2]; } handlerBox.EventHandlers[i](arg); } } } else { ctx.UncaughtHandler(eventName, eventHandlerArg); } ctx.ReceiveHandler(eventName, eventHandlerArg); } else if (Next != null) { Next.Parse(ctx, resMsg); } }
void OnDialogResponse(object o, ResponseArgs args) { /* * //ResponseType.Accept -> Add new exercise * if (args.ResponseId.Equals(ResponseType.Accept)) * { * var distance = Convert.ToInt32(distanceEntry.Text); * var minutes = Convert.ToInt32(minutesEntry.Text); * var ex = new Exercise(distance, minutes); * exerciseService.Add(ex); * store.AppendValues(ex.Distance, ex.Minutes, ex.Id); * } * * //ResponseType.Apply -> Edit exercise * if (args.ResponseId.Equals(ResponseType.Apply)) * { * var distance = Convert.ToInt32(distanceEntry.Text); * var minutes = Convert.ToInt32(minutesEntry.Text); * * var ex = exerciseService.Get(selectedEx_Id); * ex.Distance = distance; * ex.Minutes = minutes; * exerciseService.Update(ex); * * TreeIter iter; * TreeModel model; * if (treeView.Selection.GetSelected(out model, out iter)) * { * store.SetValue(iter, (int)Column.Distance, ex.Distance); * store.SetValue(iter, (int)Column.Minutes, ex.Minutes); * store.SetValue(iter, (int)Column.Id, ex.Id); * } * } */ //ResponseType.Reject -> Delete exercise if (args.ResponseId.Equals(ResponseType.Reject)) { TreeIter iter; TreeModel model; if (treeView.Selection.GetSelected(out model, out iter)) { var id = (int)store.GetValue(iter, (int)Column.Id); exerciseService.Delete(id); store.Remove(ref iter); } } }
private void on_dialog_response(object sender, ResponseArgs args) { if (args.ResponseId != Gtk.ResponseType.Ok) { // FIXME this is to work around a bug in gtk+ where // the filesystem events are still listened to when // a FileChooserButton is destroyed but not finalized // and an event comes in that wants to update the child widgets. uri_chooser.Dispose(); uri_chooser = null; } else if (args.ResponseId == Gtk.ResponseType.Ok) { zip(); } zipdiag.Destroy(); }
private void OnResponse(object o, ResponseArgs args) { ResponseType response = args.ResponseId; if (response == ResponseType.Apply) { Queue(); return; } if (response == ResponseType.Ok) { Play(); } Destroy(); }
protected void OnResponse(object o, ResponseArgs args) { if (args.ResponseId == ResponseType.Ok) { Properties = new ExportProperties { Type = (ExportType)ExportTypeSelection.Active, Height = (uint)HeightInput.Value, Width = (uint)WidthInput.Value, Color = new byte[3] { MapToByte(ColorButton.Color.Red), MapToByte(ColorButton.Color.Green), MapToByte(ColorButton.Color.Blue) } }; } }
/// <summary> /// Event handler for Conflict Dialog Response event /// </summary> private void OnConflictDialogResponse(object o, ResponseArgs args) { if (ConflictDialog != null) { if (args.ResponseId == ResponseType.Help) { Util.ShowHelp("conflicts.html", this); } else { ConflictDialog.Hide(); ConflictDialog.Destroy(); ConflictDialog = null; } } // CRG: TODO // At this point, refresh the selected iFolder to see if it // has any more conflicts }
private void OnResponse(object sender, ResponseArgs args) { Destroy(); if (args.ResponseId == Gtk.ResponseType.Ok) { FeedAutoDownload new_sync_pref = new_episode_option_combo.ActiveSyncPreference; if (feed.AutoDownload != new_sync_pref || feed.Title != name_entry.Text) { feed.AutoDownload = new_sync_pref; feed.Title = name_entry.Text; feed.Save(); } } (sender as Dialog).Response -= OnResponse; (sender as Dialog).Destroy(); }
/// <summary> /// Handles all processing when the user selects the OK or Cancel buttons. /// </summary> /// <param name="o">system parameter</param> /// <param name="args">system parameter</param> private void frmOptions_Response(object o, ResponseArgs args) { if (args.ResponseId == ResponseType.Ok) { // General Core.GeneralSettings.MaximumMRUPaths = cboMRU.Active + 1; Core.GeneralSettings.ExtensionExcludeList = txtExcludeExtensions.Text; // Only load new language on a change if (!Core.GeneralSettings.Language.Equals(cboLanguage.ActiveText)) { Core.GeneralSettings.Language = cboLanguage.ActiveText; __LanguageChange = true; } // Results Core.GeneralSettings.HighlightForeColor = Common.ConvertColorToString(btnMatchForeColor.Color); Core.GeneralSettings.HighlightBackColor = Common.ConvertColorToString(btnMatchBackColor.Color); Core.GeneralSettings.ResultsForeColor = Common.ConvertColorToString(btnResultsForeColor.Color); Core.GeneralSettings.ResultsBackColor = Common.ConvertColorToString(btnResultsBackColor.Color); // Save all options Core.GeneralSettings.Save(); } }
private static void Server_ResponseEvent(object sender, ResponseArgs e) { switch (e.responseType) { case "RegisterClient": // Send All Resume Points to Client SendAllResumePoints(e.clientIp); // Write to Log log.WriteLine($"Client ({e.clientIp}) Registered"); break; case "ResumeUpdate": // Receive the Resume Update ReceiveResumeUpdate(JsonConvert.DeserializeObject <RecordingsJson>(e.response.Replace("<EOF>", ""))); // Distribute the Resume Update to all Clients DistributeResumeUpdate(e.response, e.clientIp); break; } }
/* Event members */ protected void OnResponse(object o, ResponseArgs args) { bool keepVisible = ProcessResponse(args.ResponseId); if (keepVisible && (args.ResponseId != ResponseType.DeleteEvent)) { return; } if (this.Scope == DialogScope.Singleton) { Destroy(); } else { Hide(); args.RetVal = true; } }
/// <summary> /// Invoked when the user clicks OK or Apply in the font selection /// dialog. Changes the font on all widgets and saves the new font /// in the config file. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="args">Event arguments.</param> private void OnChangeFont(object sender, ResponseArgs args) { try { string fontName = fontDialog.Font; Pango.FontDescription newFont = Pango.FontDescription.FromString(fontName); Utility.Configuration.Settings.FontName = newFont.ToString(); ChangeFont(newFont); if (args.ResponseId != ResponseType.Apply) { fontDialog.Dispose(); } } catch (Exception err) { ShowError(err); } }
private void OnResponse(object sender, ResponseArgs args) { if (args.ResponseId == Gtk.ResponseType.Ok) { bool changed = false; if (feed.IsSubscribed != subscribed_check.Active) { feed.IsSubscribed = subscribed_check.Active; changed = true; } if (feed.IsSubscribed) { if (feed.AutoDownload != DownloadPref) { feed.AutoDownload = DownloadPref; changed = true; } if (feed.MaxItemCount != MaxItemCount) { feed.MaxItemCount = MaxItemCount; changed = true; } } if (feed.Title != name_entry.Text) { feed.Title = name_entry.Text; source.Reload(); changed = true; } if (changed) { feed.Save(); } } (sender as Dialog).Response -= OnResponse; (sender as Dialog).Destroy(); }
protected void OnRespond(object o, ResponseArgs args) { if (args.ResponseId != Gtk.ResponseType.Ok) { return; } TreeIter iter; var list = new List <int> (); if (storeSelected.GetIterFirst(out iter)) { do { var enc = (int)storeSelected.GetValue(iter, 2); list.Add(enc); } while (storeSelected.IterNext(ref iter)); } TextEncoding.ConversionEncodings = list.Select(TextEncoding.GetEncoding).ToArray(); }
static void dialog_Response(object o, ResponseArgs args) { if (AutoUpdateTask && args.ResponseId == ResponseType.Ok) { Task.Name = ((Entry)Builder.GetObject("EntryNombre")).Text; Task.Descript = ((Entry)Builder.GetObject("EntryDescrip")).Text; // Update tasks var catCol = (ListStore)Builder.GetObject("CatStoreInDialog"); catCol.Foreach(delegate(ITreeModel model, TreePath path, TreeIter iter) { var catId = (int)model.GetValue(iter, 0); var state = (bool)model.GetValue(iter, 2); Task.SetCategory(catId, state); return(false); }); } Dialog.Hide(); AfterResponse?.Invoke(); }
private void OnResponse(object o, ResponseArgs args) { if (args.ResponseId == ResponseType.Ok) { List <string> list = new List <string>(); int min, max; if (numMin.ValueAsInt > numMax.ValueAsInt) { min = numMax.ValueAsInt; max = numMin.ValueAsInt; } else { min = numMin.ValueAsInt; max = numMax.ValueAsInt; } string wildcardSize = new string('0', numWildcardSize.ValueAsInt); for (int i = min; i < max; i++) { string url = maskedUrl.Text.Replace("*", i.ToString(wildcardSize)); if (!list.Contains(url)) { list.Add(url); } } using (var batchDlg = new AddMultipleDownloadDialog()) { foreach (var item in list) { batchDlg.Store.AddNode(new BatchDownloadNode { Checked = true, Url = item }); } batchDlg.Run(); batchDlg.Destroy(); } } }
public async Task EmitBufferTest(string uri) { var client = new SocketIO(uri); ResponseArgs arg0 = null, arg1 = null, arg2 = null; client.On("buffer to client", res => arg0 = res, res => arg1 = res, res => arg2 = res); await client.ConnectAsync(); await Task.Delay(1000); await client.EmitAsync("buffer to server", new { data1 = Encoding.UTF8.GetBytes("1") }, new { data2 = Encoding.UTF8.GetBytes("2") }, new { data3 = Encoding.UTF8.GetBytes("3") }); await Task.Delay(1000); await client.CloseAsync(); Assert.AreEqual(3, arg0.Buffers.Count); Assert.AreEqual(3, arg1.Buffers.Count); Assert.AreEqual(3, arg2.Buffers.Count); Assert.AreEqual("1 - str1", Encoding.UTF8.GetString(arg0.Buffers[0])); Assert.AreEqual("2 - str2", Encoding.UTF8.GetString(arg0.Buffers[1])); Assert.AreEqual("3 - str3", Encoding.UTF8.GetString(arg0.Buffers[2])); Assert.AreEqual("1 - str1", Encoding.UTF8.GetString(arg1.Buffers[0])); Assert.AreEqual("2 - str2", Encoding.UTF8.GetString(arg1.Buffers[1])); Assert.AreEqual("3 - str3", Encoding.UTF8.GetString(arg1.Buffers[2])); Assert.AreEqual("1 - str1", Encoding.UTF8.GetString(arg2.Buffers[0])); Assert.AreEqual("2 - str2", Encoding.UTF8.GetString(arg2.Buffers[1])); Assert.AreEqual("3 - str3", Encoding.UTF8.GetString(arg2.Buffers[2])); Assert.AreEqual("{\"data1\":{\"_placeholder\":true,\"num\":0}}", arg0.Text); Assert.AreEqual("{\"data2\":{\"_placeholder\":true,\"num\":1}}", arg1.Text); Assert.AreEqual("{\"data3\":{\"_placeholder\":true,\"num\":2}}", arg2.Text); }
public void ProcessWithTooMuchCachedDataTest() { // Arrange int actual = 0; var rs = new ResizerSection(ConfigXml); var c = new Config(rs); var target = c.Plugins.Get <TinyCachePlugin>(); int expected = 52; ResizeSettings settings = new ResizeSettings(); settings.Cache = ServerCacheMode.Default; ResponseArgs args = new ResponseArgs(); args.RewrittenQuerystring = settings; args.RequestKey = "test"; File.Delete(target.PhysicalCacheFile); target.VirtualCacheFile = "folder/TooMuch.txt"; if (Directory.Exists(Path.GetDirectoryName(target.PhysicalCacheFile))) { Directory.Delete(Path.GetDirectoryName(target.PhysicalCacheFile), true); } byte[] data = new byte[1024 * 1024]; // Act for (int i = 0; i < expected; i++) { args.ResizeImageToStream = (Stream ms) => { ms.Write(data, 0, data.Length); actual++; }; args.RequestKey = string.Format(CultureInfo.InvariantCulture, "test{0}", i); target.Process(HttpContext.Current, args); } // Assert Assert.Equal <int>(expected, actual); }
public void CanProcessNoWithNullContext() { // Arrange bool expected = false; var rs = new ResizerSection(ConfigXml); var c = new Config(rs); ICache target = (ICache)c.Plugins.Get <TinyCachePlugin>(); ResizeSettings settings = new ResizeSettings(); settings.Cache = ServerCacheMode.No; ResponseArgs args = new ResponseArgs(); args.RewrittenQuerystring = settings; // Act bool actual = target.CanProcess(null, args); // Assert Assert.Equal <bool>(expected, actual); }
protected void OnRespond(object o, ResponseArgs args) { if (args.ResponseId != Gtk.ResponseType.Ok) { return; } TreeIter iter; ArrayList list = new ArrayList(); if (storeSelected.GetIterFirst(out iter)) { do { string id = (string)storeSelected.GetValue(iter, 1); TextEncoding enc = TextEncoding.GetEncoding(id); list.Add(enc); }while (storeSelected.IterNext(ref iter)); } TextEncoding.ConversionEncodings = (TextEncoding[])list.ToArray(typeof(TextEncoding)); }
/// <summary> /// Event Handler for Dialog Response event /// </summary> private void OnDialogResponse(object o, ResponseArgs args) { // Unregister for domain events if (domainController != null) { domainController.DomainHostModified -= new DomainHostModifiedEventHandler(OnDomainHostModified); domainController.DomainLoggedIn -= new DomainLoggedInEventHandler(OnDomainLoggedIn); domainController.DomainLoggedOut -= new DomainLoggedOutEventHandler(OnDomainLoggedOut); domainController.DomainActivated -= new DomainActivatedEventHandler(OnDomainActivated); domainController.DomainInactivated -= new DomainInactivatedEventHandler(OnDomainInactivated); domainController.NewDefaultDomain -= new DomainNewDefaultEventHandler(OnNewDefaultDomain); domainController.DomainDeleted -= new DomainDeletedEventHandler(OnDomainDeleted); } }
protected virtual void HandleDlgResponse(object o, ResponseArgs args) { switch (args.ResponseId) { case ResponseType.Accept: if (OnOk()) { DialogResult = DialogResult.OK; Close(); } break; case ResponseType.Help: OnHelpRequest(EventArgs.Empty); break; default: DialogResult = DialogResult.Cancel; Close(); break; } }
/// <summary> /// Event handler for conflict dialog response /// </summary> /// <param name="obj"></param> /// <param name="args">argument for response</param> private void OnConflictDialogResponse(object obj, ResponseArgs args) { iFolderEnhancedConflictDialog conflictDialog = (iFolderEnhancedConflictDialog)obj; if (args.ResponseId == ResponseType.Help) { Util.ShowHelp("conflicts.html", this); } else { if (conflictDialog != null) { conflictDialog.Hide(); conflictDialog.Destroy(); /*if (ConflictDialogs.ContainsKey(conflictDialog.iFolder.ID)) * ConflictDialogs.Remove(conflictDialog.iFolder.ID);*/ conflictDialog = null; } } }
public void ProcessForceWriteCacheRemovalsTest() { // Arrange int actual = 0; var rs = new ResizerSection(ConfigXml); var c = new Config(rs); var target = c.Plugins.Get <TinyCachePlugin>(); int expected = target.MaxItems + 50; ResizeSettings settings = new ResizeSettings(); settings.Cache = ServerCacheMode.Default; ResponseArgs args = new ResponseArgs(); args.RewrittenQuerystring = settings; File.Delete(target.PhysicalCacheFile); target.VirtualCacheFile = "folder/TooMany.txt"; if (Directory.Exists(Path.GetDirectoryName(target.PhysicalCacheFile))) { Directory.Delete(Path.GetDirectoryName(target.PhysicalCacheFile), true); } // Act for (int i = 0; i < target.MaxItems + 50; i++) { args.ResizeImageToStream = (Stream ms) => { ms.WriteByte(99); actual++; }; args.RequestKey = string.Format(CultureInfo.InvariantCulture, "test{0}", i); target.Process(HttpContext.Current, args); } // Assert Assert.True(File.Exists(target.PhysicalCacheFile)); Assert.Equal <int>(expected, actual); }
protected void OnResponse(object o, ResponseArgs args) { if (args.ResponseId == ResponseType.Ok) { CurrencySelections.Clear(); for (int i = 0; i < CheckButtons.Length; i++) { if (CheckButtons[i].Active) { CurrencySelections.Add((Currencies)i); } } if (CurrencySelections.Count == 0) { MessageDialog message = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.Ok, "Gösterilecek kur seçmediniz."); message.Run(); message.Destroy(); } } }
private void OnResponse(object sender, ResponseArgs args) { if (args.ResponseId != ResponseType.Ok) { return; } // Check UserName if (Username == null) { string title = "Invalid UserName"; string message = "Please Set UserName, Null Username Found"; Base.Dialogs.MessageError(title, message); return; } // Check Insecure Auth Forms if (SecureAuthentication == false) { if (Ip == null) { Username = null; string title = "Invalid Ip"; string message = "Please Set Ip, Null Ip Found"; Base.Dialogs.MessageError(title, message); return; } if (Port == 0) { Username = null; string title = "Invalid Port"; string message = "Please Set Port, Null Port Found"; Base.Dialogs.MessageError(title, message); return; } } }
private void btnOk_Click(object o, ResponseArgs args) { if (args.ResponseId != ResponseType.Ok) { Destroy(); return; } try { rl = new ResourceLocation(); rl.URL = Url.ToString(); rl.Authenticate = HasAuth; if (HasAuth) { rl.Login = Username; rl.Password = Password; } rl.BindProtocolProviderType(); if (rl.ProtocolProviderType == null) { GtkUtils.ShowMessageBox(null, "Invalid URL format, please check the location field.", MessageType.Error); rl = null; return; } Destroy(); } catch (Exception) { rl = null; GtkUtils.ShowMessageBox(null, "Not recognized URL type.", MessageType.Error); Destroy(); } }
private static Response CreateResponse(ResponseArgs args, CultureInfo cultureInfo, Func <int, int> variantSelector) { ResponseTemplate template; if (responseTemplates.ContainsKey(args.ResponseType)) { template = responseTemplates[args.ResponseType]; } else { template = ErrorTemplate; } var answerId = variantSelector(template.TextAndSpeechTemplates.Length); var textAndSpeechTemplate = template.TextAndSpeechTemplates[answerId]; return(new Response() { Text = textAndSpeechTemplate.FormatText(cultureInfo, args.Data), Tts = textAndSpeechTemplate.FormatSpeech(cultureInfo, args.Data), Buttons = template.Buttons }); }
void OnDialogResponse(object o, ResponseArgs args) { if (!args.ResponseId.Equals(ResponseType.Cancel) && !args.ResponseId.Equals(ResponseType.DeleteEvent)) { var distance = Convert.ToInt32(distanceEntry.Text); var minutes = Convert.ToInt32(minutesEntry.Text); var date = dateEntry.Date; //ResponseType.Accept -> Add new exercise if (args.ResponseId.Equals(ResponseType.Accept)) { ex = new Exercise(distance, minutes, date); } //ResponseType.Apply -> Edit exercise if (args.ResponseId.Equals(ResponseType.Apply)) { ex.Distance = distance; ex.Minutes = minutes; ex.Date = date; } } }