Ejemplo n.º 1
0
    public CommandNode DisplayCommandAsNode(Command command)
    {
        GameObject  nodeObject = Instantiate(GetNodePrefab(command), background.transform);
        CommandNode node       = nodeObject.GetComponent <CommandNode>();

        nodes.Add(node);
        node.attachedCommand = command;
        command.SetConnectedNode(node);

        RectTransform rect = node.transform as RectTransform;

        rect.anchoredPosition = command.connectedNodePosition;

        if (node is PrintNode)
        {
            ((PrintNode)node).SetInputField();
        }
        if (node is IfSeeNode)
        {
            ((IfSeeNode)node).SetInputField();
        }
        if (node is IfInfrontNode)
        {
            ((IfInfrontNode)node).SetInputField();
        }

        return(node);
    }
Ejemplo n.º 2
0
 private void trackBar_Scroll(object sender, EventArgs e)
 {
     Guid        channelId   = _commands[trackBar.Value].Item1;
     CommandNode commandNode = _commands[trackBar.Value].Item2;
     //TODO
     //VixenSystem.Channels.GetChannel(channelId).AddData(commandNode);
 }
Ejemplo n.º 3
0
        public bool AddCommand(Command command)
        {
            var root = command.Path.First();

            if (!_root.ContainsKey(root))
            {
                _root.Add(root, new CommandNode(root));
            }

            var node = _root[root];

            for (var i = 1; i < command.Path.Count; i++)
            {
                var current = command.Path[i];
                if (node.Subcommands.ContainsKey(current))
                {
                    node = node.Subcommands[current];
                    continue;
                }

                var newNode = new CommandNode(current);
                node.AddNode(newNode);
                node = newNode;
            }

            if (!node.IsEmpty)
            {
                return(false);
            }

            node.Command = command;
            return(true);
        }
Ejemplo n.º 4
0
        private void GetAllUsage(CommandNode <TSource> node, TSource source, List <string> result, string prefix, bool restricted)
        {
            if (restricted && !node.CanUse(source))
            {
                return;
            }

            if (node.Command != null)
            {
                result.Add(prefix);
            }

            if (node.Redirect != null)
            {
                var redirect = node.Redirect == _root ? "..." : "-> " + node.Redirect.UsageText;
                result.Add(prefix.Length == 0 ? node.UsageText + ArgumentSeparator + redirect : prefix + ArgumentSeparator + redirect);
            }
            else if (node.Children.Count > 0)
            {
                foreach (var child in node.Children)
                {
                    GetAllUsage(child, source, result, prefix.Length == 0 ? child.UsageText : prefix + ArgumentSeparator + child.UsageText, restricted);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get a command node from the tree.
        /// </summary>
        /// <param name="path">Path to the command node.</param>
        /// <param name="commandNode"></param>
        /// <returns>The index of the first argument in the path or -1 if the node doesn't exist.</returns>
        public int GetNode(List <string> path, out CommandNode commandNode)
        {
            commandNode = null;
            var root = path.FirstOrDefault();

            if (root == null)
            {
                return(-1);
            }

            if (!_root.ContainsKey(root))
            {
                return(-1);
            }

            var node = _root[root];
            var i    = 1;

            for (; i < path.Count; i++)
            {
                var current = path[i];
                if (node.Subcommands.ContainsKey(current))
                {
                    node = node.Subcommands[current];
                }
                else
                {
                    break;
                }
            }

            commandNode = node;
            return(i);
        }
Ejemplo n.º 6
0
        public void GetLinearNodesTest()
        {
            var node     = new CommandNode();
            var command1 = new Command {
                Name = "show config"
            };
            var command2 = new Command {
                Name = "show"
            };
            var command3 = new Command {
                Name = "show test"
            };
            var command4 = new Command {
                Name = "linear"
            };

            node.Add(command1);
            node.Add(command2);
            node.Add(command3);
            node.Add(command4);

            int count = 0;

            foreach (var n in node.LinearNodes)
            {
                count++;
            }
            Assert.IsTrue(count == 4);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Loads previously stored projects and existing commands
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Home_Load(object sender, EventArgs e)
        {
            this.Text = Constants.FORM_TITLE;

            if (File.Exists(Constants.PROJECT_LIST))
            {
                // try loading each project
                foreach (string proj in File.ReadAllLines(Constants.PROJECT_LIST))
                {
                    try
                    {
                        Analysis     analysis     = Analysis.Load(proj);
                        AnalysisNode analysisNode = new AnalysisNode(analysis);
                        analysisNode.Control = new AnalysisOverview(analysisNode);
                        tree.Nodes.Add(analysisNode);

                        // try loading all commands
                        string memoryImage = analysis.MemoryImage;
                        foreach (string file in Directory.GetFiles(Path.GetDirectoryName(memoryImage), Path.GetFileName(memoryImage) + "-*.command"))
                        {
                            Command     cmd         = Command.Load(file);
                            CommandNode commandNode = new CommandNode(analysisNode, cmd);
                            commandNode.Control = new AnalysisCommand(commandNode);
                            analysisNode.Nodes.Add(commandNode);
                        }

                        analysisNode.ExpandAll();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Failed to open project:" + Environment.NewLine + ex.Message, Constants.MEMORY_ANALYZER_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 注册以字面量打头的指令
        /// </summary>
        /// <param name="head">指令头</param>
        /// <returns>注册的第一个节点</returns>
        public CommandNode <TEnv> Register(string head)
        {
            CommandNode <TEnv> n = PresetNodes.Literal <TEnv>(head);

            Root.AddChild(n);
            return(n);
        }
Ejemplo n.º 9
0
        /**
         * Gets all possible executable commands following the given node.
         *
         * <p>You may use {@link #getRoot()} as a target to get all usage data for the entire command tree.</p>
         *
         * <p>The returned syntax will be in "simple" form: {@code <param>} and {@code literal}. "Optional" nodes will be
         * listed as multiple entries: the parent node, and the child nodes.
         * For example, a required literal "foo" followed by an optional param "int" will be two nodes:</p>
         * <ul>
         *     <li>{@code foo}</li>
         *     <li>{@code foo <int>}</li>
         * </ul>
         *
         * <p>The path to the specified node will <b>not</b> be prepended to the output, as there can theoretically be many
         * ways to reach a given node. It will only give you paths relative to the specified node, not absolute from root.</p>
         *
         * @param node target node to get child usage strings for
         * @param source a custom "source" object, usually representing the originator of this command
         * @param restricted if true, commands that the {@code source} cannot access will not be mentioned
         * @return array of full usage strings under the target node
         */
        public string[] GetAllUsage(CommandNode <TSource> node, TSource source, bool restricted)
        {
            var result = new List <string>();

            GetAllUsage(node, source, result, "", restricted);
            return(result.ToArray());
        }
Ejemplo n.º 10
0
        internal void UpdateNode(CommandNode node)
        {
            Color color = Color.Black;  // default

            switch (node.Command.Status)
            {
            case Command.CommandStatus.CREATED:
                color = Color.LightGray;
                break;

            case Command.CommandStatus.QUEUED:
                Interlocked.Increment(ref jobCounter);
                color = Color.LightGray;
                break;

            case Command.CommandStatus.RUNNING:
                color = Color.Blue;
                break;

            case Command.CommandStatus.ABORTED:
                Interlocked.Decrement(ref jobCounter);
                color = Color.Red;
                break;

            case Command.CommandStatus.COMPLETED:
                Interlocked.Decrement(ref jobCounter);
                color = Color.Green;
                break;
            }
            node.ForeColor = color;
            lblStatus.Text = jobCounter == 0 ? "Idle" : string.Format("{0} job{1}", jobCounter, jobCounter > 1 ? "s" : "");
        }
        public void CommandEquality()
        {
            string rawLine = "::from ./bsinstalldir.txt";

            CommandNode.CommandType commandType = CommandNode.CommandType.From;
            string      commandData             = "./bsinstalldir.txt";
            CommandNode node1 = new CommandNode(rawLine);
            CommandNode node2 = new CommandNode(commandType, commandData);

            Assert.AreEqual(node1.RawLine, node2.RawLine);

            rawLine     = "::startopt";
            commandType = CommandNode.CommandType.OptionalBlock;
            commandData = "";
            node1       = new CommandNode(rawLine);
            node2       = new CommandNode(commandType, commandData);
            Assert.AreEqual(node1.RawLine, node2.RawLine);

            //rawLine = "::endopt";
            //commandType = CommandNode.CommandType.EndOptionalBlock;
            //commandData = "";
            node1 = new CommandNode(rawLine);
            node2 = new CommandNode(commandType, commandData);
            Assert.AreEqual(node1.RawLine, node2.RawLine);
        }
Ejemplo n.º 12
0
/**
 * Finds a valid path to a given node on the command tree.
 *
 * <p>There may theoretically be multiple paths to a node on the tree, especially with the use of forking or redirecting.
 * As such, this method makes no guarantees about which path it finds. It will not look at forks or redirects,
 * and find the first instance of the target node on the tree.</p>
 *
 * <p>The only guarantee made is that for the same command tree and the same version of this library, the result of
 * this method will <b>always</b> be a valid input for {@link #findNode(Collection)}, which should return the same node
 * as provided to this method.</p>
 *
 * @param target the target node you are finding a path for
 * @return a path to the resulting node, or an empty list if it was not found
 */
        public List <string> GetPath(CommandNode <TSource> target)
        {
            var nodes = new List <List <CommandNode <TSource> > >();

            AddPaths(_root, nodes, new List <CommandNode <TSource> >());

            foreach (var list in nodes)
            {
                if (list[list.Count - 1] == target)
                {
                    var result = new List <string>(list.Count);
                    foreach (var node in list)
                    {
                        if (node != _root)
                        {
                            result.Add(node.Name);
                        }
                    }

                    return(result);
                }
            }

            return(new List <string>());
        }
Ejemplo n.º 13
0
        private CommandNode.CommandFlags GetFlags(CommandNode n)
        {
            CommandNode.CommandFlags v;
            if (n is RootCommandNode)
            {
                v = CommandNode.CommandFlags.Type_Root;
            }
            else if (n is ArgumentCommandNode)
            {
                v = CommandNode.CommandFlags.Type_Argument;
            }
            else if (n is LiteralCommandNode)
            {
                v = CommandNode.CommandFlags.Type_Literal;
            }
            //this wont happen
            else
            {
                throw new Exception();
            }

            if (n.RedirectNode != null)
            {
                v |= CommandNode.CommandFlags.HasRedirect;
            }
            if (n.CommandNodes.All(x => x.GetType() == typeof(FunctionCommandNode)))
            {
                v |= CommandNode.CommandFlags.IsExecutable;
            }
            return(v);
        }
Ejemplo n.º 14
0
        private void WriteNode(CommandNode v, CommandNode[] Other)
        {
            var flags = GetFlags(v);

            Write((byte)flags);
            Write((VarInt)v.CommandNodes.ToArray().Length);
            if ((flags & CommandNode.CommandFlags.IsExecutable) != 0)
            {
                List <int> Indices = new List <int>();
                foreach (var v2 in v.CommandNodes)
                {
                    Indices.Add(Array.IndexOf(Other, v2)); //lets just assume its there
                }
                WriteArray(Indices.ToArray());
            }
            if ((flags & CommandNode.CommandFlags.HasRedirect) != 0)
            {
                Write(Array.IndexOf(Other, v.RedirectNode));
            }
            if (v is LiteralCommandNode)
            {
                Write((v as LiteralCommandNode).name);
            }
            if (v is ArgumentCommandNode)
            {
                var x2 = v as ArgumentCommandNode;
                Write(x2.name);
                Write(x2.parser.ID);
                //TODO: properties of parser
            }

            /*if ((flags & CommandNode.CommandFlags.HasCustomSuggestions) != 0)
             *  Write(SuggestionType);*///TODO: Suggestion Type
        }
 public OptionNode(
     Token token,
     Option option,
     CommandNode parent) : base(token, parent)
 {
     Option = option;
 }
Ejemplo n.º 16
0
        public override Node visitCommand(JuliarParser.CommandContext ctx)
        {
            CommandNode commandNode = new CommandNode();

            new IterateOverContext(this, ctx, this, commandNode);
            return(commandNode);
        }
Ejemplo n.º 17
0
        public int CalculatePages(Cairo.Context cr)
        {
            _cr = cr;

            // Determine certain extents for all fonts for the current context.
            foreach (FontInfo font in _appSettings.Fonts)
            {
                font.SetExtents(_cr);
            }

            // Generate page nodes
            int      pageNumber  = 0;
            PageNode currentPage = CreateNewPage(pageNumber++);

            foreach (BaseNode line in _rawLineNodes)
            {
                if (line is CommandNode)
                {
                    CommandNode command = (CommandNode)line;
                    switch (command.CommandType)
                    {
                    case CommandType.NewPage:
                        currentPage = CreateNewPage(pageNumber++);
                        break;

                    case CommandType.BeginRegion:
                        currentPage.BeginRegion(command.RegionType);
                        break;

                    case CommandType.EndRegion:
                        currentPage.EndRegion();
                        break;
                    }
                }
                else
                {
                    if (!currentPage.TryAddLine(cr, line))
                    {
                        currentPage = CreateNewPage(pageNumber++);
                        currentPage.TryAddLine(cr, line);
                    }
                }
            }

            if (_renderOption == RenderOption.ScreenView)
            {
                //_displayHeightExtent = ((Y_DISPLAY_MARGIN + _paperHeight) * _pages.Count) + Y_DISPLAY_MARGIN;
                _displayHeightExtent = ((Constants.Y_DISPLAY_MARGIN + _paperHeight) * _pages.Count) + Constants.Y_DISPLAY_MARGIN;
                _displayWidthExtent  = (Constants.X_DISPLAY_MARGIN * 2) + _paperWidth;
            }

            // Now update the total count for each page to render their header/footer information
            foreach (PageNode page in _pages)
            {
                page.SetTotalPageCount(_pages.Count);
            }

            return(_pages.Count);
        }
Ejemplo n.º 18
0
 public CommandContextBuilder <TSource> WithNode(CommandNode <TSource> node, StringRange range)
 {
     Nodes.Add(new ParsedCommandNode <TSource>(node, range));
     Range     = StringRange.Encompassing(Range, range);
     _modifier = node.RedirectModifier;
     _forks    = node.IsFork;
     return(this);
 }
Ejemplo n.º 19
0
 public DeclareCommands() : base(0x11, new byte[0])
 {
     this.RootNode = new CommandNode()
     {
         Type  = CommandNodeType.Root,
         Owner = this,
     };
 }
Ejemplo n.º 20
0
        public void AddFactory(IResourceFactory factory)
        {
            factories.Add(factory);

            // register factory command node
            var playCommand = new PlayCommand(factory.FactoryFor);

            CommandNode.AddCommand(factory.SubCommandName, playCommand.Command);
        }
Ejemplo n.º 21
0
 public CommandContextBuilder(CommandDispatcher <TSource> dispatcher, TSource source, CommandNode <TSource> rootNode, StringRange range, IDictionary <string, IParsedArgument> arguments, List <ParsedCommandNode <TSource> > nodes)
 {
     Dispatcher = dispatcher;
     Source     = source;
     RootNode   = rootNode;
     Range      = range;
     _arguments = new Dictionary <string, IParsedArgument>(arguments);
     Nodes      = new List <ParsedCommandNode <TSource> >(nodes);
 }
Ejemplo n.º 22
0
        public override void OnRegister(CmdDispatcher <DMEnv> dispatcher)
        {
            IDictionary <object, object> hardnessMap = new Dictionary <object, object> {
                ["普通"] = CheckResult.NormalSuccess,
                ["困难"] = CheckResult.HardSuccess,
                ["极难"] = CheckResult.ExtremeSuccess,
            };
            IDictionary <object, object> twiceMap = new Dictionary <object, object> {
                ["奖励"] = true,
                ["惩罚"] = false,
            };

            dispatcher.Register("检定").Then(
                MainAction = PresetNodes.String <DMEnv>("数值名")
                             .Handles(Extensions.ExistSelfValue)
                             .Executes((DMEnv env, Args args, Args dict) => SimpleCheck(env, env.Inv, args.GetStr("数值名"), CheckResult.NormalSuccess))
                             .Then(
                    PresetNodes.Or <DMEnv>("难度", "普通", "困难", "极难")
                    .Handles(PreProcesses.MapArg <DMEnv>(hardnessMap))
                    .Executes((DMEnv env, Args args, Args dict) => SimpleCheck(env, env.Inv, args.GetStr("数值名"), args.GetInt("难度")))
                    .Then(
                        PresetNodes.Or <DMEnv>("奖惩", "奖励", "惩罚")
                        .Handles(PreProcesses.MapArg <DMEnv>(twiceMap))
                        .Executes((DMEnv env, Args args, Args dict) => TwiceCheck(env, env.Inv, args.GetStr("数值名"), args.GetBool("奖惩"), args.GetInt("难度")))
                        )
                    ).Then(
                    PresetNodes.Or <DMEnv>("奖惩", "奖励", "惩罚")
                    .Handles(PreProcesses.MapArg <DMEnv>(twiceMap))
                    .Executes((DMEnv env, Args args, Args dict) => TwiceCheck(env, env.Inv, args.GetStr("数值名"), args.GetBool("奖惩"), CheckResult.NormalSuccess))
                    ).Then(
                    PresetNodes.Literal <DMEnv>("对抗").Then(
                        PresetNodes.String <DMEnv>("对手名")
                        .Handles(Extensions.ExistInv)
                        .Executes((DMEnv env, Args args, Args dict) => CheckAgainst(env, env.Inv, args.GetStr("数值名"), args.GetInv("对手名"), args.GetStr("数值名"), false))
                        .Then(
                            PresetNodes.String <DMEnv>("对抗数值名")
                            .Executes((DMEnv env, Args args, Args dict) => CheckAgainst(env, env.Inv, args.GetStr("数值名"), args.GetInv("对手名"), args.GetStr("对抗数值名"), false))
                            )
                        )
                    ).Then(
                    PresetNodes.Literal <DMEnv>("等级对抗").Then(
                        PresetNodes.String <DMEnv>("对手名")
                        .Handles(Extensions.ExistInv)
                        .Executes((DMEnv env, Args args, Args dict) => CheckAgainst(env, env.Inv, args.GetStr("数值名"), args.GetInv("对手名"), args.GetStr("数值名"), true))
                        .Then(
                            PresetNodes.String <DMEnv>("对抗数值名")
                            .Executes((DMEnv env, Args args, Args dict) => CheckAgainst(env, env.Inv, args.GetStr("数值名"), args.GetInv("对手名"), args.GetStr("对抗数值名"), true))
                            )
                        )
                    ).Then(
                    PresetNodes.String <DMEnv>("目标")
                    .Executes((DMEnv env, Args args, Args dict) => SimpleCheckTo(env, env.Inv, args.GetStr("数值名"), args.GetStr("目标")))
                    )
                );

            dispatcher.SetAlias("ch", "检定");
        }
Ejemplo n.º 23
0
        private CommandNode ResolveCommand(Dictionary <string, string> variables, XmlElement element)
        {
            var cmd = new CommandNode();

            foreach (XmlNode item in element.ChildNodes)
            {
                if (item.NodeType == XmlNodeType.Text)
                {
                    var text = ReplaceVariable(variables, item.Value);
                    cmd.Nodes.Add(new TextNode
                    {
                        Value = text
                    });
                }
                else if (item.NodeType == XmlNodeType.Element && item.Name == "where")
                {
                    var whereNode = new WhereNode();
                    foreach (XmlNode iitem in item.ChildNodes)
                    {
                        if (iitem.NodeType == XmlNodeType.Text)
                        {
                            var text = ReplaceVariable(variables, iitem.Value);
                            whereNode.Nodes.Add(new TextNode
                            {
                                Value = text
                            });
                        }
                        else if (iitem.NodeType == XmlNodeType.Element && iitem.Name == "if")
                        {
                            var test  = iitem.Attributes["test"].Value;
                            var value = string.IsNullOrEmpty(iitem.InnerText) ?
                                        (iitem.Attributes["value"]?.Value ?? string.Empty) : iitem.InnerText;
                            value = ReplaceVariable(variables, value);
                            whereNode.Nodes.Add(new IfNode
                            {
                                Test  = test,
                                Value = value
                            });
                        }
                    }
                    cmd.Nodes.Add(whereNode);
                }
                else if (item.NodeType == XmlNodeType.Element && item.Name == "if")
                {
                    var test  = item.Attributes["test"].Value;
                    var value = string.IsNullOrEmpty(item.InnerText) ?
                                (item.Attributes["value"]?.Value ?? string.Empty) : item.InnerText;
                    value = ReplaceVariable(variables, value);
                    cmd.Nodes.Add(new IfNode
                    {
                        Test  = test,
                        Value = value
                    });
                }
            }
            return(cmd);
        }
Ejemplo n.º 24
0
 public CommandContextBuilder(CommandDispatcher <TSource> dispatcher, TSource source, CommandNode <TSource> rootNode, int start)
 {
     RootNode   = rootNode;
     Dispatcher = dispatcher;
     Source     = source;
     Range      = StringRange.At(start);
     _arguments = new Dictionary <string, IParsedArgument>();
     Nodes      = new List <ParsedCommandNode <TSource> >();
 }
Ejemplo n.º 25
0
        private CommandNode ResolveCommand(XmlElement element)
        {
            var cmd = new CommandNode();

            foreach (XmlNode item in element.ChildNodes)
            {
                if (item.Name == "var" || item.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }
                if (item.NodeType == XmlNodeType.Text)
                {
                    cmd.Nodes.Add(new TextNode
                    {
                        Value = item.Value
                    });
                }
                else if (item.NodeType == XmlNodeType.Element && item.Name == "where")
                {
                    var whereNode = new WhereNode();
                    foreach (XmlNode iitem in item.ChildNodes)
                    {
                        if (iitem.NodeType == XmlNodeType.Text)
                        {
                            whereNode.Nodes.Add(new TextNode
                            {
                                Value = iitem.Value
                            });
                        }
                        else if (iitem.NodeType == XmlNodeType.Element && iitem.Name == "if")
                        {
                            var test  = iitem.Attributes["test"].Value;
                            var value = string.IsNullOrEmpty(iitem.InnerText) ?
                                        (iitem.Attributes["value"]?.Value ?? string.Empty) : iitem.InnerText;
                            whereNode.Nodes.Add(new IfNode
                            {
                                Test  = test,
                                Value = value
                            });
                        }
                    }
                    cmd.Nodes.Add(whereNode);
                }
                else if (item.NodeType == XmlNodeType.Element && item.Name == "if")
                {
                    var test  = item.Attributes["test"].Value;
                    var value = string.IsNullOrEmpty(item.InnerText) ?
                                (item.Attributes["value"]?.Value ?? string.Empty) : item.InnerText;
                    cmd.Nodes.Add(new IfNode
                    {
                        Test  = test,
                        Value = value
                    });
                }
            }
            return(cmd);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Generates a full tree from a CommandeNode tree.
        /// </summary>
        /// <param name="node"></param>
        public RemoteCommand(CommandNode node) : base(null, node.name, node.description)
        {
            this.isLeaf = node.IsLeaf;

            for (int i = 0; i < node.children.Count; i++)
            {
                this.AddChild(new RemoteCommand(node.children[i]));
            }
        }
Ejemplo n.º 27
0
        public void AddNode(CommandNode node)
        {
            this.Nodes.Add(node);

            foreach (var child in node.Children)
            {
                this.AddNode(child);
            }
        }
Ejemplo n.º 28
0
 public TThis Then(CommandNode <TSource> argument)
 {
     if (RedirectTarget != null)
     {
         throw new InvalidOperationException("Cannot add children to a redirected node");
     }
     _arguments.AddChild(argument);
     return(This);
 }
Ejemplo n.º 29
0
        public static void PrintHelp(DMEnv env, string head)
        {
            CommandNode <DMEnv> node = null;

            if ((node = Global.Dispatcher[head]) != null)
            {
                env.Next = string.Join("\n", node.GetHelp());
            }
            env.Next = $"未找到指令:{head}";
        }
Ejemplo n.º 30
0
 public AnalysisCommand(CommandNode node)
 {
     InitializeComponent();
     this.node = node;
     this.Dock = DockStyle.Fill;
     txtOutput.Control.DataBindings.Add("Text", node.Command, "LastLog");
     lblStatus.Text = node.Command.Status.ToString();
     node.Command.PropertyChanged += Command_PropertyChanged;
     node.Control = this;
 }
Ejemplo n.º 31
0
        public ChannelData Render(CommandNode commandNode, TimeSpan commandTimeSpan, TimeSpan renderStartTime, TimeSpan renderTimeSpan)
        {
            // We're adding only the parameter values.
            ChannelData data = _effect.Render(commandNode.TargetNodes.ToArray(), commandTimeSpan, ParameterValues);

            // And then restricting by time.
            TimeSpan renderEndTime = renderStartTime + renderTimeSpan;
            data = ChannelData.Restrict(data, renderStartTime, renderEndTime);

            return data;
        }
Ejemplo n.º 32
0
		bool Instance_OnExecutionStopped(CommandNode cmd, bool isCompleted = false, CommandResult rlt = null)
		{
			if (cmd is ValidateDbCommand)
			{
				ValidateDbCommand v = (ValidateDbCommand)cmd;
                if (v.IsNoException)
                {
                    if (MessageBox.Show(v.ErrorMsg, "Validation failed", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                    {
                        rlt.ShouldStop = false;
                        return false;
                    }
                }
			}
			RemoveEvents();
			Wizard.UpdateStatus("1000");
			return true;
		}
Ejemplo n.º 33
0
		void State_OnExecCmd(CommandNode cmd, bool isCompleted = false, CommandResult rlt = null)
		{
			this.Invoke((MethodInvoker)delegate
			{
				if (isCompleted && !rlt.IsSuccessful)
				{
					cmd.ExecStatus = CommandStatus.Error;
					cmd.Error = rlt.LastError;
				}
				else if (isCompleted && rlt.IsSuccessful)
				{
					cmd.ExecStatus = CommandStatus.Success;
				}
				lvCmd.Update();
				lvCmd.Invalidate();
			});
		}
Ejemplo n.º 34
0
		void Instance_OnRunCompleted(CommandNode run2Cmd, CommandNode runFromCmd, bool isStopOnError = false)
		{
			ExceptionHandler.IsFullHandling = isFullHandling;
			ExceptionHandler.Handlers.Remove(OutputError);
			OutputHandler.Handlers.Remove(Output);
			RemoveEvents();
            if (isStopOnError)
            {
                MessageBox.Show("Execution stopped by an error.  Please select the item with error status to view the details.", "Stop on Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
			Wizard.UpdateStatus("1000");
		}
Ejemplo n.º 35
0
		void Instance_OnRun(CommandNode run2Cmd, CommandNode runFromCmd)
		{
			if (run2Cmd == null && runFromCmd == null)
			{
				InitCmdStatus();
			}
			isFullHandling = ExceptionHandler.IsFullHandling;
			ExceptionHandler.IsFullHandling = false;
			ExceptionHandler.Handlers.Add(OutputError);
			OutputHandler.Handlers.Add(Output);
		}
Ejemplo n.º 36
0
		void PreviewCmdCallback(CommandNode cmd, bool isComplete, CommandResult rlt)
		{
			if (!(cmd is IfCommand) && !(cmd is DescriptionsCommand) && !(cmd is SetCommand))
			{
				cmds.Add(cmd);
			}
		}
 public void RecordCallStatus(CommandNode node, string description)
 {
     _log[node].Add(description);
     LastLogEntry = description;
 }
 private void LoadAvailableFieldsTree()
 {
     IDataSourceFieldSchema[] fieldSchemas = this.GetFieldSchemas();
     if ((fieldSchemas != null) && (fieldSchemas.Length > 0))
     {
         this._selectedDataSourceNode = new DataSourceNode();
         this._availableFieldsTree.Nodes.Add(this._selectedDataSourceNode);
         this._selectedCheckBoxDataSourceNode = new BoolDataSourceNode();
         this._availableFieldsTree.Nodes.Add(this._selectedCheckBoxDataSourceNode);
     }
     HyperLinkNode node = new HyperLinkNode(this);
     this._availableFieldsTree.Nodes.Add(node);
     ImageNode node2 = new ImageNode(this);
     this._availableFieldsTree.Nodes.Add(node2);
     ButtonNode node3 = new ButtonNode(this);
     this._availableFieldsTree.Nodes.Add(node3);
     CommandNode node4 = new CommandNode(this);
     this._availableFieldsTree.Nodes.Add(node4);
     CommandNode node5 = new CommandNode(this, 0, System.Design.SR.GetString("DCFEditor_Node_Edit"), 6);
     node4.Nodes.Add(node5);
     if (this.Control is GridView)
     {
         CommandNode node6 = new CommandNode(this, 2, System.Design.SR.GetString("DCFEditor_Node_Select"), 5);
         node4.Nodes.Add(node6);
     }
     CommandNode node7 = new CommandNode(this, 3, System.Design.SR.GetString("DCFEditor_Node_Delete"), 7);
     node4.Nodes.Add(node7);
     if (this.Control is DetailsView)
     {
         CommandNode node8 = new CommandNode(this, 1, System.Design.SR.GetString("DCFEditor_Node_Insert"), 11);
         node4.Nodes.Add(node8);
     }
     TemplateNode node9 = new TemplateNode(this);
     this._availableFieldsTree.Nodes.Add(node9);
 }
Ejemplo n.º 39
0
		public SettingTag AddCmdItem(string name, CommandNode target, string field, int editorType = 0, bool isReadonly = false)
		{
			if (target == null)
			{
				return null;
			}
			UICommandNode ucmd = null;
			if (target is UICommandNode)
			{
				ucmd = (UICommandNode)target;
			}
			PathBrowser pb = new PathBrowser();
			ComboBox rd = new ComboBox();
			TextBox editor = new TextBox();
			CheckBox ck = new CheckBox();
			Label lb = new Label { Text = name, AutoSize = true };
			if (!string.IsNullOrEmpty(target.Editor) && editors.ContainsKey(target.Editor))
			{
				editorType = editors[target.Editor];
			}
			editor.AllowDrop = true;
            editor.MouseDoubleClick += new MouseEventHandler(editor_MouseDoubleClick);
			ck.Enabled = !isReadonly;
			editor.Enabled = !isReadonly;
			rd.Enabled = !isReadonly;
			lb.MouseDown += new MouseEventHandler(lb_MouseDown);
			SettingTag rlt = null;
			FieldInfo f = target.GetType().GetField(field);
			if (f != null)
			{
				rlt = new SettingTag { FieldInfo = f, Target = target };
				lb.Tag = rlt;
				object value = f.GetValue(target);
				rlt.EditorType = editorType;
				rlt.LabelControl = lb;
				if (editorType == 1)
				{
					rlt.EditControl = ck;
					ck.Tag = rlt;
					ck.Checked = value != null ? bool.Parse(value.ToString()) : false;
					ck.CheckedChanged += new EventHandler(ck_CheckedChanged);
					UpdatePos(lb, ck);
					NotifyUINode(ucmd, ck, lb);
				}
				else if (editorType == 2)
				{
					ArrayCommand arr = target as ArrayCommand;
					if (arr != null)
					{
						//rd.DataSource = null;
						rd.Items.Clear();	 
						rlt.EditControl = rd;
						rd.Tag = rlt;
						//rd.DataSource = arr.GetList();
						rd.Items.AddRange(arr.GetList());
						rd.SelectedIndex = arr.SelectedIndex;
						rd.SelectedIndexChanged += new EventHandler(rd_SelectedIndexChanged);						
						UpdatePos(lb, rd);
						NotifyUINode(ucmd, rd, lb);
					}
				}
				else if (editorType == 3)
				{
					rlt.EditControl = pb;
					pb.Tag = rlt;
					if (value != null)
					{
						pb.StartupPath = value.ToString();
					}
					pb.OnTextChanged+=new Action<PathBrowser>(pb_OnTextChanged);
					UpdatePos(lb, pb);
					NotifyUINode(ucmd, pb, lb);
				}
				else
				{
					if (lb.Text.IndexOf("pwd", StringComparison.OrdinalIgnoreCase) >= 0 || lb.Text.IndexOf("password", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						editor.PasswordChar = '*';
					}
					editor.DragEnter += new DragEventHandler(editor_DragEnter);
					editor.DragDrop += new DragEventHandler(editor_DragDrop);
					if (editorType == 4)
					{
						editor.WordWrap = false;
						editor.ScrollBars = ScrollBars.Both;
						editor.Multiline = true;
						editor.Height = 100;
					}
					rlt.EditControl = editor;
					rlt.Id = lb.Text;
					rlt.EditorType = 0;
					editor.Tag = rlt;
					editor.Text = value != null ? value.ToString() : string.Empty;
					editor.TextChanged += new EventHandler(editor_TextChanged);
					UpdatePos(lb, editor);
					NotifyUINode(ucmd, editor, lb);
				}
			}
			return rlt;
		}
Ejemplo n.º 40
0
		public void Generate(CommandNode cmd, bool isReadonly = false)
		{
			Controls.Clear();
			CurtTop = ItemMarginTop;
			if (cmd != null)
			{
				FieldInfo[] list = cmd.GetType().GetFields();
				foreach (FieldInfo i in list)
				{
					AddCmdItem(i.Name, cmd, i.Name, i.FieldType.Name.IndexOf("bool", StringComparison.OrdinalIgnoreCase) >= 0 ? 1 : 0, isReadonly);
				}
			}
		}
Ejemplo n.º 41
0
 protected Command(CommandNode parent, string verb)
     : base(parent, verb)
 {
 }
Ejemplo n.º 42
0
 public void PreRender(CommandNode commandNode, TimeSpan commandTimeSpan)
 {
     _effect.PreRender(commandNode.TargetNodes.ToArray(), commandTimeSpan, ParameterValues);
 }
Ejemplo n.º 43
0
		private void AddCommandTreeviewNode(CommandNode cmd)
		{
			CommandTreeViewNode node = cmd.CreateTreeviewNode();
			InsertTreeViewNode(node);
		}
 public UnusedCommandViolation(CommandNode commandNode)
 {
     Node = commandNode;
 }
 public IEnumerable<string> GetLog(CommandNode node)
 {
     return _log[node];
 }