moved the setup of the tree image list to its own class

This commit is contained in:
David Sparer
2017-01-12 08:59:34 -07:00
parent 9132592fd7
commit 5bcb59f876
3 changed files with 45 additions and 29 deletions

View File

@@ -53,7 +53,6 @@ namespace mRemoteNG.UI.Controls
{
CreateNameColumn();
CreateImageList();
FillImageList();
LinkModelToView();
SetupDropSink();
SetEventHandlers();
@@ -68,34 +67,7 @@ namespace mRemoteNG.UI.Controls
private void CreateImageList()
{
_imgListTree = new ImageList(components)
{
ColorDepth = ColorDepth.Depth32Bit,
ImageSize = new System.Drawing.Size(16, 16),
TransparentColor = System.Drawing.Color.Transparent
};
SmallImageList = _imgListTree;
}
private void FillImageList()
{
try
{
_imgListTree.Images.Add(Resources.Root);
_imgListTree.Images.SetKeyName(0, "Root");
_imgListTree.Images.Add(Resources.Folder);
_imgListTree.Images.SetKeyName(1, "Folder");
_imgListTree.Images.Add(Resources.Play);
_imgListTree.Images.SetKeyName(2, "Play");
_imgListTree.Images.Add(Resources.Pause);
_imgListTree.Images.SetKeyName(3, "Pause");
_imgListTree.Images.Add(Resources.PuttySessions);
_imgListTree.Images.SetKeyName(4, "PuttySessions");
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace("FillImageList (UI.Window.ConnectionTreeWindow) failed", ex);
}
SmallImageList = StatusImageList.GetImageList();
}
private void LinkModelToView()

View File

@@ -0,0 +1,43 @@
using System;
using System.Windows.Forms;
using mRemoteNG.App;
namespace mRemoteNG.UI.Controls
{
public class StatusImageList
{
public static ImageList GetImageList()
{
var imageList = new ImageList
{
ColorDepth = ColorDepth.Depth32Bit,
ImageSize = new System.Drawing.Size(16, 16),
TransparentColor = System.Drawing.Color.Transparent
};
FillImageList(imageList);
return imageList;
}
private static void FillImageList(ImageList imageList)
{
try
{
imageList.Images.Add(Resources.Root);
imageList.Images.SetKeyName(0, "Root");
imageList.Images.Add(Resources.Folder);
imageList.Images.SetKeyName(1, "Folder");
imageList.Images.Add(Resources.Play);
imageList.Images.SetKeyName(2, "Play");
imageList.Images.Add(Resources.Pause);
imageList.Images.SetKeyName(3, "Pause");
imageList.Images.Add(Resources.PuttySessions);
imageList.Images.SetKeyName(4, "PuttySessions");
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace($"Unable to fill the image list of type {nameof(StatusImageList)}", ex);
}
}
}
}

View File

@@ -243,6 +243,7 @@
<Compile Include="UI\Controls\QuickConnectComboBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\StatusImageList.cs" />
<Compile Include="UI\Controls\ToolStripSplitButton.cs">
<SubType>Component</SubType>
</Compile>