public void ContentEditor_CreateSurveyBlast_Method_With_2_Parameters_Call_With_Reflection_No_Exception_Thrown_Test() { // Arrange var sender = Fixture.Create <object>(); var e = Fixture.Create <EventArgs>(); object[] parametersOfCreateSurveyBlast = { sender, e }; var contentEditor = new ContentEditor(); var methodName = "CreateSurveyBlast"; // Act var createSurveyBlastMethodInfo1 = contentEditor.GetType().GetMethod(methodName); var createSurveyBlastMethodInfo2 = contentEditor.GetType().GetMethod(methodName); var returnType1 = createSurveyBlastMethodInfo1.ReturnType; var returnType2 = createSurveyBlastMethodInfo2.ReturnType; // Assert parametersOfCreateSurveyBlast.ShouldNotBeNull(); contentEditor.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); createSurveyBlastMethodInfo1.ShouldNotBeNull(); createSurveyBlastMethodInfo2.ShouldNotBeNull(); createSurveyBlastMethodInfo1.ShouldBe(createSurveyBlastMethodInfo2); Should.Throw <Exception>(actual: () => createSurveyBlastMethodInfo1.Invoke(contentEditor, parametersOfCreateSurveyBlast)); Should.Throw <Exception>(actual: () => createSurveyBlastMethodInfo2.Invoke(contentEditor, parametersOfCreateSurveyBlast)); }
public FrameworkElement Render(ContentEditor contentEditor) { Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); IsLoading = true; try { ContentEditor = contentEditor; var contentModel = contentEditor.ContentModel; if (contentModel.IsMultiple) { RenderMultipleItems(contentModel); return(this); } RenderItem(contentModel.Items.First()); return(this); } finally { IsLoading = false; } }
public void ContentEditor_CreateContent_Method_With_No_Parameters_Call_With_Reflection_Exception_Thrown_Test() { // Arrange object[] parametersOutRanged = { null, null }; var contentEditor = new ContentEditor(); var methodName = "CreateContent"; // Act var createContentMethodInfo1 = contentEditor.GetType().GetMethod(methodName); var createContentMethodInfo2 = contentEditor.GetType().GetMethod(methodName); var returnType1 = createContentMethodInfo1.ReturnType; var returnType2 = createContentMethodInfo2.ReturnType; // Assert parametersOutRanged.ShouldNotBeNull(); returnType1.ShouldNotBeNull(); returnType2.ShouldNotBeNull(); returnType1.ShouldBe(returnType2); contentEditor.ShouldNotBeNull(); createContentMethodInfo1.ShouldNotBeNull(); createContentMethodInfo2.ShouldNotBeNull(); createContentMethodInfo1.ShouldBe(createContentMethodInfo2); Should.Throw <Exception>(actual: () => createContentMethodInfo1.Invoke(contentEditor, parametersOutRanged)); Should.Throw <Exception>(actual: () => createContentMethodInfo2.Invoke(contentEditor, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => createContentMethodInfo1.Invoke(contentEditor, parametersOutRanged)); Should.Throw <TargetParameterCountException>(actual: () => createContentMethodInfo2.Invoke(contentEditor, parametersOutRanged)); }
public NoFieldsPane([NotNull] ContentEditor contentEditor) { Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); InitializeComponent(); ContentEditor = contentEditor; }
public AppearanceOptions GetAppearanceOptions([NotNull] ContentEditor contentEditor) { Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); var options = AppHost.Settings.Options; var skinName = SkinName; if (string.IsNullOrEmpty(skinName)) { skinName = options.Skin ?? string.Empty; } var result = new AppearanceOptions { ContentEditor = contentEditor, SkinName = skinName, StandardFields = options.ShowStandardFields, RawValues = options.ShowRawValues, FieldInformation = options.ShowFieldInformation, FieldDisplayTitles = options.ShowFieldDisplayTitles }; var panelContext = new PanelContext(result.Skin, contentEditor.ContentModel); result.Panels = Panels.Select(d => d.Panel).Where(p => p.CanRender(panelContext)); return(result); }
public void RenameItemContentEditor(string itemName) { ContentEditor.SendKeys(Keys.F2); ModalText.SendKeys(itemName); Driver.SwitchTo().DefaultContent(); ModalButton.Click(); }
public void ContentEditor_CreateContent_Method_No_Parameters_Simple_Call_Test() { // Arrange var contentEditor = new ContentEditor(); // Act, Assert Should.Throw <Exception>(actual: () => contentEditor.CreateContent()); }
public TreeListFieldContext([NotNull] ContentEditor contentEditor, [NotNull] ItemUri itemUri) { Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); Assert.ArgumentNotNull(itemUri, nameof(itemUri)); ContentEditor = contentEditor; ItemUri = itemUri; }
public FrameworkElement Render(ContentEditor contentEditor) { Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); ContentEditor = contentEditor; return(this); }
public static AppearanceOptions GetAppearanceOptions([NotNull] ContentEditor contentEditor) { Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); var descriptor = GetAppearanceDescriptor(contentEditor.ContentModel); return(descriptor.GetAppearanceOptions(contentEditor)); }
void ContentEditor_IsEnabledChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e) { // Maintain focus on the text editor. if ((bool)e.NewValue) { Dispatcher.BeginInvoke(new Action(() => ContentEditor.Focus())); } }
private void cleanEditor() { if (_editor == null) { return; } Destroy(_editor.Base.gameObject); _editor = null; }
public void DoPreloadWork() { ContentEditorProxy.ApplyInstalledCulture(); SimpleHtmlParser.Create(); BlogClientHelper.FormatUrl("", "", "", ""); ContentEditor contentEditor = new ContentEditor(null, new Panel(), null, new BlogPostHtmlEditorControl.BlogPostHtmlEditorSecurityManager(), new ContentEditorProxy.ContentEditorTemplateStrategy(), MshtmlOptions.DEFAULT_DLCTL); contentEditor.Dispose(); }
public void Load([NotNull] ContentEditor editor) { Assert.ArgumentNotNull(editor, nameof(editor)); contentEditor = editor; RenderTitle(); RenderPanes(); }
public void PublishItemContentEditor() { ContentEditor.SendKeys(Keys.Alt + 'p'); PublishButton.Click(); ModalButton.Click(); ModalButton.Click(); }
public ValidatorContext([NotNull] ValidatorMarker validatorMarker, [NotNull] ContentEditor contentEditor, [CanBeNull] Validator validator) { Assert.ArgumentNotNull(validatorMarker, nameof(validatorMarker)); Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); ValidatorMarker = validatorMarker; ContentEditor = contentEditor; Validator = validator; }
private Control RenderCheckBox([NotNull] Grid grid, [NotNull] Field field, int count) { Debug.ArgumentNotNull(grid, nameof(grid)); Debug.ArgumentNotNull(field, nameof(field)); var fieldControl = field.Control; if (fieldControl == null) { return(null); } var control = fieldControl.GetControl() as ContentControl; if (control == null) { return(null); } control.VerticalAlignment = VerticalAlignment.Top; var label = new Default.Label { ShowColon = false, ContentEditor = ContentEditor, Field = field, VerticalAlignment = VerticalAlignment.Center, }; control.Content = label; var border = new Border { Margin = new Thickness(8, 0, 8, 12), Child = control }; border.GotKeyboardFocus += (sender, args) => ContentEditor.UpdateContextualRibbon(field); grid.Children.Add(border); var row = count / 2 * 2 + 1; var column = count % 2; border.SetValue(Grid.RowProperty, row); border.SetValue(Grid.ColumnProperty, column); if (column == 0) { grid.RowDefinitions.Add(new RowDefinition()); } borders[field] = border; return(fieldControl.GetFocusableControl()); }
/// <summary> /// Initializes the IContentEditor. /// </summary> /// <param name="factory"></param> /// <param name="contentEditorSite"></param> /// <param name="internetSecurityManager"></param> /// <param name="wysiwygHTML"></param> /// <param name="previewHTML"></param> /// <param name="newEditingContext"></param> /// <param name="templateStrategy"></param> /// <param name="dlControlFlags"> /// For Mail, these flags should always include DLCTL_DLIMAGES | DLCTL_VIDEOS | DLCTL_BGSOUNDS so that local /// images, videos and sounds are loaded. To block external content, it should also include /// DLCTL_PRAGMA_NO_CACHE | DLCTL_FORCEOFFLINE | DLCTL_NO_CLIENTPULL so that external images are not loaded /// and are displayed as a red X instead. /// </param> /// <param name="color"></param> private void ContentEditorProxyCore(ContentEditorFactory factory, IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, string wysiwygHTML, string previewHTML, IBlogPostEditingContext newEditingContext, BlogPostHtmlEditorControl.TemplateStrategy templateStrategy, int dlControlFlags, string color) { try { Debug.Assert(contentEditorSite is IUIFramework, "IContentEditorSite must also implement IUIFramework"); Debug.Assert(contentEditorSite is IDropTarget, "IContentEditorSite must also implement IDropTarget"); ApplyInstalledCulture(); this.factory = factory; _wysiwygHTML = wysiwygHTML; _previewHTML = previewHTML; _contentEditorSite = contentEditorSite; IntPtr p = _contentEditorSite.GetWindowHandle(); WINDOWINFO info = new WINDOWINFO(); User32.GetWindowInfo(p, ref info); panel = new Panel(); panel.Top = 0; panel.Left = 0; panel.Width = Math.Max(info.rcWindow.Width, 200); panel.Height = Math.Max(info.rcWindow.Height, 200); panel.CreateControl(); User32.SetParent(panel.Handle, p); accountAdapter = new ContentEditorAccountAdapter(); mainFrame = new MainFrameWindowAdapter(p, panel, _contentEditorSite, accountAdapter.Id); context = newEditingContext; contentEditor = new ContentEditor(mainFrame, panel, mainFrame, internetSecurityManager, templateStrategy, dlControlFlags); // Prevents asserts contentEditor.DisableSpelling(); contentEditor.OnEditorAccountChanged(accountAdapter); contentEditor.DocumentComplete += new EventHandler(blogPostHtmlEditor_DocumentComplete); contentEditor.GotFocus += new EventHandler(contentEditor_GotFocus); contentEditor.LostFocus += new EventHandler(contentEditor_LostFocus); contentEditor.Initialize(context, accountAdapter, wysiwygHTML, previewHTML, false); if (!string.IsNullOrEmpty(color)) { contentEditor.IndentColor = color; } this.factory.GlobalSpellingOptionsChanged += GlobalSpellingOptionsChangedHandler; } catch (Exception ex) { // Something went wrong, make sure we don't reuse a cached editor HtmlEditorControl.DisposeCachedEditor(); Trace.Fail(ex.ToString()); Trace.Flush(); throw; } }
private void createEditor() { if (_current.Volume.Data.Content == null) { return; } _editor = _factory.Create(_current.Volume.Data); _editor.Base.SetParent(_hook, false); _editor.Base.localScale = Vector3.one; }
public void SetValidator([NotNull] ContentEditor contentEditor, [NotNull] Validator validator) { Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); Assert.ArgumentNotNull(validator, nameof(validator)); ContentEditor = contentEditor; this.validator = validator; Result = this.validator.Result; Text = this.validator.Text; }
public SaveItemPipeline WithParameters([NotNull] ContentModel contentModel, [NotNull] ContentEditor editor, bool postMacro) { Assert.ArgumentNotNull(contentModel, nameof(contentModel)); Assert.ArgumentNotNull(editor, nameof(editor)); ContentModel = contentModel; Editor = editor; PostMacro = postMacro; return(Start()); }
public void ContentEditor_CreateContent_Method_No_Parameters_2_Calls_Test() { // Arrange var contentEditor = new ContentEditor(); // Act Func <int> createContent = () => contentEditor.CreateContent(); // Assert Should.Throw <Exception>(actual: () => createContent.Invoke()); }
public static AppearanceOptions GetDefaultAppearanceOptions([NotNull] ContentEditor contentEditor) { Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); var appearance = new AppearanceOptions { SkinName = AppHost.Settings.Options.Skin ?? string.Empty, Panels = new List <IPanel>(), ContentEditor = contentEditor }; return(appearance); }
public bool CanRender(ContentEditor contentEditor) { Assert.ArgumentNotNull(contentEditor, nameof(contentEditor)); var contentModel = contentEditor.ContentModel; if (!contentModel.IsSingle) { return(false); } return(true); }
public void ContentEditor_CreateSurveyBlast_Method_2_Parameters_2_Calls_Test() { // Arrange var sender = Fixture.Create <object>(); var e = Fixture.Create <EventArgs>(); var contentEditor = new ContentEditor(); // Act Action createSurveyBlast = () => contentEditor.CreateSurveyBlast(sender, e); // Assert Should.Throw <Exception>(actual: () => createSurveyBlast.Invoke()); }
private void AddCode(string code) { ContentEditor.SelectionLength = 0; var formattedCode = code.Replace("\\r", Environment.NewLine) + Environment.NewLine + Environment.NewLine; Clipboard.SetText(formattedCode); ContentEditor.Paste(); this.SaveAndRefreshDiagram(); }
public void ContentEditor_GetTextFromHTML_Method_2_Parameters_2_Calls_Test() { // Arrange var sender = Fixture.Create <object>(); var e = Fixture.Create <EventArgs>(); var contentEditor = new ContentEditor(); // Act Action getTextFromHtml = () => contentEditor.GetTextFromHTML(sender, e); // Assert Should.Throw <Exception>(actual: () => getTextFromHtml.Invoke()); }
private Control RenderControl([NotNull] Grid grid, [NotNull] Field field, int count) { Assert.ArgumentNotNull(grid, nameof(grid)); Assert.ArgumentNotNull(field, nameof(field)); if (string.Compare(field.ActualFieldType, @"checkbox", StringComparison.InvariantCultureIgnoreCase) == 0 || string.Compare(field.ActualFieldType, @"tristate", StringComparison.InvariantCultureIgnoreCase) == 0) { return(RenderCheckBox(grid, field, count)); } var fieldControl = field.Control; if (fieldControl == null) { return(null); } RenderLabel(grid, field, count); var control = fieldControl.GetControl(); control.VerticalAlignment = VerticalAlignment.Top; var border = new Border { Margin = new Thickness(8, 0, 8, 12), Child = control }; border.GotKeyboardFocus += (sender, args) => ContentEditor.UpdateContextualRibbon(field); grid.Children.Add(border); var row = count / 2 * 2 + 1; var column = count % 2; border.SetValue(Grid.RowProperty, row); border.SetValue(Grid.ColumnProperty, column); if (column == 0) { grid.RowDefinitions.Add(new RowDefinition()); } borders[field] = border; return(fieldControl.GetFocusableControl()); }
private Control RenderCheckBox([NotNull] StackPanel section, [NotNull] Field field) { Debug.ArgumentNotNull(section, nameof(section)); Debug.ArgumentNotNull(field, nameof(field)); var fieldControl = field.Control; if (fieldControl == null) { return(null); } var control = fieldControl.GetControl() as ContentControl; if (control == null) { return(null); } control.VerticalContentAlignment = VerticalAlignment.Center; var label = new Default.Label { ShowColon = false, ContentEditor = ContentEditor, Field = field, VerticalAlignment = VerticalAlignment.Center, }; control.Content = label; var border = new Border { Margin = new Thickness(8, 12, 8, 12), Child = control }; border.GotKeyboardFocus += (sender, args) => ContentEditor.UpdateContextualRibbon(field); section.Children.Add(border); borders[field] = border; return(fieldControl.GetFocusableControl()); }
private void SetLanguage([NotNull] object sender, [NotNull] SelectionChangedEventArgs e) { Debug.ArgumentNotNull(sender, nameof(sender)); Debug.ArgumentNotNull(e, nameof(e)); if (IsLoading) { return; } var listBoxItem = Languages.SelectedItem as ListBoxItem; if (listBoxItem == null) { return; } var language = listBoxItem.Tag as string; if (string.IsNullOrEmpty(language)) { return; } var contentModel = ContentEditor.ContentModel; if (contentModel.IsEmpty) { return; } if (contentModel.IsMultiple) { return; } LanguageManager.CurrentLanguage = new Language(language); var list = new List <ItemVersionUri> { new ItemVersionUri(contentModel.FirstItem.Uri.ItemUri, new Language(language), Version.Latest) }; ContentEditor.LoadItems(list, new LoadItemsOptions(true)); }
/// <summary> /// Scans the DOM for images that have not yet been properly initialized by the editor. /// As part of the initialization, the default image settings and effects will be applied to the image. /// </summary> internal static void ScanAndInitializeNewImages(IBlogPostHtmlEditor currentEditor, ISupportingFileService fileService, IEditorAccount editorAccount, ContentEditor editor, Control owner, bool useDefaultTargetSettings, bool selectLastImage) { if (currentEditor is BlogPostHtmlEditorControl) { // Scanning the images and doing basic initialization is done on the UI thread. List<NewImageInfo> newImages = ScanImages(currentEditor, editorAccount, editor, useDefaultTargetSettings); if (newImages.Count > 0) { // The time-consuming initialization is done in a background thread. ImageInitializationAsyncOperation imageInitializer = new ImageInitializationAsyncOperation(newImages, fileService, owner); imageInitializer.Completed += new EventHandler((sender, e) => ProcessInitializedImages(newImages, currentEditor, editor, owner, selectLastImage)); editor.DisposeOnEditorChange(imageInitializer); imageInitializer.Start(); } } }
private static void ProcessInitializedImages(List<NewImageInfo> newImages, IBlogPostHtmlEditor currentEditor, ContentEditor editor, Control owner, bool selectLastImage) { // Remove all invalid images first List<NewImageInfo> newImagesToUpdate = new List<NewImageInfo>(); for (int i = 0; i < newImages.Count; i++) { NewImageInfo info = newImages[i]; if (info.Remove) { using (ContentEditor.EditorUndoUnit undo = new ContentEditor.EditorUndoUnit(currentEditor, true)) { info.DisabledImageBehavior.DetachFromElement(); HTMLElementHelper.RemoveElement(info.Element); undo.Commit(); } } else { newImagesToUpdate.Add(info); } } // Queue up processing for any remaining valid images MultiTaskHelper tasks = new MultiTaskHelper(30); for (int i = 0; i < newImagesToUpdate.Count; i++) { bool lastElement = i == (newImagesToUpdate.Count - 1); NewImageInfo info = newImagesToUpdate[i]; tasks.AddWork(delegate { // WinLive 214012: If the original insertion operation is undone before we get to this point make // sure we don't attempt to update the HTML. Elements that are removed via an undo, but that we // still hold a reference to, are put into another document whose readyState is "uninitialized". // It's also possible that the picture has already been updated if a user undoes and redoes the // initial insertion multiple times. IHTMLDocument2 doc = (IHTMLDocument2)info.Element.document; if (doc == null || doc.readyState.Equals("uninitialized", StringComparison.OrdinalIgnoreCase) || BlogPostImageDataList.LookupImageDataByInlineUri(editor.ImageList, info.ImageData.InlineImageFile.Uri) != null) { info.DisabledImageBehavior.DetachFromElement(); return; } using (new QuickTimer("ProcessInitializedImage")) using (ContentEditor.EditorUndoUnit undo = new ContentEditor.EditorUndoUnit(currentEditor, true)) { editor.ImageList.AddImage(info.ImageData); info.Element.setAttribute("src", UrlHelper.SafeToAbsoluteUri(info.ImageData.InlineImageFile.Uri), 0); info.Element.removeAttribute("srcDelay", 0); // Create the decorators ImageEditingPropertyHandler.UpdateImageSource(info.ImageInfo, info.Element, editor, new ImageInsertHandler(), ImageDecoratorInvocationSource.InitialInsert); // Manually detach the behavior so that the image can be selected and resized. info.DisabledImageBehavior.DetachFromElement(); if (lastElement) { ApplicationPerformance.EndEvent("InsertImage"); HandleNewImage((BlogPostHtmlEditorControl)currentEditor, owner, info.Element, selectLastImage); } undo.Commit(); if (editor.ETWProvider != null) editor.ETWProvider.WriteEvent("InlinePhotoEnd"); } }); } // If there were no images to update, stop the perf timer if (newImagesToUpdate.Count == 0) { ApplicationPerformance.EndEvent("InsertImage"); } // When the editor is closing, or changing to a new blog post we need to get rid of this object // which will then stop all the unfinished images from continuing to load. editor.DisposeOnEditorChange(tasks); tasks.Start(); }
private static List<NewImageInfo> ScanImages(IBlogPostHtmlEditor currentEditor, IEditorAccount editorAccount, ContentEditor editor, bool useDefaultTargetSettings) { List<NewImageInfo> newImages = new List<NewImageInfo>(); ApplicationPerformance.ClearEvent("InsertImage"); ApplicationPerformance.StartEvent("InsertImage"); using (new WaitCursor()) { IHTMLElement2 postBodyElement = (IHTMLElement2)((BlogPostHtmlEditorControl)currentEditor).PostBodyElement; if (postBodyElement != null) { foreach (IHTMLElement imgElement in postBodyElement.getElementsByTagName("img")) { string imageSrc = imgElement.getAttribute("srcDelay", 2) as string; if (string.IsNullOrEmpty(imageSrc)) { imageSrc = imgElement.getAttribute("src", 2) as string; } // WinLive 96840 - Copying and pasting images within shared canvas should persist source // decorator settings. "wlCopySrcUrl" is inserted while copy/pasting within canvas. bool copyDecoratorSettings = false; string attributeCopySrcUrl = imgElement.getAttribute("wlCopySrcUrl", 2) as string; if (!string.IsNullOrEmpty(attributeCopySrcUrl)) { copyDecoratorSettings = true; imgElement.removeAttribute("wlCopySrcUrl", 0); } // Check if we need to apply default values for image decorators bool applyDefaultDecorator = true; string attributeNoDefaultDecorator = imgElement.getAttribute("wlNoDefaultDecorator", 2) as string; if (!string.IsNullOrEmpty(attributeNoDefaultDecorator) && string.Compare(attributeNoDefaultDecorator, "TRUE", StringComparison.OrdinalIgnoreCase) == 0) { applyDefaultDecorator = false; imgElement.removeAttribute("wlNoDefaultDecorator", 0); } string applyDefaultMargins = imgElement.getAttribute("wlApplyDefaultMargins", 2) as string; if (!String.IsNullOrEmpty(applyDefaultMargins)) { DefaultImageSettings defaultImageSettings = new DefaultImageSettings(editorAccount.Id, editor.DecoratorsManager); MarginStyle defaultMargin = defaultImageSettings.GetDefaultImageMargin(); // Now apply it to the image imgElement.style.marginTop = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Top); imgElement.style.marginLeft = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Left); imgElement.style.marginBottom = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Bottom); imgElement.style.marginRight = String.Format(CultureInfo.InvariantCulture, "{0} px", defaultMargin.Right); imgElement.removeAttribute("wlApplyDefaultMargins", 0); } if ((UrlHelper.IsFileUrl(imageSrc) || IsFullPath(imageSrc)) && !ContentSourceManager.IsSmartContent(imgElement)) { Uri imageSrcUri = new Uri(imageSrc); try { BlogPostImageData imageData = BlogPostImageDataList.LookupImageDataByInlineUri(editor.ImageList, imageSrcUri); Emoticon emoticon = EmoticonsManager.GetEmoticon(imgElement); if (imageData == null && emoticon != null) { // This is usually an emoticon copy/paste and needs to be cleaned up. Uri inlineImageUri = editor.EmoticonsManager.GetInlineImageUri(emoticon); imgElement.setAttribute("src", UrlHelper.SafeToAbsoluteUri(inlineImageUri), 0); } else if (imageData == null) { if (!File.Exists(imageSrcUri.LocalPath)) throw new FileNotFoundException(imageSrcUri.LocalPath); // WinLive 188841: Manually attach the behavior so that the image cannot be selected or resized while its loading. DisabledImageElementBehavior disabledImageBehavior = new DisabledImageElementBehavior(editor.IHtmlEditorComponentContext); disabledImageBehavior.AttachToElement(imgElement); Size sourceImageSize = ImageUtils.GetImageSize(imageSrcUri.LocalPath); ImagePropertiesInfo imageInfo = new ImagePropertiesInfo(imageSrcUri, sourceImageSize, new ImageDecoratorsList(editor.DecoratorsManager, new BlogPostSettingsBag())); DefaultImageSettings defaultImageSettings = new DefaultImageSettings(editorAccount.Id, editor.DecoratorsManager); // Make sure this is set because some imageInfo properties depend on it. imageInfo.ImgElement = imgElement; bool isMetafile = ImageHelper2.IsMetafile(imageSrcUri.LocalPath); ImageClassification imgClass = ImageHelper2.Classify(imageSrcUri.LocalPath); if (!isMetafile && ((imgClass & ImageClassification.AnimatedGif) != ImageClassification.AnimatedGif)) { // WinLive 96840 - Copying and pasting images within shared canvas should persist source // decorator settings. if (copyDecoratorSettings) { // Try to look up the original copied source image. BlogPostImageData imageDataOriginal = BlogPostImageDataList.LookupImageDataByInlineUri(editor.ImageList, new Uri(attributeCopySrcUrl)); if (imageDataOriginal != null && imageDataOriginal.GetImageSourceFile() != null) { // We have the original image reference, so lets make a clone of it. BlogPostSettingsBag originalBag = (BlogPostSettingsBag)imageDataOriginal.ImageDecoratorSettings.Clone(); ImageDecoratorsList originalDecoratorsList = new ImageDecoratorsList(editor.DecoratorsManager, originalBag); ImageFileData originalImageFileData = imageDataOriginal.GetImageSourceFile(); Size originalImageSize = new Size(originalImageFileData.Width, originalImageFileData.Height); imageInfo = new ImagePropertiesInfo(originalImageFileData.Uri, originalImageSize, originalDecoratorsList); } else { // There are probably decorators applied to the image, but in a different editor so we can't access them. // We probably don't want to apply any decorators to this image, so apply blank decorators and load the // image as full size so it looks like it did before. imageInfo.ImageDecorators = defaultImageSettings.LoadBlankLocalImageDecoratorsList(); imageInfo.InlineImageSizeName = ImageSizeName.Full; } } else if (applyDefaultDecorator) { imageInfo.ImageDecorators = defaultImageSettings.LoadDefaultImageDecoratorsList(); if ((imgClass & ImageClassification.TransparentGif) == ImageClassification.TransparentGif) imageInfo.ImageDecorators.AddDecorator(NoBorderDecorator.Id); } else { // Don't use default values for decorators imageInfo.ImageDecorators = defaultImageSettings.LoadBlankLocalImageDecoratorsList(); imageInfo.InlineImageSizeName = ImageSizeName.Full; } } else { ImageDecoratorsList decorators = new ImageDecoratorsList(editor.DecoratorsManager, new BlogPostSettingsBag()); decorators.AddDecorator(editor.DecoratorsManager.GetDefaultRemoteImageDecorators()); imageInfo.ImageDecorators = decorators; } imageInfo.ImgElement = imgElement; imageInfo.DhtmlImageViewer = editorAccount.EditorOptions.DhtmlImageViewer; //discover the "natural" target settings from the DOM string linkTargetUrl = imageInfo.LinkTargetUrl; if (linkTargetUrl == imageSrc) { imageInfo.LinkTarget = LinkTargetType.IMAGE; } else if (!String.IsNullOrEmpty(linkTargetUrl) && !UrlHelper.IsFileUrl(linkTargetUrl)) { imageInfo.LinkTarget = LinkTargetType.URL; } else { imageInfo.LinkTarget = LinkTargetType.NONE; } if (useDefaultTargetSettings) { if (!GlobalEditorOptions.SupportsFeature(ContentEditorFeature.SupportsImageClickThroughs) && imageInfo.DefaultLinkTarget == LinkTargetType.IMAGE) imageInfo.DefaultLinkTarget = LinkTargetType.NONE; if (imageInfo.LinkTarget == LinkTargetType.NONE) imageInfo.LinkTarget = imageInfo.DefaultLinkTarget; if (imageInfo.DefaultLinkOptions.ShowInNewWindow) imageInfo.LinkOptions.ShowInNewWindow = true; imageInfo.LinkOptions.UseImageViewer = imageInfo.DefaultLinkOptions.UseImageViewer; imageInfo.LinkOptions.ImageViewerGroupName = imageInfo.DefaultLinkOptions.ImageViewerGroupName; } Size defaultImageSize = defaultImageSettings.GetDefaultInlineImageSize(); Size initialSize = ImageUtils.GetScaledImageSize(defaultImageSize.Width, defaultImageSize.Height, sourceImageSize); // add to list of new images newImages.Add(new NewImageInfo(imageInfo, imgElement, initialSize, disabledImageBehavior)); } else { // When switching blogs, try to adapt image viewer settings according to the blog settings. ImagePropertiesInfo imageInfo = new ImagePropertiesInfo(imageSrcUri, ImageUtils.GetImageSize(imageSrcUri.LocalPath), new ImageDecoratorsList(editor.DecoratorsManager, imageData.ImageDecoratorSettings)); imageInfo.ImgElement = imgElement; // Make sure the new crop and tilt decorators get loaded imageInfo.ImageDecorators.MergeDecorators(DefaultImageSettings.GetImplicitLocalImageDecorators()); string viewer = imageInfo.DhtmlImageViewer; if (viewer != editorAccount.EditorOptions.DhtmlImageViewer) { imageInfo.DhtmlImageViewer = editorAccount.EditorOptions.DhtmlImageViewer; imageInfo.LinkOptions = imageInfo.DefaultLinkOptions; } // If the image is an emoticon, update the EmoticonsManager with the image's uri so that duplicate emoticons can point to the same file. if (emoticon != null) editor.EmoticonsManager.SetInlineImageUri(emoticon, imageData.InlineImageFile.Uri); } } catch (ArgumentException e) { Trace.WriteLine("Could not initialize image: " + imageSrc); Trace.WriteLine(e.ToString()); } catch (DirectoryNotFoundException) { Debug.WriteLine("Image file does not exist: " + imageSrc); } catch (FileNotFoundException) { Debug.WriteLine("Image file does not exist: " + imageSrc); } catch (IOException e) { Debug.WriteLine("Image file cannot be read: " + imageSrc + " " + e); DisplayMessage.Show(MessageId.FileInUse, imageSrc); } } } } } return newImages; }