File TabContainer.xaml.cs¶
File List > PGRControls > TabContainer.xaml.cs
Go to the documentation of this file
//=============================================================================
// Copyright (c) 2026 FLIR Integrated Imaging Solutions, Inc. All Rights Reserved.
//
// This software is the confidential and proprietary information of FLIR
// Integrated Imaging Solutions, Inc. ("Confidential Information"). You
// shall not disclose such Confidential Information and shall use it only in
// accordance with the terms of the license agreement you entered into
// with FLIR Integrated Imaging Solutions, Inc. (FLIR)
//
// FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
// SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES
// SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
// THIS SOFTWARE OR ITS DERIVATIVES.
//=============================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using SpinnakerNET.GenApi;
namespace SpinnakerNET.GUI
{
namespace WPFControls
{
public sealed partial class TabContainer : BaseClass
{
#region FIELDS
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(TabContainer));
private CameraControlCollection _children;
private List<string>_childrenStringList;
private List<string>_tabNameList;
private List<int>_childrenIndexList;
private Dock _tabOrientation = Dock.Left;
private XMLParser _parser;
private List<string>_requiredChildren;
private bool _isComplete = true;
#endregion
#region PROPERTIES
public bool IsComplete
{
get
{
return _isComplete;
}
}
internal List<string>RequiredChildren
{
get
{
return _requiredChildren;
}
set
{
_requiredChildren = value;
}
}
internal XMLParser Parser
{
set
{
this._parser = value;
}
get
{
return _parser;
}
}
public Dock TabOrientation
{
get
{
return _tabOrientation;
}
set
{
_tabOrientation = value;
SetTabOrientation(_tabOrientation);
}
}
public List<string>ChildrenStringList
{
get
{
return _childrenStringList;
}
set
{
this._childrenStringList = value;
}
}
public List<string>TabNameList
{
get
{
return _tabNameList;
}
set
{
this._tabNameList = value;
}
}
public List<int>ChildrenIndexList
{
get
{
return _childrenIndexList;
}
set
{
_childrenIndexList = value;
}
}
public override string ControlNameLabel
{
get
{
return string.Empty;
}
set
{
}
}
#endregion
#region CONSTRUCTORS
public TabContainer()
{
InitializeComponent();
_requiredChildren = new List<string>();
_childrenIndexList = new List<int>();
_childrenStringList = new List<string>();
_children = new CameraControlCollection();
}
internal TabContainer(TabContainer originalControl)
{
InitializeComponent();
_requiredChildren = new List<string>();
_childrenIndexList = new List<int>();
_childrenStringList = new List<string>();
_children = new CameraControlCollection();
// Common Properties
this.SetMapper(originalControl.GetMapper());
this.SetVisibility(originalControl.Visibility);
this.SetControlID(originalControl.ControlID);
this.SetMin(originalControl.GetMin());
this.SetMax(originalControl.GetMax());
this.SetControlNameLabel(originalControl.ControlNameLabel);
this.SetNameLabelVisibility(originalControl.GetNameLabelVisibility());
this.SetNameLabelBoldness(originalControl.GetNameLabelBoldness());
try
{
this.SetToolTip(originalControl.GetToolTip());
}
catch (System.Exception /*ex*/)
{
}
this.SetMaximumControlSize(originalControl.GetMaximumControlSize());
this.SetMinimumControlSize(originalControl.GetMinimumControlSize());
this.SetControlHeight(originalControl.GetControlHeight());
this.SetControlWidth(originalControl.GetControlWidth());
this.SetRefreshTime(originalControl.GetRefreshTime());
this.SetMargin(originalControl.GetMargin());
this.Parser = originalControl.Parser;
// Tab specific properties
this.TabNameList = originalControl.TabNameList;
this.ChildrenStringList = originalControl.ChildrenStringList;
this.ChildrenIndexList = originalControl.ChildrenIndexList;
this.TabOrientation = originalControl.TabOrientation;
}
#endregion
#region TAB_BEHAVIOR_CONTROL
public void SetTabOrientation(Dock dock)
{
switch (dock)
{
case Dock.Left:
Style styleLeft = this.FindResource("TabControlLeft") as Style;
tabControl.Style = styleLeft;
tabControl.TabStripPlacement = Dock.Left;
_tabOrientation = Dock.Left;
break;
case Dock.Top:
Style styleTop = this.FindResource("TabControlTop") as Style;
tabControl.Style = styleTop;
tabControl.TabStripPlacement = Dock.Top;
_tabOrientation = Dock.Top;
break;
case Dock.Right:
Style styleRight = this.FindResource("TabControlRight") as Style;
tabControl.Style = styleRight;
tabControl.TabStripPlacement = Dock.Right;
_tabOrientation = Dock.Right;
break;
case Dock.Bottom:
Style styleBottom = this.FindResource("TabControlBottom") as Style;
tabControl.Style = styleBottom;
tabControl.TabStripPlacement = Dock.Bottom;
_tabOrientation = Dock.Bottom;
break;
default:
Style styleDefault = this.FindResource("TabControlLeft") as Style;
tabControl.Style = styleDefault;
tabControl.TabStripPlacement = Dock.Left;
_tabOrientation = Dock.Left;
break;
}
}
public Dock GetTabOrientation()
{
return _tabOrientation;
}
public bool PopulateTabContainer(CameraControlCollection ChildControls)
{
try
{
// Find and add child controls to dictionary container
if (_children.Count == 0)
{
if (_childrenStringList != null && _childrenStringList.Count > 0)
{
for (int i = 0; i < _childrenStringList.Count; i++)
{
bool childFound = false;
foreach(BaseClass control in ChildControls)
{
if (control == null)
{
continue;
}
if (_childrenStringList[i].Equals(control.GetControlID()))
{
// Found child control in collection.
_children.Add(control);
childFound = true;
break;
}
}
if (!childFound)
{
// Indicate that table contains missing child
_isComplete = false;
if (_requiredChildren.Contains(_childrenStringList[i]))
{
if (_parser != null && _parser.DebugModeEnabled)
{
log.Warn(string.Format(
"{2}Essential child \"{0}\" was missing from \"{1}\" Tab container.",
_childrenStringList[i],
ControlID,
FormattedSerialNumber));
log.Warn(string.Format(
"{2}Creating dummy child \"{0}\" for \"{1}\" Tab container.",
_childrenStringList[i],
ControlID,
FormattedSerialNumber));
// Get dummy control for this empty child
BaseClass dummyControl =
_parser.CreateDummyControl(_childrenStringList[i], true);
_children.Add(dummyControl);
}
else
{
// Non-debug mode.
// Return empty container
log.Warn(string.Format(
"Essential child \"{0}\" was missing from \"{1}\" Tab control. Returning empty table.",
_childrenStringList[i],
ControlID));
_featureAvailable = false;
return false;
}
}
else
{
// case for an optional control
if (_parser != null && _parser.DebugModeEnabled)
{
log.Warn(string.Format(
"{2}Creating dummy child \"{0}\" for \"{1}\" Tab container.",
_childrenStringList[i],
ControlID,
FormattedSerialNumber));
// Debug mode enabled
// Get dummy control for this empty child
BaseClass dummyControl = _parser.CreateDummyControl(_childrenStringList[i]);
_children.Add(dummyControl);
}
}
}
}
}
else
{
// Empty tab
_featureAvailable = true;
return true;
}
}
List<TabItem>items = new List<TabItem>();
for (int i = 0; i < _tabNameList.Count; i++)
{
string name = TabNameList[i];
TabItem item = new TabItem();
item.Header = name;
items.Add(item);
tabControl.Items.Add(item);
}
// Position Child controls
for (int i = 0; i < _children.Count; i++)
{
UserControl control = (UserControl) _children[i];
if (control == null)
{
continue;
}
if (control.Parent != null)
{
UserControl newDuplicatedControl = Parser.GetControlByName(_children[i].GetControlID());
control = newDuplicatedControl;
}
items[_childrenIndexList[i]].Content = control;
}
if (tabControl.Items.Count == 0 && (_parser != null && !_parser.DebugModeEnabled))
{
// Empty container is not return in release mode
log.Debug(string.Format(
"{1}Empty Tab Container \"{0}\" is not returned due to [Debug Flag = false]",
ControlID,
FormattedSerialNumber));
_featureAvailable = false;
return false;
}
else
{
// Empty container is returned in debug mode or if container is non-empty
_featureAvailable = true;
return true;
}
}
catch (System.Exception ex)
{
log.Error(string.Format("{0}Problem building Tab Container.", FormattedSerialNumber), ex);
Debug.WriteLine("Problem building Tab container!");
_featureAvailable = false;
return false;
}
}
#endregion
#region ICameraControl Interface
public override void Connect(INodeMap nodemap, string nodeName, string nameLabel)
{
// throw new NotImplementedException();
}
public override void Disconnect()
{
if (_children != null && _children.Count > 0)
{
foreach(ICameraControl control in _children)
{
try
{
control.Disconnect();
}
catch (System.Exception /*ex*/)
{
}
}
}
}
public override bool GetNameLabelBoldness()
{
return false;
}
public override void SetNameLabelBoldness(bool status)
{
/*throw new NotImplementedException();*/
}
public override void SetToolTip(string tooltip)
{
this.tabControl.ToolTip = tooltip;
}
public override void SetControlNameLabel(string nameLabel)
{
//
}
public override void SetNameLabelVisibility(System.Windows.Visibility visibility)
{
//
}
public override void SetRefreshTime(int seconds)
{
// throw new NotImplementedException();
}
public override void Refresh()
{
if (_children != null && _children.Count > 0)
{
foreach(ICameraControl info in _children)
{
info.Refresh();
}
}
}
public override string GetToolTip()
{
return this.tabControl.ToolTip.ToString();
}
public override string GetControlNameLabel()
{
return string.Empty;
}
public override System.Windows.Visibility GetNameLabelVisibility()
{
return System.Windows.Visibility.Visible;
}
public override string GetNodeToControl()
{
return string.Empty;
}
#endregion
}
}
}