コード例 #1
0
            /// <summary>
            /// Add the given predicate to this node?
            /// </summary>
            internal override void Add(ILocPredicate p)
            {
                var node = p.Accept(Default <ItemBuilder> .Instance, railway);

                Nodes.Add(node);
                Expand();
            }
コード例 #2
0
        /// <summary>
        /// Default ctor
        /// </summary>
        public PredicateEditorForm(ILocPredicate predicate, IRailway railway)
        {
            this.predicate = predicate;
            InitializeComponent();
            if (predicate != null)
            {
                rootNode      = predicate.Accept(Default <ItemBuilder> .Instance, railway);
                rootNode.Text = "Permissions";
                tvItems.Nodes.Add(rootNode);
                tvItems.ExpandAll();

                // Locs
                foreach (var locRef in railway.Locs)
                {
                    ILoc loc;
                    if (locRef.TryResolve(out loc))
                    {
                        var menuItem = new LocEqualsMenuItem(loc, railway);
                        menuItem.Click += (s, x) => Execute(menuItem);
                        tbAddLocs.DropDownItems.Add(menuItem);
                    }
                }

                // LocGroups
                foreach (var group in railway.LocGroups)
                {
                    var menuItem = new LocGroupEqualsMenuItem(group, railway);
                    menuItem.Click += (s, x) => Execute(menuItem);
                    tbAddLocGroups.DropDownItems.Add(menuItem);
                }

                // Specials
                {
                    // Change direction
                    {
                        var menuItem = new LocCanChangeDirectionMenuItem(railway);
                        menuItem.Click += (s, x) => Execute(menuItem);
                        tbAddSpecial.DropDownItems.Add(menuItem);
                    }
                    // Time predicate
                    {
                        var menuItem = new LocTimeMenuItem(railway);
                        menuItem.Click += (s, x) => Execute(menuItem);
                        tbAddSpecial.DropDownItems.Add(menuItem);
                    }
                    // AND
                    {
                        var menuItem = new LocAndMenuItem(railway);
                        menuItem.Click += (s, x) => Execute(menuItem);
                        tbAddSpecial.DropDownItems.Add(menuItem);
                    }
                    // OR
                    {
                        var menuItem = new LocOrMenuItem(railway);
                        menuItem.Click += (s, x) => Execute(menuItem);
                        tbAddSpecial.DropDownItems.Add(menuItem);
                    }
                }

                UpdateToolbar();
            }
        }