Skip to content

Commit 2393bb6

Browse files
committed
Added New Methods.
1 parent 757e53e commit 2393bb6

File tree

2 files changed

+263
-24
lines changed

2 files changed

+263
-24
lines changed

ProductivityFunctionsLibrary/ControlsMethods.cs

+261-22
Original file line numberDiff line numberDiff line change
@@ -592,21 +592,11 @@ public static void FillImageList(this ImageList imageList, List<Icon> icons)
592592
imageList.Images.Add(icon);
593593
}
594594

595-
}
595+
}
596596

597597
#endregion
598598

599-
/*TODO- ListView Functions
600-
- LoadFoldersListWithIcons(folderName);
601-
- LoadFoldersListWithIconsAsync(folderName);
602-
- LoadFilesListWithIconsAysnc(folderName);
603-
- LoadFilesAndFolders(folderName);
604-
- LoadFilesAndFoldersAysnc(folderName);
605-
- LoadFilesAndFoldersWithIcons(folderName);
606-
- LoadFilesAndFoldersWithIconsAysnc(folderName);
607-
- LoadList(list<T>);
608-
- LoadList(list<T>,ImageList images);
609-
*/
599+
#region ListView Methods
610600

611601
/// <summary>
612602
/// Loads all the folders inside parent directory.
@@ -679,7 +669,7 @@ public static void LoadFilesList(this ListView listView, string parentDirectory)
679669
public static async void LoadFilesListAysnc(this ListView listView, string parentDirectory)
680670
{
681671

682-
List<string> ItemsList = await LoadAllFiles(parentDirectory);
672+
List<string> ItemsList = await LoadAllFiles(parentDirectory);
683673

684674
if (ItemsList.Count > 0)
685675
{
@@ -727,7 +717,105 @@ public static void LoadFilesWithIcons(this ListView listView, string parentDirec
727717
public static async void LoadFilesWithIconsAysnc(this ListView listView, string parentDirectory)
728718
{
729719

730-
List<string> ItemsList = await LoadAllFiles(parentDirectory);
720+
List<string> ItemsList = await LoadAllFiles(parentDirectory);
721+
ImageList imageList = new ImageList();
722+
imageList.FillImageList(await LoadAllFileIconsAysnc(parentDirectory));
723+
724+
if (ItemsList.Count > 0)
725+
{
726+
listView.Items.Clear();
727+
listView.LargeImageList = imageList;
728+
listView.SmallImageList = imageList;
729+
foreach (string item in ItemsList)
730+
{
731+
listView.Items.Add(item);
732+
listView.Items[listView.Items.Count - 1].ImageIndex = (listView.Items.Count - 1);
733+
}
734+
}
735+
736+
}
737+
738+
/// <summary>
739+
/// Load all files and folders inside of parent Directory.
740+
/// </summary>
741+
/// <param name="listView">The list view to load files on</param>
742+
/// <param name="parentDirectory">Full path of the parent directory.</param>
743+
public static void LoadFilesAndFolders(this ListView listView, string parentDirectory)
744+
{
745+
746+
List<string> ItemsList = LoadAllFiles_(parentDirectory);
747+
ItemsList.AddRange(LoadAllFolders_(parentDirectory));
748+
749+
if (ItemsList.Count > 0)
750+
{
751+
listView.Items.Clear();
752+
foreach (string item in ItemsList)
753+
{
754+
listView.Items.Add(item);
755+
}
756+
}
757+
758+
}
759+
760+
/// <summary>
761+
/// Load all files and folders inside of parent Directory aysnc.
762+
/// </summary>
763+
/// <param name="listView">The list view to load files on</param>
764+
/// <param name="parentDirectory">Full path of the parent directory.</param>
765+
public static async void LoadFilesAndFoldersAysnc(this ListView listView, string parentDirectory)
766+
{
767+
768+
List<string> ItemsList = await LoadAllFiles(parentDirectory);
769+
ItemsList.AddRange(await LoadAllFolders(parentDirectory));
770+
771+
if (ItemsList.Count > 0)
772+
{
773+
listView.Items.Clear();
774+
foreach (string item in ItemsList)
775+
{
776+
listView.Items.Add(item);
777+
}
778+
}
779+
780+
}
781+
782+
/// <summary>
783+
/// Load all files and folders inside of parent Directory with thier icons.
784+
/// </summary>
785+
/// <param name="listView">The list view to load files on</param>
786+
/// <param name="parentDirectory">Full path of the parent directory.</param>
787+
public static void LoadFilesAndFoldersWithIcons(this ListView listView, string parentDirectory)
788+
{
789+
790+
List<string> ItemsList = LoadAllFiles_(parentDirectory);
791+
ItemsList.AddRange(LoadAllFolders_(parentDirectory));
792+
ImageList imageList = new ImageList();
793+
imageList.FillImageList(LoadAllFileIcons(parentDirectory));
794+
795+
if (ItemsList.Count > 0)
796+
{
797+
listView.Items.Clear();
798+
listView.LargeImageList = imageList;
799+
listView.SmallImageList = imageList;
800+
foreach (string item in ItemsList)
801+
{
802+
listView.Items.Add(item);
803+
listView.Items[listView.Items.Count - 1].ImageIndex = (listView.Items.Count - 1);
804+
}
805+
}
806+
807+
}
808+
809+
/// <summary>
810+
/// Load all files and folders inside of parent Directory with thier icons aysnc.
811+
/// </summary>
812+
/// <param name="listView">The list view to load files on</param>
813+
/// <param name="parentDirectory">Full path of the parent directory.</param>
814+
public static async void LoadFilesAndFoldersWithIconsAysnc(this ListView listView, string parentDirectory)
815+
{
816+
817+
List<string> ItemsList = await LoadAllFiles(parentDirectory);
818+
ItemsList.AddRange(await LoadAllFolders(parentDirectory));
731819
ImageList imageList = new ImageList();
732820
imageList.FillImageList(await LoadAllFileIconsAysnc(parentDirectory));
733821

@@ -745,15 +833,166 @@ public static async void LoadFilesWithIconsAysnc(this ListView listView, string
745833

746834
}
747835

748-
/*TODO- TreeView Functions
749-
- LoadFoldersList(folderName);
750-
- LoadFilesList(folderName);
751-
-
752-
*/
836+
/*TODO- ListView Functions
837+
- LoadList(list<T>);
838+
- LoadList(list<T>,ImageList images);
839+
*/
840+
841+
#endregion
842+
843+
#region TreeView Methods
753844

754-
/* TODO- RichTextBox Functions
755-
- LoadFile(fileName);
756-
*/
845+
/// <summary>
846+
/// Loads all the folders inside parent directory.
847+
/// </summary>
848+
/// <param name="treeView">The tree view to load folders on.</param>
849+
/// <param name="parentDirectory">Full path of the parent directory.</param>
850+
public static void LoadFoldersList(this TreeView treeView, string parentDirectory)
851+
{
852+
853+
List<string> ItemsList = LoadAllFolders_(parentDirectory);
854+
855+
if (ItemsList.Count > 0)
856+
{
857+
treeView.Nodes.Clear();
858+
foreach (string item in ItemsList)
859+
{
860+
treeView.Nodes.Add(item);
861+
}
862+
}
863+
864+
}
865+
866+
/// <summary>
867+
/// Loads all the folders inside parent directory aysnc.
868+
/// </summary>
869+
/// <param name="treeView">The tree view to load folders on.</param>
870+
/// <param name="parentDirectory">Full path of the parent directory.</param>
871+
public static async void LoadFoldersListAysnc(this TreeView treeView, string parentDirectory)
872+
{
873+
874+
List<string> ItemsList = await LoadAllFolders(parentDirectory);
875+
876+
if (ItemsList.Count > 0)
877+
{
878+
treeView.Nodes.Clear();
879+
foreach (string item in ItemsList)
880+
{
881+
treeView.Nodes.Add(item);
882+
}
883+
}
884+
885+
}
886+
887+
/// <summary>
888+
/// Loads all the files inside parent directory.
889+
/// </summary>
890+
/// <param name="treeView">The tree view to load files on.</param>
891+
/// <param name="parentDirectory">Full path of the parent directory.</param>
892+
public static void LoadFilesList(this TreeView treeView, string parentDirectory)
893+
{
894+
895+
List<string> ItemsList = LoadAllFiles_(parentDirectory);
896+
897+
if (ItemsList.Count > 0)
898+
{
899+
treeView.Nodes.Clear();
900+
foreach (string item in ItemsList)
901+
{
902+
treeView.Nodes.Add(item);
903+
}
904+
}
905+
906+
}
907+
908+
/// <summary>
909+
/// Loads all the files inside parent directory aysnc.
910+
/// </summary>
911+
/// <param name="treeView">The tree view to load files on.</param>
912+
/// <param name="parentDirectory">Full path of the parent directory.</param>
913+
public static async void LoadFilesListAysnc(this TreeView treeView, string parentDirectory)
914+
{
915+
916+
List<string> ItemsList = await LoadAllFiles(parentDirectory);
917+
918+
if (ItemsList.Count > 0)
919+
{
920+
treeView.Nodes.Clear();
921+
foreach (string item in ItemsList)
922+
{
923+
treeView.Nodes.Add(item);
924+
}
925+
}
926+
927+
}
928+
929+
/// <summary>
930+
/// Loads all the files and folders inside parent directory.
931+
/// </summary>
932+
/// <param name="treeView">The tree view to load files and folders on.</param>
933+
/// <param name="parentDirectory">Full path of the parent directory.</param>
934+
public static void LoadFilesAndFolders(this TreeView treeView, string parentDirectory)
935+
{
936+
937+
List<string> ItemsList = LoadAllFiles_(parentDirectory);
938+
ItemsList.AddRange(LoadAllFolders_(parentDirectory));
939+
940+
if (ItemsList.Count > 0)
941+
{
942+
treeView.Nodes.Clear();
943+
foreach (string item in ItemsList)
944+
{
945+
treeView.Nodes.Add(item);
946+
}
947+
}
948+
949+
}
950+
951+
/// <summary>
952+
/// Loads all the files and folders inside parent directory aysnc.
953+
/// </summary>
954+
/// <param name="treeView">The tree view to load files and folders on.</param>
955+
/// <param name="parentDirectory">Full path of the parent directory.</param>
956+
public static async void LoadFilesAndFoldersAysnc(this TreeView treeView, string parentDirectory)
957+
{
958+
959+
List<string> ItemsList = await LoadAllFiles(parentDirectory);
960+
ItemsList.AddRange(await LoadAllFolders(parentDirectory));
961+
962+
if (ItemsList.Count > 0)
963+
{
964+
treeView.Nodes.Clear();
965+
foreach (string item in ItemsList)
966+
{
967+
treeView.Nodes.Add(item);
968+
}
969+
}
970+
971+
}
972+
973+
#endregion
974+
975+
#region RichTextBox Methods
976+
977+
/// <summary>
978+
/// Load Image to picture box from file that user choises.
979+
/// </summary>
980+
/// <param name="richTextBox">The rich text box to load file on.</param>
981+
/// <param name="filter">The filter to be used to get type of document. example ("Doc Files|*.doc|Txt Files|*.txt")</param>
982+
/// <param name="fileDialogTitle">The title for the dialog appears for the user.</param>
983+
public static void LoadFile(this RichTextBox richTextBox,string filter,string fileDialogTitle)
984+
{
985+
OpenFileDialog openFileDialog = new OpenFileDialog();
986+
openFileDialog.Filter = filter;
987+
openFileDialog.Title = fileDialogTitle;
988+
openFileDialog.FileName = "";
989+
if (openFileDialog.ShowDialog() == DialogResult.OK)
990+
{
991+
richTextBox.Text = File.ReadAllText(openFileDialog.FileName);
992+
}
993+
}
994+
995+
#endregion
757996

758997
}
759998

ProductivityFunctionsLibrary/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.0.0")]
36-
[assembly: AssemblyFileVersion("2.0.0.0")]
35+
[assembly: AssemblyVersion("2.1.0.0")]
36+
[assembly: AssemblyFileVersion("2.1.0.0")]

0 commit comments

Comments
 (0)