iiswebsitelistviewitem.cs

来自「用ADSI操作IIS文件」· CS 代码 · 共 71 行

CS
71
字号
// 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.Drawing;
using System.Windows.Forms;

namespace IIsAdmin
{
	/// <summary>
	/// Defines a
	/// </summary>
    public class IIsWebSiteListViewItem : ListViewItem 
    {
        private IIsWebSite _site;

        /// <summary>
        /// Initializes a new instance of the IIsWebSiteListViewItem class
        /// </summary>
        /// <param name="site"></param>
        public IIsWebSiteListViewItem(IIsWebSite site) : base(site.Name)
        {
            base.Checked = (site.State == IIsWebSiteStates.Started); 
            if (base.Checked)
            {
                this.MakeBold(true);
            }

            base.SubItems.Add(site.Index.ToString());
            _site = site;
        }
        
        /// <summary>
        /// Makes the item bold
        /// </summary>
        /// <param name="bold">A flag to indicate if the item is displayed in bold or normal font</param>
        public void MakeBold(bool bold)
        {
            if (bold)
            {
                base.Font = new Font(this.Font.FontFamily.Name, this.Font.Size, FontStyle.Bold | FontStyle.Underline);               
            }
            else
            {
                base.Font = new Font(this.Font.FontFamily.Name, this.Font.Size, FontStyle.Regular);
            }
        }

        /// <summary>
        /// Returns the site represented by this item
        /// </summary>
        public IIsWebSite WebSite
        {
            get
            {
                return _site;
            }
        }
    }
}

⌨️ 快捷键说明

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