using System;
using System.Collections;
using System.Threading;
using Ironring.MMC.PropertyPages;
using Ironring.MMC.Core;
namespace Ironring.MMC.Nodes{
/// <summary>
/// Items in a listview modeled as seperate items. Note: the images are leached from
/// the report-node image list: we don't want to re-load images everytime.
/// </summary>
public class ResultViewItem : IMMCSelected, IMMCPropertyPage
{
///////////////////////////////////////////////////////////////////////
//
// Member variables
//
#region
private readonly static System.Type _class = typeof(ResultViewItem);
private SnapinBase _snapin;
private ReportNode _node;
private bool _selected;
private String _displayName;
private int _largeImage;
private int _smallImage;
private int _dummy1;
private int _dummy2;
private uint _itemID;
private PropertySheet _propsheet;
private Hashtable _details = new Hashtable();
private ArrayList _tasks = null;
private ArrayList _menus = null;
#endregion
///////////////////////////////////////////////////////////////////////
//
// Properties
//
/// <summary>
///
/// </summary>
public static System.Type Class
{
get { return _class; }
}
#region
/// <summary>
/// Get a reference back to the snapin
/// </summary>
public SnapinBase SnapinBase
{
get { return _snapin; }
}
/// <summary>
/// Get a reference back to the node where we belong to
/// </summary>
public ReportNode Node
{
get { return _node; }
}
/// <summary>
/// Get/set the property sheet for this item.
/// </summary>
public PropertySheet PropertySheet
{
get { return _propsheet; }
set { this._propsheet = value; }
}
/// <summary>
/// Get/set the displayname of this ResultViewItem
/// </summary>
public String DisplayName
{
get { return _displayName; }
set { _displayName = value; }
}
/// <summary>
/// Get/set the selected status of this node
/// </summary>
public bool Selected
{
get { return _selected; }
set { _selected = value; }
}
/// <summary>
/// Get/set the ItemID of this ResultViewItem
/// </summary>
public uint ItemID
{
get { return this._itemID; }
set { this._itemID = value; }
}
/// <summary>
/// Get/set the details for this list-item. The keys are ResultViewItemColumn references, the values
/// are the details (as Strings).
/// </summary>
public virtual Hashtable Details
{
get { return this._details; }
set { this._details = value; }
}
/// <summary>
/// Get the index of the largeImage
/// </summary>
public virtual int LargeImage
{
get { return this._largeImage; }
}
/// <summary>
/// Get the index of he SmallImage
/// </summary>
public virtual int SmallImage
{
get { return this._smallImage; }
}
/// <summary>
/// Get/set TopLevel menus for this node (MenuItem).
/// </summary>
public virtual ArrayList Menus
{
get { return _menus; }
set { _menus = value; }
}
/// <summary>
/// Return all Tasks for this node (MenuItem).
/// FIXME: are there any task thingies available from the mmc side ?
/// is this even possible?
/// </summary>
public virtual ArrayList Tasks
{
get { return _tasks; }
set { _tasks = value;}
}
#endregion
////////////////////////////////////////////////////////////////////////////
//
// Constructors
//
#region
/// <summary>
/// System.Type.GetType() is misdesigned. creating and getting the type
/// at least gives us a Typecheck! This constructor exists just for that
/// purpose.
/// </summary>
internal ResultViewItem()
{
}
/// <summary>
/// Create a new resultview item for the given snapin/node with the given display name.
/// </summary>
/// <param name="snapin">The snapin</param>
/// <param name="node">The reportnode-ext</param>
/// <param name="displayName">The display name for the item. This is the only guaranteed visible column.</param>
public ResultViewItem(SnapinBase snapin, ReportNode node, String displayName) : this(snapin, node, displayName, "", "")
{
}
/// <summary>
/// Extended constructor with picture support!
/// </summary>
/// <param name="snapin">The snapin</param>
/// <param name="node">The reportnode</param>
/// <param name="displayName">The display name for the item. This is the only guaranteed visible column.</param>
/// <param name="smallImageName">The name of the small-image. Should be available in the report node</param>
/// <param name="largeImageName">The name of the large-image. Should be available in the report node</param>
public ResultViewItem(SnapinBase snapin, ReportNode node, String displayName, String smallImageName, String largeImageName)
{
_snapin = snapin;
_displayName = displayName;
_node = node;
if(node.ResultPaneImages == null)
{
node.ResultPaneImages = new ImageList();
}
_largeImage = node.ResultPaneImages.Add(largeImageName);
_smallImage = node.ResultPaneImages.Add(smallImageName);
_dummy1 = node.ResultPaneImages.Add(largeImageName);
_dummy2 = node.ResultPaneImages.Add(smallImageName);
}
#endregion
/// <summary>
/// Add detail for the given column.
/// </summary>
/// <param name="col">The column object</param>
/// <param name="detail">The detail-text</param>
public virtual void AddDetail(ResultViewColumn col, String detail)
{
this.Details.Add(col, detail);
}
/// <summary>
/// Remove all details.
/// </summary>
public virtual void ClearDetail()
{
this.Details.Clear();
}
/// <summary>
/// Callback from the reportnodeext to get the details for a given item/subitem.
/// </summary>
/// <param name="key">The columnname we are looking for</param>
/// <returns>The details for the column</returns>
public virtual String GetDetail(ResultViewColumn key)
{
return (String)this._details[key];
}
#region IMMCPropertyPage Members
protected ArrayList m_propertypages = new ArrayList();
public virtual ArrayList PropertyPages
{
get { return m_propertypages; }
set { m_propertypages = value;}
}
#endregion
/// <summary>
/// Called when this item is selected. Note: it might be called twice
/// due to unforseen bugs.
/// </summary>
/// <remarks>The default implementation does nothing</remarks>
public virtual void OnSelect()
{
// Called when this item is selected. We do nothing in the default implementation.
}
/// <summary>
/// Called when this item is selected. Note: it might be called twice
/// due to unforseen bugs.
/// </summary>
/// <remarks>The default implementation does nothing</remarks>
public virtual void OnDeselect()
{
// Called when this item is selected. We do nothing in the default implementation.
}
}
}
|