Пример #1
0
        public PermissionsDialog(IServiceProvider serviceProvider, HandlersFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            cbRead.Checked    = (feature.AccessPolicy & 1L) == 1L;
            cbScript.Checked  = (feature.AccessPolicy & 512L) == 512L;
            cbExecute.Checked = (feature.AccessPolicy & 4L) == 4L;

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                if (cbRead.Checked)
                {
                    feature.AccessPolicy |= 1L;
                }
                else
                {
                    feature.AccessPolicy &= ~1L;
                }

                if (cbScript.Checked)
                {
                    feature.AccessPolicy |= 512L;
                }
                else
                {
                    feature.AccessPolicy &= ~512L;
                }

                if (cbExecute.Checked)
                {
                    feature.AccessPolicy |= 4L;
                }
                else
                {
                    feature.AccessPolicy &= ~4L;
                }

                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }
Пример #2
0
 protected override bool ShowHelp()
 {
     _feature.ShowHelp();
     return(true);
 }