private void AddGroupPlacement(Button button, CommandID commandBar) { string key = button.Command.ToString() + commandBar.ToString(); if (!placements.ContainsKey(key)) { // Create or get the gruop associted with commandBar NewGroup newGroup = CreateNewGroup(commandBar.ToString(), button.Priority, commandBar); CMDPlacement placement = new CMDPlacement(button.Command, newGroup.Group, button.Priority); placements.Add(key, placement); } }
/// <summary> /// Main goal of the constructor is to extract command text template /// for the resources. /// </summary> protected BaseCommand() { // Univeral prefix for all commands string resourceName = "Command"; // Determine group specific prefix part if (GroupID == GuidList.guidMySqlProviderCmdSet) { resourceName += '_'; } else if (GroupID == GuidList.guidDataCmdSet) { resourceName += "BuiltIn_"; } else { resourceName += GroupID.ToString(); } // Append command ID resourceName += CommandID.ToString("X", CultureInfo.InvariantCulture); // Extract resource string commandTextVal = Resources.ResourceManager.GetString(resourceName); }
/// <summary> /// Saves the command to the specified file. /// </summary> public bool Save(string fileName, out string errMsg) { try { StringBuilder sb = new StringBuilder("[TeleCommand]") .Append("CommandID=").AppendLine(CommandID.ToString()) .Append("CreationTime=").AppendLine(CreationTime.ToString(DateTimeFormatInfo.InvariantInfo)) .Append("UserID=").AppendLine(UserID.ToString()) .Append("OutCnlNum=").AppendLine(OutCnlNum.ToString()) .Append("CmdTypeID=").AppendLine(CmdTypeID.ToString()) .Append("ObjNum=").AppendLine(ObjNum.ToString()) .Append("DeviceNum=").AppendLine(DeviceNum.ToString()) .Append("CmdNum=").AppendLine(CmdNum.ToString()) .Append("CmdCode=").AppendLine("CmdCode") .Append("CmdVal=").AppendLine(CmdVal.ToString(NumberFormatInfo.InvariantInfo)) .Append("CmdData=").AppendLine(ScadaUtils.BytesToHex(CmdData)) .Append("RecursionLevel=").AppendLine(RecursionLevel.ToString()) .AppendLine("End="); using (StreamWriter writer = new StreamWriter(fileName, false, Encoding.UTF8)) { writer.Write(sb.ToString()); } errMsg = ""; return(false); } catch (Exception ex) { errMsg = string.Format(Locale.IsRussian ? "Ошибка при сохранении команды ТУ: " : "Error saving telecontrol command: ") + ex.Message; return(false); } }
public void ToString_Invoke_ReturnsExpected() { Guid guid = Guid.NewGuid(); var commandId = new CommandID(guid, 10); Assert.Equal($"{guid} : 10", commandId.ToString()); }
private void AddCommand(Button button, Configuration.RecipeHostData hostData) { buttons.Add(button); //Uncomment if you need to support visibility for a command //visibilities.Add(new Visibility(button.Command, new Guid(UIContextGuids.SolutionExists))); if (hostData != null && hostData.CommandBar != null) { if (hostData.CommandBar.Length == 0) { // Check that we always get at least one command bar return; } Dictionary <CommandID, string> installedBars = new Dictionary <CommandID, string>(); for (int iCommand = 0; iCommand < hostData.CommandBar.Length; iCommand++) { Configuration.CommandBar configCommandBar = hostData.CommandBar[iCommand]; CommandID commandBar = GetCommandID(configCommandBar); CommandID parentCommandBar = GetCommandParentID(configCommandBar); if (installedBars.ContainsKey(parentCommandBar)) { throw new InvalidOperationException( String.Format(Properties.Resources.CTC_RepeatedCommandBar, parentCommandBar.ToString())); } else { AddGroupPlacement(button, commandBar); installedBars.Add(parentCommandBar, commandBar.ToString()); } } } }
/// <summary> /// Saves the options to the specified writer. /// </summary> public void Save(Stream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } StringBuilder sb = new StringBuilder() .AppendLine("[TeleCommand]") .Append("CommandID=").AppendLine(CommandID.ToString()) .Append("CreationTime=").AppendLine(CreationTime.ToString(DateTimeFormatInfo.InvariantInfo)) .Append("ClientName=").AppendLine(ClientName) .Append("UserID=").AppendLine(UserID.ToString()) .Append("CnlNum=").AppendLine(CnlNum.ToString()) .Append("ObjNum=").AppendLine(ObjNum.ToString()) .Append("DeviceNum=").AppendLine(DeviceNum.ToString()) .Append("CmdNum=").AppendLine(CmdNum.ToString()) .Append("CmdCode=").AppendLine(CmdCode) .Append("CmdVal=").AppendLine(CmdVal.ToString(NumberFormatInfo.InvariantInfo)) .Append("CmdData=").AppendLine(ScadaUtils.BytesToHex(CmdData)) .Append("RecursionLevel=").AppendLine(RecursionLevel.ToString()) .AppendLine("End="); using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8, 1024, true)) { writer.Write(sb.ToString()); } }
public override string ToString() { if (CommandID == CometCommandID.NA) { return(""); } return(CommandID.ToString()); }
public void SendCommand(CommandID cmd) { arduino.Write(new byte[] { (byte)cmd }, 0, 1); responseReceived.Reset(); responseReceived.WaitOne(100); try { commsLogWriter.WriteLine("(TX) " + cmd.ToString()); } catch (Exception e) { Console.WriteLine("Boned." + e.ToString()); } }
/// <summary> /// 执行命令 /// </summary> /// <param name="cmd"></param> private void DoCommand(Command cmd) { CommandID id = (CommandID)cmd.type; if (Debuger.ENABLELOG) { Debug.Log("执行关键帧 = " + id.ToString() + ",frametime = " + cmd.time); } CommandDispatch.Dispatch(cmd); }
private MenuGroup AddMenuGroup(string menuName, string menuText, int priority, Configuration.CommandBar commandBar) { if (!menus.ContainsKey(menuName)) { CommandID commandID = GetCommandID(commandBar); NewGroup newGroup = CreateNewGroup(commandID.ToString(), priority, commandID); CommandID newMenuCommand = new CommandID(guidRecipeFrameworkPkgCmdSet, this.menuCounter++); MenuGroup myNewMenu = new MenuGroup( newMenuCommand, newGroup.Group, priority, CommandType.MenuContext, menuName, menuText); menus.Add(menuName, myNewMenu); } return(menus[menuName]); }
/// <summary> /// Create A CommandID object for the specified parameters /// </summary> /// <param name="id">ID of the command</param> /// <param name="commandGuid">GUID of the command to create</param> /// <param name="commandText">Text for the Command</param> /// <returns>A CommandID object for the UI</returns> private static CommandID CreateCommand(int id, Guid commandGuid, string commandText) { CommandID commandID = new CommandID(commandGuid, id); Command command = new Command(commandID) { Text = commandText }; if (CommandService.TryAdd(command)) { Log.WriteTrace( EventType.UIActivity, "Successfully created a UI Command without Image", commandID.ToString() + " == " + commandText); return(commandID); } return(null); }
/// \brief Handle command /// /// \param[in] cc command context /// \param[in] marObj marshal object /// /// \return 0 for success and -1 for failure public override int HandleCommand(CommandContext pContext, ISyncResult pSyncResult) { try { CommandID id = (CommandID)pContext.iCommandId; Logger.LogFuncUp("Command: " + id.ToString()); switch (id) { case CommandID.SWITCH_TO_APPLICATION: { Logger.LogInfo("Get Mainframe's SWITCH_TO_APPLICATION information!"); if (!FilmingViewerContainee.IsInitialized) { FilmingViewerContainee.InitializeFilmingCard(); } //var switchHandler=new SwitchToFilmingCommandHandler(pContext.sSerializeObject); //switchHandler.LoadStudyByInterationInfo(pContext.sSerializeObject); var infoWrapper = new InteractionInfoWrapper(); infoWrapper.Deserialize(pContext.sSerializeObject); if (infoWrapper.GetSrcAppName().ToUpper() == "PA") //只有从pa进入的切换才进入JobManager队列处理 { var filmingCard = FilmingViewerContainee.FilmingViewerWindow as FilmingCard; if (filmingCard != null && filmingCard.IsModalityDBT()) { break; } List <string> studyInstanceUidList = (from study in infoWrapper.GetStudyList() select study.UID).ToList(); if (studyInstanceUidList.Count > 0) { FilmingViewerContainee.DataHeaderJobManagerInstance.PushProcessedJob( new SwitchToFilmingCommandHandler(infoWrapper)); } } } break; case CommandID.SynchronousStudyList: { Logger.LogInfo("Get Mainframe's Update_StudyList information!"); if (!FilmingViewerContainee.IsInitialized) { FilmingViewerContainee.InitializeFilmingCard(); } SynchronousLoadStudyByInterationInfo(pContext.sSerializeObject); // FilmingViewerContainee.DataHeaderJobManagerInstance.PushProcessedJob(new SynchronousToFilmingCommandHandler(pContext.sSerializeObject)); } break; case CommandID.SAVE_EFILM_COMPLETE_COMMAND: var encoding = new UTF8Encoding( ); string constructedString = encoding.GetString(pContext.sSerializeObject); string[] msg = constructedString.Split('#'); //msg = "patientName" + ["#ErrorInfo"] if (msg.Length > 1) { //FilmingViewerContainee.ShowStatusWarning("UID_Filming_Fail_To_Save_EFilm", msg[0]); FilmingViewerContainee.Main.ShowStatusWarning("UID_Filming_Fail_To_Save_EFilm", msg[0]); } else { //FilmingViewerContainee.Main.ShowStatusInfo("UID_Filming_Complete_To_Save_EFilm", msg[0]); FilmingViewerContainee.Main.ShowStatusInfo("UID_Filming_Complete_To_Save_EFilm", msg[0]); } break; case CommandID.AutoLoadSeries: //auto load series from review //var seriesUids = pContext.sStringObject.Split(';'); //LoadSeries(seriesUids); //FilmingViewerContainee.Main.ShowStatusInfo("UID_Filming_Request_Of_Loading_Series_From_Review"); FilmingViewerContainee.Main.ShowStatusInfo("UID_Filming_Request_Of_Loading_Series_From_Review"); FilmingViewerContainee.DataHeaderJobManagerInstance.PushProcessedJob(new ReviewSeriesCommandHandler(pContext.sStringObject)); break; case CommandID.SET_LAYOUT_COMMAND: if (!FilmingViewerContainee.IsInitialized) { FilmingViewerContainee.InitializeFilmingCard(); } FilmingViewerContainee.DataHeaderJobManagerInstance.PushProcessedJob(new SetLayoutCommandHandler(new LayoutCommandInfo(pContext.sStringObject))); break; default: break; } Logger.LogFuncDown(); } catch (Exception exp) { //MedViewerLogger.Instance.LOG_DEV_ERROR( // MedViewerLogger.Source, // MedViewerLogger.LogUID, // "Exception: " + exp.Message); Logger.LogFuncException(exp.Message); return(-1); } return(0); }
public override void ExecCommand(CommandID cmdID) { DesignSection designSe = this.DesignerHost.SectionList.GetActiveSection(); if (cmdID.Equals(RptDesignCommands.InsertTopMarginBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.TopMargin); } else if (cmdID.Equals(RptDesignCommands.InsertReportHeaderBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.ReportTitle); } else if (cmdID.Equals(RptDesignCommands.InsertPageHeaderBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.PageHead); } else if (cmdID.Equals(RptDesignCommands.InsertGroupHeaderBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.GroupHead); } else if (cmdID.Equals(RptDesignCommands.InsertDetailBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.Detail); } else if (cmdID.Equals(RptDesignCommands.InsertGroupFooterBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.GroupFooter); } else if (cmdID.Equals(RptDesignCommands.InsertPageFooterBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.PageFooter); } else if (cmdID.Equals(RptDesignCommands.InsertReportFooterBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.ReportBottom); } else if (cmdID.Equals(RptDesignCommands.InsertBottomMarginBand)) { this.DesignerHost.SectionList.DataObj.AddbySectionType(DIYReport.SectionType.BottomMargin); } else if (cmdID.Equals(StandardCommands.Delete)) { this.DesignerHost.DeleteSelectedControls(); } else if (cmdID.Equals(StandardCommands.Cut)) { this.DesignerHost.Cut(); } else if (cmdID.Equals(StandardCommands.Copy)) //Redo { this.DesignerHost.Copy(); } else if (cmdID.Equals(StandardCommands.Paste)) //Redo { this.DesignerHost.Past(); } else { Debug.Assert(false, "该命令" + cmdID.ToString() + "目前还没有进行处理。"); } }
public bool QueryStatus(CommandID cmdId, CommandStatus status, CommandText text) { if (Control.MemoryView.Focused) { if (cmdId.Guid == CmdSets.GuidReko) { switch (cmdId.ID) { case CmdIds.ViewGoToAddress: case CmdIds.ActionMarkType: case CmdIds.ViewFindWhatPointsHere: case CmdIds.ActionMarkProcedure: case CmdIds.TextEncodingChoose: status.Status = MenuStatus.Visible | MenuStatus.Enabled; return(true); case CmdIds.EditCopy: case CmdIds.ViewFindPattern: status.Status = ValidSelection() ? MenuStatus.Visible | MenuStatus.Enabled : MenuStatus.Visible; return(true); } } } else if (Control.DisassemblyView.Focused) { var selAddress = Control.DisassemblyView.SelectedObject as Address; var instr = Control.DisassemblyView.SelectedObject as MachineInstruction; if (cmdId.ID == CmdIds.EditRegisterValues) { cmdId.ToString(); //$DEBUG } if (cmdId.Guid == CmdSets.GuidReko) { switch (cmdId.ID) { case CmdIds.EditCopy: status.Status = ValidDisassemblerSelection() ? MenuStatus.Visible | MenuStatus.Enabled : MenuStatus.Visible; return(true); case CmdIds.OpenLink: case CmdIds.OpenLinkInNewWindow: status.Status = selAddress != null ? MenuStatus.Visible | MenuStatus.Enabled : 0; return(true); case CmdIds.EditAnnotation: case CmdIds.EditRegisterValues: status.Status = instr != null ? MenuStatus.Visible | MenuStatus.Enabled : 0; return(true); case CmdIds.ActionCallTerminates: if (instr != null) { if ((instr.InstructionClass & InstrClass.Call) != 0) { status.Status = MenuStatus.Visible | MenuStatus.Enabled; } else { status.Status = MenuStatus.Visible; } } else { status.Status = 0; } return(true); case CmdIds.ViewPcRelative: status.Status = MenuStatus.Visible | MenuStatus.Enabled | (control.DisassemblyView.ShowPcRelative ? MenuStatus.Checked : 0); return(true); case CmdIds.TextEncodingChoose: return(true); } } } return(false); }
/// <summary> /// 执行命令 /// </summary> /// <param name="cmdID"></param> public override void ExecCommand(CommandID cmdID) { try { IForm activeForm = this.HostMdiMainForm.GetActiveMdiChildForm(); if (object.Equals(cmdID, UICommand.UICommands.Exit)) { this.HostMdiMainForm.Exit(); } else if (object.Equals(cmdID, UICommand.UICommands.MdiSaveLayout)) { this.HostMdiMainForm.SaveMdiLayput(); } else if (object.Equals(cmdID, UICommand.UICommands.About)) { frmDefaultAbout frm = new frmDefaultAbout(); frm.Show(); } else if (object.Equals(cmdID, UICommand.UICommands.Calculator)) { openTools(ToolsType.Calc); } else if (object.Equals(cmdID, UICommand.UICommands.HelpList)) { openHelpFile(); } else if (object.Equals(cmdID, UICommand.UICommands.FunctionTree)) { this.HostMdiMainForm.ShowFunctionTree(); } else if (object.Equals(cmdID, UICommand.UICommands.OnlineMessage)) { this.HostMdiMainForm.ShowOnlineMessage(); } else if (object.Equals(cmdID, UICommand.UICommands.Individuality)) { this.HostMdiMainForm.ShowUserSetting(); } else if (object.Equals(cmdID, UICommand.UICommands.SysSetting)) { this.HostMdiMainForm.ShowApplicationSetting(); } else if (activeForm != null && activeForm.ActiveUIType == ClientUIType.ObjectEditForm) { execEditCommand(activeForm as IBaseEditForm, cmdID); } else if (activeForm != null && (activeForm.ActiveUIType == ClientUIType.GridViewForm || activeForm.ActiveUIType == ClientUIType.AsynViewForm || activeForm.ActiveUIType == ClientUIType.TreeListViewForm || activeForm.ActiveUIType == ClientUIType.GridViewEditForm)) { execViewFormCommand(activeForm as IViewGridForm, cmdID); } else { MB.Util.TraceEx.Assert(false, string.Format("对CommandID:{0} 还没有实现相应的代码!", cmdID.ToString())); } } catch (Exception ex) { MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex); } }
//从对象浏览窗口的角度执行相应的Command. private int execViewFormCommand(IViewGridForm activeForm, CommandID cmdID) { if (activeForm == null) { return(0); } if (object.Equals(cmdID, UICommand.UICommands.AddNew)) { return(activeForm.AddNew()); } if (object.Equals(cmdID, UICommand.UICommands.Save)) { return(activeForm.Save()); } else if (object.Equals(cmdID, UICommand.UICommands.Open)) { return(activeForm.Open()); } else if (object.Equals(cmdID, UICommand.UICommands.Copy)) { return(activeForm.CopyAsNew()); } else if (object.Equals(cmdID, UICommand.UICommands.Delete)) { return(activeForm.Delete()); } else if (object.Equals(cmdID, UICommand.UICommands.Query)) { return(activeForm.Query()); } else if (object.Equals(cmdID, UICommand.UICommands.Refresh)) { return(activeForm.Refresh()); } else if (object.Equals(cmdID, UICommand.UICommands.DataExport)) { outputToExcel(activeForm); return(1); } else if (object.Equals(cmdID, UICommand.UICommands.DataImport)) { return(activeForm.DataImport()); } else if (object.Equals(cmdID, UICommand.UICommands.PrintPreview)) { showPrintPreview(activeForm); return(1); } else { MB.Util.TraceEx.Assert(false, string.Format("对CommandID:{0} 还没有实现相应的代码!", cmdID.ToString())); } return(0); }
//从对象浏览窗口的角度执行相应的Command. private int execEditCommand(IBaseEditForm activeForm, CommandID cmdID) { if (activeForm == null) { return(0); } if (object.Equals(cmdID, UICommand.UICommands.AddNew)) { return(activeForm.AddNew()); } else if (object.Equals(cmdID, UICommand.UICommands.Save)) { return(activeForm.Save()); } else if (object.Equals(cmdID, UICommand.UICommands.Delete)) { return(activeForm.Delete()); } else if (object.Equals(cmdID, UICommand.UICommands.Exit)) { activeForm.Close(); } else { MB.Util.TraceEx.Assert(false, string.Format("对CommandID:{0} 还没有实现相应的代码!", cmdID.ToString())); } return(0); }
/// <include file='doc\ControlCommandSet.uex' path='docs/doc[@for="ControlCommandSet.OnKeySize"]/*' /> /// <devdoc> /// Called for the various sizing commands we support. /// </devdoc> protected void OnKeySize(object sender, EventArgs e) { // Arrow keys. Begin a drag if the selection isn't locked. // ISelectionService selSvc = SelectionService; ISelectionUIService uiSvc = SelectionUIService; if (uiSvc != null && selSvc != null) { //added to remove the selection rectangle: bug(54692) // uiSvc.Visible = false; object comp = selSvc.PrimarySelection; if (comp != null && comp is IComponent) { PropertyDescriptor lockedProp = TypeDescriptor.GetProperties(comp)["Locked"]; if (lockedProp == null || (lockedProp.PropertyType == typeof(bool) && ((bool)lockedProp.GetValue(comp))) == false) { SelectionRules rules = SelectionRules.Visible; CommandID cmd = ((MenuCommand)sender).CommandID; bool invertSnap = false; int moveOffsetX = 0; int moveOffsetY = 0; if (cmd.Equals(MenuCommands.KeySizeHeightDecrease)) { moveOffsetY = -1; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeySizeHeightIncrease)) { moveOffsetY = 1; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeySizeWidthDecrease)) { moveOffsetX = -1; rules |= SelectionRules.RightSizeable; } else if (cmd.Equals(MenuCommands.KeySizeWidthIncrease)) { moveOffsetX = 1; rules |= SelectionRules.RightSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeHeightDecrease)) { moveOffsetY = -1; invertSnap = true; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeHeightIncrease)) { moveOffsetY = 1; invertSnap = true; rules |= SelectionRules.BottomSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeWidthDecrease)) { moveOffsetX = -1; invertSnap = true; rules |= SelectionRules.RightSizeable; } else if (cmd.Equals(MenuCommands.KeyNudgeWidthIncrease)) { moveOffsetX = 1; invertSnap = true; rules |= SelectionRules.RightSizeable; } else { Debug.Fail("Unknown command mapped to OnKeySize: " + cmd.ToString()); } if (uiSvc.BeginDrag(rules, 0, 0)) { bool snapOn = false; Size snapSize = Size.Empty; IComponent snapComponent = null; PropertyDescriptor snapProperty = null; // Gets the needed snap information // IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); DesignerTransaction trans = null; try { if (host != null) { GetSnapInformation(host, (IComponent)comp, out snapSize, out snapComponent, out snapProperty); if (selSvc.SelectionCount > 1) { trans = host.CreateTransaction(SR.GetString(SR.DragDropSizeComponents, selSvc.SelectionCount)); } else { trans = host.CreateTransaction(SR.GetString(SR.DragDropSizeComponent, ((IComponent)comp).Site.Name)); } if (snapProperty != null) { snapOn = (bool)snapProperty.GetValue(snapComponent); if (invertSnap) { snapOn = !snapOn; snapProperty.SetValue(snapComponent, snapOn); } } } if (snapOn && !snapSize.IsEmpty) { moveOffsetX *= snapSize.Width; moveOffsetY *= snapSize.Height; } // Now move the controls the correct # of pixels. // uiSvc.DragMoved(new Rectangle(0, 0, moveOffsetX, moveOffsetY)); uiSvc.EndDrag(false); if (host != null) { if (invertSnap && snapProperty != null) { snapOn = !snapOn; snapProperty.SetValue(snapComponent, snapOn); } } } finally { if (trans != null) { trans.Commit(); uiSvc.Visible = true; } } } } } uiSvc.Visible = true; } }
private void MessageReceiver_FMD_CS_CHATMESSAGE(AllegianceInterop.ClientConnection client, AllegianceInterop.FMD_CS_CHATMESSAGE message) { var ship = client.GetShip(); if (ship.GetCommandTarget((sbyte)CommandType.c_cmdCurrent) != null) { Log($"\tcommandCurrent: {ship.GetCommandID((sbyte)CommandType.c_cmdCurrent)}, commandTarget: {ship.GetCommandTarget((sbyte)CommandType.c_cmdCurrent).GetName()}"); Log($"\tcommandPlan: {ship.GetCommandID((sbyte)CommandType.c_cmdPlan)}, commandTarget: {ship.GetCommandTarget((sbyte)CommandType.c_cmdPlan).GetName()}"); Log($"\tship.GetAutopilot() = {ship.GetAutopilot()}"); } if (message.Message == "go") { var side = client.GetSide(); var mission = side.GetMission(); var hullTypes = mission.GetHullTypes(); var station = ship.GetStation(); if (station == null) { // Works! //{ // var buoy = client.CreateBuoy((sbyte)BuoyType.c_buoyWaypoint, _random.Next(-1000, 1000), _random.Next(-1000, 1000), _random.Next(-1000, 1000), ship.GetCluster().GetObjectID(), true); // var command = ship.GetDefaultOrder(buoy); // ship.SetCommand((sbyte)CommandType.c_cmdCurrent, buoy, command); // ship.SetAutopilot(true); //} // Works! { var warps = ship.GetCluster().GetWarps(); var warp = warps[_random.Next(0, warps.Count)]; //var warp = ship.GetCluster().GetWarps().First(); CommandID command = (CommandID)ship.GetDefaultOrder(warp); Log($"moving to point: {warp.GetName()}, command: {command.ToString()}"); // This should be it. ship.SetCommand((sbyte)CommandType.c_cmdCurrent, warp, (sbyte)CommandID.c_cidGoto); ship.SetAutopilot(true); } return; } List <AllegianceInterop.IhullTypeIGCWrapper> buyableHullTypes = new List <AllegianceInterop.IhullTypeIGCWrapper>(); foreach (var hullType in hullTypes) { if (hullType.GetGroupID() >= 0 && station.CanBuy(hullType) == true && station.IsObsolete(hullType) == false) { Log("buyable hullType: " + hullType.GetName()); buyableHullTypes.Add(hullType); } } // Get a scout. var scoutHull = buyableHullTypes.FirstOrDefault(p => p.GetName().Contains("Scout")); if (scoutHull == null) { return; } Log($"Found Scout: {scoutHull.GetName()}"); var partTypes = mission.GetPartTypes(); List <AllegianceInterop.IpartTypeIGCWrapper> buyablePartTypes = new List <AllegianceInterop.IpartTypeIGCWrapper>(); foreach (var partType in partTypes) { if (partType.GetGroupID() >= 0 && station.CanBuy(partType) == true && station.IsObsolete(partType) == false) { short equipmentTypeID = partType.GetEquipmentType(); bool isIncluded = false; switch ((EquipmentType)equipmentTypeID) { case EquipmentType.NA: isIncluded = true; break; case EquipmentType.ET_Weapon: case EquipmentType.ET_Turret: for (sbyte i = 0; i < scoutHull.GetMaxFixedWeapons(); i++) { isIncluded |= scoutHull.GetPartMask(equipmentTypeID, i) != 0 && scoutHull.CanMount(partType, i) == true; } break; default: isIncluded |= scoutHull.GetPartMask(equipmentTypeID, 0) != 0 && scoutHull.CanMount(partType, 0) == true; break; } if (isIncluded == true) { buyablePartTypes.Add(partType); Log($"\tFound part: {partType.GetName()}, capacity for part: {scoutHull.GetCapacity(partType.GetEquipmentType())}"); } } } var mines = buyablePartTypes.FirstOrDefault(p => p.GetName().Contains("Prox Mine") == true); //scoutHull. // Creating the empty ship adds the ship object to the core so that it will receive updates when the core.Update() is called. //var ship = client.CreateEmptyShip(); ship.SetBaseHullType(scoutHull); client.BuyDefaultLoadout(ship, station, scoutHull, client.GetMoney()); // Clear the cargo. for (sbyte i = -5; i < 0; i++) { var currentPart = ship.GetMountedPart((short)EquipmentType.NA, i); if (currentPart != null) { currentPart.Terminate(); } } if (mines != null) { for (sbyte i = -5; i < 0; i++) { int amount = client.BuyPartOnBudget(ship, mines, i, client.GetMoney()); Log("Bought: " + amount + " mines."); } var dispenser = ship.GetMountedPart((short)EquipmentType.ET_Dispenser, 0); dispenser.Terminate(); client.BuyPartOnBudget(ship, mines, 0, client.GetMoney()); } client.BuyLoadout(ship, true); // Clean up the newShip. //newShip.Terminate(); //ship = client.Get Task.Run(() => { // Wait for the ship to enter the cluster. while (ship.GetCluster() == null) { Thread.Sleep(100); } client.FireDispenser(ship); //var buoy = client.CreateBuoy((sbyte)BuoyType.c_buoyWaypoint, 3000, 0, 0, ship.GetCluster().GetObjectID(), true); //ship.SetAutopilot(true); //ship.SetCommand((sbyte)CommandType.c_cmdAccepted, buoy, (sbyte)CommandID.c_cidGoto); //ship.SetAutopilot(true); //// Drop mines! //var launcher = AllegianceInterop.IdispenserIGCWrapper.GetDispenserForPart(ship.GetMountedPart((short)EquipmentType.ET_Dispenser, 0)); ////var launcher = (AllegianceInterop.IdispenserIGCWrapper) ship.GetMountedPart((short) EquipmentType.ET_Dispenser, 0); //client.FireExpendable(ship, launcher, (uint)DateTime.Now.Ticks); }); } if (message.Message == "miner") { var side = client.GetSide(); var buckets = side.GetBuckets(); var money = client.GetMoney(); foreach (var bucket in buckets) { if (bucket.GetName() == ".Miner") { if (money > bucket.GetPrice() && bucket.GetCompleteF() == false) { Log("Adding money to bucket. Bucket wants: " + bucket.GetPrice() + ", we have: " + money); client.AddMoneyToBucket(bucket, bucket.GetPrice()); } else { Log("Already building: " + bucket.GetPercentComplete()); } } } } }