Example #1
0
        private void ShowSiteProperties(string sKey)
        {
            SitePropertiesDialog dlg = new SitePropertiesDialog(
                _started ? SitePropertiesDialog.OpenMode.MODE_READONLY : SitePropertiesDialog.OpenMode.MODE_EDIT,
                _webSites,
                sKey);

            dlg.txtKeyName.Text            = sKey;
            dlg.txtDefaultPage.Text        = _webSites[sKey].DefaultPage;
            dlg.txtPhysicalPath.Text       = _webSites[sKey].PhysicalPath;
            dlg.txtPortNumber.Text         = _webSites[sKey].Port.ToString();
            dlg.txtVirtualPath.Text        = _webSites[sKey].VirtualPath.Substring(1);
            dlg.chkLogPageRequests.Checked = _webSites[sKey].LogPageRequests;
            dlg.txtKeyName.Enabled         = !_started;
            dlg.txtDefaultPage.Enabled     = !_started;
            dlg.txtPhysicalPath.Enabled    = !_started;
            dlg.txtPortNumber.Enabled      = !_started;
            dlg.txtVirtualPath.Enabled     = !_started;
            dlg.btnOk.Enabled = !_started;

            if (dlg.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _webSites.Remove(sKey);

            WebSite ws = new WebSite();

            ws.DefaultPage     = dlg.txtDefaultPage.Text;
            ws.PhysicalPath    = dlg.txtPhysicalPath.Text;
            ws.Port            = Convert.ToInt32(dlg.txtPortNumber.Text);
            ws.VirtualPath     = dlg.txtVirtualPath.Text;
            ws.LogPageRequests = dlg.chkLogPageRequests.Checked;

            _webSites.Add(dlg.txtKeyName.Text, ws);
            _webSites.Save(_allowRemoteConnections, _hideAtStartup, _startAutomatically);

            UpdateUI();
        }
Example #2
0
        /// <summary>
        /// This is the constructor that is used when command line parameters are used
        /// </summary>
        /// <param name="PhysicalPath"></param>
        /// <param name="VirtualPath"></param>
        /// <param name="Port"></param>
        /// <param name="DefaultPage"></param>
        /// <param name="AllowRemoteConnection"></param>
        /// <param name="LogPageRequests"></param>
        public SmallUIForm(string PhysicalPath, string VirtualPath, int Port, string DefaultPage, bool AllowRemoteConnection, bool LogPageRequests)
        {
            InitializeComponent();

            _webSite.PhysicalPath    = PhysicalPath;
            _webSite.VirtualPath     = VirtualPath;
            _webSite.Port            = Port;
            _webSite.DefaultPage     = DefaultPage;
            _webSite.LogPageRequests = LogPageRequests;

            _allowRemoteConnection = AllowRemoteConnection;

            txtPhysicalPath.Text = _webSite.PhysicalPath;
            txtVirtualPath.Text  = _webSite.VirtualPath.Substring(1);
            txtPortNumber.Text   = _webSite.Port.ToString();
            txtDefaultPage.Text  = _webSite.DefaultPage;

            linkLabel.Text = _webSite.Url;
            chkAllowRemoteConnection.Checked = _allowRemoteConnection;
            chkLogPageRequests.Checked       = _webSite.LogPageRequests;

            // Create a listener for ServerManager messages
            _webSites = new WebSites();
            _webSites.Add("FormSite", _webSite);
            _managerListener = new ServerManagerListener(Program.SERVER_MANAGER_BASE_PORT, this, _webSites);
            _managerListener.StartListening();

            // Create the help site and start the server unless another instance of the app has already done it
            _helpSite = Program.CreateHelpWebSite();

            if (!Program.PortIsInUse(_helpSite.Port, false) && (_helpSite.PhysicalPath != String.Empty))
            {
                _helpSite.WebServer = new Server(_helpSite.Port, _helpSite.VirtualPath, _helpSite.PhysicalPath, _helpSite.DefaultPage, false, false);
            }

            // Set the main window title
            this.Text = String.Format("{0} [{1}]", Program.ApplicationTitle, _webSite.Port.ToString());
        }
Example #3
0
        private void addSiteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SitePropertiesDialog dlg = new SitePropertiesDialog(SitePropertiesDialog.OpenMode.MODE_ADD,
                                                                _webSites,
                                                                null);

            if (dlg.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            WebSite ws = new WebSite();

            ws.DefaultPage  = dlg.txtDefaultPage.Text;
            ws.PhysicalPath = dlg.txtPhysicalPath.Text;
            ws.Port         = Convert.ToInt32(dlg.txtPortNumber.Text);
            ws.VirtualPath  = dlg.txtVirtualPath.Text;

            _webSites.Add(dlg.txtKeyName.Text, ws);
            _webSites.Save(_allowRemoteConnections, _hideAtStartup, _startAutomatically);

            UpdateUI();
        }