//-----------------------------------------------------------------------
//
// Copyright © 2012 Nils Hammar. All rights reserved.
//
//-----------------------------------------------------------------------
/*
* Software to access vehicle information via the OBD-II connector.
*
* Copyright © 2012 Nils Hammar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Alternative licensing is possible, see the licensing document.
*
* The above text may not be removed or modified.
*/
namespace UserInterface.GUI.Objects
{
using System;
using System.Runtime.Serialization;
using System.Windows.Forms;
///
/// Class extending the TreeNode class with connected data.
///
[Serializable]
public class PanelTreeNode : TreeNode, ISerializable
{
///
/// Gets the user control bound to the node.
///
public UserControl userControl { get; private set; }
///
/// Gets Freeze Frame number.
///
public int frameNumber { get; private set; }
///
/// Initializes a new instance of the class.
///
/// The user control bound to the node.
public PanelTreeNode(UserControl userControl)
: base()
{
this.userControl = userControl;
this.frameNumber = 0;
}
///
/// Initializes a new instance of the class.
///
/// Text to display for node.
/// The user control bound to the node.
public PanelTreeNode(string text, UserControl userControl)
: base(text)
{
this.userControl = userControl;
this.frameNumber = 0;
}
///
/// Initializes a new instance of the class.
///
/// Text to display for node.
/// Child Nodes.
/// The user control bound to the node.
public PanelTreeNode(string text, TreeNode[] children, UserControl userControl)
: base(text, children)
{
this.userControl = userControl;
this.frameNumber = 0;
}
///
/// Initializes a new instance of the class.
///
/// Text to display for node.
/// Image icon for unselected node.
/// Image icon for selected node.
/// The user control bound to the node.
public PanelTreeNode(string text, string imageKey, string selectedImageKey, UserControl userControl)
: base(text)
{
this.userControl = userControl;
this.ImageKey = imageKey;
this.SelectedImageKey = selectedImageKey;
this.frameNumber = 0;
}
///
/// Initializes a new instance of the class.
///
/// Text to display for node.
/// Image icon for unselected node.
/// Image icon for selected node.
/// The user control bound to the node.
/// Freeze Frame number.
public PanelTreeNode(string text, string imageKey, string selectedImageKey, UserControl userControl, int frameNumber)
: base(text)
{
this.userControl = userControl;
this.ImageKey = imageKey;
this.SelectedImageKey = selectedImageKey;
this.frameNumber = frameNumber;
}
///
/// Initializes a new instance of the class.
///
/// Text to display for node.
/// Image icon for unselected node.
/// Image icon for selected node.
/// Child Nodes.
/// The user control bound to the node.
public PanelTreeNode(string text, string imageKey, string selectedImageKey, TreeNode[] children, UserControl userControl)
: base(text, children)
{
this.userControl = userControl;
this.ImageKey = imageKey;
this.SelectedImageKey = selectedImageKey;
this.frameNumber = 0;
}
///
/// Initializes a new instance of the class.
///
/// Serialization info.
/// Streaming context.
protected PanelTreeNode(SerializationInfo info, StreamingContext context)
: base(info, context)
{
if (info != null)
{
this.userControl = (UserControl)info.GetValue("userControl", typeof(UserControl));
}
this.frameNumber = 0;
}
///
/// Serialize the object.
///
/// Serialization info.
/// Streaming context.
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info != null)
{
info.AddValue("userControl", this.userControl);
}
}
}
}