Exemple #1
0
        Timer timer = new Timer(1000 * 1); //Every second

        #endregion Fields

        #region Constructors

        // Constructor
        public CmdJail(CommandGroup g, GroupEnum group, string name)
            : base(g, group, name)
        {
            blnConsoleSupported = false;
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Enabled = true;
        }
Exemple #2
0
        private void AddCommandList(Document doc, CommandGroup group)
        {
            ParagraphStyle style = new ParagraphStyle
            {
                Indent = 3,
                Tabs = new[] { 22 }
            };

            // TODO - add option to show ALL commands/groups
            const bool showHidden = false;

            var commands = GetExpandedCommandNodes(group, showHidden)
                .Select(x => new { x.Node, x.Depth, Verb = VerbPath(x.Node, x.Depth - 1) });

            foreach (var entry in commands.OrderBy(x => x.Verb))
            {
                if (entry.Node.Hidden)
                {
                    continue;
                }

                var para = doc.AddParagraph(new Paragraph(style));

                // TODO - highlight the command by setting span style?
                para.AddSpan(new Span(entry.Verb));
                para.AddTab();

                if (!string.IsNullOrEmpty(entry.Node.Summary))
                {
                    para.AddSpan(new Span(entry.Node.Summary));
                }
            }
        }
 // Constructor
 public Command(CommandGroup g, GroupEnum group, string name)
 {
     cmdGroup = g;
     accessGroup = group;
     strName = name;
     blnConsoleSupported = false;
 }
	Lane GetLane(CommandGroup commandGroup) {
		Lane lane = Lane.Middle;
		foreach (var flag in commandGroup.flags) {
			if (flag == Flag.Top) lane = Lane.Top;
			else if (flag == Flag.Bottom) lane = Lane.Bottom;
		}
		return lane;
	}
	public void Process(CommandGroup commandGroup, Side side) {
		this.side = side;
		this.commandGroup = commandGroup;
		if (commandGroup.command == Command.Attack && commandGroup.argument == Argument.Virus) {
			SendVirus();
		} else if (commandGroup.command == Command.Defense && commandGroup.argument == Argument.Firewall) {
			CreateFirewall();
		}
	}
	void Behave() {
		int randAction = UnityEngine.Random.Range(0, 2);
		int randLane = UnityEngine.Random.Range(0, 3);
		Command command = randAction == 0 ? Command.Attack : Command.Defense;
		Argument argument = randAction == 0 ? Argument.Virus : Argument.Firewall;
		Flag[] flags = new Flag[1];
		flags[0] = (Flag)randLane;
		var commandGroup = new CommandGroup(command, argument, flags, 0);
		processor.Process(commandGroup, Side.Right);
	}
 public void LoadCommands(params Assembly[] assemblies)
 {
     _commands = assemblies
         .SelectMany(a => 
             a.GetExportedTypes()
              .Where(t => !t.IsAbstract && t.Namespace.StartsWith("NuCmd.Commands") && typeof(ICommand).IsAssignableFrom(t))
              .Select(CommandDefinition.FromType))
         .ToList();
     _groups = new ReadOnlyDictionary<string, CommandGroup>(
         _commands
             .GroupBy(c => c.Group ?? String.Empty)
             .Where(c => !String.IsNullOrEmpty(c.Key))
             .Select(cs => CommandGroup.Create(cs))
             .ToDictionary(g => g.Name));
     _rootCommands = new CommandGroup(
         String.Empty,
         String.Empty,
         _commands
             .Where(c => String.IsNullOrEmpty(c.Group)));
 }
	public void Evaluate(string userInput) {
		List<string> sections = new List<string>();
		sections.AddRange(userInput.Split(' '));
		Command? command = null;
		Argument? argument = null;
		List<Flag> flags = new List<Flag>();
		int amountFlag = 0;
		foreach (var cmd in commandSymbols) {
			if (cmd.symbol == sections[0]) command = cmd.command;
		}
		foreach (var arg in argumentSymbols) {
			bool didGetArg = false;
			for (int i = 1; i < sections.Count; i++) {
				if (arg.symbol == sections[i]) {
					argument = arg.argument;
					didGetArg = true;
					break;
				}
			}
			if (didGetArg) break;
		}
		foreach (var fl in flagSymbols) {
			for (int i = 0; i < sections.Count; i++) {
				if (fl.symbol == sections[i]) {
					flags.Add(fl.flag);
				}
			}
		}
		foreach (var section in sections) {
			if (int.TryParse(section, out amountFlag)) break;
		}
		if (command != null && argument != null) {
			var commandGroup = new CommandGroup(command.Value, argument.Value, flags.ToArray(), amountFlag);
			if (CommandInvoked != null) CommandInvoked(commandGroup, Side.Left);
		}
	}
Exemple #9
0
        public void CannotConstructWithNonEnumCommandType()
        {
            Action a = () => { var x = new CommandGroup <NonEnumValueType>(null); };

            a.Should().Throw <NotSupportedException>();
        }
Exemple #10
0
 // Constructor
 public CmdReplace(CommandGroup g, GroupEnum group, string name)
     : base(g, group, name)
 {
     blnConsoleSupported = false; /* By default no console support*/
 }
Exemple #11
0
 // Constructor
 public CmdFollow(CommandGroup g, GroupEnum group, string name)
     : base(g, group, name)
 {
     fTimer.Elapsed += new ElapsedEventHandler(fTimer_Elapsed);
     fTimer.Enabled = true;
 }
Exemple #12
0
        private Document GroupHelp(CommandGroup group)
        {
            Document doc = new Document();

            var para = doc.AddParagraph(new Paragraph(new ParagraphStyle { LinesAfter = 1 }));
            para.AddSpan("usage: " + VerbPath(group));

            AddNamed(para, group.NamedParameters);
            // TODO - include --help!

            if (group.Nodes.Any())
            {
                para.AddSpan("<command>");
            }

            if (group.Nodes.Any(x => x.PositionalParameters.Any()))
            {
                para.AddSpan("[<args>]");
            }

            // TODO - add usage
            // TODO - add overall command description

            // TODO - include "Help" in the command list!
            AddCommandList(doc, group);

            // TODO - add help blurb
            if (group.Nodes.Any())
            {
                var p = doc.AddParagraph(new Paragraph(new ParagraphStyle { LinesBefore = 1 }));
                var helpVerb = "help";  // TODO - pull from settings!
                p.AddSpan("See '{0} {1} <command>' to read about a specific subcommand.", VerbPath(group), helpVerb);
            }

            return doc;
        }
Exemple #13
0
 private void ReportMalformedCommand(CommandGroup group)
 {
     Dispatch(new UnknownCommandArgs($"possibly a malformed {group.ToString().ToUpper()}"));
 }
Exemple #14
0
        private void CreateCommandTabBox(CommandGroup cmdGroup, Dictionary <CommandSpec, int> commands)
        {
            m_Logger.Log($"Creating command tab box");

            var tabCommands = new List <TabCommandInfo>();

            foreach (var cmdData in commands)
            {
                var cmd   = cmdData.Key;
                var cmdId = cmdData.Value;

                if (cmd.HasTabBox)
                {
                    var docTypes = new List <swDocumentTypes_e>();

                    if (cmd.SupportedWorkspace.HasFlag(WorkspaceTypes_e.Part))
                    {
                        docTypes.Add(swDocumentTypes_e.swDocPART);
                    }

                    if (cmd.SupportedWorkspace.HasFlag(WorkspaceTypes_e.Assembly))
                    {
                        docTypes.Add(swDocumentTypes_e.swDocASSEMBLY);
                    }

                    if (cmd.SupportedWorkspace.HasFlag(WorkspaceTypes_e.Drawing))
                    {
                        docTypes.Add(swDocumentTypes_e.swDocDRAWING);
                    }

                    tabCommands.AddRange(docTypes.Select(
                                             t => new TabCommandInfo(
                                                 t, cmdId, ConvertTextDisplay(cmd.TabBoxStyle))));
                }
            }

            foreach (var cmdGrp in tabCommands.GroupBy(c => c.DocType))
            {
                var docType = cmdGrp.Key;

                var cmdTab = CmdMgr.GetCommandTab((int)docType, cmdGroup.Name);

                if (cmdTab == null)
                {
                    cmdTab = CmdMgr.AddCommandTab((int)docType, cmdGroup.Name);
                }

                if (cmdTab != null)
                {
                    var cmdIds   = cmdGrp.Select(c => c.CmdId).ToArray();
                    var txtTypes = cmdGrp.Select(c => (int)c.TextType).ToArray();

                    var cmdBox = TryFindCommandTabBox(cmdTab, cmdIds);

                    if (cmdBox == null)
                    {
                        cmdBox = cmdTab.AddCommandTabBox();
                    }
                    else
                    {
                        if (!IsCommandTabBoxChanged(cmdBox, cmdIds, txtTypes))
                        {
                            continue;
                        }
                        else
                        {
                            ClearCommandTabBox(cmdBox);
                        }
                    }

                    if (!cmdBox.AddCommands(cmdIds, txtTypes))
                    {
                        throw new InvalidOperationException("Failed to add commands to commands tab box");
                    }
                }
                else
                {
                    throw new NullReferenceException("Failed to create command tab box");
                }
            }
        }
Exemple #15
0
        public void CanConstructWithNonEnumCommandType()
        {
            Action a = () => { var group = new CommandGroup <CommandType>(null); };

            a.Should().NotThrow <Exception>();
        }
Exemple #16
0
        public void TestThreeCommandOnSubSystem()
        {
            ASubsystem subsystem = new ASubsystem();

            MockCommand command1 = new MockCommand();

            command1.AddRequires(subsystem);

            MockCommand command2 = new MockCommand();

            command2.AddRequires(subsystem);

            MockCommand command3 = new MockCommand();

            command3.AddRequires(subsystem);

            CommandGroup commandGroup = new CommandGroup();

            commandGroup.AddSequential(command1, 1.0);
            commandGroup.AddSequential(command2, 2.0);
            commandGroup.AddSequential(command3);

            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            AssertCommandState(command3, 0, 0, 0, 0, 0);
            commandGroup.Start();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            AssertCommandState(command3, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            AssertCommandState(command3, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            AssertCommandState(command3, 0, 0, 0, 0, 0);
            Sleep(1000);// Command 1 timeout
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 1);
            AssertCommandState(command2, 1, 1, 1, 0, 0);
            AssertCommandState(command3, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 1);
            AssertCommandState(command2, 1, 2, 2, 0, 0);
            AssertCommandState(command3, 0, 0, 0, 0, 0);
            Sleep(2000);// Command 2 timeout
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 1);
            AssertCommandState(command2, 1, 2, 2, 0, 1);
            AssertCommandState(command3, 1, 1, 1, 0, 0);

            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 1);
            AssertCommandState(command2, 1, 2, 2, 0, 1);
            AssertCommandState(command3, 1, 2, 2, 0, 0);
            command3.SetHasFinished(true);
            AssertCommandState(command1, 1, 1, 1, 0, 1);
            AssertCommandState(command2, 1, 2, 2, 0, 1);
            AssertCommandState(command3, 1, 2, 2, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 1);
            AssertCommandState(command2, 1, 2, 2, 0, 1);
            AssertCommandState(command3, 1, 3, 3, 1, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 1);
            AssertCommandState(command2, 1, 2, 2, 0, 1);
            AssertCommandState(command3, 1, 3, 3, 1, 0);
        }
Exemple #17
0
 // Constructor
 public CmdLoad(CommandGroup g, GroupEnum group, string name) : base(g, group, name)
 {
     blnConsoleSupported = true;                                                                                   /* By default no console support*/
 }
Exemple #18
0
        /// <summary>
        /// Loading Enesy Command Method (ECM) information in this assembly
        /// </summary>
        /// <param name="markedOnly">Default value: false</param>
        internal void LoadingECM(bool markedOnly)
        {
            // Write message to command window
            Autodesk.AutoCAD.EditorInput.Editor ed =
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.
                MdiActiveDocument.Editor;
            ed.WriteMessage("\nLoading ECM Database ...");

            // Just get the commands for this assembly
            Assembly asm = Assembly.GetExecutingAssembly();

            // for command category
            object[] categorys = asm.GetCustomAttributes(typeof(CommandGroup), true);
            Type[]   catTypes;
            int      catNumtypes = categorys.Length;



            // Get EnesyCommandMethod attributes
            object[] objs = asm.GetCustomAttributes(typeof(EnesyCADCommandMethod), true);
            Type[]   tps;
            int      numTypes = objs.Length;

            if (numTypes > 0)
            {
                tps = new Type[numTypes];
                for (int i = 0; i < numTypes; i++)
                {
                    CommandClassAttribute cca = objs[i] as CommandClassAttribute;
                    if (cca != null)
                    {
                        tps[i] = cca.Type;
                    }
                }
            }
            else
            {
                // If we're only looking for specifically marked CommandClasses, then use an
                // empty list
                if (markedOnly)
                {
                    tps = new Type[0];
                }
                else
                {
                    tps = asm.GetExportedTypes();
                }
            }

            // Append valid value into Database
            foreach (Type tp in tps)
            {
                MethodInfo[] meths = tp.GetMethods();
                foreach (MethodInfo meth in meths)
                {
                    objs = meth.GetCustomAttributes(typeof(EnesyCADCommandMethod), true);
                    foreach (object obj in objs)
                    {
                        EnesyCADCommandMethod attb = (EnesyCADCommandMethod)obj;
                        if (!attb.IsTest)
                        {
                            // get command category
                            object[] cats     = meth.GetCustomAttributes(typeof(CommandGroup), true);
                            string   category = "";
                            int      index    = 0;
                            foreach (object c in cats)
                            {
                                index++;
                                CommandGroup commandCat = c as CommandGroup;
                                //GLOBAL.WriteMessage("Command " + attb.GlobalName + " - Category: " + commandCat.Category);
                                category = commandCat.Category;
                            }
                            //GLOBAL.WriteMessage("\nCategory " + index + "");
                            //
                            CmdRecord cmd = new CmdRecord(attb.GlobalName,
                                                          attb.Tag,
                                                          attb.Description,
                                                          attb.Author,
                                                          attb.Email,
                                                          attb.WebLink,
                                                          category
                                                          );
                            // Check if Database contains this cmd
                            if (!this.CmdTableRecord.Contains(attb.GlobalName))
                            {
                                this.CmdTableRecord.Add(attb.GlobalName,
                                                        attb.Tag,
                                                        !String.IsNullOrEmpty(attb.Tag) ? "[" + attb.Tag + "] " + GetCommandDescription(attb.Description) : GetCommandDescription(attb.Description),
                                                        attb.Author,
                                                        attb.Email,
                                                        attb.WebLink,
                                                        category
                                                        );
                                //if (!String.IsNullOrEmpty(cat.Category))
                                //{
                                //    GLOBAL.WriteMessage("Category: " + cat.Category);
                                //}
                            }
                        }
                    }
                }
            }
            //
        }
Exemple #19
0
 // Constructor
 public CmdFollow(CommandGroup g, GroupEnum group, string name) : base(g, group, name)
 {
     fTimer.Elapsed += new ElapsedEventHandler(fTimer_Elapsed);
     fTimer.Enabled  = true;
 }
        public static ToolStripContainer AddToolStrip(this ToolStripContainer container, CommandGroup group, params Command[] commands)
        {
            var ts = commands.Aggregate(new ToolStrip {
                Name = "tsp" + group.ToString()
            }, (b, c) => b.AddToolStripItem(c));

            container.TopToolStripPanel.Controls.Add(ts);

            return(container);
        }
Exemple #21
0
 internal void TransformMe(TransformConfig config, Matrix4D transform, CommandGroup undoGroup)
 {
     this.TransformMe(config, Transformation3D.From(transform), undoGroup);
 }
 public CommandAttribute(string description, CommandGroup group)
 {
     _group = group;
     _description = description;
 }
	void OnCommandInvoked(CommandGroup commandGroup, Side side) {
		processor.Process(commandGroup, side);
	}
        IEnumerator TransformSelected(TransformType type)
        {
            isTransforming      = true;
            totalScaleAmount    = 0;
            totalRotationAmount = Quaternion.identity;

            Vector3 originalPivot = pivotPoint;

            Vector3 planeNormal           = (transform.position - originalPivot).normalized;
            Vector3 axis                  = GetNearAxisDirection();
            Vector3 projectedAxis         = Vector3.ProjectOnPlane(axis, planeNormal).normalized;
            Vector3 previousMousePosition = Vector3.zero;

            List <ICommand> transformCommands = new List <ICommand>();

            for (int i = 0; i < targetRootsOrdered.Count; i++)
            {
                transformCommands.Add(new TransformCommand(this, targetRootsOrdered[i]));
            }

            while (!Input.GetMouseButtonUp(0))
            {
                Ray     mouseRay      = myCamera.ScreenPointToRay(Input.mousePosition);
                Vector3 mousePosition = Geometry.LinePlaneIntersect(mouseRay.origin, mouseRay.direction, originalPivot, planeNormal);

                if (previousMousePosition != Vector3.zero && mousePosition != Vector3.zero)
                {
                    if (type == TransformType.Move)
                    {
                        float   moveAmount = ExtVector3.MagnitudeInDirection(mousePosition - previousMousePosition, projectedAxis) * moveSpeedMultiplier;
                        Vector3 movement   = axis * moveAmount;

                        for (int i = 0; i < targetRootsOrdered.Count; i++)
                        {
                            Transform target = targetRootsOrdered[i];

                            target.Translate(movement, Space.World);
                        }

                        SetPivotPointOffset(movement);
                    }
                    else if (type == TransformType.Scale)
                    {
                        Vector3 projected   = (nearAxis == Axis.Any) ? transform.right : projectedAxis;
                        float   scaleAmount = ExtVector3.MagnitudeInDirection(mousePosition - previousMousePosition, projected) * scaleSpeedMultiplier;

                        //WARNING - There is a bug in unity 5.4 and 5.5 that causes InverseTransformDirection to be affected by scale which will break negative scaling. Not tested, but updating to 5.4.2 should fix it - https://issuetracker.unity3d.com/issues/transformdirection-and-inversetransformdirection-operations-are-affected-by-scale
                        Vector3 localAxis = (space == TransformSpace.Local && nearAxis != Axis.Any) ? mainTargetRoot.InverseTransformDirection(axis) : axis;

                        Vector3 targetScaleAmount = Vector3.one;
                        if (nearAxis == Axis.Any)
                        {
                            targetScaleAmount = (ExtVector3.Abs(mainTargetRoot.localScale.normalized) * scaleAmount);
                        }
                        else
                        {
                            targetScaleAmount = localAxis * scaleAmount;
                        }

                        for (int i = 0; i < targetRootsOrdered.Count; i++)
                        {
                            Transform target = targetRootsOrdered[i];

                            Vector3 targetScale = target.localScale + targetScaleAmount;

                            if (pivot == TransformPivot.Pivot)
                            {
                                target.localScale = targetScale;
                            }
                            else if (pivot == TransformPivot.Center)
                            {
                                if (scaleType == ScaleType.FromPoint)
                                {
                                    target.SetScaleFrom(originalPivot, targetScale);
                                }
                                else if (scaleType == ScaleType.FromPointOffset)
                                {
                                    target.SetScaleFromOffset(originalPivot, targetScale);
                                }
                            }
                        }

                        totalScaleAmount += scaleAmount;
                    }
                    else if (type == TransformType.Rotate)
                    {
                        float   rotateAmount = 0;
                        Vector3 rotationAxis = axis;

                        if (nearAxis == Axis.Any)
                        {
                            Vector3 rotation = transform.TransformDirection(new Vector3(Input.GetAxis("Mouse Y"), -Input.GetAxis("Mouse X"), 0));
                            Quaternion.Euler(rotation).ToAngleAxis(out rotateAmount, out rotationAxis);
                            rotateAmount *= allRotateSpeedMultiplier;
                        }
                        else
                        {
                            Vector3 projected = (nearAxis == Axis.Any || ExtVector3.IsParallel(axis, planeNormal)) ? planeNormal : Vector3.Cross(axis, planeNormal);
                            rotateAmount = (ExtVector3.MagnitudeInDirection(mousePosition - previousMousePosition, projected) * rotateSpeedMultiplier) / GetDistanceMultiplier();
                        }

                        for (int i = 0; i < targetRootsOrdered.Count; i++)
                        {
                            Transform target = targetRootsOrdered[i];

                            if (pivot == TransformPivot.Pivot)
                            {
                                target.Rotate(rotationAxis, rotateAmount, Space.World);
                            }
                            else if (pivot == TransformPivot.Center)
                            {
                                target.RotateAround(originalPivot, rotationAxis, rotateAmount);
                            }
                        }

                        totalRotationAmount *= Quaternion.Euler(rotationAxis * rotateAmount);
                    }
                }

                previousMousePosition = mousePosition;

                yield return(null);
            }

            for (int i = 0; i < transformCommands.Count; i++)
            {
                ((TransformCommand)transformCommands[i]).StoreNewTransformValues();
            }
            CommandGroup commandGroup = new CommandGroup();

            commandGroup.Set(transformCommands);
            UndoRedoManager.Insert(commandGroup);

            totalRotationAmount = Quaternion.identity;
            totalScaleAmount    = 0;
            isTransforming      = false;

            SetPivotPoint();
        }
Exemple #25
0
            public static bool AddCommand(string[] args, CommandGroup command)
            {
                if (args == null || args.Count() < 2)
                {
                    return(false);
                }

                uint objectId;

                uint.TryParse(args[0], out objectId);

                if (objectId == 0)
                {
                    return(false);
                }

                uint spawntimeSecs;

                uint.TryParse(args[1], out spawntimeSecs);

                GameObjectTemplate objectInfo = ObjMgr.GetGameObjectTemplate(objectId);

                if (objectInfo == null)
                {
                    command.SendErrorMessage(CypherStrings.GameobjectNotExist, objectId);
                    return(false);
                }

                //if (objectInfo.displayId != 0 && !DBCStorage.sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
                {
                    // report to DB errors log as in loading case
                    //sLog->outError(LOG_FILTER_SQL, "Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId);
                    //handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, objectId);
                    //return false;
                }

                Player player = command.GetSession().GetPlayer();
                float  x      = player.GetPositionX();
                float  y      = player.GetPositionY();
                float  z      = player.GetPositionZ();
                float  o      = player.GetOrientation();
                Map    map    = player.GetMap();

                GameObject obj     = new GameObject();
                uint       guidLow = ObjMgr.GenerateLowGuid(HighGuidType.GameObject);

                if (!obj.Create(guidLow, objectInfo.entry, map, 1 /*player.GetPhaseMgr().GetPhaseMaskForSpawn()*/, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GameObjectState.Ready))
                {
                    return(false);
                }

                //if (spawntimeSecs != 0)
                {
                    //obj.SetRespawnTime(spawntimeSecs);
                }

                // fill the gameobject data and save to the db
                //obj.SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMgr().GetPhaseMaskForSpawn());

                // this will generate a new guid if the object is in an instance
                if (!obj.LoadGameObjectFromDB(guidLow, map))
                {
                    return(false);
                }

                // TODO: is it really necessary to add both the real and DB table guid here ?
                ObjMgr.AddGameObjectToGrid(guidLow, ObjMgr.GetGOData(guidLow));
                command.SendSysMessage(CypherStrings.GameobjectAdd, objectId, objectInfo.name, guidLow, x, y, z);
                return(true);
            }
Exemple #26
0
 internal SwCommandGroup(SwApplication app, CommandGroupSpec spec, CommandGroup cmdGroup)
 {
     Spec         = spec;
     CommandGroup = cmdGroup;
     m_App        = app;
 }
Exemple #27
0
 // Constructor
 public CmdKick(CommandGroup g, GroupEnum group, string name)
     : base(g, group, name)
 {
     blnConsoleSupported = true; /* By default no console support*/
 }
        public async Task GenerateCommandListAsync(CommandContext ctx,
                                                   [RemainingText, Description("File path.")] string path = null)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                path = "Documentation";
            }

            DirectoryInfo current;
            DirectoryInfo parts;

            try {
                if (Directory.Exists(path))
                {
                    Directory.Delete(path, recursive: true);
                }
                current = Directory.CreateDirectory(path);
                parts   = Directory.CreateDirectory(Path.Combine(current.FullName, "Parts"));
            } catch (IOException e) {
                throw new CommandFailedException("Failed to create the directories!", e);
            }

            var sb = new StringBuilder();

            sb.AppendLine("# Command list");
            sb.AppendLine();

            IReadOnlyList <Command> commands = ctx.CommandsNext.GetAllRegisteredCommands();
            var modules = commands
                          .GroupBy(c => ModuleAttribute.ForCommand(c))
                          .OrderBy(g => g.Key.Module)
                          .ToDictionary(g => g.Key, g => g.OrderBy(c => c.QualifiedName).ToList());

            foreach ((ModuleAttribute mattr, List <Command> cmdlist) in modules)
            {
                sb.Append("# Module: ").Append(mattr.Module.ToString()).AppendLine().AppendLine();

                foreach (Command cmd in cmdlist)
                {
                    if (cmd is CommandGroup || cmd.Parent == null)
                    {
                        sb.Append("## ").Append(cmd is CommandGroup ? "Group: " : "").AppendLine(cmd.QualifiedName);
                    }
                    else
                    {
                        sb.Append("### ").AppendLine(cmd.QualifiedName);
                    }

                    sb.AppendLine("<details><summary markdown='span'>Expand for additional information</summary><p>").AppendLine();

                    if (cmd.IsHidden)
                    {
                        sb.AppendLine(Formatter.Italic("Hidden.")).AppendLine();
                    }

                    sb.AppendLine(Formatter.Italic(cmd.Description ?? "No description provided.")).AppendLine();

                    IEnumerable <CheckBaseAttribute> execChecks = cmd.ExecutionChecks.AsEnumerable();
                    CommandGroup parent = cmd.Parent;
                    while (parent != null)
                    {
                        execChecks = execChecks.Union(parent.ExecutionChecks);
                        parent     = parent.Parent;
                    }

                    IEnumerable <string> perms = execChecks
                                                 .Where(chk => chk is RequirePermissionsAttribute)
                                                 .Select(chk => chk as RequirePermissionsAttribute)
                                                 .Select(chk => chk.Permissions.ToPermissionString())
                                                 .Union(execChecks
                                                        .Where(chk => chk is RequireOwnerOrPermissionsAttribute)
                                                        .Select(chk => chk as RequireOwnerOrPermissionsAttribute)
                                                        .Select(chk => chk.Permissions.ToPermissionString())
                                                        );
                    IEnumerable <string> uperms = execChecks
                                                  .Where(chk => chk is RequireUserPermissionsAttribute)
                                                  .Select(chk => chk as RequireUserPermissionsAttribute)
                                                  .Select(chk => chk.Permissions.ToPermissionString());
                    IEnumerable <string> bperms = execChecks
                                                  .Where(chk => chk is RequireBotPermissionsAttribute)
                                                  .Select(chk => chk as RequireBotPermissionsAttribute)
                                                  .Select(chk => chk.Permissions.ToPermissionString());

                    if (execChecks.Any(chk => chk is RequireOwnerAttribute))
                    {
                        sb.AppendLine(Formatter.Bold("Owner-only.")).AppendLine();
                    }
                    if (execChecks.Any(chk => chk is RequirePrivilegedUserAttribute))
                    {
                        sb.AppendLine(Formatter.Bold("Privileged users only.")).AppendLine();
                    }

                    if (perms.Any())
                    {
                        sb.AppendLine(Formatter.Bold("Requires permissions:"));
                        sb.AppendLine(Formatter.InlineCode(string.Join(", ", perms))).AppendLine();
                    }
                    if (uperms.Any())
                    {
                        sb.AppendLine(Formatter.Bold("Requires user permissions:"));
                        sb.AppendLine(Formatter.InlineCode(string.Join(", ", uperms))).AppendLine();
                    }
                    if (bperms.Any())
                    {
                        sb.AppendLine(Formatter.Bold("Requires bot permissions:"));
                        sb.AppendLine(Formatter.InlineCode(string.Join(", ", bperms))).AppendLine();
                    }

                    if (cmd.Aliases.Any())
                    {
                        sb.AppendLine(Formatter.Bold("Aliases:"));
                        sb.AppendLine(Formatter.InlineCode(string.Join(", ", cmd.Aliases))).AppendLine();
                    }

                    foreach (CommandOverload overload in cmd.Overloads.OrderByDescending(o => o.Priority))
                    {
                        if (!overload.Arguments.Any())
                        {
                            continue;
                        }

                        sb.AppendLine(Formatter.Bold(cmd.Overloads.Count > 1 ? $"Overload {overload.Priority.ToString()}:" : "Arguments:")).AppendLine();
                        foreach (CommandArgument arg in overload.Arguments)
                        {
                            if (arg.IsOptional)
                            {
                                sb.Append("(optional) ");
                            }

                            string type = $"[{ctx.CommandsNext.GetUserFriendlyTypeName(arg.Type)}";
                            if (arg.IsCatchAll)
                            {
                                type += "...";
                            }
                            type += "]";

                            sb.Append(Formatter.InlineCode(type));
                            sb.Append(" : ");

                            sb.Append(string.IsNullOrWhiteSpace(arg.Description) ? "No description provided." : Formatter.Italic(arg.Description));

                            if (arg.IsOptional)
                            {
                                sb.Append(" (def: ").Append(Formatter.InlineCode(arg.DefaultValue != null ? arg.DefaultValue.ToString() : "None")).Append(")");
                            }

                            sb.AppendLine().AppendLine();
                        }
                    }

                    if (cmd.CustomAttributes.FirstOrDefault(chk => chk is UsageExamplesAttribute) is UsageExamplesAttribute examples)
                    {
                        sb.AppendLine(Formatter.Bold("Examples:")).AppendLine().AppendLine(Formatter.BlockCode(examples.JoinExamples()));
                    }

                    sb.AppendLine("</p></details>").AppendLine().AppendLine("---").AppendLine();
                }

                string filename = Path.Combine(parts.FullName, $"{mattr.Module.ToString()}.md");
                try {
                    File.WriteAllText(filename, sb.ToString());
                } catch (IOException e) {
                    throw new CommandFailedException($"IO Exception occured while saving {filename}!", e);
                }

                sb.Clear();
            }

            sb.AppendLine("# Command modules:");
            foreach ((ModuleAttribute mattr, List <Command> cmdlist) in modules)
            {
                string mname = mattr.Module.ToString();
                sb.Append("* ").Append('[').Append(mname).Append(']').Append("(").Append(parts.Name).Append('/').Append(mname).Append(".md").AppendLine(")");
            }

            try {
                File.WriteAllText(Path.Combine(current.FullName, $"README.md"), sb.ToString());
            } catch (IOException e) {
                throw new CommandFailedException($"IO Exception occured while saving the main file!", e);
            }

            await this.InformAsync(ctx, $"Command list created at: {Formatter.InlineCode(current.FullName)}!", important : false);
        }
Exemple #29
0
 /// <summary>
 /// Attaches a CanExecute handler to the given command.
 /// </summary>
 /// <param name="commandGroup">The command group to which <paramref name="command"/> belongs.</param>
 /// <param name="command">The command to which an can execute handler needs to be attached.</param>
 static partial void AttachCanExecuteHandler(CommandGroup commandGroup, RelayCommand command);
Exemple #30
0
 public static bool Activate(string[] args, CommandGroup command)
 {
     return(false);
 }
Exemple #31
0
        private IEnumerable<CommandChildEntry> GetExpandedCommandNodes(CommandGroup group, bool showHidden)
        {
            // Can't use recursion here, as that prevents yielding the results, so use a stack...
            Stack<CommandChildEntry> stack = new Stack<CommandChildEntry>(new[] { new CommandChildEntry(group, 0) });

            while (stack.Count > 0)
            {
                var entry = stack.Pop();

                var command = entry.Node as Command;
                if ((command != null) && (showHidden || !command.Hidden))
                {
                    yield return entry;
                }

                var childGroup = entry.Node as CommandGroup;
                if (childGroup != null)
                {
                    if ((entry.Depth == 0) || (CountChildCommands(childGroup, showHidden) <= _settings.ChildThreshold))
                    {
                        foreach (var child in childGroup.Nodes)
                        {
                            if (showHidden || !child.Hidden)
                            {
                                stack.Push(new CommandChildEntry(child, entry.Depth + 1));
                            }
                        }
                    }
                    else
                    {
                        yield return entry;
                    }
                }
            }
        }
Exemple #32
0
        private void CreateMenu(CommandGroup [] groups)
        {
            _menuStrip = new MenuStrip ();
            _pluginMenu = new ToolStripMenuItem ("Plugins");
            foreach (CommandGroup cg in groups) {
                var topItem = new ToolStripMenuItem (cg.Name);
                topItem.DropDownItems.AddRange
                    (cg.Items.Select (x => new ToolStripMenuItem (x.Name, null, x.Event)).ToArray());

                _menuStrip.Items.Add (topItem);
            }
            _menuStrip.Items.Add (_pluginMenu);
            CollectPlugins ();
            MainMenuStrip = _menuStrip;
        }
Exemple #33
0
            internal void TransformMe(TransformConfig config, Matrix3D transform, CommandGroup undoGroup)
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: variable of a compiler-generated type
                DxfPattern.Line.Class465 class465 = new DxfPattern.Line.Class465();
                // ISSUE: reference to a compiler-generated field
                class465.line_0 = this;
                TransformConfig.HatchPatternTransform hatchPatternHandling = config.HatchPatternHandling;
                if (hatchPatternHandling == TransformConfig.HatchPatternTransform.DontTransform)
                {
                    return;
                }
                // ISSUE: reference to a compiler-generated field
                class465.double_0 = this.double_0;
                // ISSUE: reference to a compiler-generated field
                class465.point2D_0 = this.point2D_0;
                // ISSUE: reference to a compiler-generated field
                class465.vector2D_0 = this.vector2D_0;
                // ISSUE: reference to a compiler-generated field
                class465.list_0 = new List <double>((IEnumerable <double>) this.list_0);
                Vector2D vector = new Vector2D(System.Math.Cos(this.double_0), System.Math.Sin(this.double_0));

                if (hatchPatternHandling == TransformConfig.HatchPatternTransform.CompleteTransform)
                {
                    Vector2D vector2D = transform.Transform(vector);
                    // ISSUE: reference to a compiler-generated field
                    class465.double_1 = System.Math.Atan2(vector2D.Y, vector2D.X);
                    double length = vector2D.GetLength();
                    // ISSUE: reference to a compiler-generated field
                    class465.point2D_1 = transform.Transform(this.point2D_0);
                    // ISSUE: reference to a compiler-generated field
                    class465.vector2D_1 = transform.Transform(this.vector2D_0);
                    // ISSUE: reference to a compiler-generated field
                    class465.list_1 = new List <double>(this.list_0.Count);
                    foreach (double num in this.list_0)
                    {
                        // ISSUE: reference to a compiler-generated field
                        class465.list_1.Add(length * num);
                    }
                }
                else
                {
                    // ISSUE: reference to a compiler-generated field
                    class465.double_1 = this.double_0;
                    // ISSUE: reference to a compiler-generated field
                    class465.point2D_1 = this.point2D_0 + (Vector2D)transform.Transform(WW.Math.Point2D.Zero);
                    // ISSUE: reference to a compiler-generated field
                    class465.vector2D_1 = this.vector2D_0;
                    // ISSUE: reference to a compiler-generated field
                    // ISSUE: reference to a compiler-generated field
                    class465.list_1 = class465.list_0;
                }
                // ISSUE: reference to a compiler-generated method
                // ISSUE: reference to a compiler-generated method
                undoGroup?.UndoStack.Push((ICommand) new Command((object)this, new System.Action(class465.method_0), new System.Action(class465.method_1)));
                // ISSUE: reference to a compiler-generated field
                this.double_0 = class465.double_1;
                // ISSUE: reference to a compiler-generated field
                this.point2D_0 = class465.point2D_1;
                // ISSUE: reference to a compiler-generated field
                this.vector2D_0 = class465.vector2D_1;
                this.list_0.Clear();
                // ISSUE: reference to a compiler-generated field
                this.list_0.AddRange((IEnumerable <double>)class465.list_1);
            }
Exemple #34
0
 // Constructor
 public CmdNewLvl(CommandGroup g, GroupEnum group, string name) : base(g, group, name)
 {
     blnConsoleSupported = false;                                                                                     /* By default no console support*/
 }
Exemple #35
0
        public override void TransformMe(
            TransformConfig config,
            Matrix4D matrix,
            CommandGroup undoGroup)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            DxfInsertBase.Class476 class476 = new DxfInsertBase.Class476();
            // ISSUE: reference to a compiler-generated field
            class476.dxfInsertBase_0 = this;
            // ISSUE: reference to a compiler-generated field
            class476.vector3D_0 = this.vector3D_0;
            // ISSUE: reference to a compiler-generated field
            class476.point3D_0 = this.insertionPoint;
            // ISSUE: reference to a compiler-generated field
            class476.double_0 = this.rotation;
            // ISSUE: reference to a compiler-generated field
            class476.vector3D_1 = this.scaleFactor;
            this.vector3D_0     = matrix.Transform(this.ZAxis).GetUnit();
            Matrix4D inverse = DxfUtil.GetToWCSTransform(this.ZAxis).GetInverse();
            // ISSUE: reference to a compiler-generated field
            Matrix4D toWcsTransform = DxfUtil.GetToWCSTransform(class476.vector3D_0);

            // ISSUE: reference to a compiler-generated field
            this.insertionPoint = inverse.Transform(matrix.Transform(toWcsTransform.Transform(class476.point3D_0)));
            // ISSUE: reference to a compiler-generated field
            Vector3D vector3D = inverse.Transform(matrix.Transform(toWcsTransform.Transform(Transformation4D.RotateZ(class476.double_0).Transform(Vector3D.XAxis))));

            this.rotation = System.Math.Atan2(vector3D.Y, vector3D.X);
            if (this.Rotation < 0.0)
            {
                this.Rotation += 2.0 * System.Math.PI;
            }
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            this.scaleFactor = Transformation4D.RotateZ(-this.Rotation).Transform(inverse.Transform(matrix.Transform(toWcsTransform.Transform(Transformation4D.RotateZ(class476.double_0).Transform(class476.vector3D_1)))));
            CommandGroup undoGroup1 = (CommandGroup)null;

            if (undoGroup != null)
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: variable of a compiler-generated type
                DxfInsertBase.Class477 class477 = new DxfInsertBase.Class477();
                // ISSUE: reference to a compiler-generated field
                class477.class476_0 = class476;
                undoGroup1          = new CommandGroup((object)this);
                undoGroup.UndoStack.Push((ICommand)undoGroup1);
                // ISSUE: reference to a compiler-generated field
                class477.vector3D_0 = this.vector3D_0;
                // ISSUE: reference to a compiler-generated field
                class477.point3D_0 = this.insertionPoint;
                // ISSUE: reference to a compiler-generated field
                class477.double_0 = this.rotation;
                // ISSUE: reference to a compiler-generated field
                class477.vector3D_1 = this.scaleFactor;
                // ISSUE: reference to a compiler-generated method
                // ISSUE: reference to a compiler-generated method
                undoGroup1.UndoStack.Push((ICommand) new Command((object)this, new System.Action(class477.method_0), new System.Action(class476.method_0)));
            }
            foreach (DxfEntity dxfEntity in (DxfHandledObjectCollection <DxfAttribute>) this.activeDxfHandledObjectCollection_0)
            {
                dxfEntity.TransformMe(config, matrix, undoGroup1);
            }
        }
Exemple #36
0
 public static bool Phase(string[] args, CommandGroup command)
 {
     return(false);
 }
Exemple #37
0
        /// <summary>
        /// Adds the specified command handler associated with the command type.
        /// </summary>
        /// <param name="commandType">The command type.</param>
        /// <param name="commandGroup">The command group.</param>
        /// <param name="handler">The command handler.</param>
        public void AddCommandHandler(CommandType commandType, CommandGroup commandGroup, ExecuteCommandDelegate handler)
        {
            var commandHandle = new CommandHandle(commandType, commandGroup, handler);

            _commandHandles.Add(commandHandle);
        }
Exemple #38
0
        protected CommandGroup[] CreateCommandGroups()
        {
            var fileOps = new CommandGroup ("File");
            fileOps.Items.AddRange (new Command [] {
                    new Command ("Open",    (obj, e) => Open()),
                    new Command ("Save",    (obj, e) => Save()),
                });

            var actions = new CommandGroup ("Actions");
            actions.Items.AddRange (new Command [] {
                    new Command ("Add",        (obj, e) => _state = new Adding (_doc, this)),
                    new Command ("Delete",     (obj, e) => _state = new Deleting (_doc, this)),
                    new Command ("Connect",    (obj, e) => _state = new Connecting (_doc, this)),
                    new Command ("Disconnect", (obj, e) => _state = new Disconnecting (_doc, this)),
                    new Command ("Select",     (obj, e) => _state = new Idle (_doc, this)),
                });

            return new CommandGroup [] {fileOps, actions};
        }
Exemple #39
0
 /// <summary>
 /// Removes all command handlers for the specified command group.
 /// </summary>
 /// <param name="commandGroup">The command group.</param>
 public void RemoveCommandHandlers(CommandGroup commandGroup)
 {
     _commandHandles.RemoveAll(p => p.CommandGroup == commandGroup);
 }
Exemple #40
0
 private void CreateToolbarButtons(CommandGroup [] groups)
 {
     foreach (CommandGroup cg in groups) {
         _toolStrip.Items.AddRange (cg.Items.Select (x => CreateButton (x)).ToArray ());
         _toolStrip.Items.Add (new ToolStripSeparator ());
     }
 }
        private void CreateCommandItems(CommandGroup cmdGroup, int groupId, Enum[] cmds,
                                        Delegate callbackMethod, Delegate enableMethod)
        {
            var callbackMethodName = nameof(OnCommandClick);
            var enableMethodName   = nameof(OnCommandEnable);

            for (int i = 0; i < cmds.Length; i++)
            {
                var cmd = cmds[i];

                var cmdTitle   = "";
                var cmdToolTip = "";
                swCommandItemType_e menuToolbarOpts = 0;
                swWorkspaceTypes_e  suppWorkSpaces  = 0;

                if (!cmd.TryGetAttribute <DisplayNameAttribute>(
                        att => cmdTitle = att.DisplayName))
                {
                    cmdTitle = cmd.ToString();
                }

                if (!cmd.TryGetAttribute <DescriptionAttribute>(
                        att => cmdToolTip = att.Description))
                {
                    cmdToolTip = cmd.ToString();
                }

                if (!cmd.TryGetAttribute <CommandItemInfoAttribute>(
                        att =>
                {
                    if (att.HasMenu)
                    {
                        menuToolbarOpts |= swCommandItemType_e.swMenuItem;
                    }

                    if (att.HasToolbar)
                    {
                        menuToolbarOpts |= swCommandItemType_e.swToolbarItem;
                    }

                    suppWorkSpaces = att.SupportedWorkspaces;
                }))
                {
                    menuToolbarOpts = swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem;
                    suppWorkSpaces  = swWorkspaceTypes_e.All;
                }

                if (menuToolbarOpts == 0)
                {
                    throw new InvalidMenuToolbarOptionsException(cmd);
                }

                var cmdId = Convert.ToInt32(cmd);

                var cmdName = $"{groupId}.{cmdId}";

                m_CachedCmdsEnable.Add(cmdName, suppWorkSpaces);
                m_CallbacksParams.Add(cmdName, new Tuple <Delegate, Enum>(callbackMethod, cmd));

                if (enableMethod != null)
                {
                    m_EnableParams.Add(cmdName, new Tuple <Delegate, Enum>(enableMethod, cmd));
                }

                var callbackFunc = $"{callbackMethodName}({cmdName})";
                var enableFunc   = $"{enableMethodName}({cmdName})";

                cmdGroup.AddCommandItem2(cmdTitle, -1, cmdToolTip,
                                         cmdTitle, i, callbackFunc, enableFunc, cmdId,
                                         (int)menuToolbarOpts);
            }
        }
        public void SetupCommands()
        {
            BitmapHandler imageManager = new BitmapHandler();
            Assembly thisAssembly;
            int cmdIndex0, cmdIndex1, cmdIndex2, cmdIndex3, cmdIndex4, cmdIndex5;
            string Title = "Gazebo", ToolTip = "Tools for exporting this assembly as a robot for simulation in Gazebo";

            int cmdGroupErr = 0;
            bool ignorePrevious = false;

            object registryIDs;
            //get the ID information stored in the registry
            bool getDataResult = iCmdMgr.GetGroupDataFromRegistry(cmdGroupID, out registryIDs);

            int[] knownIDs = new int[3] {settingsItemID, manageRobotItemID, exportItemID};

            if (getDataResult)
            {
                if (!CompareIDs((int[])registryIDs, knownIDs)) //if the IDs don't match, reset the commandGroup
                {
                    ignorePrevious = true;
                }
            }
            ignorePrevious = true;

            //Get a reference to the current assembly and load bitmaps form it into a new command group
            thisAssembly = System.Reflection.Assembly.GetAssembly(this.GetType());
            cmdGroup = iCmdMgr.CreateCommandGroup2(cmdGroupID, Title, ToolTip, "", -1, ignorePrevious, ref cmdGroupErr);
            cmdGroup.LargeIconList = imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.ToolbarLarge.bmp", thisAssembly);
            cmdGroup.SmallIconList = imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.ToolbarSmall.bmp", thisAssembly);
            cmdGroup.LargeMainIcon = imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.MainIconLarge.bmp", thisAssembly);
            cmdGroup.SmallMainIcon = imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.MainIconSmall.bmp", thisAssembly);
            GazeboLogo = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Gazebo.png", thisAssembly));
            MotorPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.motor.png", thisAssembly));
            EncoderPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.QuadratureEncoder.png", thisAssembly));
            PotPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.AnalogPotentiometer.png", thisAssembly));
            GyroPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Gyro.png", thisAssembly));
            RangefinderPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Ultrasonic.png", thisAssembly));
            CameraPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Camera.png", thisAssembly));
            ExtLimitSwitchPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.LimitSwitch_E.png", thisAssembly));
            IntLimitSwitchPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.LimitSwitch_I.png", thisAssembly));
            PistonPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.Piston.png", thisAssembly));
            NewLinkPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.NewLinkIcon.png", thisAssembly));
            NewJointPic = Image.FromFile(imageManager.CreateFileFromResourceBitmap("GazeboExporter.Images.NewJointIcon.png", thisAssembly));

            int menuToolbarOption = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);
            cmdIndex3 = cmdGroup.AddCommandItem2("Exporter Settings", -1, "Change exporter plugin settings", "Exporter settings", 0, "settingsCB", "settingsEN", settingsItemID, menuToolbarOption);
            cmdIndex4 = cmdGroup.AddCommandItem2("Manage Robot", -1, "Manage robot paramters", "Manage Robot", 1, "manageRobotCB", "manageRobotEN", manageRobotItemID, menuToolbarOption);
            cmdIndex5 = cmdGroup.AddCommandItem2("Export", -1, "Save this robot as a Gazebo package", "Export", 2, "exportCB", "exportEN", exportItemID, menuToolbarOption);

            cmdGroup.HasToolbar = true;
            cmdGroup.HasMenu = true;
            cmdGroup.Activate();

            cmdTab = iCmdMgr.GetCommandTab((int)swDocumentTypes_e.swDocASSEMBLY, Title);

            if (cmdTab != null & !getDataResult | ignorePrevious)//if tab exists, but we have ignored the registry info (or changed command group ID), re-create the tab.  Otherwise the ids won't matchup and the tab will be blank
            {
                bool res = iCmdMgr.RemoveCommandTab(cmdTab);
                cmdTab = null;
            }

            //if cmdTab is null, must be first load (possibly after reset), add the commands to the tabs
            if (cmdTab == null)
            {
                cmdTab = iCmdMgr.AddCommandTab((int)swDocumentTypes_e.swDocASSEMBLY, Title);

                cmdBox = cmdTab.AddCommandTabBox();

                int[] cmdIDs = new int[3];
                int[] TextType = new int[3];

                cmdIDs[0] = cmdGroup.get_CommandID(cmdIndex3);
                cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex4);
                cmdIDs[2] = cmdGroup.get_CommandID(cmdIndex5);

                TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                TextType[2] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                /*int[] cmdIDs = new int[2];
                int[] TextType = new int[2];

                cmdIDs[0] = cmdGroup.get_CommandID(cmdIndex4);
                cmdIDs[1] = cmdGroup.get_CommandID(cmdIndex5);

                TextType[0] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;
                TextType[1] = (int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow;*/

                cmdBox.AddCommands(cmdIDs, TextType);
            }

            thisAssembly = null;
            imageManager.Dispose();
        }
Exemple #43
0
 public CommandLineParser(CommandGroup root, IReadOnlyCollection <Parameter> globalParameters)
 {
     _root             = root;
     _globalParameters = globalParameters;
 }
 // Constructor
 public CmdPermissionBuild(CommandGroup g, GroupEnum group, string name)
     : base(g, group, name)
 {
     blnConsoleSupported = false; /* By default no console support*/
 }
Exemple #45
0
        private void ParseSbCommand(string line)
        {
            int depth = 0;

            while (line.StartsWith(" ") || line.StartsWith("_"))
            {
                ++depth;
                line = line.Substring(1);
            }

            if (depth < 2)
            {
                commandGroup = (lastDrawable as IHasCommands).Commands;
            }

            string[] tokens = line.Split(',');

            string type = tokens[0];

            switch (type)
            {
            case "T":
            {
                string triggerName = tokens[1];
                int    startTime   = Convert.ToInt32(tokens[2]);
                int    endTime     = Convert.ToInt32(tokens[3]);
                int    groupNumber = tokens.Length > 4 ? Convert.ToInt32(tokens[4]) : 0;
                commandGroup = commandGroup.AddTrigger(triggerName, startTime, endTime, groupNumber).Commands;
            }
            break;

            case "L":
            {
                int startTime = Convert.ToInt32(tokens[1]);
                int loopCount = Convert.ToInt32(tokens[2]);
                commandGroup = commandGroup.AddLoop(startTime, loopCount).Commands;
            }
            break;

            default:
            {
                if (string.IsNullOrEmpty(tokens[3]))
                {
                    tokens[3] = tokens[2];
                }

                Easing easing    = (Easing)Convert.ToInt32(tokens[1]);
                int    startTime = Convert.ToInt32(tokens[2]);
                int    endTime   = Convert.ToInt32(tokens[3]);

                switch (type)
                {
                case "F":
                {
                    float startValue = ParseHelper.ToFloat(tokens[4]);
                    float endValue   = tokens.Length > 5 ? ParseHelper.ToFloat(tokens[5]) : startValue;
                    commandGroup.Commands.Add(new Command(CommandType.Fade, easing, startTime, endTime, startValue, endValue));
                }
                break;

                case "M":
                {
                    float startX = ParseHelper.ToFloat(tokens[4]);
                    float startY = ParseHelper.ToFloat(tokens[5]);
                    float endX   = tokens.Length > 6 ? ParseHelper.ToFloat(tokens[6]) : startX;
                    float endY   = tokens.Length > 7 ? ParseHelper.ToFloat(tokens[7]) : startY;
                    commandGroup.Commands.Add(new Command(CommandType.Movement, easing, startTime, endTime, new Tuple <float, float>(startX, startY), new Tuple <float, float>(endX, endY)));
                }
                break;

                case "MX":
                {
                    float startValue = ParseHelper.ToFloat(tokens[4]);
                    float endValue   = tokens.Length > 5 ? ParseHelper.ToFloat(tokens[5]) : startValue;
                    commandGroup.Commands.Add(new Command(CommandType.MovementX, easing, startTime, endTime, startValue, endValue));
                }
                break;

                case "MY":
                {
                    float startValue = ParseHelper.ToFloat(tokens[4]);
                    float endValue   = tokens.Length > 5 ? ParseHelper.ToFloat(tokens[5]) : startValue;
                    commandGroup.Commands.Add(new Command(CommandType.MovementY, easing, startTime, endTime, startValue, endValue));
                }
                break;

                case "S":
                {
                    float startValue = ParseHelper.ToFloat(tokens[4]);
                    float endValue   = tokens.Length > 5 ? ParseHelper.ToFloat(tokens[5]) : startValue;
                    commandGroup.Commands.Add(new Command(CommandType.Scale, easing, startTime, endTime, startValue, endValue));
                }
                break;

                case "V":
                {
                    float startX = ParseHelper.ToFloat(tokens[4]);
                    float startY = ParseHelper.ToFloat(tokens[5]);
                    float endX   = tokens.Length > 6 ? ParseHelper.ToFloat(tokens[6]) : startX;
                    float endY   = tokens.Length > 7 ? ParseHelper.ToFloat(tokens[7]) : startY;
                    commandGroup.Commands.Add(new Command(CommandType.VectorScale, easing, startTime, endTime,
                                                          new Tuple <float, float>(startX, startY), new Tuple <float, float>(endX, endY)));
                }
                break;

                case "R":
                {
                    float startValue = ParseHelper.ToFloat(tokens[4]);
                    float endValue   = tokens.Length > 5 ? ParseHelper.ToFloat(tokens[5]) : startValue;
                    commandGroup.Commands.Add(new Command(CommandType.Rotation, easing, startTime, endTime, startValue, endValue));
                }
                break;

                case "C":
                {
                    float startRed   = ParseHelper.ToFloat(tokens[4]);
                    float startGreen = ParseHelper.ToFloat(tokens[5]);
                    float startBlue  = ParseHelper.ToFloat(tokens[6]);
                    float endRed     = tokens.Length > 7 ? ParseHelper.ToFloat(tokens[7]) : startRed;
                    float endGreen   = tokens.Length > 8 ? ParseHelper.ToFloat(tokens[8]) : startGreen;
                    float endBlue    = tokens.Length > 9 ? ParseHelper.ToFloat(tokens[9]) : startBlue;
                    commandGroup.Commands.Add(new Command(easing, startTime, endTime,
                                                          Color.FromArgb(255, (int)startRed, (int)startGreen, (int)startBlue),
                                                          Color.FromArgb(255, (int)endRed, (int)endGreen, (int)endBlue)));
                }
                break;

                case "P":
                {
                    string parameter = tokens[4];

                    switch (parameter)
                    {
                    case "H":
                        commandGroup.Commands.Add(new Command(CommandType.FlipHorizontal, easing, startTime, endTime));
                        break;

                    case "V":
                        commandGroup.Commands.Add(new Command(CommandType.FlipVertical, easing, startTime, endTime));
                        break;

                    case "A":
                        commandGroup.Commands.Add(new Command(CommandType.BlendingMode, easing, startTime, endTime));
                        break;
                    }
                }
                break;
                }
            }
            break;
            }
        }