/// <summary> /// 控制命令执行的事件处理 /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void UpdateCommandExecuteInfo(Object sender, CommandExecuteEventArgs args) { string info = string.Empty; info = string.Format("{0}号设备:{1}操作命令已执行!", args.DevNo, args.CmdType); memoClipboard.MaskBox.AppendText(info + "\r\n"); }
public void TestHandlerRequiresAuth(bool actionRequiresAuth, bool transactionRequiresAuth, bool authenticated) { using (ShimsContext.Create()) { Transaction.SettingsGet = () => new StubIReceiveSettings { RequireAuthGet = () => transactionRequiresAuth }; AddTransactionProperty("Authenticated", authenticated); var handler = new AUTHHandler(GetDefaulLoader()); var otherHandler = actionRequiresAuth ? (ICommandHandler) new HandlerWithRequiresAuth() : new StubICommandHandler(); var args = new CommandExecuteEventArgs(Transaction, otherHandler, ""); handler.OnCommandExecute(otherHandler, args); if (actionRequiresAuth && transactionRequiresAuth && !authenticated) { Assert.NotNull(args.Response); Assert.Equal(SMTPStatusCode.AuthRequired, args.Response.Code); } else { Assert.Null(args.Response); } } }
public void TestOnCommandExecute(bool unsecuredAllowed, bool requireEncryption, bool isSecured, bool error) { using (ShimsContext.Create()) { Transaction.SettingsGet = () => new StubIReceiveSettings { RequireTLSGet = () => requireEncryption }; Transaction.TLSActiveGet = () => isSecured; ICommandHandler otherHandler = unsecuredAllowed ? (ICommandHandler) new HandlerWithUnsecureAllowed() : new StubICommandHandler(); var handler = new STARTTLSHandler(); var args = new CommandExecuteEventArgs(Transaction, otherHandler, ""); handler.OnCommandExecute(otherHandler, args); if (error) { Assert.NotNull(args.Response); Assert.Equal(SMTPStatusCode.AuthRequired, args.Response.Code); } else { Assert.Null(args.Response); } } }
protected virtual void OnCommandExecute(CommandExecuteEventArgs e) { if (CommandExecute != null) { CommandExecute(this, e); } }
/// <summary> /// 控制命令执行的事件处理 /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void UpdateCommandExecuteInfo(Object sender, CommandExecuteEventArgs args) { string info = string.Empty; info = string.Format("{0}号设备:{1}操作命令已执行!", args.DevNo, args.CmdType); lsbInfoBoard.Items.Add(info); }
public override string Execute(Maoubot mb, CommandExecuteEventArgs e) { if (!MayExecute(e.Permission)) { return(null); } //if (e.CommandArgs.Length < 1) return GetHelp(mb); String c = (e.CommandArgs.Length >= 1) ? e.CommandArgs[0] : String.Empty; String sc = (e.CommandArgs.Length >= 2) ? e.CommandArgs[1] : String.Empty; String c_ = String.Empty; foreach (ChatCommand cc in mb.GetCommands()) { if (cc.Command == c) { return(cc.GetHelp(mb, sc)); } c_ += cc.Command; if (!(cc == mb.GetCommands().Last())) { c_ += ", "; } } return(String.Format("Available Commands: {0}!", c_)); }
private void OnHandleAddSummaryField(object sender, CommandExecuteEventArgs e) { var designPanel = designMdiController.ActiveDesignPanel; var node = (DataMemberListNodeBase)e.Args[0]; var report = designPanel.Report; var designerHost = designPanel.GetService <IDesignerHost>(); var changeServ = designPanel.GetService <IComponentChangeService>(); var selectionServ = designPanel.GetService <ISelectionService>(); // Functionality patterned after AddCalculatedField() from DevExpress.XtraReports.Design.Commands.FieldListCommandExecutor, DevExpress.XtraReports.v16.1.Extensions.dll, Version=16.1.4.0 var c = new SummaryField { DataSource = node.DataSource != report.DataSource ? node.DataSource : null, DataMember = node.DataMember ?? string.Empty }; var description = $"Add {nameof(SummaryField)} object"; var transaction = designerHost.CreateTransaction(description); try { var propertyDescriptor = XRAccessor.GetPropertyDescriptor(report, "CalculatedFields"); changeServ.OnComponentChanging(report, propertyDescriptor); DesignToolHelper.AddToContainer(designerHost, c); report.CalculatedFields.Add(c); changeServ.OnComponentChanged(report, propertyDescriptor, null, null); } finally { transaction.Commit(); } selectionServ.SetSelectedComponents(new[] { c }); }
public override string Execute(Maoubot mb, CommandExecuteEventArgs e) { if (e.CommandArgs.Length == 0) { return(GetHelp(mb)); } return(String.Format("Cat. {0}", String.Join(" ", e.CommandArgs))); }
/// <summary> /// 控制命令执行的事件处理 /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void UpdateCommandExecuteInfo(Object sender, CommandExecuteEventArgs args) { string info = string.Empty; info = string.Format("{0}区系统:{1}操作命令已执行!", args.DevNo, args.CmdType); UpdateClipBoardInfo(info); }
public override string Execute(Maoubot mb, CommandExecuteEventArgs e) { if (!MayExecute(e.Permission)) { return(String.Empty); } return(Format(Output, e)); }
protected virtual void OnCommandExecuted(string commandName) { var args = new CommandExecuteEventArgs(((IDictionary <string, object>)Commands)[commandName] as INamedCommand); _commandExecuted?.Invoke(this, args); if (_commandHandlersByName.TryGetValue(commandName, out var handler)) { handler?.Invoke(this, args); } }
/// <summary> /// Executes the commands /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Tcb_CommandExecute(object sender, CommandExecuteEventArgs e) { if (!BotFile.EnableCommands) { return; } //if (!IsWhisper && OnlyAllowWhisperCommands) return; Console.WriteLine("Executing {0}. Whisper: {1}", e.Command, e.IsWhisper); // TextCommands. foreach (TextCommand tc in BotFile.TextCommands) { if (tc.Command == e.Command) { if (tc.MayExecute(e.Permission)) { if (e.IsWhisper) { Tcb.SendWhisperMessage(e.Nick, tc.Format(e)); } else { Tcb.SendChatMessage(tc.Format(e)); } } return; } } foreach (ChatCommand cc in Commands) { if (cc.Command == e.Command) { String Output = cc.Execute(this, e); if (String.IsNullOrEmpty(Output)) { return; } if (e.IsWhisper) { Tcb.SendWhisperMessage(e.Nick, Output); } else { Tcb.SendChatMessage(Output); } return; } } }
public override bool Execute(CommandExecuteEventArgs args) { if (_forEdit) { SuperController.singleton.LoadSceneForEditDialog(); } else { SuperController.singleton.LoadSceneDialog(); } return(true); }
public override bool Execute(CommandExecuteEventArgs args) { switch (SuperController.singleton.gameMode) { case SuperController.GameMode.Edit: SuperController.singleton.gameMode = SuperController.GameMode.Play; break; case SuperController.GameMode.Play: SuperController.singleton.gameMode = SuperController.GameMode.Edit; break; } return(true); }
public override bool Execute(CommandExecuteEventArgs args) { var panel = SuperController.singleton.errorLogPanel.Find("Panel"); var panelIsShowing = panel?.gameObject.activeInHierarchy ?? false; if (panelIsShowing) { SuperController.singleton.CloseErrorLogPanel(); } else { SuperController.singleton.OpenErrorLogPanel(); } return(true); }
public static String Format(String Input, CommandExecuteEventArgs e, params Object[] format) { String LastIteration = Input; int Depth = 0; do { Depth++; LastIteration = Input; Input = String.Format(Input, format); Input = Input.Replace("%nick%", e.Nick); Input = Input.Replace("%name%", e.Nick); Input = Input.Replace("%permission%", e.Permission.ToString()); Input = Input.Replace("%turbo%", e.IsTurbo.ToString()); Input = Input.Replace("%time%", DateTime.Now.ToString()); Input = Input.Replace("%cargs%", String.Join(" ", e.CommandArgs)); Input = Input.Replace("%noma-brainpower%", @"O-oooooooooo AAAAE-A-A-I-A-U- JO-oooooooooooo AAE-O-A-A-U-U-A- E-eee-ee-eee AAAAE-A-E-I-E-A- JO-ooo-oo-oo-oo EEEEO-A-AAA-AAAA"); // replace "tag[/w+]" to the e.GetSafeTag(/w+) Regex TagRegex = new Regex(@"%tag\[[\w|\-]+\]%"); MatchCollection TagRegexCollection = TagRegex.Matches(Input); foreach (Match Match in TagRegexCollection) { String Result = Match.Value; if (!Result.Substring(1, Result.Length - 2).Contains("%")) // Make sure it isn't a layered tag ( Like: %tag[%cArgs%]% ) { String TagName = e.GetSafeTag(Result.Substring(5, Result.Length - 7)); Input = Input.Replace(Result, TagName); } } }while (LastIteration != Input && !(Depth >= 10)); if (Input.Length >= MAX_MESSAGE_LENGTH) { Console.WriteLine("String cut, Length: {0}", Input.Length); Input = Input.Substring(0, MAX_MESSAGE_LENGTH); } return(Input); }
public override String Execute(Maoubot mb, CommandExecuteEventArgs e) { if (e.IsWhisper) { return("This command is not available in whisper mode"); } if (!MayExecute(e.Permission)) { return(String.Empty); } if (e.CommandArgs.Length == 0) { return(GetHelp(mb)); } Random r = new Random(); return(String.Format("{0}: {1}", e.Nick, BallMessages[r.Next(BallMessages.Length)])); }
private void OnHandleAddSummaryField(object sender, CommandExecuteEventArgs e) { var designPanel = designMdiController.ActiveDesignPanel; var fieldListControl = ((FieldListDockPanel)designDockManager[DesignDockPanelType.FieldList]).GetFieldList(); var node = fieldListControl.DataMemberNode; if (node == null) { return; } if (!node.IsList) { node = (DataMemberListNodeBase)node.ParentNode; } var report = designPanel.Report; var designerHost = designPanel.GetService <IDesignerHost>(); var changeServ = designPanel.GetService <IComponentChangeService>(); var selectionServ = designPanel.GetService <ISelectionService>(); // Functionality patterned after AddCalculatedField() from DevExpress.XtraReports.Design.Commands.FieldListCommandExecutor, DevExpress.XtraReports.v14.1.Extensions.dll, Version=14.1.5.0 var c = new SummaryField { DataSource = node.DataSource != report.DataSource ? node.DataSource : null, DataMember = node.DataMember ?? string.Empty }; var description = string.Format("Add {0} object", typeof(SummaryField).Name); var transaction = designerHost.CreateTransaction(description); try { var propertyDescriptor = XRAccessor.GetPropertyDescriptor(report, "CalculatedFields"); changeServ.OnComponentChanging(report, propertyDescriptor); DesignToolHelper.AddToContainer(designerHost, c); report.CalculatedFields.Add(c); changeServ.OnComponentChanged(report, propertyDescriptor, null, null); } finally { transaction.Commit(); } selectionServ.SetSelectedComponents(new[] { c }); }
public override bool Execute(CommandExecuteEventArgs args) { SuperController.singleton.SetFreezeAnimation(!SuperController.singleton.freezeAnimation); return(true); }
public override string Execute(Maoubot mb, CommandExecuteEventArgs e) { return(String.Format("Cheered bits: {0}!", mb.BotFile.CheeredBits)); }
public override bool Execute(CommandExecuteEventArgs args) { SuperController.singleton.HardReset(); return(true); }
public override string Execute(Maoubot mb, CommandExecuteEventArgs e) { if (!MayExecute(e.Permission)) { return(null); } if (e.CommandArgs.Length == 0) { // Add somebody to the queue. if (!Queue.Contains(e.Nick)) { Queue.Add(e.Nick); return(String.Format("{0}: Added you to the queue. Position #{1}", e.Nick, Queue.Count)); } else { return(String.Format("{0}: You're at position #{1} in the queue.", e.Nick, Queue.IndexOf(e.Nick))); } } else { String SubCommand = e.CommandArgs[0]; if (SubCommand == @"list") { String l = "Current queue: "; int names_to_display = 5; for (int i = 0; i < names_to_display && i < Queue.Count; i++) { l += String.Format("{0}", Queue[i]); if (i < Queue.Count - 1 && i < names_to_display - 1) { l += ", "; } } if (Queue.Count > 5) { l += String.Format(" | {0} people left", Queue.Count - 5); } return(l); } else if (SubCommand == @"next") { if (e.Permission >= Permission.Moderator) { if (Queue.Count < 1) { return("The queue is empty. :("); } String NextPerson = Queue[0]; Queue.RemoveAt(0); return(String.Format("Next is: {0}", NextPerson)); } else { return(String.Empty); } } else if (SubCommand == @"clear") { if (e.Permission >= Permission.Moderator) { Queue.Clear(); return("Queue has been cleared."); } else { return(String.Empty); } } else if (SubCommand == @"addrange") { if (e.Permission < Permission.Moderator) { return(null); } List <String> ca = e.CommandArgs.ToList(); ca.RemoveAt(0); ca = String.Join(",", ca).Replace(",,", ",").Split(',').ToList(); foreach (String name in ca) { if (!Queue.Contains(name)) { Queue.Add(name); } else { ca.Remove(name); } } return(String.Format("Added {0} people to the queue. Total: {1}", ca.Count, this.Queue.Count)); } } return(null); }
public override String Execute(Maoubot mb, CommandExecuteEventArgs e) { if (this.Permission >= Permission.Subscriber && e.IsWhisper) { return("This command is not available in whisper mode"); } if (!MayExecute(e.Permission)) { return(String.Empty); } if (e.CommandArgs.Length >= 1) { String SubCommand = e.CommandArgs[0]; if (SubCommand == "add") { if (e.CommandArgs.Length >= 3) { String Command = e.CommandArgs[1]; String Text = String.Empty; List <String> t_ = e.CommandArgs.ToList(); t_.RemoveAt(0); // remove the "add"-subcommand t_.RemoveAt(0); // remove the commandname Text = String.Join(" ", t_); // Check if the command already exists.. if (mb.BotFile.UpdateCommand(Command, Text)) { return(String.Format("{0}: Command updated.", e.Nick)); } mb.BotFile.AddCommand(Command, Text); mb.RefreshCommands(); return(String.Format("{0}: Added command", e.Nick)); } else { return(GetHelp(mb, SubCommand)); } } else if (SubCommand == "delete") { if (e.CommandArgs.Length >= 2) { String Command = e.CommandArgs[1]; if (mb.BotFile.DeleteCommand(Command)) { mb.RefreshCommands(); return(String.Format("{0}: Command deleted", e.Nick)); } else { return(String.Format("{0}: Command not found!", e.Nick)); } } else { return(GetHelp(mb, SubCommand)); } } else { return(GetHelp(mb)); } } else { return(GetHelp(mb)); } }
public override bool Execute(CommandExecuteEventArgs args) { SuperController.singleton.gameMode = _mode; return(true); }
public override bool Execute(CommandExecuteEventArgs args) { SuperController.singleton.SelectModeScreenshot(); return(true); }
public abstract bool Execute(CommandExecuteEventArgs args);
void OnHandleHideGrid(object sender, CommandExecuteEventArgs e) { SetDrawGrid(false); }
void OnHandleShowGrid(object sender, CommandExecuteEventArgs e) { SetDrawGrid(true); }
private void OnHandleAddSummaryField(object sender, CommandExecuteEventArgs e) { var designPanel = designMdiController.ActiveDesignPanel; var fieldListControl = ((FieldListDockPanel)designDockManager[DesignDockPanelType.FieldList]).GetFieldList(); var node = fieldListControl.DataMemberNode; if (node == null) return; if (!node.IsList) node = (DataMemberListNodeBase)node.ParentNode; var report = designPanel.Report; var designerHost = designPanel.GetService<IDesignerHost>(); var changeServ = designPanel.GetService<IComponentChangeService>(); var selectionServ = designPanel.GetService<ISelectionService>(); // Functionality patterned after AddCalculatedField() from DevExpress.XtraReports.Design.Commands.FieldListCommandExecutor, DevExpress.XtraReports.v14.1.Extensions.dll, Version=14.1.5.0 var c = new SummaryField { DataSource = node.DataSource != report.DataSource ? node.DataSource : null, DataMember = node.DataMember ?? string.Empty }; var description = string.Format("Add {0} object", typeof(SummaryField).Name); var transaction = designerHost.CreateTransaction(description); try { var propertyDescriptor = XRAccessor.GetPropertyDescriptor(report, "CalculatedFields"); changeServ.OnComponentChanging(report, propertyDescriptor); DesignToolHelper.AddToContainer(designerHost, c); report.CalculatedFields.Add(c); changeServ.OnComponentChanged(report, propertyDescriptor, null, null); } finally { transaction.Commit(); } selectionServ.SetSelectedComponents(new[] { c }); }
public override bool Execute(CommandExecuteEventArgs args) { SuperController.singleton.RescanPackages(); return(true); }
public String Format(CommandExecuteEventArgs e) { return(Format(Output, e)); }