Exemplo n.º 1
0
        private void CmdUpload_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = Filter;
            if (openFileDialog.ShowDialog() == false)
            {
                return;
            }

            String fileName = openFileDialog.FileName;

            long length = new System.IO.FileInfo(fileName).Length;

            if (length > FileSizeLimit)
            {
                CHelper.ShowErorMessage(FileSizeLimit.ToString(), "ERROR_UPLOAD_FILE_SIZE", null);
                return;
            }

            WinUploadProgress wp = new WinUploadProgress(fileName);

            wp.ShowDialog();

            CUploadResult result = wp.UploadResult;

            displayImage(result.Token, "wip");

            internalUpdate = true;
            FileName       = result.Token;
            internalUpdate = false;

            updateExtFlag("U");

            if (SelectedFileChanged != null)
            {
                SelectedFileChanged(this, null);
            }
        }
        public void Build(ContentTypePartDefinitionBuilder builder)
        {
            builder.WithSetting("FileUploadPartSettings.FileCountLimit", FileCountLimit.HasValue ? FileCountLimit.ToString() : string.Empty);
            builder.WithSetting("FileUploadPartSettings.FileSizeLimit", FileSizeLimit.HasValue ? FileSizeLimit.ToString() : string.Empty);
            builder.WithSetting("FileUploadPartSettings.FileTypes", FileTypes);
            builder.WithSetting("FileUploadPartSettings.PublicMediaPath", PublicMediaPath);

            builder.WithSetting("FileUploadPartSettings.DisplayFileUploadInDisplayMode", DisplayFileUploadInDisplayMode.ToString(CultureInfo.InvariantCulture));
            builder.WithSetting("FileUploadPartSettings.HideFileUploadInEditModel", HideFileUploadInEditModel.ToString(CultureInfo.InvariantCulture));
        }