コード例 #1
0
 /// <summary> Gets a list of commands in a specified category.
 /// Note that commands may belong to more than one category. </summary>
 public static CommandDescriptor[] GetCommands(CommandCategory category, bool includeHidden)
 {
     return(Commands.Values
            .Where(cmd => (includeHidden || !cmd.IsHidden) &&
                   (cmd.Category & category) == category)
            .ToArray());
 }
コード例 #2
0
ファイル: WoWConsole.cs プロジェクト: wampirr/IceFlake
        public bool RegisterCommand(string command, CommandHandler handler, CommandCategory category, string help)
        {
            if (_registerCommand == null)
            {
                _registerCommand =
                    Manager.Memory.RegisterDelegate <ConsoleRegisterCommandDelegate>(
                        (IntPtr)Pointers.Console.RegisterCommand);
            }

            if (_stringPointers.ContainsKey(command)) // Commmand by that name already registered
            {
                return(false);
            }

            var cmdPtr = Marshal.AllocHGlobal(command.Length + 1);

            Manager.Memory.WriteString(cmdPtr, command, Encoding.UTF8);

            var helpPtr = Marshal.AllocHGlobal(help.Length + 1);

            Manager.Memory.WriteString(helpPtr, help, Encoding.UTF8);

            _stringPointers.Add(command, new KeyValuePair <IntPtr, IntPtr>(cmdPtr, helpPtr));

            return(_registerCommand(cmdPtr, Marshal.GetFunctionPointerForDelegate(handler), category, helpPtr));
        }
コード例 #3
0
ファイル: CommandManager.cs プロジェクト: venofox/AtomicCraft
 /// <summary> Gets a list of commands in a specified category.
 /// Note that commands may belong to more than one category. </summary>
 public static CommandDescriptor[] GetCommands( CommandCategory category, bool includeHidden )
 {
     return Commands.Values
                    .Where( cmd => ( includeHidden || !cmd.IsHidden ) &&
                                   ( cmd.Category & category ) == category )
                    .ToArray();
 }
コード例 #4
0
        public async Task Help(CommandCategory category)
        {
            string         path     = "Resources/Commands.json";
            List <Command> commands = new List <Command>();

            if (File.Exists(path))
            {
                commands = JsonConvert.DeserializeObject <List <Command> >(File.ReadAllText(path));
            }

            string log = "";

            foreach (Command command in commands)
            {
                if (command.category == category)
                {
                    if (log != "")
                    {
                        log += "\n";
                    }
                    log += $"{command.name}. {command.description}";
                }
            }

            await ReplyAsync(log);
        }
コード例 #5
0
        private byte[] ConstructPacket(int deviceAddress, RWMode readOrWrite, CommandCategory category, string command, params byte[] data)
        {
            List <byte> packet = new List <byte>(14 + data.Length);

            // 0
            packet.Add((byte)Terminator.Start);
            // 1-4
            packet.AddRange(Address(deviceAddress));
            // 5
            packet.Add((byte)readOrWrite);
            // 6
            packet.Add((byte)category);
            // 7-9
            packet.AddRange(ToAsciiBytes(command, 3, 0x00));
            // 10
            packet.Add((byte)Terminator.Separator);

            if (data.Length > 0)
            {
                packet.AddRange(data);
            }

            packet.Add((byte)Terminator.Separator);

            packet.Add(CheckSum(packet));

            packet.Add((byte)Terminator.End);

            return(packet.ToArray());
        }
コード例 #6
0
ファイル: Help.cs プロジェクト: AkyrosXD/AkyBot
        /// <summary>
        /// Gets all the commands in the category.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns></returns>
        private string GetCommands(CommandCategory category)
        {
            string result = string.Empty;

            if (category == CommandCategory.AnimeActions)
            {
                foreach (string cmd in AnimeAction.AnimeActions)
                {
                    result += $"**`{AkyBot.Prefix}{cmd}`**";
                    result += ' ';
                }
            }
            else
            {
                foreach (Command command in AkyBot.CommandsList)
                {
                    if (command.Category != category)
                    {
                        continue;
                    }

                    result += $"**`{AkyBot.Prefix}{command.Trigger}`**";
                    result += ' ';
                }
            }

            result += "\n\n";
            return(result);
        }
コード例 #7
0
 public Button(string DisplayName, string internalName, string clientId, string description, string tooltip, Icon standarticon, Icon largeIcon, string catName = "CSharp")
 {
     try
     {
         stdole.IPictureDisp standartIconIPictureDisp;
         standartIconIPictureDisp = OleCreateConverter.ImageToPictureDisp(standarticon.ToBitmap());
         stdole.IPictureDisp largeIconIPictureDisp;
         largeIconIPictureDisp = OleCreateConverter.ImageToPictureDisp(largeIcon.ToBitmap());
         m_buttonDefinition    = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(DisplayName,
                                                                                                             "Autodesk:Macros:" + internalName, CommandTypesEnum.kNonShapeEditCmdType, clientId, description, tooltip, standartIconIPictureDisp,
                                                                                                             largeIconIPictureDisp, ButtonDisplayEnum.kDisplayTextInLearningMode);
         m_buttonDefinition.Enabled = true;
         ButtonDefinition_OnExecuteEventDelegate = new ButtonDefinitionSink_OnExecuteEventHandler(ButtonDefinition_OnExecute);
         m_buttonDefinition.OnExecute           += ButtonDefinition_OnExecuteEventDelegate;
         if (catName != "")
         {
             CommandCategory cat = u.get <CommandCategory>(m_inventorApplication.CommandManager.CommandCategories, c => c.DisplayName == catName) ??
                                   m_inventorApplication.CommandManager.CommandCategories.Add(catName, "Autodesk:Macros:" + catName);
             cat.Add(m_buttonDefinition);
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #8
0
 public Command(BotClient bc)
 {
     _mClient          = bc;
     WriteLineDelegate = StaticWriteLine;
     Name = GetType().Name.Replace("Command", "");
     if (!(this is BotCommand))
     {
         DLRConsole.DebugWriteLine("" + this + " is not a BotCommand?!");
     }
     if (this is BotPersonalCommand)
     {
         //Parameters = CreateParams();
         Category = CommandCategory.Other;
     }
     if (this is BotSystemCommand)
     {
         //Parameters = CreateParams();
         Category = CommandCategory.Simulator;
     }
     if (this is RegionMasterCommand)
     {
         // Parameters = new[] { new NamedParam(typeof(Simulator), null) };
         Category = CommandCategory.Simulator;
     }
     if (this is SystemApplicationCommand)
     {
         // Parameters = CreateParams();
         Category = CommandCategory.BotClient;
     }
     if (this.GetType().Namespace.ToString() == "Cogbot.Actions.Movement")
     {
         Category = CommandCategory.Movement;
     }
 } // constructor
コード例 #9
0
        private void Write <T>(CommandCategory category, string command, T value)
        {
            //adjust the ReceiveTimeout for write operations, since the device doesn't respond
            // until its done effecting the change
            int temp = this.ReceiveTimeout;

            this.ReceiveTimeout = _writeReceiveTimeout;

            try
            {
                PrintDebug("WRITE " + category + "-" + command);
                byte[] data = null;
                if (typeof(T) == typeof(byte))
                {
                    data    = new byte[1];
                    data[0] = (byte)Convert.ChangeType(value, typeof(byte));
                }
                else if (typeof(T) == typeof(byte[]))
                {
                    data = (byte[])Convert.ChangeType(value, typeof(byte[]));
                }
                else
                {
                    string szValue = value.ToString();
                    data = ToAsciiBytes(szValue);
                }

                byte[] packet = ConstructPacket(_deviceAddress, RWMode.Write, category, command, data);
                bool   success;
                byte[] response = BlockingSend(packet, out success, ETX);
                if (success)
                {
                    int            addr;
                    ResponseStatus status;
                    byte[]         respData;
                    ParseResponse(response, out addr, out status, out respData);

                    if (status != ResponseStatus.OK)
                    {
                        throw new Exception("Command " + category + "-" + command + " failed. Receiver responded with failure: " + status);
                    }
                }
                else
                {
                    if (response == null)
                    {
                        throw new Exception("Command " + category + "-" + command + " failed. Send failed!");
                    }
                    else
                    {
                        throw new Exception("Command " + category + "-" + command + " failed. No data received!");
                    }
                }
            }
            finally
            {
                //restore Read timeout
                this.ReceiveTimeout = temp;
            }
        }
コード例 #10
0
        /// <summary>
        /// modifies Drawing ribbon by adding two buttons used by the add-in
        /// </summary>
        private void modifyRibbon()
        {
            //get Command manager
            cmdMan = m_inventorApplication.CommandManager;

            //get control definitions
            ctrlDefs = cmdMan.ControlDefinitions;

            //define command category for add-in's buttons
            cmdCat = cmdMan.CommandCategories.Add("Auto-Breaker", "Autodesk:CmdCategory:AutoBreaker", addInGuid);

            //get 'Drawing' ribbon
            drawingRibbon = m_inventorApplication.UserInterfaceManager.Ribbons["Drawing"];

            //get 'Place Views' tab from 'Drawing' ribbon
            placeTab = drawingRibbon.RibbonTabs["id_TabPlaceViews"];

            //define 'Apply break' button
            applyButton            = ctrlDefs.AddButtonDefinition("Apply!", "Autodesk:AutoBreaker:ApplyButton", CommandTypesEnum.kQueryOnlyCmdType, addInGuid, "auto-break description", "auto-break tooltip", plus16obj, plus128obj, ButtonDisplayEnum.kAlwaysDisplayText);
            applyButton.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(customAction);
            cmdCat.Add(applyButton);

            //define 'Settings' button
            settingsButton            = ctrlDefs.AddButtonDefinition("Settings", "Autodesk:AutoBreaker:SettingsButton", CommandTypesEnum.kQueryOnlyCmdType, addInGuid, "auto-breaker settings description", "auto-break settings tool-tip", gear16obj, gear128obj, ButtonDisplayEnum.kAlwaysDisplayText);
            settingsButton.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(settingsClick);
            cmdCat.Add(settingsButton);

            //define panel in 'Place Views' tab
            panel                = placeTab.RibbonPanels.Add("Auto-Breaker", "Autodesk:AutoBreaker:AutoBreakerPanel", addInGuid);
            controlApplyBreak    = panel.CommandControls.AddButton(applyButton, true, true);
            controlSettingsBreak = panel.CommandControls.AddButton(settingsButton, true, true);
        }
コード例 #11
0
 public IList <IConnector> ConnectorsInCategory(CommandCategory category)
 {
     if (categoryConnectors.ContainsKey(category))
     {
         return(categoryConnectors[category]);
     }
     return(null);
 }
コード例 #12
0
ファイル: InfoCommands.cs プロジェクト: TheDireMaster/fCraft
        internal static void Commands(Player player, Command cmd)
        {
            string param = cmd.Next();

            CommandDescriptor[] cd;

            if (param == null)
            {
                player.Message("List of available commands:");
                cd = CommandManager.GetCommands(false);
            }
            else if (param.StartsWith("@"))
            {
                string rankName = param.Substring(1);
                Rank   rank     = RankManager.FindRank(rankName);
                if (rank == null)
                {
                    player.Message("Unknown rank: {0}", rankName);
                    return;
                }
                else
                {
                    player.Message("List of commands available to {0}&S:", rank.GetClassyName());
                    cd = CommandManager.GetCommands(rank, true);
                }
            }
            else if (param.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                player.Message("List of ALL commands:");
                cd = CommandManager.GetCommands();
            }
            else if (param.Equals("hidden", StringComparison.OrdinalIgnoreCase))
            {
                player.Message("List of hidden commands:");
                cd = CommandManager.GetCommands(true);
            }
            else if (Enum.GetNames(typeof(CommandCategory)).Contains(param, StringComparer.OrdinalIgnoreCase))
            {
                CommandCategory category = (CommandCategory)Enum.Parse(typeof(CommandCategory), param, true);
                player.Message("List of {0} commands:", category);
                cd = CommandManager.GetCommands(category, false);
            }
            else if (Enum.GetNames(typeof(Permission)).Contains(param, StringComparer.OrdinalIgnoreCase))
            {
                Permission permission = (Permission)Enum.Parse(typeof(Permission), param, true);
                player.Message("List of commands that need {0} permission:", permission);
                cd = CommandManager.GetCommands(permission, true);
            }
            else
            {
                cdCommands.PrintUsage(player);
                return;
            }

            string[] commandNames = cd.Select(desc => desc.Name).ToArray();

            player.MessagePrefixed("&S   ", "&S   " + String.Join(", ", commandNames));
        }
コード例 #13
0
ファイル: ControlLinker.cs プロジェクト: mdehoog/iScanControl
        private void ConnectButtonControl(ListCommand command, int v, Button button, CommandCategory category)
        {
            ListValue value = command.ListValues.ValueToValue(v);

            if (value != null)
            {
                new ButtonConnector(command, value, button, category);
            }
        }
コード例 #14
0
ファイル: BotCommand.cs プロジェクト: byBlurr/bBotLibrary
 public BotCommand(string name, CommandUsage[] usage, string description, CommandCategory category, string extra = "", bool newCommand = false)
 {
     Name        = name ?? throw new ArgumentNullException(nameof(name));
     Usage       = usage ?? throw new ArgumentNullException(nameof(usage));
     Description = description ?? throw new ArgumentNullException(nameof(description));
     Category    = category;
     ExtraInfo   = extra;
     New         = newCommand;
 }
コード例 #15
0
        private ButtonDefinition GetShowTextButton(string addinId, Application application)
        {
            CommandCategory slotCmdCategory = application.CommandManager.CommandCategories.Add("Slot", "Autodesk:YourAddIn:ShowTextCmd", addinId);

            var btn = new TestButton(application, addinId);

            slotCmdCategory.Add(btn.ButtonDefinition);

            return(btn.ButtonDefinition);
        }
コード例 #16
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender            = actionInput.Controller;
            string      requestedCategory = actionInput.Tail.ToLower();

            // Get a command array of all commands available to this controller
            List <Command> commands = CommandManager.Instance.GetCommandsForController(sender);

            var             output   = new StringBuilder();
            CommandCategory category = CommandCategory.None;

            Enum.TryParse(requestedCategory, true, out category);

            if (requestedCategory == "all" || category != CommandCategory.None)
            {
                if (category == CommandCategory.None)
                {
                    output.AppendLine("All commands:");
                }
                else
                {
                    output.AppendFormat("{0} commands:\n", category.ToString());
                }

                // Sort and then output commands in this category
                commands.Sort((Command a, Command b) => a.Name.CompareTo(b.Name));
                foreach (Command c in commands)
                {
                    if (c.Category.HasFlag(category))
                    {
                        output.AppendFormat("{0}{1}\n", c.Name.PadRight(15), c.Description);
                    }
                }
            }
            else
            {
                // Build a list of categories for the commands available to this player.
                output.AppendLine("Please specify a command category:\nAll");

                foreach (CommandCategory c in Enum.GetValues(typeof(CommandCategory)))
                {
                    if (c != CommandCategory.None)
                    {
                        List <Command> matchingcommands = commands.FindAll(c2 => c2.Category.HasFlag(c));
                        if (matchingcommands.Count() > 0)
                        {
                            output.AppendFormat("{0} ({1})\n", c.ToString(), matchingcommands.Count());
                        }
                    }
                }
            }

            sender.Write(output.ToString());
        }
コード例 #17
0
 public CommandAttribute(string command, Permissions permissions, string help, CommandCategory commandCategory = CommandCategory.Miscellaneous, string?commandParent = null, bool requiresQuotes = false, bool showWait = true)
 {
     this.Command         = command;
     this.CommandLower    = this.Command.ToLower();
     this.CommandCategory = permissions == Permissions.Administrators ? CommandCategory.Administration : commandCategory;
     this.CommandParent   = commandParent;
     this.Permissions     = permissions;
     this.Help            = help;
     this.RequiresQuotes  = requiresQuotes;
     this.ShowWait        = showWait;
 }
コード例 #18
0
        public ButtonConnector(ListCommand command, ListValue value, Button button, CommandCategory category)
        {
            this.command  = command;
            this.value    = value;
            this.button   = button;
            this.category = category;

            Context.ConnectorRegistry.RegisterOtherControl(button);

            button.Click += new EventHandler(button_Click);
        }
コード例 #19
0
ファイル: HelpCommand.cs プロジェクト: twobe7/KupoNutsBot
        public HelpCommand(string name, CommandCategory category, string help, Permissions permission, string?shortcut = null)
        {
            this.CommandName     = name;
            this.CommandCategory = category;
            this.Help            = help;
            this.Permission      = permission;
            this.CommandCount    = 1;

            if (shortcut != null)
            {
                this.CommandShortcuts.Add(shortcut);
            }
        }
コード例 #20
0
        /// <summary> Gets a list of commands in a specified category.
        /// Note that commands may belong to more than one category. </summary>
        public static CommandDescriptor[] GetCommands(CommandCategory category, bool includeHidden)
        {
            List <CommandDescriptor> list = new List <CommandDescriptor>();

            foreach (CommandDescriptor cmd in Commands.Values)
            {
                if ((!cmd.IsHidden || includeHidden) && (cmd.Category & category) == category)
                {
                    list.Add(cmd);
                }
            }
            return(list.ToArray());
        }
コード例 #21
0
        /// <summary>
        /// Issuse the specified READ command to the receiver
        /// </summary>
        /// <typeparam name="T">type of data we're trying to retreive</typeparam>
        /// <param name="category">command category</param>
        /// <param name="command">command to issue</param>
        /// <returns>the data we're requesting</returns>
        private T Read <T>(CommandCategory category, string command)
        {
            int tries = 0;

            do
            {
                try
                {
                    PrintDebug("READ " + category + "-" + command);
                    byte[] packet = ConstructPacket(_deviceAddress, RWMode.Read, category, command);
                    bool   success;
                    byte[] response = BlockingSend(packet, out success, ETX);
                    if (success)
                    {
                        int            addr;
                        ResponseStatus status;
                        byte[]         data;
                        ParseResponse(response, out addr, out status, out data);
                        if (data == null)
                        {
                            throw new Exception("Command " + category + "-" + command + " failed. No data parsed! addr=" + addr + " status=" + status.ToString());
                        }


                        string d = ToAsciiChars(data);
                        return((T)Convert.ChangeType(d, typeof(T)));
                    }
                    else
                    {
                        if (response == null)
                        {
                            throw new Exception("Command " + category + "-" + command + " failed. Send failed!");
                        }
                        else
                        {
                            throw new Exception("Command " + category + "-" + command + " failed. No data received!");
                        }
                    }
                }
                catch (FormatException ex)
                {
                    PrintDebug(ex.ToString());
                }
                catch (TimeoutException ex)
                {
                    PrintDebug(ex.ToString());
                }
            }while (tries++ < _serialRetries);

            throw new TimeoutException("Command " + category + "-" + command + " failed. The number of Read attempts was exceeded.");
        }
コード例 #22
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////
    #region Constructors

    /// <summary>
    /// Creates a new instance of the <see cref="CommandCategoryAttribute"/>.
    /// </summary>
    /// <param name="category">The <see cref="CommandCategory"/> to assign the command to.</param>
    /// <param name="order">The order of the command inside the <see cref="CommandCategory"/>.</param>
    /// <exception cref="ArgumentOutOfRangeException"><paramref name="category"/> equals <see cref="CommandCategory.Undefined"/> or <paramref name="order"/> equals 0.</exception>
    public CommandCategoryAttribute(CommandCategory category,
                                    uint order)
    {
        if (category == CommandCategory.Undefined)
        {
            throw new ArgumentOutOfRangeException(nameof(category), $"Value cannot be '{nameof(CommandCategory.Undefined)}'.");
        }
        if (order == 0)
        {
            throw new ArgumentOutOfRangeException(nameof(order), "Value cannot be '0'.");
        }
        Category = category;
        Order    = order;
    }
コード例 #23
0
        /// <summary>
        /// Handle a command
        /// </summary>
        /// <param name="command">Command to handle</param>
        /// <returns>Command process response</returns>
        public static List <string> Handle(string command)
        {
            History.Add(command);
            command = command.Trim();
            if (!string.IsNullOrEmpty(command))
            {
                CommandCategory category = ParseCommandCategory(ref command);

                if (category != CommandCategory.None)
                {
                    if (!string.IsNullOrEmpty(command))
                    {
                        string name = ParseCommandName(ref command);

                        ICommand iCommand = (from c in Commands where c.Name.ToUpper() == name.ToUpper() && c.Category == category select c).FirstOrDefault();
                        if (iCommand != null)
                        {
                            string[] args = ParseCommandArgs(name, command);
                            return(iCommand.Execute(ref args));
                        }
                        else
                        {
                            return(new List <string> {
                                "Unknow command"
                            });                                          //TODO remove string from the code
                        }
                    }
                    else
                    {
                        return(new List <string> {
                            "Empty command name"
                        });                                              //TODO remove string from the code
                    }
                }
                else
                {
                    return(new List <string> {
                        "Unknow category"
                    });                                           //TODO remove string from the code
                }
            }
            else
            {
                return(new List <string> {
                    "Empty command"
                });                                         //TODO remove string from the code
            }
        }
コード例 #24
0
ファイル: MenuBinder.cs プロジェクト: qrunner/Default
        private static void Bind(this ToolStripDropDownItem menuItem, CommandCategory commandCategory)
        {
            menuItem.Name = commandCategory.Name;

            foreach (var command in commandCategory.Commands.ToArray())
            {
                var cmd = command;
                var mi = menuItem.DropDownItems.Add(command.Name) as ToolStripMenuItem;
                //mi.ShortcutKeyDisplayString = command.Shortcut;
                mi.Click += (sender, e) => cmd.Execute(sender);
            }

            foreach (var category in commandCategory.ChildItems)
            {
                ((ToolStripMenuItem) menuItem.DropDownItems.Add(category.Name)).Bind(category);
            }
        }
コード例 #25
0
        public bool ToggleArmedStateForCategory(CommandCategory category)
        {
            if (!categoryConnectors.ContainsKey(category))
            {
                return(false);
            }

            IList <IConnector> connectors = categoryConnectors[category];
            bool arm = !AllCommandsArmedForCategory(category);

            foreach (IConnector connector in connectors)
            {
                if (connector.ICommand.IsSavable)
                {
                    Context.ControlColorer.UpdateState(connector.ICommand, arm ? ControlColorer.ColorState.Armed : ControlColorer.ColorState.Disarmed);
                }
            }
            return(arm);
        }
コード例 #26
0
        public bool AllCommandsArmedForCategory(CommandCategory category)
        {
            if (!categoryConnectors.ContainsKey(category))
            {
                return(false);
            }

            IList <IConnector> connectors = categoryConnectors[category];
            bool anyDisarmed = false;

            foreach (IConnector connector in connectors)
            {
                if (connector.ICommand.IsSavable && !connector.ICommand.IsArmed)
                {
                    anyDisarmed = true;
                    break;
                }
            }

            return(!anyDisarmed);
        }
コード例 #27
0
        internal override string RawCommand(string userinput)
        {
            string reply = string.Empty;

            try
            {
                string[]        parts = userinput.Split(new char[] { ';' }, 2);
                RWMode          mode  = (RWMode)parts[0][0];
                CommandCategory cat   = (CommandCategory)parts[0][1];
                string          cmd   = parts[0].Substring(2, 3);
                reply = mode + " " + cat + "-" + cmd + Environment.NewLine;

                byte[] data = new byte[0];
                if (parts.Length == 2)
                {
                    data = System.Text.Encoding.ASCII.GetBytes(parts[1]);
                }
                byte[] packet = ConstructPacket(_deviceAddress, mode, cat, cmd, data);
                bool   success;
                byte[] response = BlockingSend(packet, out success, Vislink_HDR1000.ETX);
                if (response != null)
                {
                    int            addr;
                    ResponseStatus status;
                    byte[]         respData;
                    ParseResponse(response, out addr, out status, out respData);
                    reply += "Received Bytes: " + ByteArrayToString(response) + Environment.NewLine;
                    reply += " Addr = " + addr + " Status = " + status + " (" + (char)status + ") Data = \"" + ToAsciiChars(respData) + "\"" + Environment.NewLine;
                }
                else
                {
                    reply += "<no response received>" + Environment.NewLine;
                }
            }
            catch (Exception ex)
            {
                reply += Environment.NewLine + ex.ToString();
            }
            return(reply);
        }
コード例 #28
0
        public OperationController()
        {
            _formsController = new FormsController();

            var references = new CommandCategory {Name = "СПРАВОЧНИКИ"};
            references.RegisterCommand(new UiCommand("Единицы измерения", x => _formsController.ShowReference<ReferenceVM<MeasureUnit>, ViewMeasureUnits>()));
            references.RegisterCommand(new UiCommand("Контрагенты", x => _formsController.ShowReference<ReferenceVM<Contractor>, ViewNamedEntity>()));
            references.RegisterCommand(new UiCommand("Организации", x => _formsController.ShowReference<ReferenceVM<Company>, ViewNamedEntity>()));
            references.RegisterCommand(new UiCommand("Категории ТМЦ", x => _formsController.ShowReference<ReferenceVM<UnitCategory>, ViewNamedEntity>()));
            references.RegisterCommand(new UiCommand("Товарно-материальные ценности", x => _formsController.ShowReference<ReferenceVM<Unit>, ViewUnits>()));
            references.RegisterCommand(new UiCommand("Участки учета", x => _formsController.ShowReference<ReferenceVM<AccountingSite>, ViewAccountingSites>()));
            references.RegisterCommand(new UiCommand("Типы документов", x => _formsController.ShowReference<ReferenceVM<DocumentType>, ViewDocumentTypes>()));
            references.RegisterCommand(new UiCommand("Рецепты", x => _formsController.ShowReference<ReferenceVM<Recipe>, ViewNamedEntity>()));

            var accountingSites = new CommandCategory {Name = "УЧЕТ"};

            using (var ctx = new Context())
            {
                foreach (var accountingSite in ctx.Sites)
                {
                    var site = accountingSite;

                    var siteCategory = new CommandCategory {Name = accountingSite.Name};
                    accountingSites.ChildItems.Add(siteCategory);

                    siteCategory.RegisterCommand(new UiCommand("Приход", x => _formsController.Show<UnitEntryListVM, ViewEntryList>(site.Id, UnitEntryListType.Income)));
                    siteCategory.RegisterCommand(new UiCommand("Наличие", x => _formsController.Show<UnitEntryListVM, ViewEntryList>(site.Id, UnitEntryListType.Balance)));
                    siteCategory.RegisterCommand(new UiCommand("Расход", x => _formsController.Show<UnitEntryListVM, ViewEntryList>(site.Id, UnitEntryListType.Outcome)));
                    siteCategory.RegisterCommand(new UiCommand("Документы", x => _formsController.Show<DocumentsListVM, ViewDocuments>(site.Id)));
                }
            }

            var settings = new CommandCategory {Name = "НАСТРОЙКИ"};

            var production = new CommandCategory {Name = "ПРОИЗВОДСТВО"};
            production.RegisterCommand(new UiCommand("Заказы", x => { }));
            production.RegisterCommand(new UiCommand("Наряды", x => { }));

            _categories = new[] {accountingSites, production, references, settings};
        }
コード例 #29
0
        public Connector(Command <T> command, Control control, Label label, CommandCategory category)
        {
            this.command       = command;
            this.control       = control;
            this.label         = label;
            this.category      = category;
            this.lastGoodValue = command.DefaultValue;

            this.queryListener = new ConnectorQueryCommandListener(this);
            this.setListener   = new ConnectorSetCommandListener(this);

            panel           = new Panel();
            panel.Location  = new Point(control.Location.X - 2, control.Location.Y - 2);
            panel.Size      = new Size(control.Size.Width + 4, control.Size.Height + 4);
            panel.BackColor = Color.Transparent;
            Control.Parent.Controls.Add(panel);
            Control.BringToFront();

            Context.ControlColorer.RegisterConnector(this);
            Context.ConnectorRegistry.RegisterConnector(this);

            SetupControl();
            AddControlChangeListener(new EventHandler(ControlChanged));
        }
コード例 #30
0
        public void Deactivate()
        {
            // This method is called by Inventor when the AddIn is unloaded.
            // The AddIn will be unloaded either manually by the user or
            // when the Inventor session is terminated

            // TODO: Add ApplicationAddInServer.Deactivate implementation

            // Release objects.
            m_inventorApplication = null;
            model      = null;
            plus16obj  = null;
            plus128obj = null;
            gear16obj  = null;
            gear128obj = null;

            cmdMan   = null;
            ctrlDefs = null;
            cmdCat.Delete();
            cmdCat        = null;
            drawingRibbon = null;
            placeTab      = null;
            applyButton.Delete();
            applyButton = null;
            settingsButton.Delete();
            settingsButton = null;
            panel.Delete();
            panel = null;
            controlApplyBreak.Delete();
            controlApplyBreak = null;
            controlSettingsBreak.Delete();
            controlSettingsBreak = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the ActionPrimaryAliasAttribute class.
 /// </summary>
 /// <param name="alias">The actual alias that a user types in.</param>
 /// <param name="category">The category that this action is under.</param>
 public ActionPrimaryAliasAttribute(string alias, CommandCategory category)
 {
     this.Alias = alias;
     this.Category = category;
 }
コード例 #32
0
 /// <summary>Initializes a new instance of the ActionAliasAttribute class.</summary>
 /// <param name="alias">An alias for the action.</param>
 /// <param name="category">Category that this action is part of.</param>
 public ActionAliasAttribute(string alias, CommandCategory category)
 {
     Alias    = alias.ToLower();
     Category = category;
 }
コード例 #33
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;

            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.

            ControlDefinitions oCtrlDefs = m_inventorApplication.CommandManager.ControlDefinitions;

            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

            string[] resources = assembly.GetManifestResourceNames();

            System.IO.Stream oStream1 = assembly.GetManifestResourceStream("ZeroRibbon.resources.Icon1.ico");
            System.IO.Stream oStream2 = assembly.GetManifestResourceStream("ZeroRibbon.resources.Icon2.ico");

            System.Drawing.Icon oIcon1 = new System.Drawing.Icon(oStream1);
            System.Drawing.Icon oIcon2 = new System.Drawing.Icon(oStream2);

            object oIPictureDisp1 = AxHostConverter.ImageToPictureDisp(oIcon1.ToBitmap());
            object oIPictureDisp2 = AxHostConverter.ImageToPictureDisp(oIcon2.ToBitmap());

            try
            {
                Zero_GetStarted_LaunchPanel_ButtonDef = oCtrlDefs["Autodesk:ZeroRibbon:ButtonDef1"] as ButtonDefinition;
                Zero_GetStarted_NewPanel_ButtonDef    = oCtrlDefs["Autodesk:ZeroRibbon:ButtonDef2"] as ButtonDefinition;
            }
            catch (Exception ex)
            {
                Zero_GetStarted_LaunchPanel_ButtonDef = oCtrlDefs.AddButtonDefinition("Ribbon Demo1",
                                                                                      "Autodesk:ZeroRibbon:ButtonDef1",
                                                                                      CommandTypesEnum.kEditMaskCmdType,
                                                                                      addInGuid,
                                                                                      "Ribbon Demo",
                                                                                      "Ribbon Demo Description",
                                                                                      oIPictureDisp1,
                                                                                      oIPictureDisp1,
                                                                                      ButtonDisplayEnum.kDisplayTextInLearningMode);

                Zero_GetStarted_NewPanel_ButtonDef = oCtrlDefs.AddButtonDefinition("Ribbon Demo2",
                                                                                   "Autodesk:ZeroRibbon:ButtonDef2",
                                                                                   CommandTypesEnum.kEditMaskCmdType,
                                                                                   addInGuid,
                                                                                   "Ribbon Demo",
                                                                                   "Ribbon Demo Description",
                                                                                   oIPictureDisp2,
                                                                                   oIPictureDisp2,
                                                                                   ButtonDisplayEnum.kDisplayTextInLearningMode);

                CommandCategory cmdCat = m_inventorApplication.CommandManager.CommandCategories.Add("RibbonDemo C#", "Autodesk:CmdCategory:RibbonDemoC#", addInGuid);


                cmdCat.Add(Zero_GetStarted_LaunchPanel_ButtonDef);
                cmdCat.Add(Zero_GetStarted_NewPanel_ButtonDef);
            }



            Ribbon      ribbon      = m_inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
            RibbonTab   tab         = ribbon.RibbonTabs["id_GetStarted"];
            RibbonPanel built_panel = tab.RibbonPanels["id_Panel_Launch"];

            built_panel.CommandControls.AddButton(Zero_GetStarted_LaunchPanel_ButtonDef, true);

            RibbonPanel panel1 = tab.RibbonPanels.Add("Ribbon Demo", "Autodesk:RibbonDemoC#:Panel1", addInGuid, "", false);

            panel1.CommandControls.AddButton(Zero_GetStarted_NewPanel_ButtonDef, true);


            Zero_GetStarted_LaunchPanel_ButtonDef.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(Zero_GetStarted_LaunchPanel_ButtonDef_OnExecute);
            Zero_GetStarted_NewPanel_ButtonDef.OnExecute    += new ButtonDefinitionSink_OnExecuteEventHandler(Zero_GetStarted_NewPanel_ButtonDef_OnExecute);
        }
コード例 #34
0
ファイル: WoWConsole.cs プロジェクト: alex-v-odesk/IceFlake
        public bool RegisterCommand(string command, CommandHandler handler, CommandCategory category, string help)
        {
            if (_registerCommand == null)
                _registerCommand =
                Manager.Memory.RegisterDelegate<ConsoleRegisterCommandDelegate>(
                    (IntPtr)Pointers.Console.RegisterCommand);

            if (_stringPointers.ContainsKey(command)) // Commmand by that name already registered
                return false;

            var cmdPtr = Marshal.AllocHGlobal(command.Length + 1);
            Manager.Memory.WriteString(cmdPtr, command, Encoding.UTF8);

            var helpPtr = Marshal.AllocHGlobal(help.Length + 1);
            Manager.Memory.WriteString(helpPtr, help, Encoding.UTF8);

            _stringPointers.Add(command, new KeyValuePair<IntPtr, IntPtr>(cmdPtr, helpPtr));

            return _registerCommand(cmdPtr, Marshal.GetFunctionPointerForDelegate(handler), category, helpPtr);
        }
コード例 #35
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            try
            {
                //the Activate method is called by Inventor when it loads the addin
                //the AddInSiteObject provides access to the Inventor Application object
                //the FirstTime flag indicates if the addin is loaded for the first time

                //initialize AddIn members
                m_inventorApplication = addInSiteObject.Application;
                InvAddIn.Button.InventorApplication = m_inventorApplication;

                //initialize event delegates
                m_userInterfaceEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

                UserInterfaceEventsSink_OnResetCommandBarsEventDelegate = new UserInterfaceEventsSink_OnResetCommandBarsEventHandler(UserInterfaceEvents_OnResetCommandBars);
                m_userInterfaceEvents.OnResetCommandBars += UserInterfaceEventsSink_OnResetCommandBarsEventDelegate;

                UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate = new UserInterfaceEventsSink_OnResetEnvironmentsEventHandler(UserInterfaceEvents_OnResetEnvironments);
                m_userInterfaceEvents.OnResetEnvironments += UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate;

                UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate = new UserInterfaceEventsSink_OnResetRibbonInterfaceEventHandler(UserInterfaceEvents_OnResetRibbonInterface);
                m_userInterfaceEvents.OnResetRibbonInterface += UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate;

                //load image icons for UI items
                IPictureDisp createMasterMIcon = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap());
                IPictureDisp createMasterMICON = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap());

                IPictureDisp helpIcon = AxHostConverter.ImageToPictureDisp(Resources.icon1.ToBitmap());
                IPictureDisp helpICON = AxHostConverter.ImageToPictureDisp(Resources.icon1.ToBitmap());

                //retrieve the GUID for this class
                GuidAttribute addInCLSID;
                addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(typeof(StandardAddInServer), typeof(GuidAttribute));
                string addInCLSIDString;
                addInCLSIDString = "{" + addInCLSID.Value + "}";

                //create buttons
                ButtON = new BenjaminButton(
                    "MasterModel", "MasterModel:StandardAddInServer:BenjaminBUTTON", CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Create a Master Model File",
                    "keep the model simple", createMasterMIcon, createMasterMICON, ButtonDisplayEnum.kDisplayTextInLearningMode, false);
                //ButtON.HeySherlock = (PartDocument) m_inventorApplication.ActiveDocument;
                Help = new BenjaminButton(
                    "How to", "Help:StandardAddInServer:BenjaminBUTTON", CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Help Creating a Master Model File",
                    "keep the model simple", helpIcon, helpICON, ButtonDisplayEnum.kDisplayTextInLearningMode, true);
                //create the command category
                CommandCategory MasterMCmdCategory = m_inventorApplication.CommandManager.CommandCategories.Add("Master Model", "MasterModel:StandardAddInServer:BenjaminBUTTON", addInCLSIDString);

                MasterMCmdCategory.Add(ButtON.ButtonDefinition);
                MasterMCmdCategory.Add(Help.ButtonDefinition);

                if (firstTime == true)
                {
                    //access user interface manager
                    UserInterfaceManager userInterfaceManager;
                    userInterfaceManager = m_inventorApplication.UserInterfaceManager;

                    InterfaceStyleEnum interfaceStyle;
                    interfaceStyle = userInterfaceManager.InterfaceStyle;

                    //create the UI for classic interface
                    if (interfaceStyle == InterfaceStyleEnum.kClassicInterface)
                    {
                        //create toolbar
                        CommandBar MasterCommander;
                        MasterCommander = userInterfaceManager.CommandBars.Add("Master Model", "MasterModel:StandardAddInServer:BenjaminBUTTONToolbar", CommandBarTypeEnum.kRegularCommandBar, addInCLSIDString);

                        //add buttons to toolbar
                        MasterCommander.Controls.AddButton(ButtON.ButtonDefinition, 0);
                        MasterCommander.Controls.AddButton(Help.ButtonDefinition, 0);

                        //Get the 2d sketch environment base object
                        Inventor.Environment partToolEnvironment;
                        partToolEnvironment = userInterfaceManager.Environments["PMxPartSkEnvironment"];

                        //make this command bar accessible in the panel menu for the Tool environment.
                        partToolEnvironment.PanelBar.CommandBarList.Add(MasterCommander);
                    }
                    //create the UI for ribbon interface
                    else
                    {
                        //get the ribbon associated with part document
                        Inventor.Ribbons ribbons;
                        ribbons = userInterfaceManager.Ribbons;

                        Inventor.Ribbon partRibbon;
                        partRibbon = ribbons["Part"];

                        //get the tabs associated with part ribbon
                        RibbonTabs ribbonTabs;
                        ribbonTabs = partRibbon.RibbonTabs;

                        //get the Tool tab
                        RibbonTab partToolRibbonTab;
                        partToolRibbonTab = ribbonTabs["id_TabTools"];

                        //create a new panel with the tab
                        RibbonPanels ribbonPanels;
                        ribbonPanels = partToolRibbonTab.RibbonPanels;

                        partToolMasterRibbonPanel = ribbonPanels.Add("Master Model", "MasterModel:StandardAddInServer:BenjaminBUTTONRibbonPanel", "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);

                        //add controls to the MasterModel panel
                        CommandControls partToolMasterRibbonPanelCtrls;
                        partToolMasterRibbonPanelCtrls = partToolMasterRibbonPanel.CommandControls;

                        //add the buttons to the ribbon panel
                        CommandControl MasterMoRiPaCtrl;
                        MasterMoRiPaCtrl = partToolMasterRibbonPanelCtrls.AddButton(ButtON.ButtonDefinition, false, true, "", false);
                        MasterMoRiPaCtrl = partToolMasterRibbonPanelCtrls.AddButton(Help.ButtonDefinition, false, true, "", false);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #36
0
        public static void Register(ICommandManager cm) {
            _terminalEdit = new CommandCategory("CommandCategory.TerminalEdit");
            _terminal = new CommandCategory("CommandCategory.Terminal").SetPosition(PositionType.NextTo, _terminalEdit);
            _hiddenTerminal = new CommandCategory("", false);

            //以下、編集メニュー内にあるもの
            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.copyaslook",
                "Command.CopyAsLook", _terminalEdit, new ExecuteDelegate(CmdCopyAsLook), DoesExistSelection));
            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.copytofile",
                "Command.CopyToFile", _terminalEdit, new ExecuteDelegate(CmdCopyToFile), DoesExistSelection));
            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.pastefromfile",
                "Command.PasteFromFile", _terminalEdit, new ExecuteDelegate(CmdPasteFromFile), DoesOpenTargetSession));

            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.clearbuffer",
                "Command.ClearBuffer", _terminalEdit, new ExecuteDelegate(CmdClearBuffer), TerminalCommand.DoesExistTargetSession));
            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.clearscreen",
                "Command.ClearScreen", _terminalEdit, new ExecuteDelegate(CmdClearScreen), TerminalCommand.DoesExistTargetSession));

            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.selectall",
                "Command.SelectAll", _terminalEdit, new ExecuteDelegate(CmdSelectAll), TerminalCommand.DoesExistCharacterDocumentViewer));

            //以下、コンソールメニュー内にあるもの
            //TODO いくつかはTerminalSessionにあるべき意味合いだ
            //cm.Register(new TerminalCommand("org.poderosa.terminalemulator.reproduce", new ExecuteDelegate(CmdReproduce), new EnabledDelegate(DoesOpenTargetSession)));

            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.newline.cr",
                "Command.NewLine.CR", _hiddenTerminal, new ExecuteDelegate(CmdNewLineCR), DoesOpenTargetSession));
            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.newline.lf",
                "Command.NewLine.LF", _hiddenTerminal, new ExecuteDelegate(CmdNewLineLF), DoesOpenTargetSession));
            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.newline.crlf",
                "Command.NewLine.CRLF", _hiddenTerminal, new ExecuteDelegate(CmdNewLineCRLF), DoesOpenTargetSession));

            foreach (EncodingType enc in Enum.GetValues(typeof(EncodingType))) {
                EncodingType encodingType = enc;
                cm.Register(
                    new TerminalCommand("org.poderosa.terminalemulator.encoding." + encodingType.ToString(),
                    "Command.Encoding." + encodingType.ToString(), _hiddenTerminal,
                    delegate(ICommandTarget target) {
                        return CmdEncoding(target, encodingType);
                    },
                    DoesOpenTargetSession));
            }

            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.receivelinebreak",
                "Command.ReceiveLineBreak", _terminal, new ExecuteDelegate(CmdReceiveLineBreak), DoesOpenTargetSession));

            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.togglelocalecho",
                "Command.ToggleLocalEcho", _terminal, new ExecuteDelegate(CmdToggleLocalEcho), DoesOpenTargetSession));


            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.sendbreak",
                "Command.SendBreak", _terminal, new ExecuteDelegate(CmdSendBreak), DoesOpenTargetSession));
            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.sendAYT",
                "Command.AreYouThere", _terminal, new ExecuteDelegate(CmdSendAYT), DoesOpenTargetSession));
            cm.Register(new TerminalCommand("org.poderosa.terminalemulator.resetterminal",
                "Command.ResetTerminal", _terminal, new ExecuteDelegate(CmdResetTerminal), DoesOpenTargetSession));

            //IntelliSense
            cm.Register(new ToggleIntelliSenseCommand());
        }
コード例 #37
0
 public TerminalCommand(string id, string description, CommandCategory category, ExecuteDelegate body, CanExecuteDelegate enabled)
     :
     base(id, GEnv.Strings, description, category, body, enabled) {
 }
コード例 #38
0
 public CommandCategory SetPosition(PositionType positiontype, CommandCategory target) {
     _positionType = positiontype;
     _designationTarget = target;
     return this;
 }
コード例 #39
0
 /// <summary>
 /// Initializes a new instance of the ActionAliasAttribute class.
 /// </summary>
 /// <param name="alias">An alias for the action.</param>
 /// <param name="category">Category that this action is part of.</param>
 public ActionAliasAttribute(string alias, CommandCategory category)
 {
     this.Alias = alias.ToLower();
     this.Category = category;
 }
コード例 #40
0
ファイル: CommandManager.cs プロジェクト: fragmer/fCraft
 /// <summary> Gets a list of commands in a specified category.
 /// Note that commands may belong to more than one category. </summary>
 public static CommandDescriptor[] GetCommands( CommandCategory category, bool includeHidden ) {
     List<CommandDescriptor> list = new List<CommandDescriptor>();
     foreach( CommandDescriptor cmd in Commands.Values ) {
         if( (!cmd.IsHidden || includeHidden) && (cmd.Category & category) == category ) {
             list.Add( cmd );
         }
     }
     return list.ToArray();
 }