diff --git a/mRemoteV1/UI/Controls/ConnectionTree.cs b/mRemoteV1/UI/Controls/ConnectionTree.cs index df06414e6..36d39e328 100644 --- a/mRemoteV1/UI/Controls/ConnectionTree.cs +++ b/mRemoteV1/UI/Controls/ConnectionTree.cs @@ -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() diff --git a/mRemoteV1/UI/Controls/StatusImageList.cs b/mRemoteV1/UI/Controls/StatusImageList.cs new file mode 100644 index 000000000..987952aa0 --- /dev/null +++ b/mRemoteV1/UI/Controls/StatusImageList.cs @@ -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); + } + } + } +} \ No newline at end of file diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index 38570f53c..6a7c9a0dc 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -243,6 +243,7 @@ Component + Component