Ejemplo n.º 1
0
 private void editRoles_Click(object sender, EventArgs e)
 {
     using (var frmRoleDialog = new FrmRoleDialog(_myAccessToken))
     {
         var result = frmRoleDialog.ShowDialog();
         if (result == DialogResult.OK)
         {
             _editingRoleControls = RoleManager.GetControlsByRole(frmRoleDialog.SelectedRole.Id);
             _currentRoleID       = frmRoleDialog.SelectedRole.Id;
             foreach (var control in _controls)
             {
                 if (control is MenuStrip)
                 {
                     var menuStrip = (MenuStrip)control;
                     menuStrip.Enabled    = true;
                     menuStrip.Visible    = true;
                     menuStrip.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PopupContextMenu);
                     foreach (var item in menuStrip.Items)
                     {
                         var itemControl = (ToolStripMenuItem)item;
                         itemControl.Enabled    = true;
                         itemControl.Visible    = true;
                         itemControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PopupContextMenu);
                     }
                 }
                 else
                 {
                     if (control is Button || control is ComboBox || control is TextBox ||
                         control is ListBox || control is DataGridView || control is RadioButton ||
                         control is RichTextBox || control is TabPage || control is ListView)
                     {
                         RemoveEvents(control);
                         control.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PopupContextMenu);
                         control.Enabled    = true;
                         control.Visible    = true;
                     }
                 }
             }
             _roleMenuStrip.Items[0].Text = "Editing " + frmRoleDialog.SelectedRole.Name + " Role";
             _currentForm.Text            = "Admin Edit Mode Enabled";
         }
     }
 }
Ejemplo n.º 2
0
        private void editRoles_Click(object sender, EventArgs e)
        {
            using (var frmRoleDialog = new FrmRoleDialog(_myAccessToken))
            {
                var result = frmRoleDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    _editingRoleControls = RoleManager.GetControlsByRole(frmRoleDialog.SelectedRole.Id);
                    _currentRoleID = frmRoleDialog.SelectedRole.Id;
                    foreach (var control in _controls)
                    {
                        if (control is MenuStrip)
                        {
                            var menuStrip = (MenuStrip)control;
                            menuStrip.Enabled = true;
                            menuStrip.Visible = true;
                            menuStrip.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PopupContextMenu);
                            foreach (var item in menuStrip.Items)
                            {
                                var itemControl = (ToolStripMenuItem)item;
                                itemControl.Enabled = true;
                                itemControl.Visible = true;
                                itemControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PopupContextMenu);

                            }
                        }
                        else
                        {
                            if (control is Button || control is ComboBox || control is TextBox ||
                                control is ListBox || control is DataGridView || control is RadioButton ||
                                control is RichTextBox || control is TabPage || control is ListView)
                            {
                                RemoveEvents(control);
                                control.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PopupContextMenu);
                                control.Enabled = true;
                                control.Visible = true;
                            }
                        }
                    }
                    _roleMenuStrip.Items[0].Text = "Editing " + frmRoleDialog.SelectedRole.Name + " Role";
                    _currentForm.Text = "Admin Edit Mode Enabled";
                }
            }
        }