Ejemplo n.º 1
0
        private void Menu_Select(object sender, System.EventArgs e)
        {
            MenuItem     ItemClicked = (MenuItem)sender;
            MenuItemInfo ItmInfo     = MenuItemInfoTable[ItemClicked.Tag.ToString()];

            if (ItmInfo.Funcion == "MENU Lbl.Cajas.Caja" && ItemClicked.IsParent == false)
            {
                DataTable Cajas = Lfx.Workspace.Master.MasterConnection.Select("SELECT id_caja, nombre FROM cajas WHERE estado>0 ORDER BY nombre");

                foreach (System.Data.DataRow Caja in Cajas.Rows)
                {
                    MenuItem     ItmH     = new MenuItem(Caja["nombre"].ToString(), new System.EventHandler(Menu_Click));
                    MenuItemInfo ItmInfoH = new MenuItemInfo();
                    ItmInfoH.Item       = ItmH;
                    ItmInfoH.Funcion    = "INSTANCIAR Lfc.Cajas.Movimientos " + Caja["id_caja"].ToString();
                    ItmInfoH.ParentText = ItmInfo.Text;
                    ItmInfoH.Text       = System.Convert.ToString(Caja["nombre"]).QuitarAcentos();
                    AgregarAlMenu(ItemClicked, ItmH, ItmInfoH);
                }
            }
        }
Ejemplo n.º 2
0
                private void Menu_Select(object sender, System.EventArgs e)
                {
                        MenuItem ItemClicked = (MenuItem)sender;
                        MenuItemInfo ItmInfo = MenuItemInfoTable[ItemClicked.Tag.ToString()];

                        if (ItmInfo.Funcion == "MENU Lbl.Cajas.Caja" && ItemClicked.IsParent == false) {
                                DataTable Cajas = Lfx.Workspace.Master.MasterConnection.Select("SELECT id_caja, nombre FROM cajas WHERE estado>0 ORDER BY nombre");

                                foreach (System.Data.DataRow Caja in Cajas.Rows) {
                                        MenuItem ItmH = new MenuItem(Caja["nombre"].ToString(), new System.EventHandler(Menu_Click));
                                        MenuItemInfo ItmInfoH = new MenuItemInfo();
                                        ItmInfoH.Item = ItmH;
                                        ItmInfoH.Funcion = "INSTANCIAR Lfc.Cajas.Movimientos " + Caja["id_caja"].ToString();
                                        ItmInfoH.ParentText = ItmInfo.Text;
                                        ItmInfoH.Text = System.Convert.ToString(Caja["nombre"]).QuitarAcentos();
                                        AgregarAlMenu(ItemClicked, ItmH, ItmInfoH);
                                }
                        }
                }
Ejemplo n.º 3
0
 /// <summary>
 /// Agrega un ítem a un menú y lo hace OwnerDraw.
 /// </summary>
 /// <param name="ColgarDe">Objeto Menu del cual colgar este menú.</param>
 /// <param name="Itm">Objeto Menu que se quiere agregar</param>
 /// <param name="ItmInfo">Estructura con información extendida sobre Itm</param>
 private void AgregarAlMenu(Menu ColgarDe, MenuItem Itm, MenuItemInfo ItmInfo)
 {
         // Para los tem OwnerDraw, ver las funciones Menu_Select, Menu_MeasureItem y Menu_DrawItem más abajo
         if (Lfx.Environment.SystemInformation.Platform == Lfx.Environment.SystemInformation.Platforms.Windows) {
                 Itm.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.Menu_MeasureItem);
                 Itm.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.Menu_DrawItem);
                 Itm.OwnerDraw = true;
         }
         Itm.Tag = Itm.GetHashCode();
         ColgarDe.MenuItems.Add(Itm);
         MenuItemInfoTable.Add(Itm.Tag.ToString(), ItmInfo);
 }
Ejemplo n.º 4
0
                /// <summary>
                /// Carga un menú desde un documento Xml.
                /// </summary>
                private void CargarMenuXml(XmlNode node, Menu colgarDe, string parentText)
                {
                        Lfx.Data.Connection Conn = null;

                        if (node.ChildNodes.Count > 0) {
                                foreach (XmlNode opcion in node.ChildNodes) {
                                        MenuItem Itm = new MenuItem(opcion.Attributes["Nombre"].Value, new System.EventHandler(Menu_Click));

                                        MenuItemInfo ItmInfo = new MenuItemInfo();
                                        ItmInfo.Item = Itm;
                                        if (opcion.Attributes["Funcion"] != null) {
                                                ItmInfo.Funcion = opcion.Attributes["Funcion"].Value;
                                                if (opcion.Attributes["Funcion"].Value == "MDILIST")
                                                        Itm.MdiList = true;
                                        }
                                        ItmInfo.ParentText = parentText.QuitarAcentos();
                                        ItmInfo.Text = opcion.Attributes["Nombre"].Value.QuitarAcentos();

                                        AgregarAlMenu(colgarDe, Itm, ItmInfo);

                                        if (ItmInfo.Funcion == "MENU Lbl.Cajas.Caja")
                                                Itm.Select += new EventHandler(Menu_Select);

                                        string NuevoParentText = null;

                                        if (parentText.Length > 0)
                                                NuevoParentText = parentText + "." + opcion.Attributes["Nombre"].Value;
                                        else
                                                NuevoParentText = opcion.Attributes["Funcion"].Value;

                                        CargarMenuXml(opcion, Itm, NuevoParentText);
                                }
                        }

                        if (Conn != null)
                                Conn.Dispose();
                }
Ejemplo n.º 5
0
                // **************************************************************************************************
                // **************************************************************************************************
                // **************************************************************************************************
                // Sistema de Menú
                // **************************************************************************************************
                // **************************************************************************************************
                // **************************************************************************************************

                private void CargarMenuComponentes()
                {
                        foreach (Lfx.Components.IComponent CompInfo in Lfx.Components.Manager.ComponentesCargados.Values) {
                                // Registro el componente
                                Lfx.Types.OperationResult Res = Lfx.Components.Manager.RegisterComponent(CompInfo);

                                if (Res.Success == false && Res.Message != null)
                                        Lui.Forms.MessageBox.Show(Res.Message, "Error");

                                if (CompInfo != null && CompInfo.MenuEntries != null) {
                                        foreach (Lfx.Components.MenuEntry MenuItem in CompInfo.MenuEntries) {
                                                //Busco el Parent
                                                MenuItem ColgarDe = null;
                                                MenuItemInfo ItmInfo;
                                                foreach (MenuItemInfo ItemInfo in MenuItemInfoTable.Values) {
                                                        if (ItemInfo.ParentText + "." + ItemInfo.Text == ("Menu." + MenuItem.Parent).QuitarAcentos()) {
                                                                ColgarDe = ItemInfo.Item;
                                                                break;
                                                        }
                                                }
                                                if (ColgarDe == null) {
                                                        //Si no hay de donde colgarlo, lo creo
                                                        ColgarDe = new MenuItem(MenuItem.Parent, new System.EventHandler(Menu_Click));
                                                        ItmInfo = new MenuItemInfo();
                                                        ItmInfo.Item = ColgarDe;
                                                        ItmInfo.Funcion = "";
                                                        ItmInfo.ParentText = "Menu".QuitarAcentos();
                                                        ItmInfo.Text = MenuItem.Parent.QuitarAcentos();

                                                        AgregarAlMenu(this.MainMenu, ColgarDe, ItmInfo);
                                                }

                                                MenuItem Itm = new MenuItem(MenuItem.Name, new System.EventHandler(Menu_Click));
                                                ItmInfo = new MenuItemInfo();
                                                ItmInfo.Item = Itm;
                                                ItmInfo.Funcion = MenuItem.Function;
                                                ItmInfo.ParentText = "Menu." + MenuItem.Parent.QuitarAcentos();
                                                ItmInfo.Text = MenuItem.Name.QuitarAcentos();
                                                AgregarAlMenu(ColgarDe, Itm, ItmInfo);
                                        }
                                }
                        }
                }