Пример #1
0
        /// <summary>
        /// Selects single node from passed XmlNode and returns corresponding CommandBarViewMode, if the node is not found the given defaultvalue is returned
        /// </summary>
        /// <param name="xpath">Expression to select node containing setting value</param>
        /// <param name="selectionNode">Node to apply xpath expression on</param>
        /// <param name="defaultValue">Value to return if node is not found or not possible to parse as a CommandBarViewMode</param>
        public static PCAxis.Web.Controls.CommandBar.CommandBarViewMode GetSettingValue(string xpath, XmlNode selectionNode, PCAxis.Web.Controls.CommandBar.CommandBarViewMode defaultValue)
        {
            PCAxis.Web.Controls.CommandBar.CommandBarViewMode returnValue = defaultValue;
            XmlNode node = null;

            if (selectionNode != null)
            {
                node = selectionNode.SelectSingleNode(xpath);
            }
            if (node != null)
            {
                switch (node.InnerText)
                {
                case "ImageButtons":
                    returnValue = PCAxis.Web.Controls.CommandBar.CommandBarViewMode.ImageButtons;
                    break;

                case "Hidden":
                    returnValue = PCAxis.Web.Controls.CommandBar.CommandBarViewMode.Hidden;
                    break;

                default:
                    returnValue = PCAxis.Web.Controls.CommandBar.CommandBarViewMode.DropDown;
                    break;
                }
            }
            return(returnValue);
        }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Master.EnableSave(new EventHandler(MasterSave_Click));
     if (IsPostBack)
     {
         _viewMode = (PCAxis.Web.Controls.CommandBar.CommandBarViewMode)Enum.Parse(typeof(PCAxis.Web.Controls.CommandBar.CommandBarViewMode), lstViewMode.SelectedValue.ToString());
     }
     else
     {
         lstViewMode.Items.Add(new ListItem(Master.GetLocalizedString("PxWebAdminSettingsPresentationCommandBarViewModeDropDown"), PCAxis.Web.Controls.CommandBar.CommandBarViewMode.DropDown.ToString()));
         lstViewMode.Items.Add(new ListItem(Master.GetLocalizedString("PxWebAdminSettingsPresentationCommandBarViewModeImageButtons"), PCAxis.Web.Controls.CommandBar.CommandBarViewMode.ImageButtons.ToString()));
         lstViewMode.Items.Add(new ListItem(Master.GetLocalizedString("PxWebAdminSettingsPresentationCommandBarViewModeHidden"), PCAxis.Web.Controls.CommandBar.CommandBarViewMode.Hidden.ToString()));
         _viewMode = PXWeb.Settings.Current.Presentation.CommandBar.ViewMode;
         DisplaySavedSettings();
     }
 }
Пример #3
0
 /// <summary>
 /// Change viewmode
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void lstViewMode_SelectedIndexChanged(object sender, EventArgs e)
 {
     _viewMode = (PCAxis.Web.Controls.CommandBar.CommandBarViewMode)Enum.Parse(typeof(PCAxis.Web.Controls.CommandBar.CommandBarViewMode), lstViewMode.SelectedValue.ToString());
     DisplaySavedSettings();
 }
Пример #4
0
        /// <summary>
        /// Save ViewMode setting
        /// Read checkboxes and save the settings
        /// </summary>
        private void SaveSettings()
        {
            if (PXWeb.Settings.BeginUpdate())
            {
                try
                {
                    CommandBarSettings cmd = (CommandBarSettings)PXWeb.Settings.NewSettings.Presentation.CommandBar;
                    _viewMode    = (PCAxis.Web.Controls.CommandBar.CommandBarViewMode)Enum.Parse(typeof(PCAxis.Web.Controls.CommandBar.CommandBarViewMode), lstViewMode.SelectedValue.ToString());
                    cmd.ViewMode = _viewMode;

                    //Dropdown mode
                    if (_viewMode == PCAxis.Web.Controls.CommandBar.CommandBarViewMode.DropDown)
                    {
                        ((List <string>)PXWeb.Settings.NewSettings.Presentation.CommandBar.Operations).Clear();
                        ((List <string>)PXWeb.Settings.NewSettings.Presentation.CommandBar.OperationShortcuts).Clear();
                    }
                    else //Button mode
                    {
                        ((List <string>)PXWeb.Settings.NewSettings.Presentation.CommandBar.OperationButtons).Clear();
                    }

                    CheckBox cbx;
                    foreach (RepeaterItem itm in rptSettings.Items)
                    {
                        if ((itm.ItemType == ListItemType.Item) || (itm.ItemType == ListItemType.AlternatingItem))
                        {
                            HiddenField hidSetting = (HiddenField)itm.FindControl("hidSetting");

                            //Saved if viewmode is DropDown
                            if (_viewMode == PCAxis.Web.Controls.CommandBar.CommandBarViewMode.DropDown)
                            {
                                //Operations
                                cbx = (CheckBox)itm.FindControl("cbxOperationSelect");
                                if (cbx.Checked)
                                {
                                    ((List <string>)PXWeb.Settings.NewSettings.Presentation.CommandBar.Operations).Add(hidSetting.Value);
                                }
                                //OperationShortcuts
                                cbx = (CheckBox)itm.FindControl("cbxOperationShortcut");
                                if (cbx.Checked)
                                {
                                    ((List <string>)PXWeb.Settings.NewSettings.Presentation.CommandBar.OperationShortcuts).Add(hidSetting.Value);
                                }
                            }
                            else //Saved if viewmode is Buttons
                            {
                                //CommandBar.OperationButtons
                                cbx = (CheckBox)itm.FindControl("cbxOperationSelect");
                                if (cbx.Checked)
                                {
                                    ((List <string>)PXWeb.Settings.NewSettings.Presentation.CommandBar.OperationButtons).Add(hidSetting.Value);
                                }
                            }
                        }
                    }
                    PXWeb.Settings.Save();
                }
                finally
                {
                    PXWeb.Settings.EndUpdate();
                }
            }
        }