Exemplo n.º 1
0
        public NewApplicationDialog(IServiceProvider serviceProvider, FastCgiItem existing, FastCgiFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            Text                        = string.Format("{0} FastCGI Application", existing == null ? "Add" : "Edit");
            txtPath.ReadOnly            = txtArguments.ReadOnly = existing != null;
            Item                        = existing ?? new FastCgiItem(null);
            txtPath.Text                = Item.Path;
            txtArguments.Text           = Item.Arguments;
            pgProperties.SelectedObject = Item;

            var container = new CompositeDisposable();

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

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                Item.Path      = txtPath.Text;
                Item.Arguments = txtArguments.Text;

                if (!txtPath.ReadOnly && feature.Items.Any(item => item.Match(Item)))
                {
                    ShowMessage(
                        "This FastCGI application already exists.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                    return;
                }

                DialogResult = DialogResult.OK;
            }));

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

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnBrowse, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                DialogHelper.ShowOpenFileDialog(txtPath, "CGI Executables|*.exe|CGI Files|*.dll|All Files|*.*");
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }
Exemplo n.º 2
0
 public FastCgiListViewItem(FastCgiItem item, FastCgiPage page)
     : base(item.Path)
 {
     Item  = item;
     _page = page;
     SubItems.Add(new ListViewSubItem(this, item.Arguments));
     SubItems.Add(new ListViewSubItem(this, item.MaxInstances.ToString()));
     SubItems.Add(new ListViewSubItem(this, item.InstanceMaxRequests.ToString()));
 }