コード例 #1
0
 /// <summary>
 /// Refresh authorization and update
 /// all controls.
 /// </summary>
 public void Refresh()
 {
     _source = DataObject as IAuthorizeReadWrite;
     if (_source != null)
     {
         base.FindChildBindings();
     }
 }
コード例 #2
0
        private void SetRead(Binding bnd, UIElement ctl, IAuthorizeReadWrite source)
        {
            bool           canRead        = source.CanReadProperty(bnd.Path.Path);
            VisibilityMode visibilityMode = GetNotVisibleMode(ctl);

            if (canRead)
            {
                switch (visibilityMode)
                {
                case VisibilityMode.Collapsed:
                    if (ctl.Visibility == Visibility.Collapsed)
                    {
                        ctl.Visibility = Visibility.Visible;
                    }
                    break;

                case VisibilityMode.Hidden:
                    if (ctl.Visibility == Visibility.Hidden)
                    {
                        ctl.Visibility = Visibility.Visible;
                    }
                    break;

                default:
                    break;
                }
            }
            else
            {
                switch (visibilityMode)
                {
                case VisibilityMode.Collapsed:
                    ctl.Visibility = Visibility.Collapsed;
                    break;

                case VisibilityMode.Hidden:
                    ctl.Visibility = Visibility.Hidden;
                    break;

                default:
                    break;
                }
            }
        }
コード例 #3
0
        private void SetWrite(Binding bnd, UIElement ctl, IAuthorizeReadWrite source)
        {
            bool canWrite = source.CanWriteProperty(bnd.Path.Path);

            // enable/disable writing of the value
            PropertyInfo propertyInfo =
                ctl.GetType().GetProperty("IsReadOnly",
                                          BindingFlags.FlattenHierarchy |
                                          BindingFlags.Instance |
                                          BindingFlags.Public);

            if (propertyInfo != null)
            {
                propertyInfo.SetValue(
                    ctl, !canWrite, new object[] { });
            }
            else
            {
                ctl.IsEnabled = canWrite;
            }
        }