/// <summary> 执行外部命令,并且在执行命令之前,自动将 事务打开</summary> /// <param name="cmd">要执行的命令</param> public static void ExecuteCommand(ExternalCommand cmd) { using (DocumentModifier docMdf = new DocumentModifier(openDebugerText: true)) { try { var impliedSelection = docMdf.acEditor.SelectImplied().Value; var res = cmd(docMdf, impliedSelection); // switch (res) { case ExternalCmdResult.Commit: docMdf.acTransaction.Commit(); break; case ExternalCmdResult.Cancel: docMdf.acTransaction.Abort(); break; default: docMdf.acTransaction.Abort(); break; } } catch (System.Exception ex) { docMdf.acTransaction.Abort(); // Abort the transaction and rollback to the previous state string errorMessage = ex.Message + "\r\n\r\n" + ex.StackTrace; MessageBox.Show(errorMessage, @"出错", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
void Awake() { resetParameters = new Dictionary <string, float>(); foreach (ResetParameter kv in defaultResetParameters) { resetParameters[kv.key] = kv.value; } GetBrains(gameObject, brains); InitializeAcademy(); foreach (Brain brain in brains) { brain.InitializeBrain(); } if (communicator != null) { communicator.InitializeCommunicator(); externalCommand = communicator.GetCommand(); } windowResize = true; done = true; acceptingSteps = true; }
/// <summary> 执行外部命令,并且在执行命令之前,自动将 事务打开</summary> /// <param name="cmd">要执行的命令</param> public static void ExecuteCommand(ExternalCommand cmd) { using (DocumentModifier docMdf = new DocumentModifier(openDebugerText: true)) { try { // 刷新所有的全局选项到内存中 DbXdata.LoadAllOptionsFromDbToMemory(docMdf); // var impliedSelection = docMdf.acEditor.SelectImplied().Value; var res = cmd(docMdf, impliedSelection); // switch (res) { case ExternalCmdResult.Commit: docMdf.acTransaction.Commit(); break; case ExternalCmdResult.Cancel: docMdf.acTransaction.Abort(); break; default: docMdf.acTransaction.Abort(); break; } } catch (System.Exception ex) { docMdf.acTransaction.Abort(); // Abort the transaction and rollback to the previous state MessageBox.Show(ex.AppendMessage(), @"出错", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
void Awake() { resetParameters = new Dictionary <string, float>(); foreach (ResetParameter kv in defaultResetParameters) { resetParameters[kv.key] = kv.value; } GetBrains(gameObject, brains); InitializeAcademy(); communicator = new ExternalCommunicator(this); if (!communicator.CommunicatorHandShake()) { communicator = null; } foreach (Brain brain in brains) { brain.InitializeBrain(); } if (communicator != null) { communicator.InitializeCommunicator(); externalCommand = communicator.GetCommand(); } isInference = (communicator == null); _isCurrentlyInference = !isInference; done = true; acceptingSteps = true; }
private void OpenEditorWindow(ExternalCommand command) { if (command == null) { command = new ExternalCommand(); } var vm = new CommandEditorWindowViewModel(command, ExternalCommands); var window = new CommandEditorWindow() { DataContext = vm }; window.ShowDialog(); if (!vm.IsDone || command.Equals(vm.Command)) { return; } var index = ExternalCommands.IndexOf(command); if (index >= 0) { RemoveExternalComand(command); ExternalCommands.Insert(index, vm.Command); } else { ExternalCommands.Add(vm.Command); } IsDirty = true; UpdateView(); }
private void OnExternalCommandSelected(ExternalCommand ec) { this.lastSelectedExternalCommand = ec; EventHandler handler = this.ExternalCommandSelected; if (null != handler) { handler(this, EventArgs.Empty); } }
void radio_CheckedChanged(object sender, EventArgs e) { RadioButton radio = (RadioButton)sender; if (radio.Checked) { _selectedCommand = (ExternalCommand)radio.Tag; } }
public CommandEditorWindowViewModel(ExternalCommand command, List <ExternalCommand> commands) { this.commands = commands; this.originalName = command.Name; Command = new ExternalCommand(command.Name, command.Command, command.Args); CancelCommand = new DelegateCommand <Window>(Cancel); ApplyCommand = new DelegateCommand <Window>(Apply); }
private void btnInsert_Click(object sender, EventArgs e) { ExternalCommand ec = new ExternalCommand(this.txtTitle.Text, this.txtFile.Text, this.txtArg.Text); if(this.lboxCommands.SelectedIndex < 0) { Program.ExternalCommandsManager.Add(ec); } else { Program.ExternalCommandsManager.Insert(this.lboxCommands.SelectedIndex + 1, ec); this.lboxCommands.SelectedIndex++; } }
public MainWindow() { InitializeComponent(); if (cmd == null) { cmd = new ExternalCommand(); } if (ee == null) { ee = ExternalEvent.Create(cmd); } }
public TerminalViewModel() { CloudSetupProcess = new CloudSetupProcess("..\\..\\..\\Configs\\WireCloud\\cloudConfig.xml"); CloudSetupProcess.LinksCreated += new LinksCreatedHandler(onLinksCreated); CloudSetupProcess.LinkCreated += new LinkCreatedHandler(onLinkCreated); CloudSetupProcess.StartCloudProcess(); prepareLinkAction(); PerformLinkAction = new ExternalCommand(performAction, areActionElementsReady); CloseAllConections = new ExternalCommand(performCloseConnections, isClosingReady); CreateLink = new ExternalCommand(createLink, isCreationReady); DeleteLink = new ExternalCommand(deleteLink, isLinkSelected); }
void GinCommandsToolBox_MouseMove(object sender, MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { if (dragBoxFromMouseDown != Rectangle.Empty && !dragBoxFromMouseDown.Contains(e.X, e.Y)) { screenOffset = SystemInformation.WorkingArea.Location; ExternalCommand command = (ExternalCommand)draggedListItem.Tag; if (command != null) { DragDropEffects dropEffect = this.DoDragDrop(command, DragDropEffects.All | DragDropEffects.Link); } } } }
internal static ExternalCommandResult DebugInAddinManager(ExternalCommand cmd, SelectionSet impliedSelection, ref string errorMessage, ref IList <ObjectId> elementSet) { var dat = new DllActivator_RESD(); dat.ActivateReferences(); using (var docMdf = new DocumentModifier(true)) { try { // 先换个行,显示效果更清爽 docMdf.WriteNow("\n"); // 刷新所有的全局选项到内存中 DbXdata.LoadAllOptionsFromDbToMemory(docMdf); // 运行具体的命令 var canCommit = cmd(docMdf, impliedSelection); // switch (canCommit) { case ExternalCmdResult.Commit: docMdf.acTransaction.Commit(); return(ExternalCommandResult.Succeeded); break; case ExternalCmdResult.Cancel: docMdf.acTransaction.Abort(); return(ExternalCommandResult.Cancelled); break; default: docMdf.acTransaction.Abort(); return(ExternalCommandResult.Cancelled); break; } } catch (Exception ex) { docMdf.acTransaction.Abort(); // Abort the transaction and rollback to the previous state errorMessage = ex.AppendMessage(); return(ExternalCommandResult.Failed); } } }
internal static ExternalCommandResult DebugInAddinManager(ExternalCommand cmd, SelectionSet impliedSelection, ref string errorMessage, ref IList <ObjectId> elementSet) { var dat = new DllActivator_eZcadTools(); dat.ActivateReferences(); using (var docMdf = new DocumentModifier(true)) { try { // 先换个行,显示效果更清爽 docMdf.WriteNow("\n"); var canCommit = cmd(docMdf, impliedSelection); // switch (canCommit) { case ExternalCmdResult.Commit: docMdf.acTransaction.Commit(); return(ExternalCommandResult.Succeeded); break; case ExternalCmdResult.Cancel: docMdf.acTransaction.Abort(); return(ExternalCommandResult.Cancelled); break; default: docMdf.acTransaction.Abort(); return(ExternalCommandResult.Cancelled); break; } } catch (Exception ex) { docMdf.acTransaction.Abort(); // Abort the transaction and rollback to the previous state errorMessage = ex.Message + "\r\n\r\n" + ex.StackTrace; return(ExternalCommandResult.Failed); } } }
private CommandTreeNode IntermediateWithSequence(TreeNodeData currentNodeData) { CommandTreeNode sequenceCommandsTreeNode = null; GinMetaData metaData = GinMetaData.GetInstance(); ExternalCommand sequence = metaData.Commands.Where(c => c.Instance is CommandSequence).FirstOrDefault(); if (sequence != null) { IEnumerable <CommandTreeNode> removedNodes = currentNodeData.Node.Childs; currentNodeData.Node.ClearChilds(); CommandTreeNode sequenceTreeNode = AppendCommandAfter(currentNodeData.Node, sequence.Instance, null); sequenceCommandsTreeNode = sequenceTreeNode.Childs.FirstOrDefault(); foreach (CommandTreeNode node in removedNodes) { AppendCommandAfter(sequenceCommandsTreeNode, node.Data.Command, null); } } return(sequenceCommandsTreeNode); }
public void InitDroppedCommands(ExternalCommand[] commands) { panelCommands.SuspendLayout(); panelCommands.Controls.Clear(); bool isFirstRadio = true; foreach (ExternalCommand command in commands) { RadioButton radio = new RadioButton(); radio.Text = command.Metadata.Name; radio.Tag = command; radio.CheckedChanged += new EventHandler(radio_CheckedChanged); if (isFirstRadio) { radio.Checked = true; isFirstRadio = false; } panelCommands.Controls.Add(radio); } panelCommands.ResumeLayout(); AdjustControlSize(); }
/// <summary> /// 用于在调试完成后,最终在 Excel 的 UI 界面中,通过界面中的按钮执行相关操作 /// </summary> /// <param name="cmd"></param> /// <param name="excelApp"></param> /// <param name="errorMessage"></param> /// <param name="errorRange"></param> /// <returns></returns> public static ExternalCommandResult ExecuteInRibbon(ExternalCommand cmd, Application excelApp, ref string errorMessage, ref Range errorRange) { //DllActivator_eZx dat = new DllActivator_eZx(); //dat.ActivateReferences(); try { var res = cmd(excelApp); switch (res) { } return(res); } catch (Exception ex) { errorMessage = ex.Message + "\r\n\r\n" + ex.StackTrace; return(ExternalCommandResult.Failed); } finally { excelApp.ScreenUpdating = true; } }
/// Listens to the socket for a command and returns the corresponding /// External Command. public void UpdateCommand() { int location = sender.Receive(messageHolder); string message = Encoding.ASCII.GetString(messageHolder, 0, location); switch (message) { case "STEP": command = ExternalCommand.STEP; break; case "RESET": command = ExternalCommand.RESET; break; case "QUIT": command = ExternalCommand.QUIT; break; default: command = ExternalCommand.QUIT; break; } }
// Contains logic for taking steps in environment simulation. /** Based on presence of communicator, inference mode, and frameSkip, * decides whether the environment should be stepped or reset. */ void RunMdp() { if (isInference != _isCurrentlyInference) { ConfigureEngine(); _isCurrentlyInference = isInference; } if ((isInference) && (timeAtStep + waitTime > Time.time)) { return; } timeAtStep = Time.time; framesSinceAction += 1; currentStep += 1; if ((currentStep >= maxSteps) && maxSteps > 0) { done = true; } if ((framesSinceAction > frameToSkip) || done) { skippingFrames = false; framesSinceAction = 0; } else { skippingFrames = true; } if (skippingFrames == false) { if (communicator != null) { if (externalCommand == ExternalCommand.STEP) { Step(); externalCommand = communicator.GetCommand(); } if (externalCommand == ExternalCommand.RESET) { Dictionary <string, float> NewResetParameters = communicator.GetResetParameters(); foreach (KeyValuePair <string, float> kv in NewResetParameters) { resetParameters[kv.Key] = kv.Value; } Reset(); externalCommand = ExternalCommand.STEP; RunMdp(); return; } if (externalCommand == ExternalCommand.QUIT) { Application.Quit(); return; } } else { if (done) { Reset(); RunMdp(); return; } else { Step(); } } DecideAction(); AcademyStep(); foreach (Brain brain in brains) { brain.Step(); } } }
private void _tree_DragDrop(object sender, DragEventArgs e) { bool needRebuild = false; if (e.Data.GetDataPresent(typeof(ExternalCommand))) { ExternalCommand command = (ExternalCommand)e.Data.GetData(typeof(ExternalCommand)); if (e.Effect == DragDropEffects.Move) { if (_nodeWhereToDrop != null) { Command newInstance = command.Clone().Instance; InsertCommandIntoTree((TreeNodeData)_nodeWhereToDrop.Tag, newInstance); needRebuild = true; } } } if (e.Data.GetDataPresent(typeof(TreeNodeData))) { TreeNodeData data = (TreeNodeData)e.Data.GetData(typeof(TreeNodeData)); if (e.Effect == DragDropEffects.Move || e.Effect == DragDropEffects.Copy) { if (_nodeWhereToDrop != null) { Command cmd = data.Command; if (e.Effect == DragDropEffects.Copy) { cmd = data.Command.Copy(); } ExternalCommand command = new ExternalCommand(cmd); TreeNodeData dataWhereToDrop = (TreeNodeData)_nodeWhereToDrop.Tag; if (data.Node.HasNested(dataWhereToDrop.Node)) { return; } bool commandMoved = InsertCommandIntoTree(dataWhereToDrop, command.Instance); needRebuild = commandMoved; if (commandMoved && e.Effect == DragDropEffects.Move) { data.Node.Remove(); } } } } if (e.Data.GetDataPresent("FileDrop")) { if (e.Effect == DragDropEffects.Move) { if (_nodeWhereToDrop != null) { string[] fileNames = (string[])e.Data.GetData("FileDrop"); GinMetaData metadata = GinMetaData.GetInstance(); bool applyToAllCommands = false; ExternalCommand selectedCommand = null; int lastIndex = -1; for (int i = 0; i < fileNames.Length; i++) { string fileName = fileNames[i]; ExternalCommand[] commands = metadata.GetAssumedCommands(fileName); if (commands.Length == 0) { return; } if (commands.Length == 1) { InsertCommandIntoTree((TreeNodeData)_nodeWhereToDrop.Tag, commands[0].Instance); needRebuild = true; return; } if (commands.Length > 1) { ChooseDroppedCommandForm form = new ChooseDroppedCommandForm(); form.InitDroppedCommands(commands); if (form.ShowDialog() == DialogResult.OK) { InsertCommandIntoTree((TreeNodeData)_nodeWhereToDrop.Tag, form.SelectedExternalCommand.Instance); needRebuild = true; applyToAllCommands = form.ApplyToAllCommands; if (applyToAllCommands) { selectedCommand = form.SelectedExternalCommand; lastIndex = i; break; } } } } if (applyToAllCommands) { for (int i = lastIndex + 1; i < fileNames.Length; i++) { string fileName = fileNames[i]; InsertCommandIntoTree((TreeNodeData)_nodeWhereToDrop.Tag, selectedCommand.Instance); needRebuild = true; } } } } } if (needRebuild) { ((TreeNodeData)_rootNode.Nodes[0].Tag).Node.Rebuild(true); } }
public ToolStripMenuItemWithExternalCommand(ExternalCommand ec) : base(ec.Title) { this.ec = ec; }
private void btnModify_Click(object sender, EventArgs e) { ExternalCommand ec = new ExternalCommand(this.txtTitle.Text, this.txtFile.Text, this.txtArg.Text); Program.ExternalCommandsManager.BeginUpdate(); Program.ExternalCommandsManager.RemoveAt(this.lboxCommands.SelectedIndex); Program.ExternalCommandsManager.Insert(this.lboxCommands.SelectedIndex, ec); Program.ExternalCommandsManager.EndUpdate(); }
void radio_CheckedChanged(object sender, EventArgs e) { RadioButton radio = (RadioButton)sender; if (radio.Checked) { _selectedCommand = (ExternalCommand)radio.Tag; } }
public void SetCommand(ExternalCommand c) { command = c; }
private void RemoveExternalComand(ExternalCommand command) { IsDirty |= ExternalCommands.Remove(command); UpdateView(); }