├── .gitattributes
├── .github
└── ISSUE_TEMPLATE
│ └── feature_request.md
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE.md
├── ProductivityFunctionsLibrary
├── CollectionsAndObjectsMethods.cs
├── ControlsMethods.cs
├── ProductivityFunctionsLibrary.csproj
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── ProductivityFunctionsNuget.sln
├── ProductivityLogo.png
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at abubakrmahdi20@gmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Want to join , then you are good to go!!!
2 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2007 James Newton-King
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/ProductivityFunctionsLibrary/CollectionsAndObjectsMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.IO;
5 |
6 | namespace ProductivityFunctionsLibrary
7 | {
8 |
9 | ///
10 | /// This class is for methods that attached to collections and objects.
11 | ///
12 | public static class CollectionsAndObjectsMethods
13 | {
14 |
15 | ///
16 | /// Gets image form byte array.
17 | ///
18 | /// The byte array.
19 | public static Image GetImageFromByteArray(byte[] byteArray)
20 | {
21 |
22 | MemoryStream stream = new MemoryStream(byteArray);
23 | Bitmap bmp = new Bitmap(stream);
24 | var img = Image.FromStream(stream);
25 |
26 | stream.Close();
27 | return img;
28 |
29 | }
30 |
31 | ///
32 | /// Exports the exception data to csv file , its get the source and the message and stackTrace of the exciption.
33 | ///
34 | /// The exception to export it's data.
35 | public static void ExportExceptionData(this Exception exception)
36 | {
37 |
38 | List Lines = new List();
39 | Lines.Add($"{ exception.Source },{ exception.Message },{ exception.StackTrace }");
40 | File.WriteAllLines("ExceptionsLog.csv", Lines);
41 |
42 | }
43 |
44 | /*String Object Functions
45 | - GetFileIcon(fileName); returns Image.
46 | - GetFileIcon(fileName); returns Icon.
47 | - GetFileIcon(fileName); returns byte array.
48 | */
49 |
50 | /////
51 | ///// Gets the icon of the file.
52 | ///// Important Note : make sure that your string is a file path.
53 | /////
54 | ///// Full path of the file.
55 | /////
56 | //public static Bitmap GetFileIcon(this string fileName)
57 | //{
58 |
59 | // if (fileName.Contains(@"\") != true) return null;
60 | // Bitmap bitmap = Icon.ExtractAssociatedIcon(fileName).ToBitmap();
61 | // return bitmap;
62 |
63 | //}
64 |
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/ProductivityFunctionsLibrary/ControlsMethods.cs:
--------------------------------------------------------------------------------
1 | using iTextSharp.text;
2 | using iTextSharp.text.pdf;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Drawing;
6 | using System.Drawing.Imaging;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 | using System.Windows.Forms;
12 | using Microsoft.Office.Interop;
13 |
14 | namespace ProductivityFunctionsLibrary
15 | {
16 |
17 | ///
18 | /// This class is contains all the functions that been attched to Controls.
19 | ///
20 | public static class ControlsMethods
21 | {
22 |
23 | #region Private Helper Methods
24 |
25 | private static void ReleaseObject(object obj)
26 | {
27 | try
28 | {
29 | System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
30 | obj = null;
31 | }
32 | catch (Exception ex)
33 | {
34 | obj = null;
35 | MessageBox.Show("Exception Occured while releasing object " + ex.Message, "Error");
36 | }
37 | finally
38 | {
39 | GC.Collect();
40 | }
41 | }
42 |
43 | private static List LoadAllFolders_(string parentDirectory)
44 | {
45 |
46 | List output = new List();
47 |
48 | if (Directory.Exists(parentDirectory))
49 | {
50 | var foldersList = Directory.GetDirectories(parentDirectory);
51 | if (foldersList.Length != 0)
52 | {
53 | foreach (string directory in foldersList)
54 | {
55 | output.Add(directory);
56 | }
57 | }
58 | }
59 |
60 | return output;
61 |
62 | }
63 |
64 | private static async Task> LoadAllFolders(string parentDirectory)
65 | {
66 |
67 | List output = await Task.Run(() => LoadAllFolders_(parentDirectory));
68 | return output;
69 |
70 | }
71 |
72 | private static List LoadAllFiles_(string parentDirectory)
73 | {
74 |
75 | List output = new List();
76 |
77 | var filesList = Directory.GetFiles(parentDirectory);
78 |
79 | if (filesList.Length != 0)
80 | {
81 | foreach (string file in filesList)
82 | {
83 | output.Add(file);
84 | }
85 | }
86 |
87 | return output;
88 |
89 | }
90 |
91 | private static async Task> LoadAllFiles(string parentDirectory)
92 | {
93 |
94 | List output = await Task.Run(() => LoadAllFiles_(parentDirectory));
95 | return output;
96 |
97 | }
98 |
99 | private static void FillIconsList(this List files,List iconsList)
100 | {
101 | Icon tempIcon;
102 |
103 | foreach (string file in files)
104 | {
105 | tempIcon = Icon.ExtractAssociatedIcon(file);
106 | iconsList.Add(tempIcon);
107 | }
108 |
109 | }
110 |
111 | private static async void FillIconsListAysnc(this List files, List iconsList)
112 | {
113 | Icon tempIcon;
114 |
115 | await Task.Run(() => {
116 | foreach (string file in files)
117 | {
118 | tempIcon = Icon.ExtractAssociatedIcon(file);
119 | iconsList.Add(tempIcon);
120 | }
121 | });
122 |
123 | }
124 |
125 | private static List LoadAllFileIcons(string parentDirectory)
126 | {
127 |
128 | List output = new List();
129 | List allFiles = LoadAllFiles_(parentDirectory);
130 | if (allFiles.Count > 0)
131 | {
132 | allFiles.FillIconsList(output);
133 | }
134 |
135 | return output;
136 |
137 | }
138 |
139 | private static async Task> LoadAllFileIconsAysnc(string parentDirectory)
140 | {
141 |
142 | List output = new List();
143 | List allFiles = await LoadAllFiles(parentDirectory);
144 | if (allFiles.Count > 0)
145 | {
146 | await Task.Run(() => allFiles.FillIconsList(output));
147 | }
148 |
149 | return output;
150 |
151 | }
152 |
153 | //private static List LoadAllFoldersIcons(string parentDirectory)
154 | //{
155 |
156 | // List output = new List();
157 | // List allFolders = Directory.GetFiles(parentDirectory).ToList();
158 | // Icon tempIcon;
159 | // if (allFolders.Count > 0)
160 | // {
161 | // foreach (string file in allFolders)
162 | // {
163 | // tempIcon = Icon.ExtractAssociatedIcon(file);
164 | // output.Add(tempIcon);
165 | // }
166 | // }
167 |
168 | // return output;
169 |
170 | //}
171 |
172 | #endregion
173 |
174 | #region PictureBox Methods
175 |
176 | ///
177 | /// Load Image to picture box from file that user choises.
178 | ///
179 | /// The picture box to load image on.
180 | /// The filter to be used to get type of images. example ("PNG Files|*.png|BMP Files|*.bmp")
181 | /// The title for the dialog appears for the user.
182 | public static void LoadImageFromFile(this PictureBox pictureBox, string filter, string fileDialogTitle)
183 | {
184 | OpenFileDialog openFileDialog = new OpenFileDialog();
185 | openFileDialog.Filter = filter;
186 | openFileDialog.Title = fileDialogTitle;
187 | openFileDialog.FileName = "";
188 | if (openFileDialog.ShowDialog() == DialogResult.OK)
189 | {
190 | pictureBox.Image = System.Drawing.Image.FromFile(openFileDialog.FileName);
191 | }
192 |
193 | }
194 |
195 | ///
196 | /// Load Image to picture box from a byte array.
197 | ///
198 | /// The picture box to load image on.
199 | /// The byte array to get image form.
200 | public static void LoadImageFromByteArray(this PictureBox pictureBox, byte[] byteArray)
201 | {
202 |
203 | MemoryStream stream = new MemoryStream(byteArray);
204 | var img = System.Drawing.Image.FromStream(stream);
205 | stream.Close();
206 | pictureBox.Image = img;
207 |
208 | }
209 |
210 | ///
211 | /// Gets a byte array copy of the image inside picture box.
212 | ///
213 | /// The picture box to get byte image form.
214 | ///
215 | public static byte[] GetByteImage(this PictureBox pictureBox)
216 | {
217 |
218 | byte[] ImgByteArray;
219 | MemoryStream stream = new MemoryStream();
220 | pictureBox.Image.Save(stream, ImageFormat.Jpeg); //TODO- Fix gdi+ error
221 | ImgByteArray = stream.ToArray();
222 | stream.Close();
223 |
224 | return ImgByteArray;
225 | }
226 |
227 | ///
228 | /// Load Image to picture box from file that user choises.
229 | ///
230 | /// The picture box to save its image
231 | /// The filter to be used to get type of images. example ("PNG Files|*.png|BMP Files|*.bmp")
232 | /// The title for the save dialog appears for the user.
233 | public static void SaveImageInFile(this PictureBox pictureBox, string filter, string saveDialogTitle)
234 | {
235 |
236 | SaveFileDialog saveFileDialog = new SaveFileDialog();
237 |
238 | saveFileDialog.Title = saveDialogTitle;
239 | saveFileDialog.Filter = filter;
240 | saveFileDialog.FileName = "";
241 | if (saveFileDialog.ShowDialog() == DialogResult.OK)
242 | {
243 | var s = pictureBox.Size;
244 | var memoryImage = new Bitmap(s.Width, s.Height);
245 | var memoryGraphics = Graphics.FromImage(memoryImage);
246 | var screenPos = pictureBox.PointToScreen(new Point(0, 0));
247 | memoryGraphics.CopyFromScreen(screenPos.X, screenPos.Y, 0, 0, s);
248 | memoryImage.Save(saveFileDialog.FileName);
249 | }
250 |
251 | }
252 |
253 | /*TODO- PictureBox Functions
254 | - GenerateQRCode(text);
255 | - GenerateBarcode(text);
256 | */
257 |
258 | #endregion
259 |
260 | #region DataGridView Methods
261 |
262 | ///
263 | /// Updates the data source of data grid view with disabling auto generate columns.
264 | ///
265 | /// The data grid view to update data source.
266 | /// The data source.
267 | public static void UpdateDataSource(this DataGridView gridView, object dataSource)
268 | {
269 | gridView.AutoGenerateColumns = false;
270 | gridView.DataSource = null;
271 | gridView.DataSource = dataSource;
272 | }
273 |
274 | ///
275 | /// Export all the DataGridView data to a csv file.
276 | ///
277 | /// The grid view you want to export its contents.
278 | /// The title of the save dialog appears to user.
279 | public static void ExportToCSVFile(this DataGridView gridView, string saveDialogTitle)
280 | {
281 | if (gridView.Rows.Count == 0) return;
282 |
283 | SaveFileDialog saveFileDialog = new SaveFileDialog();
284 |
285 | saveFileDialog.Title = saveDialogTitle;
286 | saveFileDialog.Filter = "CSV Files|*.csv";
287 | saveFileDialog.FileName = "";
288 | bool fileError = false;
289 | if (saveFileDialog.ShowDialog() == DialogResult.OK)
290 | {
291 |
292 | if (File.Exists(saveFileDialog.FileName))
293 | {
294 | try
295 | {
296 | File.Delete(saveFileDialog.FileName);
297 | }
298 | catch (IOException ex)
299 | {
300 | fileError = true;
301 | MessageBox.Show("can't write the data to the disk." + ex.Message);
302 | }
303 | }
304 | if (!fileError)
305 | {
306 | try
307 | {
308 | int columnCount = gridView.Columns.Count;
309 | string columnNames = "";
310 | string[] outputCsv = new string[gridView.Rows.Count + 1];
311 | for (int i = 0; i < columnCount; i++)
312 | {
313 | columnNames += gridView.Columns[i].HeaderText.ToString() + ",";
314 | }
315 | outputCsv[0] += columnNames;
316 |
317 | for (int i = 1; (i - 1) < gridView.Rows.Count; i++)
318 | {
319 | for (int j = 0; j < columnCount; j++)
320 | {
321 | outputCsv[i] += gridView.Rows[i - 1].Cells[j].Value.ToString() + ",";
322 | }
323 | }
324 |
325 | File.WriteAllLines(saveFileDialog.FileName, outputCsv, Encoding.UTF8);
326 | MessageBox.Show("Data Exported Successfully !!!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
327 | }
328 | catch (Exception ex)
329 | {
330 | MessageBox.Show("Error :" + ex.Message);
331 | }
332 | }
333 | }//End of Save file dialog
334 | else
335 | {
336 | MessageBox.Show("No Record To Export !!!", "Info");
337 | }
338 |
339 | }
340 |
341 | public static void ExportToPDFFile(this DataGridView gridView, string saveDialogTitle)
342 | {
343 |
344 | if (gridView.Rows.Count == 0) return;
345 |
346 | SaveFileDialog saveFileDialog = new SaveFileDialog();
347 |
348 | saveFileDialog.Title = saveDialogTitle;
349 | saveFileDialog.Filter = "CSV Files|*.csv";
350 | saveFileDialog.FileName = "";
351 | bool fileError = false;
352 |
353 | if (saveFileDialog.ShowDialog() == DialogResult.OK)
354 | {
355 | if (File.Exists(saveFileDialog.FileName))
356 | {
357 | try
358 | {
359 | File.Delete(saveFileDialog.FileName);
360 | }
361 | catch (IOException ex)
362 | {
363 | fileError = true;
364 | MessageBox.Show("It wasn't possible to write the data to the disk." + ex.Message);
365 | }
366 | }
367 | if (!fileError)
368 | {
369 | try
370 | {
371 | PdfPTable pdfTable = new PdfPTable(gridView.Columns.Count);
372 | pdfTable.DefaultCell.Padding = 3;
373 | pdfTable.WidthPercentage = 100;
374 | pdfTable.HorizontalAlignment = Element.ALIGN_LEFT;
375 |
376 | foreach (DataGridViewColumn column in gridView.Columns)
377 | {
378 | PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText));
379 | pdfTable.AddCell(cell);
380 | }
381 |
382 | foreach (DataGridViewRow row in gridView.Rows)
383 | {
384 | foreach (DataGridViewCell cell in row.Cells)
385 | {
386 | pdfTable.AddCell(cell.Value.ToString());
387 | }
388 | }
389 |
390 | using (FileStream stream = new FileStream(saveFileDialog.FileName, FileMode.Create))
391 | {
392 | Document pdfDoc = new Document(PageSize.A4, 10f, 20f, 20f, 10f);
393 | PdfWriter.GetInstance(pdfDoc, stream);
394 | pdfDoc.Open();
395 | pdfDoc.Add(pdfTable);
396 | pdfDoc.Close();
397 | stream.Close();
398 | }
399 |
400 | MessageBox.Show("Data Exported Successfully !!!", "Info");
401 | }
402 | catch (Exception ex)
403 | {
404 | MessageBox.Show("Error :" + ex.Message);
405 | }
406 | }
407 | }
408 | }
409 |
410 | public static void ExportToExcelFile(this DataGridView gridView, string saveDialogTitle)
411 | {
412 |
413 | if (gridView.Rows.Count > 0)
414 | {
415 | SaveFileDialog saveFileDialog = new SaveFileDialog();
416 | saveFileDialog.Filter = "Excel (.xlsx)| *.xlsx";
417 | saveFileDialog.FileName = "Output.xlsx";
418 | bool fileError = false;
419 | if (saveFileDialog.ShowDialog() == DialogResult.OK)
420 | {
421 | if (File.Exists(saveFileDialog.FileName))
422 | {
423 | try
424 | {
425 | File.Delete(saveFileDialog.FileName);
426 | }
427 | catch (IOException ex)
428 | {
429 | fileError = true;
430 | MessageBox.Show("It wasn't possible to write the data to the disk." + ex.Message);
431 | }
432 | }
433 | if (!fileError)
434 | {
435 | try
436 | {
437 | Microsoft.Office.Interop.Excel.Application XcelApp = new Microsoft.Office.Interop.Excel.Application();
438 | Microsoft.Office.Interop.Excel._Workbook workbook = XcelApp.Workbooks.Add(Type.Missing);
439 | Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
440 |
441 | worksheet = workbook.Sheets["Sheet1"];
442 | worksheet = workbook.ActiveSheet;
443 | worksheet.Name = "Output";
444 | worksheet.Application.ActiveWindow.SplitRow = 1;
445 | worksheet.Application.ActiveWindow.FreezePanes = true;
446 |
447 | for (int i = 1; i < gridView.Columns.Count + 1; i++)
448 | {
449 | worksheet.Cells[1, i] = gridView.Columns[i - 1].HeaderText;
450 | worksheet.Cells[1, i].Font.NAME = "Calibri";
451 | worksheet.Cells[1, i].Font.Bold = true;
452 | worksheet.Cells[1, i].Interior.Color = Color.Wheat;
453 | worksheet.Cells[1, i].Font.Size = 12;
454 | }
455 |
456 | for (int i = 0; i < gridView.Rows.Count; i++)
457 | {
458 | for (int j = 0; j < gridView.Columns.Count; j++)
459 | {
460 | worksheet.Cells[i + 2, j + 1] = gridView.Rows[i].Cells[j].Value.ToString();
461 | }
462 | }
463 |
464 | worksheet.Columns.AutoFit();
465 | workbook.SaveAs(saveFileDialog.FileName);
466 | XcelApp.Quit();
467 |
468 | ReleaseObject(worksheet);
469 | ReleaseObject(workbook);
470 | ReleaseObject(XcelApp);
471 |
472 | MessageBox.Show("Data Exported Successfully !!!", "Info");
473 | }
474 | catch (Exception ex)
475 | {
476 | MessageBox.Show("Error :" + ex.Message);
477 | }
478 | }
479 | }
480 | }
481 | else
482 | {
483 | MessageBox.Show("No Record To Export !!!", "Info");
484 | }
485 | }
486 |
487 | #endregion
488 |
489 | #region DataGridViewComboBoxCell Methods
490 |
491 | ///
492 | /// Updates the combo box data source with value and display members.
493 | /// Important Note : Use this method in RowsAdded Event of the DataGridView.
494 | ///
495 | /// The combo box.
496 | /// The Data source.
497 | /// The display member.
498 | /// The value memeber.
499 | public static void UpdateDataSource(this DataGridViewComboBoxCell comboBox, object dataSource, string displayMember, string valueMember)
500 | {
501 | comboBox.DataSource = null;
502 | comboBox.DataSource = dataSource;
503 | comboBox.DisplayMember = displayMember;
504 | comboBox.ValueMember = valueMember;
505 | }
506 |
507 | #endregion
508 |
509 | #region ComboBox Methods
510 |
511 | ///
512 | /// Updates the combo box data source with value and display members.
513 | ///
514 | /// The combo box.
515 | /// The Data source.
516 | /// The display member.
517 | /// The value memeber.
518 | public static void UpdateDataSource(this ComboBox comboBox, object dataSource, string displayMember, string valueMember)
519 | {
520 | comboBox.DataSource = null;
521 | comboBox.DataSource = dataSource;
522 | comboBox.DisplayMember = displayMember;
523 | comboBox.ValueMember = valueMember;
524 |
525 | comboBox.SelectedIndex = -1;
526 | }
527 |
528 | #endregion
529 |
530 | #region Form Methods
531 |
532 | public static void ClearForm(this Form form)
533 | {
534 |
535 | foreach (Control parentControl in form.Controls)
536 | {
537 |
538 | if (parentControl.HasChildren)
539 | {
540 | foreach (Control childControl in parentControl.Controls)
541 | {
542 | if (childControl.GetType().ToString().Contains("TextBox"))
543 | {
544 | ((TextBox)childControl).Text = "";
545 | }
546 | else if (childControl.GetType().ToString().Contains("DateTimePicker"))
547 | {
548 | ((DateTimePicker)childControl).Value = DateTime.Today.Date;
549 | }
550 | else if (childControl.GetType().ToString().Contains("ComboBox"))
551 | {
552 | ((ComboBox)childControl).SelectedIndex = -1;
553 | ((ComboBox)childControl).Text = "";
554 | }
555 | }
556 | }
557 | else
558 | {
559 | if (parentControl.GetType().ToString().Contains("TextBox"))
560 | {
561 | ((TextBox)parentControl).Text = "";
562 | }
563 | else if (parentControl.GetType().ToString().Contains("DateTimePicker"))
564 | {
565 | ((DateTimePicker)parentControl).Value = DateTime.Today.Date;
566 | }
567 | else if (parentControl.GetType().ToString().Contains("ComboBox"))
568 | {
569 | ((ComboBox)parentControl).SelectedIndex = -1;
570 | ((ComboBox)parentControl).Text = "";
571 | }
572 | }
573 |
574 | }
575 |
576 | }
577 |
578 | #endregion
579 |
580 | #region ImageList Methods
581 |
582 | ///
583 | /// Fills the ImageList.Images Property.
584 | ///
585 | /// The image list control to fill.
586 | /// The list of icons to be inserted in the list.
587 | public static void FillImageList(this ImageList imageList, List icons)
588 | {
589 |
590 | foreach (Icon icon in icons)
591 | {
592 | imageList.Images.Add(icon);
593 | }
594 |
595 | }
596 |
597 | #endregion
598 |
599 | #region ListView Methods
600 |
601 | ///
602 | /// Loads all the folders inside parent directory.
603 | ///
604 | /// The list view to load folders on.
605 | /// Full path of the parent directory.
606 | public static void LoadFoldersList(this ListView listView, string parentDirectory)
607 | {
608 |
609 | List ItemsList = LoadAllFolders_(parentDirectory);
610 |
611 | if (ItemsList.Count > 0)
612 | {
613 | listView.Items.Clear();
614 | foreach (string item in ItemsList)
615 | {
616 | listView.Items.Add(item);
617 | }
618 | }
619 |
620 | }
621 |
622 | ///
623 | /// Loads all the folders inside parent directory aysnc.
624 | ///
625 | /// The list view to load folders on.
626 | /// Full path of the parent directory.
627 | public static async void LoadFoldersListAysnc(this ListView listView, string parentDirectory)
628 | {
629 |
630 | List listViewItems = await LoadAllFolders(parentDirectory);
631 |
632 | if (listViewItems.Count > 0)
633 | {
634 | listView.Items.Clear();
635 | foreach (string item in listViewItems)
636 | {
637 | listView.Items.Add(item);
638 | }
639 | }
640 |
641 | }
642 |
643 | ///
644 | /// Load all files inside of parent Directory.
645 | ///
646 | /// The list view to load files on
647 | /// Full path of the parent directory.
648 | public static void LoadFilesList(this ListView listView, string parentDirectory)
649 | {
650 |
651 | List ItemsList = LoadAllFiles_(parentDirectory);
652 |
653 | if (ItemsList.Count > 0)
654 | {
655 | listView.Items.Clear();
656 | foreach (string item in ItemsList)
657 | {
658 | listView.Items.Add(item);
659 | }
660 | }
661 |
662 | }
663 |
664 | ///
665 | /// Load all files inside of parent Directory aysnc.
666 | ///
667 | /// The list view to load files on
668 | /// Full path of the parent directory.
669 | public static async void LoadFilesListAysnc(this ListView listView, string parentDirectory)
670 | {
671 |
672 | List ItemsList = await LoadAllFiles(parentDirectory);
673 |
674 | if (ItemsList.Count > 0)
675 | {
676 | listView.Items.Clear();
677 | foreach (string item in ItemsList)
678 | {
679 | listView.Items.Add(item);
680 | }
681 | }
682 |
683 | }
684 |
685 | ///
686 | /// Load all files inside of parent Directory.
687 | ///
688 | /// The list view to load files on
689 | /// Full path of the parent directory.
690 | public static void LoadFilesWithIcons(this ListView listView, string parentDirectory)
691 | {
692 |
693 | List ItemsList = LoadAllFiles_(parentDirectory);
694 | ImageList imageList = new ImageList();
695 | imageList.FillImageList(LoadAllFileIcons(parentDirectory));
696 |
697 | if (ItemsList.Count > 0)
698 | {
699 | listView.Items.Clear();
700 | //int lastIndex = listView.Items.Count - 1;
701 | listView.LargeImageList = imageList;
702 | listView.SmallImageList = imageList;
703 | foreach (string item in ItemsList)
704 | {
705 | listView.Items.Add(item);
706 | listView.Items[listView.Items.Count - 1].ImageIndex = (listView.Items.Count - 1);
707 | }
708 | }
709 |
710 | }
711 |
712 | ///
713 | /// Load all files inside of parent directoryaysnc.
714 | ///
715 | /// The list view to load files on
716 | /// Full path of the parent directory.
717 | public static async void LoadFilesWithIconsAysnc(this ListView listView, string parentDirectory)
718 | {
719 |
720 | List 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 | ///
739 | /// Load all files and folders inside of parent Directory.
740 | ///
741 | /// The list view to load files on
742 | /// Full path of the parent directory.
743 | public static void LoadFilesAndFolders(this ListView listView, string parentDirectory)
744 | {
745 |
746 | List 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 | ///
761 | /// Load all files and folders inside of parent Directory aysnc.
762 | ///
763 | /// The list view to load files on
764 | /// Full path of the parent directory.
765 | public static async void LoadFilesAndFoldersAysnc(this ListView listView, string parentDirectory)
766 | {
767 |
768 | List 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 | ///
783 | /// Load all files and folders inside of parent Directory with thier icons.
784 | ///
785 | /// The list view to load files on
786 | /// Full path of the parent directory.
787 | public static void LoadFilesAndFoldersWithIcons(this ListView listView, string parentDirectory)
788 | {
789 |
790 | List 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 | ///
810 | /// Load all files and folders inside of parent Directory with thier icons aysnc.
811 | ///
812 | /// The list view to load files on
813 | /// Full path of the parent directory.
814 | public static async void LoadFilesAndFoldersWithIconsAysnc(this ListView listView, string parentDirectory)
815 | {
816 |
817 | List ItemsList = await LoadAllFiles(parentDirectory);
818 | ItemsList.AddRange(await LoadAllFolders(parentDirectory));
819 | ImageList imageList = new ImageList();
820 | imageList.FillImageList(await LoadAllFileIconsAysnc(parentDirectory));
821 |
822 | if (ItemsList.Count > 0)
823 | {
824 | listView.Items.Clear();
825 | listView.LargeImageList = imageList;
826 | listView.SmallImageList = imageList;
827 | foreach (string item in ItemsList)
828 | {
829 | listView.Items.Add(item);
830 | listView.Items[listView.Items.Count - 1].ImageIndex = (listView.Items.Count - 1);
831 | }
832 | }
833 |
834 | }
835 |
836 | /*TODO- ListView Functions
837 | - LoadList(list);
838 | - LoadList(list,ImageList images);
839 | */
840 |
841 | #endregion
842 |
843 | #region TreeView Methods
844 |
845 | ///
846 | /// Loads all the folders inside parent directory.
847 | ///
848 | /// The tree view to load folders on.
849 | /// Full path of the parent directory.
850 | public static void LoadFoldersList(this TreeView treeView, string parentDirectory)
851 | {
852 |
853 | List 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 | ///
867 | /// Loads all the folders inside parent directory aysnc.
868 | ///
869 | /// The tree view to load folders on.
870 | /// Full path of the parent directory.
871 | public static async void LoadFoldersListAysnc(this TreeView treeView, string parentDirectory)
872 | {
873 |
874 | List 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 | ///
888 | /// Loads all the files inside parent directory.
889 | ///
890 | /// The tree view to load files on.
891 | /// Full path of the parent directory.
892 | public static void LoadFilesList(this TreeView treeView, string parentDirectory)
893 | {
894 |
895 | List 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 | ///
909 | /// Loads all the files inside parent directory aysnc.
910 | ///
911 | /// The tree view to load files on.
912 | /// Full path of the parent directory.
913 | public static async void LoadFilesListAysnc(this TreeView treeView, string parentDirectory)
914 | {
915 |
916 | List 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 | ///
930 | /// Loads all the files and folders inside parent directory.
931 | ///
932 | /// The tree view to load files and folders on.
933 | /// Full path of the parent directory.
934 | public static void LoadFilesAndFolders(this TreeView treeView, string parentDirectory)
935 | {
936 |
937 | List 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 | ///
952 | /// Loads all the files and folders inside parent directory aysnc.
953 | ///
954 | /// The tree view to load files and folders on.
955 | /// Full path of the parent directory.
956 | public static async void LoadFilesAndFoldersAysnc(this TreeView treeView, string parentDirectory)
957 | {
958 |
959 | List 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 | ///
978 | /// Load Text to rich text box from file that user choises.
979 | ///
980 | /// The rich text box to load file on.
981 | /// The filter to be used to get type of document. example ("Doc Files|*.doc|Txt Files|*.txt")
982 | /// The title for the dialog appears for the user.
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
996 |
997 | }
998 |
999 | }
1000 |
1001 |
1002 |
1003 |
--------------------------------------------------------------------------------
/ProductivityFunctionsLibrary/ProductivityFunctionsLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1C6DF7DE-AE35-4006-BAEB-E714885B3A4B}
8 | Library
9 | Properties
10 | ProductivityFunctionsLibrary
11 | ProductivityFunctionsLibrary
12 | v4.5
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | 7.2
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 | 7.2
34 |
35 |
36 |
37 | ..\packages\iTextSharp.5.5.13.1\lib\itextsharp.dll
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}
61 | 2
62 | 8
63 | 0
64 | primary
65 | False
66 | True
67 |
68 |
69 | {00020813-0000-0000-C000-000000000046}
70 | 1
71 | 9
72 | 0
73 | primary
74 | False
75 | True
76 |
77 |
78 | {0002E157-0000-0000-C000-000000000046}
79 | 5
80 | 3
81 | 0
82 | primary
83 | False
84 | True
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/ProductivityFunctionsLibrary/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ProductivityFunctionsLibrary")]
9 | [assembly: AssemblyDescription("This is a list of extension methods that make it easy to work with comon WinForms Controls and classes")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("BekoSan")]
12 | [assembly: AssemblyProduct("ProductivityFunctionsLibrary")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("BekoSan")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1c6df7de-ae35-4006-baeb-e714885b3a4b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("2.1.0.0")]
36 | [assembly: AssemblyFileVersion("2.1.0.0")]
37 |
--------------------------------------------------------------------------------
/ProductivityFunctionsLibrary/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ProductivityFunctionsNuget.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.572
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductivityFunctionsLibrary", "ProductivityFunctionsLibrary\ProductivityFunctionsLibrary.csproj", "{1C6DF7DE-AE35-4006-BAEB-E714885B3A4B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {1C6DF7DE-AE35-4006-BAEB-E714885B3A4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {1C6DF7DE-AE35-4006-BAEB-E714885B3A4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {1C6DF7DE-AE35-4006-BAEB-E714885B3A4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {1C6DF7DE-AE35-4006-BAEB-E714885B3A4B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {4EE7310B-1247-40CD-91F6-E8574EBCD6B1}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProductivityLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BekoSan/ProductivityFunctions/882334f3c391c6b80a931baf2ff921542390638c/ProductivityLogo.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ProductivityFunctions
2 | 
3 |
4 | This is a list of extension methods that make it easy to work with comon WinForms Controls and classes.
5 |
6 | # Release Notes
7 | v1.0.0
8 |
9 | ### PictureBox Methods :
10 |
11 | | Method | Description |
12 | |--------|:--------------:|
13 | |```LoadImageFormFile()```| Loads image form image file you select.|
14 | |```LoadImageFormFile()```| Loads image form image file you select.|
15 | |```LoadImageFormByteArray()```|This will load image form byte array you passed into this method.|
16 | |```GetByteImage()```|Will return a byte array copy of image inside the PictureBox.|
17 | |```SaveImageInFile()``` | Show SaveFileDialog to save image by it , you can specify the filter and title as parameters on this method.|
18 |
19 | ### DataGridView Methods:
20 |
21 | | Method | Description |
22 | |--------|:--------------:|
23 | |```UpdateDataSource()```|This method takes one parameter which is a datasource . Note :It disables the AutoGenerateColumns Property.|
24 | |```ExportToCVSFile()``` |Show SaveFileDialog and you can set its title by passing title as parameter.|
25 | |```ExportToExcelFile()```|Same as the last one it takes title as parameter.|
26 | |```ExportToPDFFile()```|Exports DataGridView to pdf file.|
27 |
28 | ### ComboBox Methods :
29 |
30 | | Method | Description |
31 | |--------|:--------------:|
32 | |```UpdateDataSource()```|It takes 3 parameters,*dataSource // the data source. *displayMember // the display member for the ComboBox. *valueMember // thevalue member for the ComboBox Its sets SelectedIndex Property to -1|
33 |
34 | ### Form Methods :
35 |
36 | | Method | Description |
37 | |--------|:--------------:|
38 | |```ClearForm()```|clears all textboxes and datetimepickers and comboboxes inside the form.|
39 |
40 | ### Byte Array Methods :
41 |
42 | | Method | Description |
43 | |--------|:--------------:|
44 | |```GetImageFromByteArray()```|it returns a Image Object from the byte array.|
45 |
46 | ### Exception Class Methods :
47 |
48 | | Method | Description |
49 | |--------|:--------------:|
50 | |```ExportExceptionData()```|Its export important exception data to csv file.|
51 |
52 | v2.0.0
53 | Added New Functions.
54 |
55 | ListView Functions:
56 |
57 | | Method | Description |
58 | |--------|:--------------:|
59 | |```LoadFoldersList()```| Takes one parameter which is parentDirectory . its loads all the folders in parentDirectory to list view.|
60 | |```LoadFoldersListAysnc()```| Takes one parameter which is parentDirectory . its loads all the folders in parentDirectory to list view aysnc.|
61 | |```LoadFilesList()```|Takes one parameter which is parentDirectory . its loads all the files in parentDirectory to list view.|
62 | |```LoadFoldersListAysnc()```|Takes one parameter which is parentDirectory . its loads all the folders in parentDirectory to list view aysnc.|
63 | |```LoadFilesListWithIcons()```|Takes one parameter which is parentDirectory . its loads all the files with there icons in parentDirectory to list view.|
64 | |```LoadFilesListWithIconsAysnc()```|Takes one parameter which is parentDirectory . its loads all the files with there icons in parentDirectory to list view aysnc.|
65 |
66 | DataGridViewComboBoxCell Methods :
67 |
68 | | Method | Description |
69 | |--------|:--------------:|
70 | |```UpdateDataSource()```|It takes 3 parameters *dataSource // the data source. *displayMember // the display member for the DataGridViewComboBoxCell. *valueMember // the value member for the DataGridViewComboBoxCell|
71 |
72 | ```####Important Note : Use this on in DataGridView.RowsAdded Event.```
73 |
74 | ImageList Methods :
75 |
76 | | Method | Description |
77 | |--------|:--------------:|
78 | |```FillImageList()```|Takes one parameter icons List List. it fills the ImageList.Images Property.|
79 |
80 | ## GetLatest Version From nuget.org
81 |
82 | [Productivity Functions Nuget](https://www.nuget.org/packages/BekoSan.ProductivityFunctions/)
83 |
--------------------------------------------------------------------------------