예제 #1
0
        public WindowsAdvancedDialog(IServiceProvider serviceProvider, WindowsItem item, AuthenticationFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            btnOK.Enabled            = false;
            cbExtended.SelectedIndex = item.TokenChecking;
            cbKernelMode.Checked     = item.UseKernelMode;

            var container = new CompositeDisposable();

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

            container.Add(
                Observable.FromEventPattern <EventArgs>(cbExtended, "SelectedIndexChanged")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnOK.Enabled = true;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(cbKernelMode, "CheckedChanged")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnOK.Enabled = true;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                item.TokenChecking = cbExtended.SelectedIndex;
                item.UseKernelMode = cbKernelMode.Checked;
                item.Apply();
                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }
예제 #2
0
        public WindowsAdvancedDialog(IServiceProvider serviceProvider, WindowsItem item)
            : base(serviceProvider)
        {
            InitializeComponent();
            btnOK.Enabled            = false;
            cbExtended.SelectedIndex = item.TokenChecking;
            cbKernelMode.Checked     = item.UseKernelMode;

            var container = new CompositeDisposable();

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

            container.Add(
                Observable.FromEventPattern <EventArgs>(cbExtended, "SelectedIndexChanged")
                .Subscribe(evt =>
            {
                btnOK.Enabled = true;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(cbKernelMode, "CheckedChanged")
                .Subscribe(evt =>
            {
                btnOK.Enabled = true;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .Subscribe(evt =>
            {
                item.TokenChecking = cbExtended.SelectedIndex;
                item.UseKernelMode = cbKernelMode.Checked;
                item.Apply();
                DialogResult = DialogResult.OK;
            }));
        }
예제 #3
0
        public ProvidersDialog(IServiceProvider serviceProvider, WindowsItem item)
            : base(serviceProvider)
        {
            InitializeComponent();
            foreach (var provider in item.Providers)
            {
                lbProviders.Items.Add(provider.Value);
            }

            foreach (var each in _allProviders)
            {
                if (!lbProviders.Items.Contains(each))
                {
                    cbAvailable.Items.Add(each);
                }
            }

            btnOK.Enabled = false;

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

            container.Add(
                Observable.FromEventPattern<EventArgs>(btnRemove, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
                {
                    cbAvailable.Items.Add(lbProviders.SelectedItem);
                    lbProviders.Items.Remove(lbProviders.SelectedItem);
                    cbAvailable.Enabled = true;
                    btnOK.Enabled = true;
                }));

            var add = Observable.FromEventPattern<EventArgs>(btnAdd, "Click");
            var load = Observable.FromEventPattern<EventArgs>(this, "Load");
            container.Add(
                add.ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
                {
                    var selected = cbAvailable.Text;
                    lbProviders.Items.Add(selected);
                    cbAvailable.Items.RemoveAt(cbAvailable.SelectedIndex);
                    cbAvailable.SelectedIndex = -1;
                    btnOK.Enabled = true;
                }));

            container.Add(
                Observable.FromEventPattern<EventArgs>(cbAvailable, "SelectedIndexChanged")
                .Merge(load)
                .Merge(add)
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
                {
                    btnAdd.Enabled = cbAvailable.SelectedIndex > -1;
                    if (cbAvailable.Items.Count == 0)
                    {
                        cbAvailable.Enabled = false;
                    }
                }));

            container.Add(
                Observable.FromEventPattern<EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
                {
                    item.Providers.Clear();
                    foreach (string provider in lbProviders.Items)
                    {
                        item.Providers.Add(new ProviderItem(null) { Value = provider });
                    }

                    item.Apply();
                    DialogResult = DialogResult.OK;
                }));

            container.Add(
                Observable.FromEventPattern<EventArgs>(lbProviders, "SelectedIndexChanged")
                .Merge(load)
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
                {
                    btnRemove.Enabled = lbProviders.SelectedIndex > -1;
                    btnUp.Enabled = lbProviders.SelectedIndex > 0;
                    btnDown.Enabled = lbProviders.SelectedIndex > -1 && lbProviders.SelectedIndex < lbProviders.Items.Count - 1;
                }));

            container.Add(
                Observable.FromEventPattern<EventArgs>(btnUp, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
                {
                    var current = lbProviders.SelectedItem;
                    var up = lbProviders.SelectedIndex - 1;
                    lbProviders.Items.RemoveAt(lbProviders.SelectedIndex);
                    lbProviders.Items.Insert(up, current);
                    lbProviders.SelectedIndex = up;
                    btnOK.Enabled = true;
                }));

            container.Add(
                Observable.FromEventPattern<EventArgs>(btnDown, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
                {
                    var current = lbProviders.SelectedItem;
                    var down = lbProviders.SelectedIndex + 1;
                    lbProviders.Items.RemoveAt(lbProviders.SelectedIndex);
                    lbProviders.Items.Insert(down, current);
                    lbProviders.SelectedIndex = down;
                    btnOK.Enabled = true;
                }));
        }