-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathFileUpload.razor.cs
1321 lines (1172 loc) · 50.7 KB
/
FileUpload.razor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#region using statements
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using System.IO;
using System.Threading.Tasks;
using System.Linq;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Threading;
using Microsoft.AspNetCore.Components.Forms;
using System.Runtime.Versioning;
using DataJuggler.UltimateHelper;
using DataJuggler.Blazor.Components.Interfaces;
using DataJuggler.Blazor.Components;
#endregion
namespace DataJuggler.Blazor.FileUpload
{
#region class FileUpload
/// <summary>
/// This class is the code behind for the BlazorFileUpload object.
/// </summary>
[SupportedOSPlatform("windows")]
public partial class FileUpload : IBlazorComponent
{
#region Private Variables
private string status;
private bool uploadComplete;
private string buttonText;
private string inputFileClassName;
private string messageClassName;
private bool showCustomButton;
private string customButtonClassName;
private string customButtonTextClassName;
private string resetButtonClassName;
private bool visible;
private bool saveToDisk;
private double progressHeight;
private double progressPercent;
private bool progressVisible;
private double progressWidth;
private bool multipleFiles;
private int maxFilesCount;
private string name;
private List<UploadedFileInfo> uploadedFiles;
private IBlazorComponentParent parent;
#endregion
#region Constructor()
/// <summary>
/// Create a new instance of a FileUpload
/// </summary>
public FileUpload()
{
// Perform initializations for this object
Init();
}
#endregion
#region Methods
#region CheckSize(string extension, MemoryStream ms, UploadedFileInfo uploadedFileInfo)
/// <summary>
/// This method returns the Size
/// </summary>
public UploadedFileInfo CheckSize(string extension, MemoryStream ms, UploadedFileInfo uploadedFileInfo)
{
try
{
// if the file is a .jpg or a .png
if (IsImageFile(extension))
{
// get the image from the memory stream
Image image = Bitmap.FromStream(ms);
// set the properties for the return value
uploadedFileInfo.Height = image.Height;
uploadedFileInfo.Width = image.Width;
// The RequiredHeight is an exact match
// if the RequiredHeight or RequiredWidth and a message is set the upload file
if (HasRequiredHeight || (HasRequiredWidth) && (HasCustomRequiredSizeMessage))
{
// check Required Size
// if a RequiredHeight is set
if ((HasRequiredHeight) && (image.Height != RequiredHeight))
{
// Abort for file being incorrect height
uploadedFileInfo.Aborted = true;
}
else if ((HasRequiredWidth) && (image.Width != RequiredWidth))
{
// Abort for file being incorrect width
uploadedFileInfo.Aborted = true;
}
}
// if not aborted
if (!uploadedFileInfo.Aborted)
{
// check Min Size
// if a MinHeight is set
if ((HasMinHeight) && (image.Height != MinHeight))
{
// Abort for file being incorrect height
uploadedFileInfo.Aborted = true;
}
else if ((HasMinWidth) && (image.Width != MinWidth))
{
// Abort for file being incorrect width
uploadedFileInfo.Aborted = true;
}
// if Aborted
if (uploadedFileInfo.Aborted)
{
// Set the Status
Status = CustomMinHeightMessage;
}
}
// if not aborted
if (!uploadedFileInfo.Aborted)
{
// check Max Size
// if a MaxHeight is set
if ((HasMaxHeight) && (image.Height != MaxHeight))
{
// Abort for file being incorrect height
uploadedFileInfo.Aborted = true;
}
else if ((HasMaxWidth) && (image.Width != MaxWidth))
{
// Abort for file being incorrect width
uploadedFileInfo.Aborted = true;
}
// if Aborted
if (uploadedFileInfo.Aborted)
{
// Set the Status
Status = CustomMaxHeightMessage;
}
}
}
}
catch (Exception error)
{
// for debugging only
DebugHelper.WriteDebugError("CheckSize", "FileUpload.razor", error);
}
// return value
return uploadedFileInfo;
}
#endregion
#region FileUploaded(UploadedFileInfo uploadedFileInfo)
/// <summary>
/// This event is fired after a file is uploaded, and is used to notify subscribers of the OnChange event.
/// </summary>
private async Task<UploadedFileInfo> FileUploaded(UploadedFileInfo uploadedFileInfo)
{
try
{
// Notify the client a file was uploaded
await OnChange.InvokeAsync(uploadedFileInfo);
}
catch (Exception error)
{
// set the exception
uploadedFileInfo.Exception = error;
}
// return value
return uploadedFileInfo;
}
#endregion
#region HandleFileUpload(IBrowserFile file, bool lastFileInBatch)
/// <summary>
/// returns the File Upload
/// </summary>
public async Task<UploadedFileInfo> HandleFileUpload(IBrowserFile file, bool lastFileInBatch)
{
// locals
UploadedFileInfo uploadedFileInfo = null;
bool abort = false;
MemoryStream ms = null;
// verify the file exists
if (file != null)
{
try
{
// the partialGuid is need to ensure uniqueness
string partialGuid = Guid.NewGuid().ToString().Substring(0, PartialGuidLength);
// create the uploadedFileInfo
uploadedFileInfo = new UploadedFileInfo(file, partialGuid, AppendPartialGuid, UploadFolder);
// Is this the last file in the batch
uploadedFileInfo.LastFileInBatch = lastFileInBatch;
// if the file is too large
if ((MaxFileSize > 0) && (file.Size > MaxFileSize))
{
// Show the FileTooLargeMessage
status = FileTooLargeMessage;
// Upload was aborted
uploadedFileInfo.Aborted = true;
uploadedFileInfo.ErrorMessage = FileTooLargeMessage;
uploadedFileInfo.Exception = new Exception("The file uploaded was too large.");
}
else
{
// Create a new instance of a 'FileInfo' object.
FileInfo fileInfo = new FileInfo(file.Name);
// Set the extension. The ToLower is for just in case. I don't know if it's even possible for an extension to be upper case
uploadedFileInfo.Extension = fileInfo.Extension.ToLower();
// if FilterByExtension is true and the AllowedExtensions text exists
if ((FilterByExtension) && (!String.IsNullOrWhiteSpace(AllowedExtensions)))
{
// verify the extension exists
if (!String.IsNullOrWhiteSpace(fileInfo.Extension))
{
// If the allowed extensions // fixed issue where uploading
abort = !AllowedExtensions.ToLower().Contains(fileInfo.Extension.ToLower());
}
else
{
// you must have an extension
abort = true;
}
}
// Set aborted to true
uploadedFileInfo.Aborted = abort;
// if we should continue
if (!abort)
{
// create the memoryStream
ms = new MemoryStream();
// await for the data to be copied to the memory stream
await file.OpenReadStream(MaxFileSize).CopyToAsync(ms);
// Check for abort 1 more time
uploadedFileInfo = CheckSize(fileInfo.Extension, ms, uploadedFileInfo);
// if abort
if (uploadedFileInfo.Aborted)
{
// Do not process due to size is not valid, message has already been set
abort = true;
}
}
// if we should continue
if (!abort)
{
// if the value for SaveToDisk is true
if (SaveToDisk)
{
// set the full path
string path = Path.Combine(UploadFolder, uploadedFileInfo.FullName);
// save the file using the FullName (If AppendPartialGuid is still true, than the Name.PartialGuid is the FullName
using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write))
{
// write out the file
ms.WriteTo(fileStream);
}
}
else
{
// Set the MemoryStream, to allow people to save outside of the project
// folder, to disk or other processing like virus scans.
uploadedFileInfo.Stream = ms;
}
// if there is a CustomSave
if (!String.IsNullOrWhiteSpace(CustomSuccessMessage))
{
// Show the CustomSuccessMessage
status = CustomSuccessMessage;
}
else
{
// set the status
status = $"Saved file {file.Size} bytes from {file.Name}";
}
// Set additional properties for UploadFileInfo from this component; these values may be null.
uploadedFileInfo.CustomId = CustomId;
uploadedFileInfo.Tag = Tag;
// The upload has completed
UploadComplete = true;
}
else
{
// If a CustomExtensionMessage has been set
if (!string.IsNullOrWhiteSpace(CustomExtensionMessage))
{
// Display the Custom extension doesn't validate message
uploadedFileInfo.ErrorMessage = CustomExtensionMessage;
}
else
{
// Can't think of a better message than this yet, just woke up
uploadedFileInfo.ErrorMessage = "The file uploaded is an invalid extension.";
}
// Show the exception
uploadedFileInfo.Exception = new Exception(uploadedFileInfo.ErrorMessage);
}
}
}
catch (Exception error)
{
// Upload was aborted
uploadedFileInfo.Aborted = true;
// Store the Exception
uploadedFileInfo.Exception = error;
// if a CustomErrorMessage is set
if (!String.IsNullOrWhiteSpace(CustomErrorMessage))
{
// Show the custom error message
status = CustomErrorMessage;
}
else
{
// show the full error
status = error.ToString();
}
// set the error message
uploadedFileInfo.ErrorMessage = status;
}
finally
{
// only call this for single files
if (!MultipleFiles)
{
// Notify the caller the upload was successful or aborted due to an error
uploadedFileInfo = await FileUploaded(uploadedFileInfo);
}
}
}
// return value
return uploadedFileInfo;
}
#endregion
#region Init()
/// <summary>
/// This method performs initializations for this object.
/// </summary>
public void Init()
{
// Set the Default Values
MessageClassName = "message";
InputFileClassName = "inputfile";
CustomButtonClassName = "buttonwide";
ResetButtonClassName = "button";
ButtonText = "Choose File";
SaveToDisk = true;
Visible = true;
ProgressVisible = true;
MaxFilesCount = 10;
ProgressHeight = 32;
MaxFileSize = 40 * 1024 * 1024; // 40 meg
}
#endregion
#region IsImageFile(string extensions)
/// <summary>
/// This method returns true if the extension is an Image File (.jpg or .png for now)
/// </summary>
public bool IsImageFile(string extension)
{
// initial value
bool isImageFile = false;
// if the string exists
if (!String.IsNullOrEmpty(extension))
{
// if a .jpg or a .png
if ((extension.ToLower() == ".jpg") || (extension.ToLower() == ".png"))
{
// set to true
isImageFile = true;
}
}
// return value
return isImageFile;
}
#endregion
#region OnFileChange(InputFileChangeEventArgs eventArgs)
/// <summary>
/// This method gives you access to the files that were uploaded
/// </summary>
/// <param name="eventArgs"></param>
private async void OnFileChange(InputFileChangeEventArgs eventArgs)
{
// locals
UploadedFileInfo uploadedFileInfo = null;
List<IBrowserFile> files = null;
IBrowserFile file = null;
// if the value for MultipleFiles is true
if (MultipleFiles)
{
// get one or more files
files = eventArgs.GetMultipleFiles(MaxFilesCount).ToList();
// If the files collection exists and has one or more items
if (ListHelper.HasOneOrMoreItems(files))
{
// Create a new collection of 'UploadedFileInfo' objects.
UploadedFiles = new List<UploadedFileInfo>();
// used to determine if this is the last file in the batch
int count = 0;
bool lastFile = false;
// Iterate the collection of IBrowserFile objects
foreach (IBrowserFile fileInBatch in files)
{
// Increment the value for count
count++;
// is this the lastFile?
lastFile = (count == files.Count);
// Handle the FileUpload
uploadedFileInfo = await HandleFileUpload(fileInBatch, lastFile);
// Add this file
UploadedFiles.Add(uploadedFileInfo);
}
// now notify the client subscribers
foreach (UploadedFileInfo fileInfo in UploadedFiles)
{
// notify the client
await FileUploaded(fileInfo);
}
}
}
else
{
// Get access to the file
file = eventArgs.File;
// Handle the FileUpload
uploadedFileInfo = await HandleFileUpload(file, true);
}
}
#endregion
#region ReceiveData(Message message)
/// <summary>
/// method receives messages from its parent
/// </summary>
public void ReceiveData(Message message)
{
// if reset
if (message.Text == "Reset")
{
// Reset this control
Reset();
}
}
#endregion
#region ResetFinished()
/// <summary>
/// This event is fired after a file is uploaded, and is used to notify subscribers of the OnChange event.
/// </summary>
private void ResetFinished()
{
try
{
// Notify the client the Reset button was clicked.
OnReset.InvokeAsync("Reset");
}
catch (Exception error)
{
// for debugging only
DebugHelper.WriteDebugError("ResetFinished", "FileUpload.razor", error);
}
}
#endregion
#region Reset()
/// <summary>
/// This method Reset
/// </summary>
public void Reset()
{
// Erase all messages
Status = "";
UploadComplete = false;
// Notify any subscribers to this event
ResetFinished();
// Update the UI
StateHasChanged();
}
#endregion
#endregion
#region Properties
#region AllowedExtensions
/// <summary>
/// This property gets or sets the value for AllowedExtensions.
/// Example: .jpg;.png;
/// </summary>
[Parameter]
public string AllowedExtensions { get; set; } = "";
#endregion
#region AppendPartialGuid
/// <summary>
/// This property gets or sets the value for AppendPartialGuid.
/// If true, a random number of digits will be appeneded to a filename to append uniqueness.
/// </summary>
[Parameter]
public bool AppendPartialGuid { get; set; } = true;
#endregion
#region ButtonText
/// <summary>
/// This property gets or sets the value for 'ButtonText'.
/// </summary>
[Parameter]
public string ButtonText
{
get { return buttonText; }
set { buttonText = value; }
}
#endregion
#region CustomButtonClassName
/// <summary>
/// This property gets or sets the value for 'CustomButtonClassName'.
/// </summary>
[Parameter]
public string CustomButtonClassName
{
get { return customButtonClassName; }
set { customButtonClassName = value; }
}
#endregion
#region CustomButtonTextClassName
/// <summary>
/// This property gets or sets the value for 'CustomButtonTextClassName'.
/// </summary>
[Parameter]
public string CustomButtonTextClassName
{
get { return customButtonTextClassName; }
set { customButtonTextClassName = value; }
}
#endregion
#region CustomErrorMessage
/// <summary>
/// This property gets or sets the value for CustomErrorMessage.
/// Change this if you wish to display a different message.
/// </summary>
[Parameter]
public string CustomErrorMessage { get; set; } = "An error occurred uploading your file.";
#endregion
#region CustomExtensionMessage
/// <summary>
/// This property gets or sets the value for CustomExtensionMessage.
/// Example: 'Only .pdf files are allowed.'
/// </summary>
[Parameter]
public string CustomExtensionMessage { get; set; } = "";
#endregion
#region CustomId
/// <summary>
/// This property gets or sets the value for RequireCustomIddSizeMessage.
/// Optional. This property can be used to set information such as databaseId, parentId,
/// categoryId or some other external classification. This value is returned with
/// UploadFileInfo.
/// </summary>
[Parameter]
public int CustomId { get; set; }
#endregion
#region CustomMaxHeightMessage
/// <summary>
/// This property gets or sets the value for CustomMaxHeightMessage.
/// If an uploaded file is a .png or .jpg file and the file exceeds MaxHeight pixels, the StatusMessage
/// will be set to CustomMaxHeightMessage. You must set CustomMaxHeightMessage and MaxHeight for this
/// validation to work.
/// </summary>
[Parameter]
public string CustomMaxHeightMessage { get; set; }
#endregion
#region CustomMaxWidthMessage
/// <summary>
/// This property gets or sets the value for CustomMaxWidthMessage.
/// If an uploaded file is a .png or .jpg file and the file exceeds MaxWidth pixels, the StatusMessage
/// will be set to CustomMaxWidthMessage. You must set CustomMaxWidthMessage and MaxWidth for this
/// validation to work.
/// </summary>
[Parameter]
public string CustomMaxWidthMessage { get; set; }
#endregion
#region CustomMinHeightMessage
/// <summary>
/// This property gets or sets the value for CustomMinHeightMessage.
/// If an uploaded file is a .png or .jpg file and the file.Height is lower than MinHeight, the StatusMessage
/// will be set to CustomMinHeightMessage. You must set CustomMinHeightMessage and MinHeight for this
/// validation to work.
/// </summary>
[Parameter]
public string CustomMinHeightMessage { get; set; }
#endregion
#region CustomMinWidthMessage
/// <summary>
/// This property gets or sets the value for CustomMinWidthMessage.
/// If an uploaded file is a .png or .jpg file and the file.Width is lower than MinWidth, the StatusMessage
/// will be set to CustomMinWidthMessage. You must set CustomMinWidthMessage and MinWidth for this
/// validation to work.
/// </summary>
[Parameter]
public string CustomMinWidthMessage { get; set; }
#endregion
#region CustomRequiredSizeMessage
/// <summary>
/// This property gets or sets the value for CustomRequiredSizeMessage.
/// Used in conjunction with RequiredHeight and / or Required Width, If RequiredSizeMessage
/// and an uploaded file that is a .png or .jpg file is not the correct size, the StatusMessage
/// will be set to this value.
/// </summary>
[Parameter]
public string CustomRequiredSizeMessage { get; set; }
#endregion
#region CustomSuccessMessage
/// <summary>
/// This property gets or sets the value for CustomSuccessMessage.
/// Example: 'Congratulations, your file has been uploaded and is being processed.'
/// </summary>
[Parameter]
public string CustomSuccessMessage { get; set; } = "";
#endregion
#region FileTooLargeMessage
/// <summary>
/// This property gets or sets the value for FileTooLargeMessage.
/// Example: 'Files must be 4 megabytes or smaller.'
/// </summary>
[Parameter]
public string FileTooLargeMessage { get; set; } = "The file uploaded is too large";
#endregion
#region FilterByExtension
/// <summary>
/// This property gets or sets the value for FilterByExtension.
/// If true, only files with a matching extension will be allowed.
/// </summary>
[Parameter]
public bool FilterByExtension { get; set; } = false;
#endregion
#region HasCustomMaxHeightMessage
/// <summary>
/// This property returns true if this object has a 'CustomMaxHeightMessage' set.
/// </summary>
public bool HasCustomMaxHeightMessage
{
get
{
// initial value
bool hasCustomMaxHeightMessage = (!String.IsNullOrEmpty(this.CustomMaxHeightMessage));
// return value
return hasCustomMaxHeightMessage;
}
}
#endregion
#region HasCustomMaxWidthMessage
/// <summary>
/// This property returns true if this object has a 'CustomMaxWidthMessage'.
/// </summary>
public bool HasCustomMaxWidthMessage
{
get
{
// initial value
bool hasCustomMaxWidthMessage = (!String.IsNullOrEmpty(CustomMaxWidthMessage));
// return value
return hasCustomMaxWidthMessage;
}
}
#endregion
#region HasCustomMinHeightMessage
/// <summary>
/// This property returns true if this object has a 'CustomMinHeightMessage'.
/// </summary>
public bool HasCustomMinHeightMessage
{
get
{
// initial value
bool hasCustomMinHeightMessage = (!String.IsNullOrEmpty(this.CustomMinHeightMessage));
// return value
return hasCustomMinHeightMessage;
}
}
#endregion
#region HasCustomMinWidthMessage
/// <summary>
/// This property returns true if this object has a 'CustomMinWidthMessage'.
/// </summary>
public bool HasCustomMinWidthMessage
{
get
{
// initial value
bool hasCustomMinWidthMessage = (!String.IsNullOrEmpty(CustomMinWidthMessage));
// return value
return hasCustomMinWidthMessage;
}
}
#endregion
#region HasCustomRequiredSizeMessage
/// <summary>
/// This property returns true if this object has a 'CustomRequiredSizeMessage'.
/// </summary>
public bool HasCustomRequiredSizeMessage
{
get
{
// initial value
bool hasCustomRequiredSizeMessage = (!String.IsNullOrEmpty(CustomRequiredSizeMessage));
// return value
return hasCustomRequiredSizeMessage;
}
}
#endregion
#region HasMaxHeight
/// <summary>
/// This property returns true if MaxHeight is greater than 0.
/// </summary>
public bool HasMaxHeight
{
get
{
// initial value
bool hasMaxHeight = (this.MaxHeight > 0);
// return value
return hasMaxHeight;
}
}
#endregion
#region HasMaxWidth
/// <summary>
/// This property returns true if 'MaxWidth' is greater than 0.
/// </summary>
public bool HasMaxWidth
{
get
{
// initial value
bool hasMaxWidth = (this.MaxWidth > 0);
// return value
return hasMaxWidth;
}
}
#endregion
#region HasMinHeight
/// <summary>
/// This property returns true if MinHeight is greater than 0.
/// </summary>
public bool HasMinHeight
{
get
{
// initial value
bool hasMinHeight = (this.MinHeight > 0);
// return value
return hasMinHeight;
}
}
#endregion
#region HasMinWidth
/// <summary>
/// This property returns true if 'MinWidth' is greater than 0.
/// </summary>
public bool HasMinWidth
{
get
{
// initial value
bool hasMinWidth = (this.MinWidth > 0);
// return value
return hasMinWidth;
}
}
#endregion
#region HasParent
/// <summary>
/// This property returns true if this object has a 'Parent'.
/// </summary>
public bool HasParent
{
get
{
// initial value
bool hasParent = (this.Parent != null);
// return value
return hasParent;
}
}
#endregion
#region HasRequiredHeight
/// <summary>
/// This property returns true if this object has a 'RequiredHeight'.
/// </summary>
public bool HasRequiredHeight
{
get
{
// initial value
bool hasRequiredHeight = (this.RequiredHeight != 0);
// return value
return hasRequiredHeight;
}
}
#endregion
#region HasRequiredWidth
/// <summary>
/// This property returns true if this object has a 'RequiredWidth' set.
/// </summary>
public bool HasRequiredWidth
{
get
{
// initial value
bool hasRequiredWidth = (this.RequiredWidth != 0);
// return value
return hasRequiredWidth;
}
}
#endregion
#region HasStatus
/// <summary>
/// This read only property returns true if the 'Status' text exists.
/// </summary>
public bool HasStatus
{
get
{
// initial value
bool hasStatus = (!String.IsNullOrEmpty(this.Status));
// return value
return hasStatus;
}
}
#endregion
#region InputFileClassName
/// <summary>
/// This property gets or sets the value for 'InputFileClassName'.
/// </summary>
[Parameter]
public string InputFileClassName
{
get { return inputFileClassName; }
set { inputFileClassName = value; }
}
#endregion
#region MaxFilesCount
/// <summary>
/// This property gets or sets the value for 'MaxFilesCount'.
/// </summary>
[Parameter]
public int MaxFilesCount
{
get { return maxFilesCount; }
set { maxFilesCount = value; }
}
#endregion
#region MaxFileSize
/// <summary>
/// This property gets or sets the value for MaxFileSize.
/// This property is the size in bytes. Example: 41943040 (40 megs).
/// </summary>
[Parameter]
public long MaxFileSize { get; set; } = 0;
#endregion
#region MaxHeight
/// <summary>
/// This property gets or sets the value for MaxHeight.
/// If MaxHeight is set, any image files exceeding the height of this value
/// will be rejected. Note: This only works for .jpg and .png files.
/// </summary>
[Parameter]
public int MaxHeight { get; set; }
#endregion
#region MaxWidth
/// <summary>
/// This property gets or sets the value for MaxWidth.
/// If MaxWidth is set, any image files exceeding the Width of this value
/// will be rejected. Note: This only works for .jpg and .png files.
/// </summary>
[Parameter]
public int MaxWidth { get; set; }
#endregion
#region MessageClassName
/// <summary>
/// This property gets or sets the value for 'MessageClassName'.
/// </summary>
[Parameter]
public string MessageClassName
{
get { return messageClassName; }
set { messageClassName = value; }
}
#endregion
#region MinHeight
/// <summary>
/// This property gets or sets the value for MinHeight.
/// If MinHeight is set, any image files less than the height of this value
/// will be rejected. Note: This only works for .jpg and .png files.
/// </summary>
[Parameter]
public int MinHeight { get; set; }