protected void Page_Load(object sender, EventArgs e)
    {
        // Find 'Insert image' button in the top toolbar and change the associated popup
        Collection <CommonButton> buttons = editor.TopToolbar.GetButtonsByType(typeof(InsertImage));

        if (buttons.Count > 0)
        {
            InsertImage button = buttons[0] as InsertImage;
            button.RelatedPopupType = typeof(CuttedImageProperties).AssemblyQualifiedName;
        }

        // Find 'Edit image' item in the context menu and change the associated popup
        buttons = editor.EditPanel.ContextMenu.GetButtonsByType(typeof(EditImageItem));
        if (buttons.Count > 0)
        {
            EditImageItem item = buttons[0] as EditImageItem;
            item.RelatedPopupType = typeof(CuttedImageProperties).AssemblyQualifiedName;
        }
        if (!Page.IsPostBack)
        {
            StreamReader input;

            input = new StreamReader(System.Web.HttpContext.Current.Server.MapPath("contents/Content1.txt"), System.Text.Encoding.ASCII);
            editor.EditPanel.Content = input.ReadToEnd();
            input.Close();
        }
    }
Beispiel #2
0
        public async Task InsertImageClick()
        {
            Message = null;
            if (file != null)
            {
                if (!ImageHelper.IsImageExtension(fileInfo.Type))
                {
                    Message = "File type not allowed, please choose an image";
                    return;
                }
                isLoading = true;
                using (var ms = await file.CreateMemoryStreamAsync(4 * 1024))
                {
                    var content = new MultipartFormDataContent();
                    content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
                    content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), "file", fileInfo.Name);
                    var response = await _api.UploadFile <FileStore_Model>("FileStore/Image/CMS.Contents/true", content);

                    if (response != null)
                    {
                        if (response.Status == 200 && !response.Data.name.isNOEOW())
                        {
                            await InsertImage.InvokeAsync(response.Data.url);

                            await _JSRuntime.InvokeVoidAsync("Benriya.closeModal", "#FormInsertImage");
                        }
                        else
                        {
                            Message = response.Message;
                        }
                    }
                }
                isLoading = false;
            }
            else if (!image_url.isNOEOW())
            {
                await InsertImage.InvokeAsync(image_url);

                await _JSRuntime.InvokeVoidAsync("Benriya.closeModal", "#FormInsertImage");
            }
            else
            {
                Message = "Please choose your an image";
            }
        }
        public async Task InsertImageClick()
        {
            Message = null;
            if (file != null)
            {
                var block = new string[] { "download", "script", "exe", "command", "bat", "com", "db", "js", "ja", "xa", "ii", "is", "ha", "bin", "cmd" };
                if (block.Any(fileInfo.Type.Contains))
                {
                    Message = "File type not allowed, please choose a correct file.";
                    return;
                }
                using (var ms = await file.CreateMemoryStreamAsync(4 * 1024))
                {
                    var content = new MultipartFormDataContent();
                    content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
                    content.Add(new StreamContent(ms, Convert.ToInt32(ms.Length)), "file", fileInfo.Name);
                    var response = await _api.UploadFile <T>($"FileStore/Image/{Module}/{IsPublic}?width={Width}&height={Height}", content);

                    if (response != null)
                    {
                        if (response.Status == 200 && response.Data != null)
                        {
                            //T xdata = response.Data;
                            //Type model = xdata.GetType();
                            //PropertyInfo uri_prop = model.GetProperty("url");
                            //Console.WriteLine(uri_prop.GetValue(xdata).ToString());
                            //var file_content = await _api.GetFile(uri_prop.GetValue(xdata).ToString());
                            //PropertyInfo content_prop = model.GetProperty("file_content");
                            //content_prop.SetValue(xdata,file_content,null);
                            //await InsertImage.InvokeAsync(xdata);
                            await InsertImage.InvokeAsync(response.Data);
                        }
                        else
                        {
                            Message = response.Message;
                        }
                    }
                }
            }
            else
            {
                Message = "Please choose your an image";
            }
        }