moved the setup of the name column to its own class

This commit is contained in:
David Sparer
2017-01-12 08:58:52 -07:00
parent ad32f4a0a3
commit 9132592fd7
3 changed files with 34 additions and 18 deletions

View File

@@ -61,14 +61,7 @@ namespace mRemoteNG.UI.Controls
private void CreateNameColumn()
{
_olvNameColumn = new OLVColumn
{
AspectName = "Name",
FillsFreeSpace = true,
IsButton = true,
AspectGetter = item => ((ConnectionInfo)item).Name,
ImageGetter = ConnectionImageGetter
};
_olvNameColumn = new NameColumn();
Columns.Add(_olvNameColumn);
AllColumns.Add(_olvNameColumn);
}
@@ -116,16 +109,6 @@ namespace mRemoteNG.UI.Controls
//ContextMenuStrip = _contextMenu;
}
private static object ConnectionImageGetter(object rowObject)
{
if (rowObject is RootPuttySessionsNodeInfo) return "PuttySessions";
if (rowObject is RootNodeInfo) return "Root";
if (rowObject is ContainerInfo) return "Folder";
var connection = rowObject as ConnectionInfo;
if (connection == null) return "";
return connection.OpenConnections.Count > 0 ? "Play" : "Pause";
}
private void SetupDropSink()
{
DropSink = new SimpleDropSink

View File

@@ -0,0 +1,30 @@
using BrightIdeasSoftware;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Tree.Root;
namespace mRemoteNG.UI.Controls
{
public class NameColumn : OLVColumn
{
public NameColumn()
{
AspectName = "Name";
FillsFreeSpace = true;
IsButton = true;
AspectGetter = item => ((ConnectionInfo) item).Name;
ImageGetter = ConnectionImageGetter;
}
private static object ConnectionImageGetter(object rowObject)
{
if (rowObject is RootPuttySessionsNodeInfo) return "PuttySessions";
if (rowObject is RootNodeInfo) return "Root";
if (rowObject is ContainerInfo) return "Folder";
var connection = rowObject as ConnectionInfo;
if (connection == null) return "";
return connection.OpenConnections.Count > 0 ? "Play" : "Pause";
}
}
}

View File

@@ -237,6 +237,9 @@
<Compile Include="UI\Controls\IPTextBox.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UI\Controls\NameColumn.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\QuickConnectComboBox.cs">
<SubType>Component</SubType>
</Compile>