//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //Events private void accordionParentButton_Clicked(object sender, EventArgs e) { AccordionParentButton clickedButton = (AccordionParentButton)sender; foreach (var item in _accordionDefinition) { _currentParentButton = (AccordionParentButton)item.Value.NodeButton; if (!_currentParentButton.Equals(clickedButton)) { _currentParentButton.Active = false; _currentParentButton.ChildBox.Visible = false; } else { _currentParentButton.Active = true; _currentParentButton.ChildBox.Visible = true; } } if (Clicked != null) { Clicked(sender, e); } }
protected void InitObject(Dictionary <string, AccordionNode> pAccordionDefinition, string pNodePrivilegesTokenFormat) { //get values of backoffice screen to set accordion font text size GlobalApp.boScreenSize = Utils.GetScreenSize(); _label = new Label(); //Parameters _accordionDefinition = pAccordionDefinition; //Local Vars bool isFirstButton = true; string currentNodePrivilegesToken; string accordionType = ""; VBox vboxOuter = new VBox(false, 2); AccordionParentButton accordionParentButton; AccordionChildButton accordionChildButton; if (_accordionDefinition != null && _accordionDefinition.Count > 0) { foreach (var parentLevel in _accordionDefinition) { if (parentLevel.Value.GroupIcon != null) { //Redimensionar Icons dos Botões Parent do accordion para 1024 HBox hboxParent = new HBox(false, 0); if (GlobalApp.boScreenSize.Height <= 800) { System.Drawing.Size sizeIcon = new System.Drawing.Size(20, 20); System.Drawing.Image imageIcon; imageIcon = System.Drawing.Image.FromFile(parentLevel.Value.GroupIcon.File.ToString()); imageIcon = Utils.ResizeAndCrop(imageIcon, sizeIcon); Gdk.Pixbuf pixBuf = Utils.ImageToPixbuf(imageIcon); Image gtkimageButton = new Image(pixBuf); hboxParent.PackStart(gtkimageButton, false, false, 3); imageIcon.Dispose(); pixBuf.Dispose(); } else { hboxParent.PackStart(parentLevel.Value.GroupIcon, false, false, 3); } _label = new Label(parentLevel.Value.Label); //Pango.FontDescription tmpFont = new Pango.FontDescription(); //tmpFont.Weight = Pango.Weight.Bold; //tmpFont.Size = 2; //Redimensionar Tamanho da Fonte dos Botões Parent do accordion para 1024 accordionType = "Parent"; ChangeFont(FrameworkUtils.StringToColor("61, 61, 61"), accordionType); hboxParent.PackStart(_label, true, true, 0); accordionParentButton = new AccordionParentButton(hboxParent) { Name = parentLevel.Key }; } else { accordionParentButton = new AccordionParentButton(parentLevel.Value.Label) { Name = parentLevel.Key }; //First Parent Node is Assigned has currentParentButton if (_currentParentButton == null) { _currentParentButton = accordionParentButton; } } accordionParentButton.Active = isFirstButton; if (isFirstButton) { isFirstButton = false; } //Add a Button Widget Reference to NodeWidget AccordionDefinition parentLevel.Value.NodeButton = accordionParentButton; //Click Event accordionParentButton.Clicked += accordionParentButton_Clicked; vboxOuter.PackStart(accordionParentButton, false, false, 0); //_log.Debug(string.Format("Accordion(): parentLevel.Value.Label [{0}]", parentLevel.Value.Label)); if (parentLevel.Value.Childs != null && parentLevel.Value.Childs.Count > 0) { foreach (var childLevel in parentLevel.Value.Childs) { HBox hboxChild = new HBox(false, 0); _label = new Label(childLevel.Value.Label); accordionType = "Child"; ChangeFont(FrameworkUtils.StringToColor("61, 61, 61"), accordionType); hboxChild.PackStart(_label, true, true, 0); //Init ChildButton accordionChildButton = new AccordionChildButton(hboxChild) { Name = childLevel.Key, Content = childLevel.Value.Content }; //accordionChildButton = new AccordionChildButton(childLevel.Value.Label) { Name = childLevel.Key, Content = childLevel.Value.Content }; //Add a Button Widget Reference to NodeWidget AccordionDefinition childLevel.Value.NodeButton = accordionChildButton; //Privileges currentNodePrivilegesToken = string.Format(pNodePrivilegesTokenFormat, childLevel.Key.ToUpper()); //_log.Debug(string.Format("currentNodePrivilegesToken: [{0}]", currentNodePrivilegesToken)); //First Child Node is Assigned has currentChildButton //if (childLevel.Value.Active) if (_currentChildButton == null) { _currentChildButton = accordionChildButton; //Assign Current Active Button with content _currentChildButtonContent = accordionChildButton; } accordionParentButton.ChildBox.PackStart(accordionChildButton, false, false, 2); //If have (Content | Events | ExternalApp) & Privileges or the Button is Enabled, Else is Disabled accordionChildButton.Sensitive = (FrameworkUtils.HasPermissionTo(currentNodePrivilegesToken) && (childLevel.Value.Content != null || childLevel.Value.Clicked != null || childLevel.Value.ExternalAppFileName != null)); //EventHandler, Redirected to public Clicked, this way we have ouside Access accordionChildButton.Clicked += accordionChildButton_Clicked; //ExternalAppFileName if (childLevel.Value.ExternalAppFileName != null) { accordionChildButton.ExternalAppFileName = childLevel.Value.ExternalAppFileName; } //Process AccordionDefinition Clicked Events if (childLevel.Value.Clicked != null) { accordionChildButton.Clicked += childLevel.Value.Clicked; } } vboxOuter.PackStart(accordionParentButton.ChildBox, false, false, 0); } } } PackStart(vboxOuter); }
protected void InitObject(Dictionary <string, AccordionNode> pAccordionDefinition, string pNodePrivilegesTokenFormat) { String fontPosBackOfficeParent = GlobalFramework.Settings["fontPosBackOfficeParent"]; String fontPosBackOfficeChild = GlobalFramework.Settings["fontPosBackOfficeChild"]; //Parameters _accordionDefinition = pAccordionDefinition; //Local Vars bool isFirstButton = true; string currentNodePrivilegesToken; VBox vboxOuter = new VBox(false, 2); AccordionParentButton accordionParentButton; AccordionChildButton accordionChildButton; if (_accordionDefinition != null && _accordionDefinition.Count > 0) { foreach (var parentLevel in _accordionDefinition) { if (parentLevel.Value.GroupIcon != null) { HBox hboxParent = new HBox(false, 0); hboxParent.PackStart(parentLevel.Value.GroupIcon, false, false, 3); Label label = new Label(parentLevel.Value.Label); //Pango.FontDescription tmpFont = new Pango.FontDescription(); Pango.FontDescription fontDescriptionParent = Pango.FontDescription.FromString(fontPosBackOfficeParent); //tmpFont.Weight = Pango.Weight.Bold; //tmpFont.Size = 2; label.ModifyFont(fontDescriptionParent); label.SetAlignment(0.0f, 0.5f); hboxParent.PackStart(label, true, true, 0); accordionParentButton = new AccordionParentButton(hboxParent) { Name = parentLevel.Key }; } else { accordionParentButton = new AccordionParentButton(parentLevel.Value.Label) { Name = parentLevel.Key }; //First Parent Node is Assigned has currentParentButton if (_currentParentButton == null) { _currentParentButton = accordionParentButton; } } accordionParentButton.Active = isFirstButton; if (isFirstButton) { isFirstButton = false; } //Add a Button Widget Reference to NodeWidget AccordionDefinition parentLevel.Value.NodeButton = accordionParentButton; //Click Event accordionParentButton.Clicked += accordionParentButton_Clicked; vboxOuter.PackStart(accordionParentButton, false, false, 0); //_log.Debug(string.Format("Accordion(): parentLevel.Value.Label [{0}]", parentLevel.Value.Label)); if (parentLevel.Value.Childs.Count > 0) { foreach (var childLevel in parentLevel.Value.Childs) { //Init ChildButton accordionChildButton = new AccordionChildButton(childLevel.Value.Label) { Name = childLevel.Key, Content = childLevel.Value.Content }; //Add a Button Widget Reference to NodeWidget AccordionDefinition childLevel.Value.NodeButton = accordionChildButton; //Privileges currentNodePrivilegesToken = string.Format(pNodePrivilegesTokenFormat, childLevel.Key.ToUpper()); //_log.Debug(string.Format("currentNodePrivilegesToken: [{0}]", currentNodePrivilegesToken)); //First Child Node is Assigned has currentChildButton //if (childLevel.Value.Active) if (_currentChildButton == null) { _currentChildButton = accordionChildButton; //Assign Current Active Button with content _currentChildButtonContent = accordionChildButton; } accordionParentButton.ChildBox.PackStart(accordionChildButton, false, false, 2); //If have (Content | Events | ExternalApp) & Privileges or the Button is Enabled, Else is Disabled accordionChildButton.Sensitive = (FrameworkUtils.HasPermissionTo(currentNodePrivilegesToken) && (childLevel.Value.Content != null || childLevel.Value.Clicked != null || childLevel.Value.ExternalAppFileName != null)); //EventHandler, Redirected to public Clicked, this way we have ouside Access accordionChildButton.Clicked += accordionChildButton_Clicked; //ExternalAppFileName if (childLevel.Value.ExternalAppFileName != null) { accordionChildButton.ExternalAppFileName = childLevel.Value.ExternalAppFileName; } //Process AccordionDefinition Clicked Events if (childLevel.Value.Clicked != null) { accordionChildButton.Clicked += childLevel.Value.Clicked; } } vboxOuter.PackStart(accordionParentButton.ChildBox, false, false, 0); } } } PackStart(vboxOuter); }