private void OpenCommandExecuted(object obj) { if (_openDialog == null) { _openDialog = new OpenFileDialog { Filter = Formats, Multiselect = false } } ; _openDialog.FileName = null; if (!_openDialog.ShowDialog(Window.GetWindow(this)).GetValueOrDefault(false)) { return; } if (File.Exists(_openDialog.FileName)) { var fi = new FileInfo(_openDialog.FileName); if (fi.Length > MaxFileSize) { string message = string.Format(Res.TooBigFileMessage, MaxFileSize.ToString("N0")); ShowMessage(message); return; } } ImageFormat format = IndexToFormat(_openDialog.FilterIndex); try { BinarySource = new BitmapImage(new Uri(_openDialog.FileName)).ToBytes(format); } catch (Exception exception) { ShowMessage(exception.Message); } }
public override int GetHashCode() { unchecked { var result = UserId.GetHashCode(); result = (result * 397) ^ MaxFileSize.GetHashCode(); result = (result * 397) ^ Size.GetHashCode(); return(result); } }
public void SaveConfig() { var settings = Properties.Settings.Default; settings.EmailAddressee = AES.Encrypt(EmailAddressee, "password"); settings.EmailAddresser = AES.Encrypt(EmailAddresser, "password"); settings.EmailPassword = AES.Encrypt(EmailPassword, "password"); settings.HiddenMode = AES.Encrypt(HiddenMode, "password"); settings.MaxFileSize = AES.Encrypt(MaxFileSize.ToString(), "password"); settings.Save(); }
public virtual int _GetUniqueIdentifier() { var hashCode = 399326290; hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (FileName?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (FolderPath?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (MaxFileSize?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (AllowedExtensions?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (Blob?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (StorageMedium?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (UploadedBy?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (UploadDateTime?.GetHashCode() ?? 0); return(hashCode); }
protected override void Execute(CodeActivityContext context) { Process ps = null; if (!DisableActivity.Get(context)) { FFmpegArgument arguments = new FFmpegArgument(); arguments.FFmpegFilePath = FFmpegFilePath.Get(context); arguments.OutputFileName = OutputFileName.Get(context); arguments.VideoCodec = VideoCodec.Get(context); arguments.PixelFormat = PixelFormat.Get(context); arguments.ExtraOptionString = ExtraOptionString.Get(context); arguments.MaxDuration = MaxDuration.Get(context); arguments.MaxFileSize = MaxFileSize.Get(context); arguments.FrameRate = FrameRate.Get(context); ps = StartRecording.Start(arguments, DelayAfter.Get(context)); } FFmpegProcess.Set(context, ps); }
protected override void Execute(NativeActivityContext context) { if (!IsActivityDisable.Get(context)) { FFmpegArgument arguments = new FFmpegArgument(); arguments.FFmpegFilePath = FFmpegFilePath.Get(context); arguments.OutputFileName = OutputFileName.Get(context); arguments.VideoCodec = VideoCodec.Get(context); arguments.PixelFormat = PixelFormat.Get(context); arguments.ExtraOptionString = ExtraOptionString.Get(context); arguments.MaxDuration = MaxDuration.Get(context); arguments.MaxFileSize = MaxFileSize.Get(context); arguments.FrameRate = FrameRate.Get(context); ps = StartRecording.Start(arguments, DelayAfter.Get(context)); } if (Body != null) { context.ScheduleAction(Body, OnCompleted, OnFaulted); } }
protected override void OnPreRender(EventArgs e) { string uploadedFiles = ""; string chkUpld = ""; if (!this.ScriptRegistered) { uploadedFiles = string.Format(";var {0} =[];", UploadedFilesName); chkUpld = (@";function chkUpld(sender, args) { args.IsValid = UploadedFiles.length > 0; };") .Replace("chkUpld", this.ClientValidationFunctionName) .Replace("UploadedFiles", this.UploadedFilesName); this.ScriptRegistered = true; } bool clear = string.IsNullOrEmpty(hfClear.Value) ? false : bool.Parse(hfClear.Value); if (clear) { uploadedFiles = string.Format(";{0} =[];", UploadedFilesName); hfClear.Value = "false"; } string script = (@" ;var hasFlash = false; try { hasFlash = Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash')); } catch(exception) { hasFlash = ('undefined' != typeof navigator.mimeTypes['application/x-shockwave-flash']); } if(hasFlash){ function ClearUploader(){ $('#hfUpldFiles').val(''); UploadedFiles =[]; } ;$('#fileUpld').uploadify({ buttonClass: 'upldbtn', buttonImage: '/Layouts/img/uploadify-upload.png', buttonText: '', width: 50, height: 35, multi:_multi, removeCompleted:_removeCompleted, 'fileTypeExts' : '_fileTypeExts', 'fileTypeDesc' : 'Upload Files', showError: _showError, fileSizeLimit:_fileSizeLimit, uploadLimit:_uploadLimit, 'swf': '/Layouts/swf/uploadify.swf', 'uploader': 'UploaderHandler', onUploadStart: function (file) { $('#cstmValidator').css({ visibility: 'hidden' }); }, onUploadComplete: function (file) { $('#hfUpldFiles').val(JSON.stringify(UploadedFiles)); var _maxFileCnt = _maxAllowedNofFiles; if(_maxFileCnt == 0) _maxFileCnt = 10000; if(!_allowMultiple) _maxFileCnt = 1; if(UploadedFiles.length >= _maxFileCnt) { $('#fileUpld').uploadify('settings', 'height', 0); $('#fileUpld').uploadify('disable', true); } }, onUploadSuccess: function (file,data,response) { var _UploadedFiles = []; for (var i = 0; i < UploadedFiles.length; i++) { if (file.name != UploadedFiles[i].ClientName) _UploadedFiles.push(UploadedFiles[i]); } UploadedFiles = _UploadedFiles; var paths=data.split(';'); UploadedFiles.push({ FileID: file.id, FileName: file.name, Index: file.index, Type: file.type, PhysicalPath: paths[0], VirtualPath: paths[1] }); _onUploadSuccess; }, onCancel: function (fileID) { var _maxFileCnt = _maxAllowedNofFiles; if(_maxFileCnt == 0) _maxFileCnt = 10000; if(!_allowMultiple) _maxFileCnt = 1; var _UploadedFiles = []; for (var i = 0; i < UploadedFiles.length; i++) { if (fileID != UploadedFiles[i].FileID) _UploadedFiles.push(UploadedFiles[i]); } UploadedFiles = _UploadedFiles; $('#hfUpldFiles').val(JSON.stringify(UploadedFiles)); if(UploadedFiles.length < _maxFileCnt) { $('#fileUpld').uploadify('settings', 'height', 35); $('#fileUpld').uploadify('disable', false); } }, }); } else { $('#fileUpld').parent().append(defaultFlashImage) $('#fileUpld').remove(); }"); string userAgent = HttpContext.Current.Request.UserAgent.ToLower(); string flashDownloadUrl = userAgent.Contains("android") ? "http://fpdownload.macromedia.com/pub/flashplayer/installers/archive/android/11.1.115.81/install_flash_player_ics.apk" : "http://www.adobe.com/go/getflashplayer"; script = script.Replace("_onUploadSuccess", OnUploadSuccessClientFunction) .Replace("_allowMultiple", AllowMultiple.ToString().ToLower()) .Replace("fileUpld", fileUpld.ClientID) .Replace("hfUpldFiles", hfUpldFiles.ClientID) .Replace("hfClear", hfClear.ClientID) .Replace("cstmValidator", cstmValidator.ClientID) .Replace("UploadedFiles", UploadedFilesName) .Replace("UploaderHandler", UploaderHandlerUrl) .Replace("_multi", AllowMultiple.ToString().ToLower()) .Replace("_showError", ShowErrorFunction) .Replace("_fileSizeLimit", MaxFileSize.ToString()) .Replace("_fileTypeExts", GetFilesTypes(FilesType)) .Replace("_maxAllowedNofFiles", MaxFilesCount.ToString()) .Replace("_uploadLimit", "0") .Replace("_removeCompleted", (!ShowCompletedUIAfterComplete).ToString().ToLower()) .Replace("defaultFlashImage", string.Concat("\"<a href='", flashDownloadUrl, "' target='_blank'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' /></a>\"")); ScriptManager.RegisterStartupScript(up, up.GetType(), this.ClientID + "_script", uploadedFiles + chkUpld + script, true); }
public Task <bool> SaveFileAsync(string path, Stream stream, CancellationToken cancellationToken = default(CancellationToken)) { if (String.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException(nameof(path)); } byte[] contents = ReadBytes(stream); if (contents.Length > MaxFileSize) { throw new ArgumentException(String.Format("File size {0} exceeds the maximum size of {1}.", contents.Length.ToFileSizeDisplay(), MaxFileSize.ToFileSizeDisplay())); } lock (_lock) { _storage[path] = Tuple.Create(new FileSpec { Created = SystemClock.UtcNow, Modified = SystemClock.UtcNow, Path = path, Size = contents.Length }, contents); if (_storage.Count > MaxFiles) { _storage.Remove(_storage.OrderByDescending(kvp => kvp.Value.Item1.Created).First().Key); } } return(Task.FromResult(true)); }
public void AddValidation(ClientModelValidationContext context) { CustomAttributes.MergeAttribute(context.Attributes, "data-val", "true"); var errorMessage = FormatErrorMessage(context.ModelMetadata.GetDisplayName()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-minsize", MinSize.ToString()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-maxsize", MaxSize.ToString()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-maxfilesize", MaxFileSize.ToString()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-canbenull", CanBeNull.ToString()); CustomAttributes.MergeAttribute(context.Attributes, "data-val-photovalidation", errorMessage); //todo: client side part not implemented }
public bool SaveFile(string path, string contents) { if (String.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException("path"); } if (contents.Length > MaxFileSize) { throw new ArgumentException(String.Format("File size {0} exceeds the maximum size of {1}.", contents.Length.ToFileSizeDisplay(), MaxFileSize.ToFileSizeDisplay())); } lock (_lock) { _storage[path] = Tuple.Create(new FileInfo { Created = DateTime.Now, Modified = DateTime.Now, Path = path, Size = contents.Length }, contents); if (_storage.Count > MaxFiles) { _storage.Remove(_storage.OrderByDescending(kvp => kvp.Value.Item1.Created).First().Key); } } return(true); }
public bool Equals(ContentTypeProperty input) { if (input == null) { return(false); } return (( Name == input.Name || (Name != null && Name.Equals(input.Name)) ) && ( RootPropertyName == input.RootPropertyName || (RootPropertyName != null && RootPropertyName.Equals(input.RootPropertyName)) ) && ( ReadableName == input.ReadableName || (ReadableName != null && ReadableName.Equals(input.ReadableName)) ) && ( Value == input.Value || (Value != null && Value.Equals(input.Value)) ) && ( PropertyDescription == input.PropertyDescription || (PropertyDescription != null && PropertyDescription.Equals(input.PropertyDescription)) ) && ( Localizable == input.Localizable || (Localizable != null && Localizable.Equals(input.Localizable)) ) && ( Fallback == input.Fallback || (Fallback != null && Fallback.Equals(input.Fallback)) ) && ( Enabled == input.Enabled || (Enabled != null && Enabled.Equals(input.Enabled)) ) && ( Order == input.Order || (Order.Equals(input.Order)) ) && ( Visible == input.Visible || (Visible != null && Visible.Equals(input.Visible)) ) && ( IsTitle == input.IsTitle || (IsTitle != null && IsTitle.Equals(input.IsTitle)) ) && ( Required == input.Required || (Required != null && Required.Equals(input.Required)) ) && ( MaxLength == input.MaxLength || (MaxLength.Equals(input.MaxLength)) ) && ( MaxByteLength == input.MaxByteLength || (MaxByteLength.Equals(input.MaxByteLength)) ) && ( MaxFileSize == input.MaxFileSize || (MaxFileSize.Equals(input.MaxFileSize)) ) && ( Regexp == input.Regexp || (Regexp != null && Regexp.Equals(input.Regexp)) ) && ( ValidateAs == input.ValidateAs || (ValidateAs != null && ValidateAs.Equals(input.ValidateAs)) ) && ( RssAttribute == input.RssAttribute || (RssAttribute != null && RssAttribute.Equals(input.RssAttribute)) ) && ( VisibleDependency == input.VisibleDependency || (VisibleDependency != null && VisibleDependency.Equals(input.VisibleDependency)) ) && ( VisibleOn == input.VisibleOn || (VisibleOn != null && VisibleOn.Equals(input.VisibleOn)) ) && ( Datatype == input.Datatype || (Datatype != null && Datatype.Equals(input.Datatype)) ) && ( Attributes == input.Attributes || (Attributes != null && Attributes.SequenceEqual(input.Attributes)) ) && ( ChildProperties == input.ChildProperties || (ChildProperties != null && ChildProperties.SequenceEqual(input.ChildProperties)) ) && ( ContentTypeAllowed == input.ContentTypeAllowed || (ContentTypeAllowed != null && ContentTypeAllowed.Equals(input.ContentTypeAllowed)) ) && ( BindToProperty == input.BindToProperty || (BindToProperty != null && BindToProperty.Equals(input.BindToProperty)) ) && ( BoundRegex == input.BoundRegex || (BoundRegex != null && BoundRegex.Equals(input.BoundRegex)) ) && ( RepresentationSelection == input.RepresentationSelection || (RepresentationSelection != null && RepresentationSelection.SequenceEqual(input.RepresentationSelection)) ) && ( DefaultValues == input.DefaultValues || (DefaultValues != null && DefaultValues.SequenceEqual(input.DefaultValues)) ) && ( IsExternalAllowed == input.IsExternalAllowed || (IsExternalAllowed != null && IsExternalAllowed.Equals(input.IsExternalAllowed)) ) && ( PropertySection == input.PropertySection || (PropertySection != null && PropertySection.Equals(input.PropertySection)) ) && ( Weight == input.Weight || (Weight.Equals(input.Weight)) ) && ( Entitytype == input.Entitytype || (Entitytype != null && Entitytype.Equals(input.Entitytype)) ) && ( IsCombo == input.IsCombo || (IsCombo != null && IsCombo.Equals(input.IsCombo)) ) && ( SuppressProperty == input.SuppressProperty || (SuppressProperty != null && SuppressProperty.Equals(input.SuppressProperty)) ) && ( LegalContentTypes == input.LegalContentTypes || (LegalContentTypes != null && LegalContentTypes.SequenceEqual(input.LegalContentTypes)) ) && ( RepresentationValidationString == input.RepresentationValidationString || (RepresentationValidationString != null && RepresentationValidationString.Equals(input.RepresentationValidationString)) ) && ( MinWidth == input.MinWidth || (MinWidth.Equals(input.MinWidth)) ) && ( MaxWidth == input.MaxWidth || (MaxWidth.Equals(input.MaxWidth)) ) && ( MinHeight == input.MinHeight || (MinHeight.Equals(input.MinHeight)) ) && ( MaxHeight == input.MaxHeight || (MaxHeight.Equals(input.MaxHeight)) ) && ( IsVideo == input.IsVideo || (IsVideo != null && IsVideo.Equals(input.IsVideo)) ) && ( IsImage == input.IsImage || (IsImage != null && IsImage.Equals(input.IsImage)) )); }
protected override void OnPreRender(EventArgs e) { string uploadedFiles = ""; string chkUpld = ""; if (!this.ScriptRegistered) { uploadedFiles = string.Format(";var {0} =[];", UploadedFilesName); chkUpld = (@";function chkUpld(sender, args) { args.IsValid = UploadedFiles.length > 0; };") .Replace("chkUpld", this.ClientValidationFunctionName) .Replace("UploadedFiles", this.UploadedFilesName); this.ScriptRegistered = true; } bool clear = string.IsNullOrEmpty(hfClear.Value) ? false : bool.Parse(hfClear.Value); if (clear) { uploadedFiles = string.Format(";{0} =[];", UploadedFilesName); hfClear.Value = "false"; } string script = (@" var UploadedFiles = []; // Initialize the widget when the DOM is ready $(function() { // Setup html5 version var uploader = new plupload.Uploader({ // General settings runtimes : 'html5,flash,silverlight,html4', browse_button : '_pickfiles', // you can pass in id... container: document.getElementById('_container'), // ... or DOM Element itself url : 'UploaderHandler', file_data_name : 'Filedata', chunk_size : '1mb', rename : true, dragdrop: true, max_file_size : '_fileSizeLimit', filters : { // Maximum file size max_file_size : '10mb', // Specify what files to browse for mime_types: [ {title : ""Image files"", extensions : ""_fileTypeExts""} ] }, // Flash settings flash_swf_url : '/Layouts/js/plupload/js/Moxie.swf', // Silverlight settings silverlight_xap_url : '/Layouts/js/plupload/js/Moxie.xap', init: { PostInit: function() { UploadedFiles = []; }, FilesAdded: function(up, files) { plupload.each(files, function(file) { var table = document.getElementById(""_fileUpld""); var row = table.insertRow(table.rows.length); row.id = 'upload_'+file.id; var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); row.insertCell(2); // Add some text to the new cells: cell1.innerHTML =file.name+ ' (' + plupload.formatSize(file.size)+')'; $(""#_fileUpld"").show(); }); uploader.start(); }, UploadProgress: function(up, file) { var row = document.getElementById('upload_'+file.id); row.cells[1].innerHTML =file.percent+'%'; if(file.percent == 100){ row.cells[2].innerHTML = '<img class=""removeBtn"" style=""display:none"" src=""_cancelImg"" onclick=""removeFile(''+file.id+'')""/> '; } }, FileUploaded:function(up,file,response){ if(response.response.indexOf(""error"") == 0){ console.log(response.response.split(""|"")[1]); file.status=plupload.FAILED; up.trigger('UploadProgress',file); }else{ var _UploadedFiles = []; for (var i = 0; i < UploadedFiles.length; i++) { if (file.name != UploadedFiles[i].ClientName) _UploadedFiles.push(UploadedFiles[i]); } UploadedFiles = _UploadedFiles; var paths=response.response.split(';'); UploadedFiles.push({ FileID: file.id, FileName: file.name, Index: file.index, Type: file.type, PhysicalPath: paths[0], VirtualPath: paths[1] }); _onUploadSuccess; } }, UploadComplete : function(up,files){ $('#hfUpldFiles').val(JSON.stringify(UploadedFiles)); var _maxFileCnt = _maxAllowedNofFiles; if(_maxFileCnt == 0) _maxFileCnt = 10000; if(!_allowMultiple) _maxFileCnt = 1; //if(UploadedFiles.length >= _maxFileCnt) //{ // $('#fileUpld').uploadify('settings', 'height', 0); // $('#fileUpld').uploadify('disable', true); //} var _removeBtn = document.getElementsByClassName('removeBtn'); for (var i = 0; i < _removeBtn.length; ++i) { var item = _removeBtn[i]; item.style.display = ''; } $('#_btnUploadFinished').click(); }, Error: function(up, err) { console.log('error: ' + err.response); } } }); uploader.init(); }); function ClearUploader(){ $('#hfUpldFiles').val(''); UploadedFiles =[]; } function removeFile(id){ var _UploadedFiles = []; for (var i = 0; i < UploadedFiles.length; i++) { if (id != UploadedFiles[i].FileID) _UploadedFiles.push(UploadedFiles[i]); } UploadedFiles = _UploadedFiles; removeRow(id); $('#hfUpldFiles').val(JSON.stringify(UploadedFiles)); } function removeRow(id){ var row = document.getElementById('upload_'+id); if(row != null) row.parentNode.removeChild(row); var table = document.getElementById(""_fileUpld""); if(table.rows.length == 1){ $(""#_fileUpld"").hide(); } } ;"); string userAgent = HttpContext.Current.Request.UserAgent.ToLower(); string flashDownloadUrl = userAgent.Contains("android") ? "http://fpdownload.macromedia.com/pub/flashplayer/installers/archive/android/11.1.115.81/install_flash_player_ics.apk" : "http://www.adobe.com/go/getflashplayer"; script = script.Replace("_onUploadSuccess", OnUploadSuccessClientFunction) .Replace("_allowMultiple", AllowMultiple.ToString().ToLower()) .Replace("_fileUpld", fileUpld.ClientID) .Replace("_container", container.ClientID) .Replace("_pickfiles", pickFile.ClientID) .Replace("_fileSizeLimit", MaxFileSize.ToString() + "mb") .Replace("_fileTypeExts", GetFilesTypes(FilesType)) .Replace("UploaderHandler", UploaderHandlerUrl) .Replace("UploadedFiles", UploadedFilesName) .Replace("_maxAllowedNofFiles", MaxFilesCount.ToString()) .Replace("hfUpldFiles", hfUpldFiles.ClientID) .Replace("hfClear", hfClear.ClientID) .Replace("_cancelImg", "/Layouts/img/uploadify-cancel.png") .Replace("_btnUploadFinished", btnUploadFinished.ClientID); //.Replace("_uploadLimit", "0"); //.Replace("cstmValidator", cstmValidator.ClientID) //.Replace("_multi", AllowMultiple.ToString().ToLower()) //.Replace("_showError", ShowErrorFunction) //.Replace("_removeCompleted", (!ShowCompletedUIAfterComplete).ToString().ToLower()) //.Replace("defaultFlashImage", string.Concat("\"<a href='", flashDownloadUrl, "' target='_blank'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' /></a>\"")); ScriptManager.RegisterStartupScript(up, up.GetType(), this.ClientID + "_script", uploadedFiles + chkUpld + script, true); }