OSDN Git Service

AppliStation-GUI,UserPrefForm.csへのコメント追加
[applistation/AppliStation.git] / AppliStation / AppliStation.Util / GUIUtils.cs
index d70989b..ed5a057 100644 (file)
@@ -3,6 +3,7 @@ using System.IO;
 using System.Runtime.InteropServices;\r
 using System.Drawing;\r
 using System.Drawing.Imaging;\r
+using System.Windows.Forms;\r
 using NaGet.Packages;\r
 using NaGet.Packages.Install;\r
 \r
@@ -13,6 +14,8 @@ namespace AppliStation.Util
        /// </summary>\r
        public sealed class GUIUtils\r
        {\r
+               #region アイコン関連\r
+               \r
                #region ExtraIcon関連\r
                \r
                [DllImport("shell32.dll")]\r
@@ -30,7 +33,7 @@ namespace AppliStation.Util
                /// <param name="lpszExeFileName">対象ファイル</param>\r
                /// <param name="nIconIndex">アイコンインデックス</param>\r
                /// <returns>生成されたアイコン</returns>\r
-               public static Icon ExtractIcon(System.Windows.Forms.Form form, string lpszExeFileName, uint nIconIndex)\r
+               public static Icon ExtractIcon(Form form, string lpszExeFileName, uint nIconIndex)\r
                {\r
                        Icon ico = null;\r
                        \r
@@ -59,7 +62,7 @@ namespace AppliStation.Util
                /// <param name="form">ハンドラ</param>\r
                /// <param name="lpszExeFileNameAndIndex">対象ファイルとアイコンインデックスの文字列表現</param>\r
                /// <returns>生成されたアイコン。</returns>\r
-               public static Icon ExtractIcon(System.Windows.Forms.Form form, string lpszExeFileNameAndIndex)\r
+               public static Icon ExtractIcon(Form form, string lpszExeFileNameAndIndex)\r
                {\r
                        int index = lpszExeFileNameAndIndex.LastIndexOf(',');\r
                        if (index >= 0) {\r
@@ -162,5 +165,29 @@ namespace AppliStation.Util
                                    GraphicsUnit.Pixel, ia);\r
                }\r
 \r
+               #endregion\r
+               \r
+               #region CheckedListBox関連\r
+               \r
+               /// <summary>\r
+               /// チェックリストボックスのアイテムをスワップする\r
+               /// </summary>\r
+               /// <param name="checkedListBox">操作対象のCheckedListBox</param>\r
+               /// <param name="indexA">アイテムインデックス</param>\r
+               /// <param name="indexB">アイテムインデックス</param>\r
+               /// <remarks>インデックス値のチェックは本メソッドでは行っていない</remarks>\r
+               public static void CheckedListBox_SwapItems(CheckedListBox checkedListBox, int indexA, int indexB) {\r
+                       int itemCount = checkedListBox.Items.Count;\r
+                       object tempItem          = checkedListBox.Items[indexA];\r
+                       CheckState tempState = checkedListBox.GetItemCheckState(indexA);\r
+                       \r
+                       checkedListBox.Items[indexA] = checkedListBox.Items[indexB];\r
+                       checkedListBox.SetItemCheckState(indexA, checkedListBox.GetItemCheckState(indexB));\r
+                       \r
+                       checkedListBox.Items[indexB] = tempItem;\r
+                       checkedListBox.SetItemCheckState(indexB, tempState);\r
+               }\r
+               \r
+               #endregion\r
        }\r
 }\r