예제 #1
0
        /// <summary>
        /// Sets the control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="rightType">Type of the right.</param>
        private static void SetControl(System.Windows.Forms.Control control, RightType rightType)
        {
            switch (rightType)
            {
            case RightType.Enable:
                control.Visible = true;
                control.Enabled = true;
                break;

            case RightType.Disable:
                control.Visible = true;
                control.Enabled = false;
                break;

            case RightType.Visible:
                control.Visible = true;
                break;

            case RightType.Hidden:
                control.Visible = false;
                break;

            default:
                control.Enabled = true;
                control.Visible = true;
                break;
            }
        }
예제 #2
0
 /// <summary>
 /// Applies the security.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="user">The user.</param>
 public static void ApplySecurityOnWinForms(System.Windows.Forms.Control control, IUser user)
 {
     foreach (var tempControl in TraverseWindowsControls(control))
     {
         var securedObjectName = string.Format("{0}.{1}", control.GetType(), tempControl.Name);
         var securityInfo      = SecurityContext.AuthorizationInfos.FirstOrDefault(tempInfo => tempInfo.ObjectName == securedObjectName);
         if ((securityInfo != null))
         {
             System.Windows.Forms.MethodInvoker methodInvoker = () => SetControl(tempControl, securityInfo.RightType);
             control.Invoke(methodInvoker);
         }
     }
 }
예제 #3
0
 private void BOk_Click(object sender, EventArgs e)
 {
     System.Windows.Forms.Control found = this.Parent;
     while (found != null)
     {
         if (found is Form foundForm)
         {
             foundForm.Close();
             return;
         }
         found = found.Parent;
     }
 }
        public void DropDownControl(System.Windows.Forms.Control control)
        {
            Debug.WriteLine("opend rop down");
            _windowsFormsHost.Child = control;
            // try
            // {
            // Window w = new Window {Content = new WindowsFormsHost() {Width = 400, Height = 400, Child = control}};
            // Debug.WriteLine(w.ToString());
            // w.ShowDialog();
            // }
            // catch (Exception ex)
            // {
            // Debug.WriteLine(ex.ToString());
            // }

            _d?.SetValue(_dropDownOpen, true);
        }
예제 #5
0
        private static IEnumerable <System.Windows.Forms.Control> TraverseWindowsControls(System.Windows.Forms.Control control)
        {
            foreach (System.Windows.Forms.Control tempControl in control.Controls)
            {
                yield return(tempControl);

                foreach (System.Windows.Forms.Control childControl in TraverseWindowsControls(tempControl))
                {
                    yield return(childControl);
                }
            }
        }