Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        protected override void beforeEach()
        {
            theChain       = new BehaviorChain();
            theChain.Route = new RouteDefinition("something")
            {
                Input = new RouteInput <FakeInput>("somepattern")
            };


            theNode = new MenuNode(FakeKeys.Key1, r => theChain);
            theNode.Resolve(null);
            theNode.BehaviorChain.ShouldBeTheSameAs(theChain);
            theNode.UrlInput = new object();

            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key2));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key3));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key4));


            MockFor <IMenuStateService>().Stub(x => x.DetermineStateFor(theNode))
            .Return(MenuItemState.Available);

            MockFor <IChainUrlResolver>().Stub(x => x.UrlFor(theNode.UrlInput, theNode.BehaviorChain))
            .Return("the full url");

            theToken = ClassUnderTest.BuildToken(theNode);
        }
        public void all_nodes_of_deep_structure()
        {
            var node1 = MenuNode.ForCreatorOf(FakeKeys.Key1, typeof(Address));
            var node2 = MenuNode.ForCreatorOf(FakeKeys.Key2, typeof(Address));
            var node3 = MenuNode.ForCreatorOf(FakeKeys.Key3, typeof(Address));
            var node4 = MenuNode.ForCreatorOf(FakeKeys.Key4, typeof(Address));
            var node5 = MenuNode.ForCreatorOf(FakeKeys.Key5, typeof(Address));
            var node6 = MenuNode.ForCreatorOf(FakeKeys.Key6, typeof(Address));
            var node7 = MenuNode.ForCreatorOf(FakeKeys.Key7, typeof(Address));
            var node8 = MenuNode.ForCreatorOf(FakeKeys.Key8, typeof(Address));

            node1.Children.AddToEnd(node2);
            node1.Children.AddToEnd(node3);

            node2.Children.AddToEnd(node4);
            node4.Children.AddToEnd(node5);

            node3.Children.AddToEnd(node6);
            node3.Children.AddToEnd(node7);
            node3.Children.AddToEnd(node8);

            var node9  = new MenuNode(FakeKeys.Key9);
            var node10 = new MenuNode(FakeKeys.Key10);

            var chain = new MenuChain(FakeKeys.Chain1);

            chain.AddToEnd(node1);

            chain.AddToEnd(node9);
            chain.AddToEnd(node10);

            chain.AllNodes().ShouldHaveTheSameElementsAs(node1, node2, node4, node5, node3, node6, node7, node8, node9, node10);
        }
        private MenuNode GetMenuConfiguracion()
        {
            /*
             * Configuración
             *  1. Usuario
             *          1.1 Perfil de Usuario (Ejemplo: Administrador, Caja, Mozo, Mozo Encargado)
             *      1.2 Usuario
             *  5. Forma de Pago (Ejemplo: Contado, Crédito)
             *          5.1 Medios de Pago (Ejemplo: Efectivo, Tarjeta, Vale)
             *  6 Productos
             *      6.1 Categoría (Ejemplo: Platos, Bebidas, Tragos, Postres)
             *      6.3 Producto
             *  7. Mesas
             *      7.1 Área (Ejemplo: Salón Principal, Exterior)
             *      7.2 Mesa
             *  8. Cliente
             *  9. Carta del Día
             *  9. Empresa
             */
            var instMenuNode = new MenuNode();

            instMenuNode.PropertyBodyHeight = 200;
            instMenuNode.PropertyTitle      = "Configuración";
            instMenuNode.PropertyPathImage  = "M22.279045,18.719475C20.804059,18.719475 19.327974,19.273442 18.202966,20.382415 17.11702,21.451381 16.518993,22.870341 16.518993,24.37728 16.518993,25.877232 17.112015,27.287189 18.188073,28.347153 19.42502,29.567114 21.132064,30.141101 22.816036,29.971093L20.544047,27.733159C20.017066,27.214194 19.727025,26.5222 19.727025,25.785224 19.727025,25.047272 20.018042,24.352287 20.548075,23.831308L21.746082,22.650347C22.826046,21.585379,24.585092,21.583365,25.665056,22.647326L27.971103,24.919255C28.146153,23.261319 27.567047,21.586355 26.331077,20.368408 25.215101,19.268438 23.74805,18.719475 22.279045,18.719475z M5.5689964,6.8070269C5.8570595,6.8070269 6.1451216,6.9153004 6.3646688,7.1318464 6.8037643,7.56394 6.8037643,8.2660913 6.3646688,8.6991844 5.9255743,9.1322775 5.2124195,9.1322775 4.773324,8.6991844 4.3342285,8.2660913 4.3342285,7.56394 4.773324,7.1318464 4.9928722,6.9153004 5.2809343,6.8070269 5.5689964,6.8070269z M5.4268923,5.689209C4.7918873,5.6902094 4.2808819,5.8862066 3.8848782,6.2762022 3.4928751,6.6621981 3.2828732,7.1931925 3.2948732,7.7711859 3.3078737,8.4541779 3.6258764,9.12817 4.1668816,9.6201644L15.777088,20.198016 15.822619,20.127297C16.105279,19.711231 16.431529,19.319431 16.799025,18.957443 17.176408,18.585705 17.583258,18.260341 18.012194,17.981359L18.036371,17.966474 7.32091,6.5541992C6.8189054,6.0182056,6.1278992,5.7032089,5.4268923,5.689209z M23.071236,1.9969091C22.749237,1.9965343,22.426988,2.116786,22.180989,2.3587904L13.841015,10.574926 14.504775,11.282347 15.529384,12.373586 23.958983,4.0688181C24.192983,3.8398142 24.319983,3.5358095 24.319983,3.2138042 24.319983,2.891799 24.192983,2.5877934 23.959983,2.3587904 23.714984,2.1182861 23.393235,1.9972839 23.071236,1.9969091z M23.069236,0C23.899484,-0.00024986267 24.72998,0.31075668 25.362979,0.93376637 25.980977,1.5417767 26.319976,2.3517895 26.319976,3.2138042 26.319976,4.0758181 25.980977,4.8858318 25.361979,5.4928417L16.898401,13.831628 19.946011,17.07742 20.066585,17.039039C20.78447,16.829308 21.527142,16.723962 22.269692,16.723026 24.249824,16.720531 26.229086,17.460513 27.73514,18.943466 29.942064,21.118383 30.606133,24.370292 29.427046,27.228201L28.860147,28.602149 24.260016,24.072298C23.957036,23.771313,23.458009,23.773296,23.150023,24.075288L21.952016,25.256249C21.806019,25.398243 21.727039,25.587233 21.727039,25.785224 21.727039,25.983215 21.805043,26.168207 21.947988,26.308217L26.57705,30.86706 25.158094,31.436042C24.211066,31.815027 23.219115,32.000018 22.238029,32.000018 20.23008,32.000018 18.262048,31.227064 16.78401,29.772094 15.324038,28.333145 14.518979,26.417223 14.518979,24.37728 14.518979,23.609681 14.632894,22.859235 14.852807,22.144664L14.873783,22.082098 10.008717,17.649282 2.3769903,25.167026 0,25.941027 0.79599667,23.590024 8.3553238,16.14279 2.819869,11.099147C1.8748598,10.238157 1.3198547,9.0391707 1.2948551,7.8101854 1.2728548,6.6771984 1.6948586,5.6272097 2.4808655,4.8512192 3.2648726,4.0792274 4.3208828,3.6622324 5.4658928,3.6892319 6.7019043,3.7142315 7.9099154,4.2592258 8.7799234,5.185215L12.47092,9.1162333 20.776993,0.93376637C21.408991,0.31175613,22.238989,0.00024986267,23.069236,0z";

            instMenuNode.Add(new MenuItems()
            {
                PropertyTitle = "Administrar", Page = new PGSGR_Administrar()
            });
            instMenuNode.Add(new MenuItems()
            {
                PropertyTitle = "Tipo de Cambio", Page = new PGSGR_ListadoTipoCambio()
            });

            var instTProductos = new MenuSubNode()
            {
                PropertyTitle = "Productos", PropertyBodyHeight = 60
            };

            instTProductos.Add(new MenuItems()
            {
                PropertyTitle = "Categoría", Page = new PGSGR_ListadoProductoCategoria()
            });
            instTProductos.Add(new MenuItems()
            {
                PropertyTitle = "Producto", Page = new PGSGR_ListadoProducto()
            });
            instMenuNode.Add(instTProductos);

            instMenuNode.Add(new MenuItems()
            {
                PropertyTitle = "Cliente", Page = new PGSGR_ListadoCliente()
            });
            instMenuNode.Add(new MenuItems()
            {
                PropertyTitle = "Carta del Día", Page = new PGSGR_ListadoCartaDia()
            });

            return(instMenuNode);
        }
Ejemplo n.º 4
0
        private string GenerateMarkup(Dictionary <string, string> Attributes)
        {
            try
            {
                PortalSettings ps = PortalController.Instance.GetCurrentSettings() as PortalSettings;

                if (ps != null && ps.ActiveTab != null && ps.ActiveTab.BreadCrumbs == null)
                {
                    ps.ActiveTab.BreadCrumbs = new System.Collections.ArrayList();
                }

                Dictionary <string, string> BaseAttributes = Core.Managers.BlockManager.GetGlobalConfigs(ps, "menu");
                if (Attributes["data-block-global"] == "true")
                {
                    Attributes = BaseAttributes;
                }
                else
                {
                    //Loop on base attributes and add missing attribute
                    foreach (KeyValuePair <string, string> attr in BaseAttributes)
                    {
                        if (!Attributes.ContainsKey(attr.Key))
                        {
                            Attributes.Add(attr.Key, attr.Value);
                        }
                    }
                }

                MenuSetting menuSetting = new MenuSetting
                {
                    NodeSelector  = Attributes["data-block-nodeselector"],
                    IncludeHidden = Convert.ToBoolean(Attributes["data-block-includehidden"]),
                };

                MenuNode rootNode = new MenuNode(
                    Localiser.LocaliseDNNNodeCollection(
                        Navigation.GetNavigationNodes(
                            ExtensionInfo.GUID,
                            Navigation.ToolTipSource.None,
                            -1,
                            -1,
                            MenuBase.GetNavNodeOptions(true))));

                MenuBase menu = new MenuBase();
                menu.ApplySetting(menuSetting);
                menu.RootNode = rootNode;
                menu.Initialize();

                IDictionary <string, object> dynObjects = new ExpandoObject() as IDictionary <string, object>;
                dynObjects.Add("Menu", menu);
                string Template = RazorEngineManager.RenderTemplate(ExtensionInfo.GUID, BlockPath, Attributes["data-block-template"], dynObjects);
                Template = new DNNLocalizationEngine(null, ResouceFilePath, false).Parse(Template);
                return(Template);
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                return(ex.Message);
            }
        }
        private MenuNode GetMenuSeguridad()
        {
            /*
             * Seguridad
             *  1. Empresa
             *  2. Usuario
             *  3. Perfil de Usuario
             *
             */
            var instMenuNode = new MenuNode();

            instMenuNode.PropertyBodyHeight = 90;
            instMenuNode.PropertyTitle      = "Seguridad";
            instMenuNode.PropertyPathImage  = "M24.998989,24C25.551989,24,25.998989,24.448,25.998989,25L25.998989,28C25.998989,28.552 25.551989,29 24.998989,29 24.445989,29 23.998989,28.552 23.998989,28L23.998989,25C23.998989,24.448,24.445989,24,24.998989,24z M19.998989,23L19.998989,30 29.998989,30 29.998989,23z M24.998986,17.000004C23.344986,17.000004 21.998986,18.363007 21.998985,20.03901 21.998986,20.348761 22.043986,20.650074 22.13272,20.938731L22.153252,21 27.845031,21 27.872002,20.916793C27.956236,20.633761 27.998986,20.339761 27.998986,20.03901 27.998986,18.363007 26.653986,17.000004 24.998986,17.000004z M10.600992,15C5.857996,15 1.999999,18.829 1.999999,23.536 1.999999,24.895 3.1159983,26 4.4879971,26L17.998989,26 17.998989,21 20.08992,21 20.074531,20.917946C20.024251,20.629992 19.998986,20.336511 19.998986,20.03901 19.998986,18.996883 20.314548,18.02774 20.854338,17.223393L20.981606,17.043204 20.976324,17.038513C19.420207,15.720703,17.453861,15,15.396988,15L12.998977,15z M12.998977,2C9.9409781,2 7.4529791,4.4669991 7.4529791,7.5 7.4529791,9.9469995 9.1079779,12.123 11.477978,12.791 12.460978,13.068 13.534977,13.07 14.520977,12.791 16.889977,12.121 18.543976,9.9460001 18.543976,7.5 18.543976,4.4669991 16.056977,2 12.998977,2z M12.998977,0C17.158976,0 20.543976,3.3640003 20.543976,7.5 20.543976,9.68925 19.57369,11.720016 17.994593,13.114946L17.807257,13.273908 18.03626,13.329436C19.666419,13.744325,21.18105,14.542659,22.458358,15.676389L22.475316,15.691801 22.618093,15.60898C23.326486,15.220704 24.137736,15 24.998986,15 27.755986,15 29.998986,17.260005 29.998986,20.03901 29.998986,20.328198 29.974869,20.614132 29.92697,20.895222L29.907801,21 31.998989,21 31.998989,32 17.998989,32 17.998989,28 4.4879971,28C2.0129995,28 0,25.997 0,23.536 0,18.633813 3.385149,14.50334 7.954566,13.33225L8.1907282,13.274841 8.0040979,13.116582C6.4241266,11.72178 5.4529791,9.6905622 5.4529791,7.5 5.4529791,3.3640003 8.8379784,0 12.998977,0z";

            instMenuNode.Add(new MenuItems()
            {
                PropertyTitle = "Empresa", Page = new PGSGR_ListadoEmpresa()
            });
            instMenuNode.Add(new MenuItems()
            {
                PropertyTitle = "Usuario", Page = new PGSGR_ListadoUsuario()
            });
            instMenuNode.Add(new MenuItems()
            {
                PropertyTitle = "Perfil de Usuario", Page = new PGSGR_ListadoPerfil()
            });

            return(instMenuNode);
        }
Ejemplo n.º 6
0
        protected override void beforeEach()
        {
            theChain       = new BehaviorChain();
            theChain.Route = new RouteDefinition("something")
            {
                Input = new RouteInput <FakeInput>("somepattern")
            };


            theNode = new MenuNode(FakeKeys.Key1, r => theChain);
            theNode.Resolve(null);
            theNode.BehaviorChain.ShouldBeTheSameAs(theChain);
            theNode.UrlInput = new object();

            theNode.Icon("some image");

            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key2));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key3));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key4));

            theIconUrl = "test.png";
            MockFor <IAssetUrls>().Stub(x => x.UrlForAsset(AssetFolder.images, theNode.Icon())).Return(theIconUrl);

            theUrls = new StubUrlRegistry();
            Services.Inject <IUrlRegistry>(theUrls);

            MockFor <IMenuStateService>().Stub(x => x.DetermineStateFor(theNode))
            .Return(MenuItemState.Available);

            MockFor <IChainUrlResolver>().Stub(x => x.UrlFor(theNode.UrlInput, theNode.BehaviorChain))
            .Return("the full url");
        }
Ejemplo n.º 7
0
        public void create_for_input_where_it_is_null()
        {
            var key  = StringToken.FromKeyString("Something");
            var node = MenuNode.ForInput <FakeInput>(key);

            node.UrlInput.ShouldBeNull();

            var chain1 = new RoutedChain("something");

            chain1.AddToEnd(ActionCall.For <FakeController>(x => x.FromInput(null)));
            chain1.Route.AddHttpMethodConstraint("GET");

            var chain2 = new RoutedChain("something");

            chain2.AddToEnd(ActionCall.For <FakeController>(x => x.FromInput(null)));
            chain2.Route.AddHttpMethodConstraint("POST");

            resolve(node, graph =>
            {
                graph.AddChain(chain1);
                graph.AddChain(chain2);
            });

            node.BehaviorChain.ShouldBeTheSameAs(chain1);
        }
Ejemplo n.º 8
0
        protected override void beforeEach()
        {
            theChain       = new BehaviorChain();
            theChain.Route = new RouteDefinition("something")
            {
                Input = new RouteInput <FakeInput>("somepattern")
            };


            theNode = new MenuNode(FakeKeys.Key1, r => theChain);
            theNode.Resolve(null);
            theNode.BehaviorChain.ShouldBeTheSameAs(theChain);
            theNode.UrlInput = new object();

            theNode.Icon("some image");

            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key2));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key3));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key4));

            theUrls = new StubUrlRegistry();
            Services.Inject <IUrlRegistry>(theUrls);

            MockFor <IMenuStateService>().Stub(x => x.DetermineStateFor(theNode))
            .Return(MenuItemState.Available);

            MockFor <ICurrentHttpRequest>().Stub(x => x.ToFullUrl(theNode.CreateUrl()))
            .Return("the full url");

            theToken = ClassUnderTest.BuildToken(theNode);
        }
Ejemplo n.º 9
0
    void Start()
    {
        node = GetComponent <MenuNode>();

        GlobalSettingsManager.Instance.OnCageChange += HandleCageChange;
        HandleCageChange();
    }
Ejemplo n.º 10
0
    public static void MapCommand(MenuManager.Context context, Vector2 position)
    {
        // TODO: Replace switch with string instead of enum
        switch (MenuManager.context)
        {
        case MenuManager.Context.MapMove:
            int  distance  = (int)Grapher.ManhattanDistance(PlayerMover.instance.transform.position, position);
            bool sprinting = MenuNode.GetCurrent() == "Sprint";

            MenuManager.instance.ClearOptions();
            PlayerMover.instance.GetComponent <Navigator>().SetDestination(position, MenuNode.GetCurrent() == "Sprint");
            break;

        case MenuManager.Context.UnitSelect:
            MenuManager.instance.ClearOptions();
            RaycastHit2D hit = Physics2D.Raycast(position, Vector3.zero, 0);
            if (hit.collider == null)
            {
                Debug.Log("Tried to shoot nonexistent enemy!");
            }
            else
            {
                PlayerMover.instance.GetComponent <Shooter>().GunAttack(PlayerMover.instance.gameObject, hit.collider.gameObject);
            }
            break;
        }
    }
        public void create_for_action_with_lambda()
        {
            var key  = StringToken.FromKeyString("Something");
            var node = MenuNode.ForAction <FakeController>(key, x => x.GetFake(), x => x.Category = "Test");

            node.Category.ShouldEqual("Test");
        }
        public void create_for_input_with_lamba()
        {
            var key  = StringToken.FromKeyString("Something");
            var node = MenuNode.ForInput <FakeInput>(key, x => x.Category = "Test");

            node.Category.ShouldEqual("Test");
        }
Ejemplo n.º 13
0
        //Preorder traversal to display the menu
        private void Display(MenuNode n, int depth)
        {
            if (n == null)
            {
                return;
            }

            //Add padding for lvl
            var pad = "";

            for (var i = 0; i < depth; i++)
            {
                pad += tab;
            }

            var line = string.Format("{0}{1}, {2} {3}", pad, n.Name, n.Path, n.Active ? active : string.Empty);

            Console.WriteLine(line);

            //Recurse and display sub menus
            foreach (var s in n.SubMenu)
            {
                Display(s, depth + 1);
            }
        }
        public void for_intput_with_model()
        {
            var key   = StringToken.FromKeyString("Something");
            var input = new FakeInput()
            {
                Name = "something"
            };
            var node = MenuNode.ForInput(key, input);

            node.UrlInput.ShouldBeTheSameAs(input);

            var chain1 = new BehaviorChain();

            chain1.AddToEnd(ActionCall.For <FakeController>(x => x.FromInput(null)));
            chain1.Route = new RouteDefinition("something");
            chain1.Route.AddHttpMethodConstraint("GET");

            var chain2 = new BehaviorChain();

            chain2.AddToEnd(ActionCall.For <FakeController>(x => x.FromInput(null)));
            chain2.Route = new RouteDefinition("something");
            chain2.Route.AddHttpMethodConstraint("POST");

            resolve(node, graph =>
            {
                graph.AddChain(chain1);
                graph.AddChain(chain2);
            });

            node.BehaviorChain.ShouldBeTheSameAs(chain1);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 处理权限
        /// </summary>
        /// <param name="topNode"></param>
        private void SetPermission(ActionExecutingContext filterContext, MenuNode <Actions> topNode)
        {
            var controller = filterContext.Controller as IManageController;

            if (controller == null)
            {
                return;
            }

            if (controller.LoginRole == Role.SuperAdmin)
            {
                topNode.SetPermission(true);
            }
            else
            {
                using (var db = new SqlDb())
                {
                    var pNodes = db.OrganizePermission
                                 .Where(item => item.OrganizeID == controller.UserInfo.OR_ID)
                                 .Select(item => new { item.AllowedAction, item.HashMd5 })
                                 .ToArray()
                                 .Select(item => new PermissionNode <Actions> {
                        AllowedAction = (Actions)item.AllowedAction, HashMd5 = item.HashMd5
                    })
                                 .ToArray();

                    topNode.SetPermission(pNodes);
                }
            }
        }
        public void set_the_icon()
        {
            var node = new MenuNode(FakeKeys.Key9);
            node.Icon("something.png").ShouldBeTheSameAs(node);

            node.Icon().ShouldEqual("something.png");
        }
Ejemplo n.º 17
0
        public void LocaliseNode(MenuNode node)
        {
            var tab = (node.TabId > 0) ? TabController.Instance.GetTab(node.TabId, Null.NullInteger, false) : null;

            if (tab != null)
            {
                var localised = LocaliseTab(tab);
                tab = localised ?? tab;

                if (localised != null)
                {
                    node.TabId   = tab.TabID;
                    node.Text    = tab.TabName;
                    node.Enabled = !tab.DisableLink;
                    if (!tab.IsVisible)
                    {
                        node.TabId = -1;
                    }
                }

                node.Title       = tab.Title;
                node.Description = tab.Description;
                node.Keywords    = tab.KeyWords;
            }
            else
            {
                node.TabId = -1;
            }

            node.Children.ForEach(LocaliseNode);
        }
        public void create_for_action()
        {
            var key  = StringToken.FromKeyString("Something");
            var node = MenuNode.ForAction <FakeController>(key, x => x.GetFake());

            var chain1 = new BehaviorChain();

            chain1.AddToEnd(ActionCall.For <FakeController>(x => x.GetFake()));
            chain1.Route = new RouteDefinition("something");
            chain1.Route.AddHttpMethodConstraint("GET");

            var chain2 = new BehaviorChain();

            chain2.AddToEnd(ActionCall.For <FakeController>(x => x.GetFake()));
            chain2.Route = new RouteDefinition("something");
            chain2.Route.AddHttpMethodConstraint("POST");

            resolve(node, graph =>
            {
                graph.AddChain(chain1);
                graph.AddChain(chain2);
                graph.AddChain(new BehaviorChain());
                graph.AddChain(new BehaviorChain());
                graph.AddChain(new BehaviorChain());
                graph.AddChain(new BehaviorChain());
            });

            node.BehaviorChain.ShouldBeTheSameAs(chain1);
        }
        public virtual MenuItemState DetermineStateFor(MenuNode node)
        {
            if (node.BehaviorChain == null)
            {
                return MenuItemState.Available;
            }

            var rights = _authorizor.Authorize(node.BehaviorChain, node.UrlInput);
            if (rights != AuthorizationRight.Allow)
            {
                return node.UnauthorizedState;
            }

            if (_current.OriginatingChain == node.BehaviorChain)
            {
                return MenuItemState.Active;
            }

            if (_conditionals.IsTrue(node.HideIfConditional))
            {
                return MenuItemState.Hidden;
            }

            if (_conditionals.IsTrue(node.IsEnabledBy()))
            {
                return MenuItemState.Available;
            }

            return MenuItemState.Disabled;
        }
Ejemplo n.º 20
0
        public CombinedSampleNative()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;

            var menuRoot = new MenuNode("<root>",
                                        new MenuNode("&File",
                                                     new MenuNode("&New", new MenuNode("Item")),
                                                     new MenuNode("&Open", new MenuNode("Item"))
            {
                IsChecked = true
            },
                                                     new MenuNode("Recent files", new MenuNode("Item"))
            {
                IsEnabled = false, IsChecked = true
            },
                                                     new MenuNode {
                IsSeparator = true
            },
                                                     new MenuNode("E&xit")
            {
                InputGestureText = "Alt+F4"
            }
                                                     ),
                                        new MenuNode("&Edit")
                                        );

            fakeMenu1.RootNode = menuRoot;
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            WriteLine("Starting dnk_game");

            GameControl gc = new GameControl();

            gc.Init();

            MenuNode mainMenu = new MenuNode("Main");

            mainMenu.AddAction("New Game", gc.NewGame);
            mainMenu.AddAction("Start", gc.Run);
            mainMenu.AddAction("Exit", null);

            MenuNode settingsMenu = mainMenu.AddSubNode("Settings");

            settingsMenu.AddSubNode("Audio");
            settingsMenu.AddSubNode("Graphics");

            do
            {
                mainMenu.Show();
            } while (mainMenu.Select(ReadDigit(), ignoreInvalid: true));

            gc.Teardown();
        }
Ejemplo n.º 22
0
 public static List<MenuNode> ConvertDNNNodeCollection(DNNNodeCollection dnnNodes, MenuNode parent)
 {
     var result = new List<MenuNode>();
     foreach (DNNNode node in dnnNodes)
         result.Add(new MenuNode(node, parent));
     return result;
 }
        public void all_nodes_of_deep_structure()
        {
            var node1 = MenuNode.ForCreatorOf(FakeKeys.Key1, typeof(Address));
            var node2 = MenuNode.ForCreatorOf(FakeKeys.Key2, typeof(Address));
            var node3 = MenuNode.ForCreatorOf(FakeKeys.Key3, typeof(Address));
            var node4 = MenuNode.ForCreatorOf(FakeKeys.Key4, typeof(Address));
            var node5 = MenuNode.ForCreatorOf(FakeKeys.Key5, typeof(Address));
            var node6 = MenuNode.ForCreatorOf(FakeKeys.Key6, typeof(Address));
            var node7 = MenuNode.ForCreatorOf(FakeKeys.Key7, typeof(Address));
            var node8 = MenuNode.ForCreatorOf(FakeKeys.Key8, typeof(Address));

            node1.Children.AddToEnd(node2);
            node1.Children.AddToEnd(node3);

            node2.Children.AddToEnd(node4);
            node4.Children.AddToEnd(node5);

            node3.Children.AddToEnd(node6);
            node3.Children.AddToEnd(node7);
            node3.Children.AddToEnd(node8);

            var node9 = new MenuNode(FakeKeys.Key9);
            var node10 = new MenuNode(FakeKeys.Key10);

            var chain = new MenuChain(FakeKeys.Chain1);
            chain.AddToEnd(node1);

            chain.AddToEnd(node9);
            chain.AddToEnd(node10);

            chain.AllNodes().ShouldHaveTheSameElementsAs(node1, node2, node4, node5, node3, node6, node7, node8, node9, node10);
        }
Ejemplo n.º 24
0
    public void ActivateActionSelection()
    {
        var leaf = SelectedAction as LeafMenuNode;

        if (leaf != null)
        {
            _finalizedAction = leaf.Move;
        }
        else
        {
            if (SelectedAction.Children.Count == 0)
            {
                if (SelectedAction == Menu[ATTACK])
                {
                    _moveContent.transform.parent.parent.gameObject.SetActive(true);
                    AddListDisplay(Battle.Instance.CurrentMonsterTurn.Item2.Moves.ToList(), _moveContent);
                }
                else if (SelectedAction == Menu[ITEM])
                {
                    _itemContent.transform.parent.parent.gameObject.SetActive(true);
                    AddListDisplay(Battle.Instance.CurrentMonsterTurn.Item1.Items.Cast <BattleExecutable>().ToList(), _itemContent);
                }
                else if (SelectedAction == Menu[SWAP])
                {
                    _monsterContent.transform.parent.parent.gameObject.SetActive(true);
                    //TODO
                }
            }
            SelectedAction = SelectedAction.Children[0];
        }
    }
Ejemplo n.º 25
0
        private SiteFooterLink ParseNodes(MenuNode node, ProvisioningTemplate template, string webServerRelativeUrl, bool persistLanguage, CultureInfo currentCulture, string parentKey, ProvisioningTemplateCreationInformation creationInfo)
        {
            var link = new SiteFooterLink();

            if (persistLanguage)
            {
                if (UserResourceExtensions.PersistResourceValue($"FooterNavigationNode_{parentKey}_{node.Key}_Title", currentCulture.LCID, node.Title, creationInfo))
                {
                    link.DisplayName = $"{{res:FooterNavigationNode_{parentKey}_{node.Key}_Title}}";
                }
            }
            else
            {
                link.DisplayName = node.Title;
            }

            link.Url = Tokenize(node.SimpleUrl, webServerRelativeUrl);

            if (node.Nodes.Count > 0)
            {
                link.FooterLinks = new SiteFooterLinkCollection(template);
                foreach (var childNode in node.Nodes)
                {
                    link.FooterLinks.Add(ParseNodes(childNode, template, webServerRelativeUrl, persistLanguage, currentCulture, node.Key, creationInfo));
                }
            }
            return(link);
        }
Ejemplo n.º 26
0
        public List <MenuNode> GetMenus(Enumeration.BelongSite belongSite, string userId)
        {
            List <MenuNode> menuNodes = new List <MenuNode>();

            var sysMenus = CurrentDb.SysMenu.Where(m => m.BelongSite == belongSite && m.Depth != 0).OrderBy(m => m.Priority).ToList();

            if (belongSite == Enumeration.BelongSite.Admin || belongSite == Enumeration.BelongSite.Merch)
            {
                sysMenus = (from menu in CurrentDb.SysMenu where (from rolemenu in CurrentDb.SysRoleMenu where (from sysUserRole in CurrentDb.SysUserRole where sysUserRole.UserId == userId select sysUserRole.RoleId).Contains(rolemenu.RoleId) select rolemenu.MenuId).Contains(menu.Id) && menu.BelongSite == belongSite select menu).Where(m => m.Depth != 0).OrderBy(m => m.Priority).ToList();
            }

            foreach (var sysMenu in sysMenus)
            {
                MenuNode menuNode = new MenuNode();
                menuNode.Id        = sysMenu.Id;
                menuNode.PId       = sysMenu.PId;
                menuNode.Path      = sysMenu.Path;
                menuNode.Name      = sysMenu.Name;
                menuNode.Icon      = sysMenu.Icon;
                menuNode.Title     = sysMenu.Title;
                menuNode.Component = sysMenu.Component;
                menuNode.IsSidebar = sysMenu.IsSidebar;
                menuNode.IsNavbar  = sysMenu.IsNavbar;
                menuNode.IsRouter  = sysMenu.IsRouter;
                menuNodes.Add(menuNode);
            }

            return(menuNodes);
        }
Ejemplo n.º 27
0
        public void add_roles_by_name()
        {
            var graph = buildGraph(x =>
            {
                x.Navigation(r =>
                {
                    r.ForMenu("Menu1");
                    r.Add += MenuNode.ForAction <OneController>("something", c => c.Go());
                    r.Add += MenuNode.ForAction <OneController>("else", c => c.Query(null));
                    r.Add += MenuNode.ForAction <OneController>("different", c => c.Report());
                });

                x.ApplyConvention <NavigationRootPolicy>(policy =>
                {
                    policy.ForKey("Menu1");
                    policy.RequireRole("role1");
                    policy.RequireRole("role2");
                });
            });

            // positive cases
            graph.BehaviorFor <OneController>(c => c.Go()).Authorization.AllowedRoles().ShouldHaveTheSameElementsAs("role1", "role2");
            graph.BehaviorFor <OneController>(c => c.Query(null)).Authorization.AllowedRoles().ShouldHaveTheSameElementsAs("role1", "role2");
            graph.BehaviorFor <OneController>(c => c.Report()).Authorization.AllowedRoles().ShouldHaveTheSameElementsAs("role1", "role2");


            graph.BehaviorFor <TwoController>(c => c.Go()).Authorization.AllowedRoles().Any().ShouldBeFalse();
            graph.BehaviorFor <ThreeController>(c => c.Go()).Authorization.AllowedRoles().Any().ShouldBeFalse();
        }
Ejemplo n.º 28
0
        public MenuNode(DNNNode dnnNode, MenuNode parent)
        {
            TabId = Convert.ToInt32(dnnNode.ID);
            Text = dnnNode.Text;
            Url = (dnnNode.ClickAction == eClickAction.PostBack)
                    ? "postback:" + dnnNode.ID
                    : String.IsNullOrEmpty(dnnNode.JSFunction) ? dnnNode.NavigateURL : "javascript:" + dnnNode.JSFunction;
            Enabled = dnnNode.Enabled;
            Selected = dnnNode.Selected;
            Breadcrumb = dnnNode.BreadCrumb;
            Separator = dnnNode.IsBreak;
            Icon = dnnNode.Image;
            Target = dnnNode.Target;
            Title = null;
            Keywords = null;
            Description = null;
            Parent = parent;
            CommandName = dnnNode.get_CustomAttribute("CommandName");
            CommandArgument = dnnNode.get_CustomAttribute("CommandArgument");

            DNNAbstract.DNNNodeToMenuNode(dnnNode, this);

            if ((dnnNode.DNNNodes != null) && (dnnNode.DNNNodes.Count > 0))
                Children = ConvertDNNNodeCollection(dnnNode.DNNNodes, this);
        }
Ejemplo n.º 29
0
        public void SetUp()
        {
            graph = new NavigationGraph(x =>
            {
                x.ForMenu(FakeKeys.Key1);
                x.Add += MenuNode.Node(FakeKeys.Key2);
                x.Add += MenuNode.Node(FakeKeys.Key3);
                x.Add += MenuNode.Node(FakeKeys.Key4);


                x.ForMenu(FakeKeys.Key5);
                x.Add += MenuNode.Node(FakeKeys.Key6);
                x.Add += MenuNode.Node(FakeKeys.Key7);


                x.ForMenu(FakeKeys.Key2);
                x.Add += MenuNode.Node(FakeKeys.Key8);
                x.Add += MenuNode.Node(FakeKeys.Key9);

                x.ForMenu(FakeKeys.Key9);
                x.Add += MenuNode.Node(FakeKeys.Key10);
            });

            graph.Compile();
        }
Ejemplo n.º 30
0
        public void when_the_menu_node_is_only_a_node_with_no_behavior_chain()
        {
            theNode = MenuNode.Node("Something");

            ClassUnderTest.DetermineStateFor(theNode)
            .ShouldEqual(MenuItemState.Available);
        }
Ejemplo n.º 31
0
 void AddMenuFromASM(Assembly asm, MenuNode root)
 {
     foreach (var extensionType in asm.DefinedTypes)
     {
         AddMenuFromType(extensionType.AsType(), root);
     }
 }
Ejemplo n.º 32
0
        public void wrap_with_chrome()
        {
            var graph = buildGraph(x =>
            {
                x.Navigation(r =>
                {
                    r.ForMenu("Menu1");
                    r.Add += MenuNode.ForAction <OneController>("something", c => c.Go());
                    r.Add += MenuNode.ForAction <OneController>("else", c => c.Query(null));
                    r.Add += MenuNode.ForAction <OneController>("different", c => c.Report());
                });

                x.ApplyConvention <NavigationRootPolicy>(policy =>
                {
                    policy.ForKey("Menu1");

                    policy.WrapWithChrome <FakeChrome>();
                });
            });

            // positive cases

            graph.BehaviorFor <OneController>(c => c.Query(null)).OfType <ChromeNode>().Single().ContentType.ShouldEqual(typeof(FakeChrome));
            graph.BehaviorFor <OneController>(c => c.Report()).OfType <ChromeNode>().Single().ContentType.ShouldEqual(typeof(FakeChrome));


            // Go() does not have any output type
            graph.BehaviorFor <OneController>(c => c.Go()).OfType <ChromeNode>().Any().ShouldBeFalse();

            graph.BehaviorFor <TwoController>(c => c.Report()).OfType <ChromeNode>().Any().ShouldBeFalse();
            graph.BehaviorFor <ThreeController>(c => c.Report()).OfType <ChromeNode>().Any().ShouldBeFalse();
        }
Ejemplo n.º 33
0
        public void MenuNodeFindSuccess()
        {
            //Arrange
            // Test the node's ability to find items in the submenu
            MenuNode testNode = new MenuNode()
            {
                Name    = "First item",
                Active  = false,
                Path    = "/root",
                SubMenu = new List <MenuNode> ()
                {
                    new MenuNode()
                    {
                        Name    = "Submenu First item",
                        Active  = false,
                        Path    = "/root/submenu/item1",
                        SubMenu = new List <MenuNode> ()
                    },
                    new MenuNode()
                    {
                        Name    = "Submenu Second item",
                        Active  = false,
                        Path    = "/root/submenu/item2",
                        SubMenu = new List <MenuNode> ()
                    }
                }
            };

            //Act
            List <MenuNode> found = testNode.FindAll(x => x.Name.Equals("Submenu Second item"));

            //Assert
            Assert.IsTrue(1 == found.Count);
            Assert.AreSame(testNode.SubMenu[1], found[0]);
        }
Ejemplo n.º 34
0
        override public MenuNode getMenuRoot()
        {
            MenuNode node = new MenuNode();

            node.setMenuID("Report Fas Alarm");
            return(node);
        }
Ejemplo n.º 35
0
        public void UndefinedMenuNodeFindFails()
        {
            //Arrange
            // Test the node's ability to find items in the submenu
            MenuNode testNode = new MenuNode()
            {
                Name    = "First item",
                Active  = false,
                Path    = "/root",
                SubMenu = new List <MenuNode> ()
                {
                    new MenuNode()
                    {
                        Name    = "Submenu First item",
                        Active  = false,
                        Path    = "/root/submenu/item1",
                        SubMenu = new List <MenuNode> ()
                    },
                    new MenuNode()
                    {
                        Name    = "Submenu Second item",
                        Active  = false,
                        Path    = "/root/submenu/item2",
                        SubMenu = new List <MenuNode> ()
                    }
                }
            };

            //Act
            List <MenuNode> found = testNode.FindAll(x => x.Name.Equals("garbage"));

            //Assert
            Assert.IsFalse(found.Count > 0);
        }
		public void set_data()
		{
			var node = new MenuNode(FakeKeys.Key9);
			var value = Guid.NewGuid();

			node["Test"] = value;
			node["Test"].ShouldEqual(value);
		}
Ejemplo n.º 37
0
 private void addToLastKey(MenuNode node)
 {
     var key = _lastKey;
     modification = graph =>
     {
         graph.AddNode(key, node);
     };
 }
		public void has_data()
		{
			var node = new MenuNode(FakeKeys.Key9);
			var value = Guid.NewGuid();

			node["Test"] = value;
			node.Has("Test").ShouldBeTrue();
		}
Ejemplo n.º 39
0
    public virtual void OnMenuChanged( MenuNode menu )
    {
        if( menu == null ) return;

        if( this.menu.menuId == menu.id )
        {
            OnMenuConstructed();
        } else {
            OnMenuDeconstructed();
        }
    }
        public void find_by_key_in_deep_structure()
        {
            var node1 = MenuNode.ForCreatorOf(FakeKeys.Key1, typeof(Address));
            var node2 = MenuNode.ForCreatorOf(FakeKeys.Key2, typeof(Address));
            var node3 = MenuNode.ForCreatorOf(FakeKeys.Key3, typeof(Address));
            var node4 = MenuNode.ForCreatorOf(FakeKeys.Key4, typeof(Address));
            var node5 = MenuNode.ForCreatorOf(FakeKeys.Key5, typeof(Address));
            var node6 = MenuNode.ForCreatorOf(FakeKeys.Key6, typeof(Address));
            var node7 = MenuNode.ForCreatorOf(FakeKeys.Key7, typeof(Address));
            var node8 = MenuNode.ForCreatorOf(FakeKeys.Key8, typeof(Address));

            node1.Children.AddToEnd(node2);
            node1.Children.AddToEnd(node3);

            node2.Children.AddToEnd(node4);
            node4.Children.AddToEnd(node5);

            node3.Children.AddToEnd(node6);
            node3.Children.AddToEnd(node7);
            node3.Children.AddToEnd(node8);

            var node9 = new MenuNode(FakeKeys.Key9);
            var node10 = new MenuNode(FakeKeys.Key10);

            var chain = new MenuChain(FakeKeys.Chain1);
            chain.AddToEnd(node1);

            chain.FindByKey(FakeKeys.Key1).ShouldBeTheSameAs(node1);
            chain.FindByKey(FakeKeys.Key2).ShouldBeTheSameAs(node2);
            chain.FindByKey(FakeKeys.Key3).ShouldBeTheSameAs(node3);
            chain.FindByKey(FakeKeys.Key4).ShouldBeTheSameAs(node4);
            chain.FindByKey(FakeKeys.Key5).ShouldBeTheSameAs(node5);
            chain.FindByKey(FakeKeys.Key6).ShouldBeTheSameAs(node6);
            chain.FindByKey(FakeKeys.Key7).ShouldBeTheSameAs(node7);

            chain.FindByKey(FakeKeys.Key9).ShouldBeNull();

            chain.AddToEnd(node9);
            chain.AddToEnd(node10);

            chain.FindByKey(FakeKeys.Key9).ShouldBeTheSameAs(node9);
            chain.FindByKey(FakeKeys.Key10).ShouldBeTheSameAs(node10);
        }
Ejemplo n.º 41
0
        // TODO -- this could really use some more end to end testing
        public MenuItemToken BuildToken(MenuNode node)
        {
            var token = new MenuItemToken {
                Children = node.Children.Select(BuildToken).ToArray(),
                Key = node.Key.Key,
                Text = node.Key.ToString(),

                MenuItemState = _stateService.DetermineStateFor(node)
            };

            if (node.Icon().IsNotEmpty())
            {
                token.IconUrl = _urls.UrlForAsset(AssetFolder.images, node.Icon());
            }

            if (node.Type == MenuNodeType.Leaf)
            {
                token.Url = _request.ToFullUrl(node.CreateUrl());
            }

            return token;
        }
        // TODO -- this could really use some more end to end testing
        public MenuItemToken BuildToken(MenuNode node)
        {
            var token = new MenuItemToken {
                Children = node.Children.Select(BuildToken).ToArray(),
                Key = node.Key.Key,
                Text = node.Key.ToString(),
                Category = node.Category,
                MenuItemState = _stateService.DetermineStateFor(node)
            };

            if (node.Icon().IsNotEmpty())
            {
                token.IconUrl = _urls.UrlForAsset(AssetFolder.images, node.Icon());
            }

            if (node.Type == MenuNodeType.Leaf)
            {
	            token.Url = _urlResolver.UrlFor(node.UrlInput, node.BehaviorChain);
            }

			node.ForData(token.Set);

            return token;
        }
Ejemplo n.º 43
0
 public void Apply(IMenuNode dependency, MenuNode node)
 {
     dependency.AddChild(node);
 }
Ejemplo n.º 44
0
		public static void DNNNodeToMenuNode(DNNNode dnnNode, MenuNode menuNode)
		{
			menuNode.LargeImage = dnnNode.LargeImage;
		}
Ejemplo n.º 45
0
 public MenuRegistration(IMenuPlacementStrategy strategy, IStringTokenMatcher matcher, MenuNode node)
 {
     _strategy = strategy;
     _matcher = matcher;
     _node = node;
 }
Ejemplo n.º 46
0
        public List<MenuNode> FlattenChildren(MenuNode root)
        {

            var flattened = new List<MenuNode>();
            if (root.TabId != 0)
            {
                flattened.Add(root);
            }

            var children = root.Children;

            if (children != null)
            {
                foreach (var child in children)
                {
                    flattened.AddRange(FlattenChildren(child));
                }
            }

            return flattened;
        }
Ejemplo n.º 47
0
        public void menu_type_when_it_is_just_a_node()
        {
            var node = new MenuNode(FakeKeys.Key5);
            node.Type.ShouldEqual(MenuNodeType.Node);

            // doesn't blow up;)
            node.Resolve(null);
        }
Ejemplo n.º 48
0
 public void Apply(IMenuNode dependency, MenuNode node)
 {
     dependency.AddAfter(node);
 }
Ejemplo n.º 49
0
    Rect GetElementPositionInScreen( MenuActionNode action, MenuNode menu )
    {
        Rect result = new Rect( menu.position.x + action.position.x,
                                             menu.position.y + action.position.y,
                                             action.position.width,
                                             action.position.height
                                           );

        return result;
    }
Ejemplo n.º 50
0
 /// <summary>
 /// Determines what the menu should do when a particular item is selected.
 /// This method must be implemented in all child classes.
 /// </summary>
 /// <param name="button">The button that is selected.</param>
 protected abstract void Select(MenuNode button);
Ejemplo n.º 51
0
        private void resolve(MenuNode node, Action<BehaviorGraph> configure)
        {
            var graph = new BehaviorGraph();
            configure(graph);
            var resolver = new ChainResolutionCache(new TypeResolver(), graph);

            node.Resolve(resolver);
        }
Ejemplo n.º 52
0
 /// <summary>
 /// Called when the user attempts to navigate through the menu.
 /// Determines where to navigate next based on the input command.
 /// </summary>
 /// <param name="direction"></param>
 private void MoveSelection(Directions direction)
 {
     switch (direction)
     {
         case Directions.Up:
             if (selectedNode.Up != null)
             {
                 selectedNode.IsSelected = false;
                 selectedNode = selectedNode.Up;
                 selectedNode.IsSelected = true;
                 soundEngine.Play(AudioEngine.SoundEffects.MenuClick);
             }
             break;
         case Directions.Down:
             if (selectedNode.Down != null)
             {
                 selectedNode.IsSelected = false;
                 selectedNode = selectedNode.Down;
                 selectedNode.IsSelected = true;
                 soundEngine.Play(AudioEngine.SoundEffects.MenuClick);
             }
             break;
         case Directions.Left:
             if (selectedNode.Left != null)
             {
                 selectedNode.IsSelected = false;
                 selectedNode = selectedNode.Left;
                 selectedNode.IsSelected = true;
                 soundEngine.Play(AudioEngine.SoundEffects.MenuClick);
             }
             break;
         case Directions.Right:
             if (selectedNode.Right != null)
             {
                 selectedNode.IsSelected = false;
                 selectedNode = selectedNode.Right;
                 selectedNode.IsSelected = true;
                 soundEngine.Play(AudioEngine.SoundEffects.MenuClick);
             }
             break;
     }
 }
 public void AddChildNode(StringToken parent, MenuNode node)
 {
     var registration = new MenuRegistration(new AddChild(), new Literal(parent), node);
     _registrations.Add(registration);
 }
Ejemplo n.º 54
0
 /// <summary>
 /// Determines the action to be taken when a menu option is selected
 /// </summary>
 /// <param name="button">The button that was selected</param>
 protected override void Select(MenuNode button)
 {
     if (button == BackButton)
         hasFocus = false;
 }
Ejemplo n.º 55
0
 /// <summary>
 /// Determines the action to be taken when a menu option is selected
 /// </summary>
 /// <param name="button">The button that was selected</param>
 protected override void Select(MenuNode button)
 {
     if (button == ResumeButton)
     {
         isPaused = false;
     }
     else if (button == LoadButton)
         callback(MenuCallbacks.LoadGame);
     else if (button == QuitButton)
         callback(MenuCallbacks.Quit);
     else if (button == OptionsButton)
     {
         optionsMenu = new OptionsMenu(gameSettings);
         isOptionsDisplayed = true;
         hasFocus = false;
     }
 }
Ejemplo n.º 56
0
 public void Apply(IMenuNode dependency, MenuNode node)
 {
     dependency.AddBefore(node);
 }
Ejemplo n.º 57
0
    void Callback( object obj )
    {
        MenuNode menu = new MenuNode( "New Screen" );
        menu.position = new Rect( mousePosition.x, mousePosition.y, 100, 100 );
        settings.menus.Add( menu );

        state = NodeEditorState.Idle;
    }
Ejemplo n.º 58
0
 private void addToLastKey(MenuNode node)
 {
     var key = _lastKey;
     _registrations.Add(new MenuRegistration(new AddChild(), new Literal(key), node));
 }
Ejemplo n.º 59
0
        /// <summary>
        /// Sets up the buttons the menu will use.
        /// </summary>
        protected override void InitializeButtons()
        {
            MusicVolume = new MenuNode();
            SoundEffectsVolume = new MenuNode();
            BackButton = new MenuNode();

            MusicVolume.Name = "Music";
            MusicVolume.Selectable = true;
            MusicVolume.IsSelected = false;
            MusicVolume.Position = new Vector2(350, 200);
            MusicVolume.Up = BackButton;
            MusicVolume.Down = SoundEffectsVolume;
            MusicVolume.Left = null;
            MusicVolume.Right = null;

            SoundEffectsVolume.Name = "Sound Effects";
            SoundEffectsVolume.Selectable = true;
            SoundEffectsVolume.IsSelected = false;
            SoundEffectsVolume.Position = new Vector2(350, 300);
            SoundEffectsVolume.Up = MusicVolume;
            SoundEffectsVolume.Down = BackButton;
            SoundEffectsVolume.Left = null;
            SoundEffectsVolume.Right = null;

            BackButton.Name = "Back";
            BackButton.Selectable = true;
            BackButton.IsSelected = false;
            BackButton.Position = new Vector2(350, 400);
            BackButton.Up = SoundEffectsVolume;
            BackButton.Down = MusicVolume;
            BackButton.Left = null;
            BackButton.Right = null;
        }
Ejemplo n.º 60
0
        public void ReadXml(XmlReader reader)
        {
            var empty = reader.IsEmptyElement;

            if (reader.MoveToFirstAttribute())
            {
                do
                {
                    switch (reader.Name.ToLowerInvariant())
                    {
                        case "id":
                            TabId = Convert.ToInt32(reader.Value);
                            break;
                        case "text":
                            Text = reader.Value;
                            break;
                        case "title":
                            Title = reader.Value;
                            break;
                        case "url":
                            Url = reader.Value;
                            break;
                        case "enabled":
                            Enabled = (reader.Value == "1");
                            break;
                        case "selected":
                            Selected = (reader.Value == "1");
                            break;
                        case "breadcrumb":
                            Breadcrumb = (reader.Value == "1");
                            break;
                        case "separator":
                            Separator = (reader.Value == "1");
                            break;
                        case "icon":
                            Icon = reader.Value;
                            break;
                        case "largeimage":
                            LargeImage = reader.Value;
                            break;
                        case "commandname":
                            CommandName = reader.Value;
                            break;
                        case "commandargument":
                            CommandArgument = reader.Value;
                            break;
                        case "target":
                            Target = reader.Value;
                            break;
                        //default:
                        //    throw new XmlException(String.Format("Unexpected attribute '{0}'", reader.Name));
                    }
                }
                while (reader.MoveToNextAttribute());
            }

            if (empty)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        switch (reader.Name.ToLowerInvariant())
                        {
                            case "node":
                                var child = new MenuNode { Parent = this };
                                child.ReadXml(reader);
                                Children.Add(child);
                                break;
                            case "keywords":
                                Keywords = reader.ReadElementContentAsString().Trim();
                                break;
                            case "description":
                                Description = reader.ReadElementContentAsString().Trim();
                                break;
                            case "root":
                                break;
                            default:
                                throw new XmlException(String.Format("Unexpected element '{0}'", reader.Name));
                        }
                        break;
                    case XmlNodeType.EndElement:
                        reader.ReadEndElement();
                        return;
                }
            }
        }