Пример #1
0
        private void CreateMenu()
        {
            int lModuleCount = 0;

            //BUSCO LOS MODULOS POR TIPO DE USUARIO
            ControlDePacientes.Dal.DockPanel lDockPanel = new DockPanel();
            mDtUsuario = new DataTable();
            mDtUsuario = lDockPanel.GetModuloByTipoUsuario(mIdTipoUsuario);

            lModuleCount = mDtUsuario.Rows.Count;



            for (int x = 0; x < lModuleCount; x++)
            {
                Expander lExpander = new Expander();
                lExpander.Name   = "exp" + x + 1;
                lExpander.Tag    = (int)mDtUsuario.Rows[x]["IdModulo"]; //x + 1;
                lExpander.Header = mDtUsuario.Rows[x]["ModuloName"];    // +"" + lBulletDecorator;
                lExpander.Width  = 175;

                stpMenu.Children.Add(lExpander);

                CreateSubMenu((int)lExpander.Tag, lExpander);

                lExpander.IsExpanded = true;
            }

            //    scrMenu.Content = stpMenu;
        }
Пример #2
0
        private void CreateSubMenu(int pIdModulo, Expander pExapnder)
        {
            try
            {
                //busco los menu hijo
                DockPanel lDockPanel    = new DockPanel();
                DataTable lDtModuloHijo = lDockPanel.GetModuloHijoByModulo(pIdModulo);

                StackPanel lStackPanel = new StackPanel();

                if (lDtModuloHijo.Rows.Count != 0)
                {
                    for (int i = 0; i < lDtModuloHijo.Rows.Count; i++)
                    {
                        Button lBtnMenuSon = new Button();

                        if (lDtModuloHijo.Rows[i]["ModuloHijoImagen"] != null)
                        {
                            Image lImage = new Image();
                            lImage.Source              = new BitmapImage(new Uri((string)lDtModuloHijo.Rows[i]["ModuloHijoImagen"], UriKind.Relative));
                            lImage.StretchDirection    = StretchDirection.Both;
                            lImage.HorizontalAlignment = HorizontalAlignment.Right;


                            TextBlock lTextBlock = new TextBlock();
                            lTextBlock.Text = (string)lDtModuloHijo.Rows[i]["ModuloHijoName"];
                            lTextBlock.HorizontalAlignment = HorizontalAlignment.Left;
                            lTextBlock.Width = 100;

                            WrapPanel lWrapPanel = new WrapPanel();
                            lWrapPanel.Width = 150;

                            lWrapPanel.Children.Add(lTextBlock);

                            lWrapPanel.Children.Add(lImage);


                            Grid lGrid = new Grid();
                            lGrid.Width = 150;
                            lGrid.Children.Add(lWrapPanel);


                            lBtnMenuSon.Content = lGrid; //lDtModuloHijo.Rows[i]["ModuloHijoName"];

                            lBtnMenuSon.HorizontalContentAlignment = HorizontalAlignment.Left;
                            lBtnMenuSon.Tag    = i + 1;
                            lBtnMenuSon.Height = 40;
                            lBtnMenuSon.Width  = 150;
                            lBtnMenuSon.Click += new RoutedEventHandler(BtnClick);
                            if (lDtModuloHijo.Rows[i]["ModuloHijoPage"] != DBNull.Value)
                            {
                                lBtnMenuSon.Name = (String)lDtModuloHijo.Rows[i]["ModuloHijoPage"];
                            }
                            lStackPanel.HorizontalAlignment = HorizontalAlignment.Left;
                            lStackPanel.Children.Add(lBtnMenuSon);
                            pExapnder.Content = lStackPanel;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ControlOperation.alertWarning("" + ex);
            }
        }