⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iismainwindow.cs

📁 用ADSI操作IIS文件
💻 CS
📖 第 1 页 / 共 3 页
字号:
// IIsAdmin.NET
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This softwareis provided "AS IS" with no warranties of any kind.
// The entire risk arising out of the use or performance of the software
// and source code is with you.
//
// THIS NOTICE MAY NOT BE REMOVED FROM THIS FILE.

using System;
using System.Diagnostics;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace IIsAdmin
{
	/// <summary>
	/// Summary description for IIsMainWindow.
	/// </summary>
	public class IIsMainWindow : System.Windows.Forms.Form
	{
        private IIsAdministrator _iisAdministrator;

        private ListView _listView;
        private StatusBar _statusBar;
        private StatusBarPanel statusBarPanel3;
        private StatusBarPanel statusBarPanel4;
        private ColumnHeader columnHeader1;
        private ColumnHeader columnHeader2;
        private Button _buttonRefresh;
        private Button _buttonStart;
        private Button _buttonStop;
        private Button _buttonCreate;
        private Button _buttonDelete;
        private Button _buttonRestartIIS;
        private Button _buttonOpenIIS;
        private System.Windows.Forms.NotifyIcon _notifyIcon;
        private System.Windows.Forms.ContextMenu _contextMenuTray;
        private System.ComponentModel.IContainer components;

        /// <summary>
        /// Initializes a new instance of the IIsMainWindow class
        /// </summary>
		public IIsMainWindow(IIsAdministrator iisAdministrator)
		{
			this.InitializeComponent();

            this.Resize += new EventHandler(IIsMainWindow_Resize);

            _iisAdministrator = iisAdministrator;
            _iisAdministrator.WebSiteStarted += new IIsWebSiteEventHandler(this.WebSite_Started);
            _iisAdministrator.WebSiteStopped += new IIsWebSiteEventHandler(this.WebSite_Stopped);

            _listView.CheckBoxes = false;
            _listView.MultiSelect = false;
            _listView.ItemCheck += new ItemCheckEventHandler(this.ListView_ItemChecked);
            _listView.SelectedIndexChanged += new EventHandler(this.ListView_SelectedItemIndexChanged);
            _listView.DoubleClick += new EventHandler(ListView_DoubleClick);

            _buttonRefresh.Click += new EventHandler(this.ButtonRefresh_Clicked);
            _buttonStart.Click += new EventHandler(this.ButtonStart_Clicked);
            _buttonStop.Click += new EventHandler(this.ButtonStop_Clicked);
            _buttonCreate.Click += new EventHandler(this.ButtonCreate_Clicked);
            _buttonDelete.Click += new EventHandler(this.ButtonDelete_Clicked);
            _buttonRestartIIS.Click += new EventHandler(this.ButtonRestartIIs_Clicked);
            _buttonOpenIIS.Click += new EventHandler(this.ButtonOpenIIs_Clicked);            

            _contextMenuTray.Popup += new EventHandler(this.ContextMenuTray_Popup);

            ConfigureNotifyIcon(true);
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(IIsMainWindow));
            this._listView = new System.Windows.Forms.ListView();
            this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
            this._buttonRefresh = new System.Windows.Forms.Button();
            this._buttonStart = new System.Windows.Forms.Button();
            this._buttonStop = new System.Windows.Forms.Button();
            this._buttonCreate = new System.Windows.Forms.Button();
            this._buttonDelete = new System.Windows.Forms.Button();
            this._buttonRestartIIS = new System.Windows.Forms.Button();
            this._buttonOpenIIS = new System.Windows.Forms.Button();
            this._statusBar = new System.Windows.Forms.StatusBar();
            this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
            this.statusBarPanel4 = new System.Windows.Forms.StatusBarPanel();
            this._contextMenuTray = new System.Windows.Forms.ContextMenu();
            this._notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
            ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).BeginInit();
            this.SuspendLayout();
            // 
            // _listView
            // 
            this._listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this._listView.CheckBoxes = true;
            this._listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeader2,
            this.columnHeader1});
            this._listView.FullRowSelect = true;
            this._listView.Location = new System.Drawing.Point(10, 9);
            this._listView.Name = "_listView";
            this._listView.Size = new System.Drawing.Size(279, 183);
            this._listView.TabIndex = 0;
            this._listView.UseCompatibleStateImageBehavior = false;
            this._listView.View = System.Windows.Forms.View.Details;
            // 
            // columnHeader2
            // 
            this.columnHeader2.Text = "Name";
            this.columnHeader2.Width = 180;
            // 
            // columnHeader1
            // 
            this.columnHeader1.Text = "Index";
            this.columnHeader1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.columnHeader1.Width = 47;
            // 
            // _buttonRefresh
            // 
            this._buttonRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this._buttonRefresh.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._buttonRefresh.Location = new System.Drawing.Point(299, 9);
            this._buttonRefresh.Name = "_buttonRefresh";
            this._buttonRefresh.Size = new System.Drawing.Size(90, 24);
            this._buttonRefresh.TabIndex = 1;
            this._buttonRefresh.Text = "Refresh";
            // 
            // _buttonStart
            // 
            this._buttonStart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this._buttonStart.Enabled = false;
            this._buttonStart.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._buttonStart.Location = new System.Drawing.Point(299, 34);
            this._buttonStart.Name = "_buttonStart";
            this._buttonStart.Size = new System.Drawing.Size(90, 25);
            this._buttonStart.TabIndex = 2;
            this._buttonStart.Text = "Start";
            // 
            // _buttonStop
            // 
            this._buttonStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this._buttonStop.Enabled = false;
            this._buttonStop.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._buttonStop.Location = new System.Drawing.Point(299, 60);
            this._buttonStop.Name = "_buttonStop";
            this._buttonStop.Size = new System.Drawing.Size(90, 25);
            this._buttonStop.TabIndex = 3;
            this._buttonStop.Text = "Stop";
            // 
            // _buttonCreate
            // 
            this._buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this._buttonCreate.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._buttonCreate.Location = new System.Drawing.Point(299, 86);
            this._buttonCreate.Name = "_buttonCreate";
            this._buttonCreate.Size = new System.Drawing.Size(90, 25);
            this._buttonCreate.TabIndex = 4;
            this._buttonCreate.Text = "Create";
            // 
            // _buttonDelete
            // 
            this._buttonDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this._buttonDelete.Enabled = false;
            this._buttonDelete.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._buttonDelete.Location = new System.Drawing.Point(299, 112);
            this._buttonDelete.Name = "_buttonDelete";
            this._buttonDelete.Size = new System.Drawing.Size(90, 25);
            this._buttonDelete.TabIndex = 5;
            this._buttonDelete.Text = "Delete";
            // 
            // _buttonRestartIIS
            // 
            this._buttonRestartIIS.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this._buttonRestartIIS.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._buttonRestartIIS.Location = new System.Drawing.Point(299, 138);
            this._buttonRestartIIS.Name = "_buttonRestartIIS";
            this._buttonRestartIIS.Size = new System.Drawing.Size(90, 25);
            this._buttonRestartIIS.TabIndex = 6;
            this._buttonRestartIIS.Text = "Restart IIS";
            // 
            // _buttonOpenIIS
            // 
            this._buttonOpenIIS.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this._buttonOpenIIS.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._buttonOpenIIS.Location = new System.Drawing.Point(299, 164);
            this._buttonOpenIIS.Name = "_buttonOpenIIS";
            this._buttonOpenIIS.Size = new System.Drawing.Size(90, 24);
            this._buttonOpenIIS.TabIndex = 7;
            this._buttonOpenIIS.Text = "Open IIS";
            // 
            // _statusBar
            // 
            this._statusBar.Location = new System.Drawing.Point(0, 208);
            this._statusBar.Name = "_statusBar";
            this._statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
            this.statusBarPanel3,
            this.statusBarPanel4});
            this._statusBar.ShowPanels = true;
            this._statusBar.Size = new System.Drawing.Size(395, 23);
            this._statusBar.TabIndex = 8;
            // 
            // statusBarPanel3
            // 
            this.statusBarPanel3.Name = "statusBarPanel3";
            // 
            // statusBarPanel4
            // 
            this.statusBarPanel4.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
            this.statusBarPanel4.Name = "statusBarPanel4";
            this.statusBarPanel4.Width = 279;
            // 
            // _notifyIcon
            // 
            this._notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("_notifyIcon.Icon")));
            this._notifyIcon.Visible = true;
            // 
            // IIsMainWindow
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(395, 231);
            this.Controls.Add(this._buttonOpenIIS);
            this.Controls.Add(this._buttonRestartIIS);
            this.Controls.Add(this._buttonDelete);
            this.Controls.Add(this._buttonCreate);
            this.Controls.Add(this._buttonStop);
            this.Controls.Add(this._buttonStart);
            this.Controls.Add(this._buttonRefresh);
            this.Controls.Add(this._listView);
            this.Controls.Add(this._statusBar);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MinimumSize = new System.Drawing.Size(403, 258);
            this.Name = "IIsMainWindow";
            this.Text = "IIsAdmin.NET 1.1";
            ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).EndInit();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -