private DialogResult EditTargetOptions(LinkTargetType linkTargetType) { using (LinkToOptionsForm linkOptionsForm = new LinkToOptionsForm()) { if (linkTargetType == LinkTargetType.IMAGE) { using (ImageTargetEditorControl editor = new ImageTargetEditorControl()) { editor.LoadImageSize(ImagePropertiesInfo.LinkTargetImageSize, ImagePropertiesInfo.ImageSourceSize, ImagePropertiesInfo.ImageRotation); editor.LinkOptions = ImagePropertiesInfo.LinkOptions; editor.EditorOptions = _imageEditingContext.EditorOptions; linkOptionsForm.EditorControl = editor; ImagePropertiesInfo.DhtmlImageViewer = _imageEditingContext.EditorOptions.DhtmlImageViewer; DialogResult result = linkOptionsForm.ShowDialog(_editorContext.MainFrameWindow); if (result == DialogResult.OK) { ImagePropertiesInfo.LinkTargetImageSize = editor.ImageSize; ImagePropertiesInfo.DhtmlImageViewer = _imageEditingContext.EditorOptions.DhtmlImageViewer; ImagePropertiesInfo.LinkOptions = editor.LinkOptions; ImagePropertiesInfo.LinkTargetImageSizeName = editor.ImageBoundsSize; } return(result); } } else if (linkTargetType == LinkTargetType.URL) { using (HyperlinkForm hyperlinkForm = new HyperlinkForm(_editorContext.CommandManager, GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ShowAllLinkOptions))) { hyperlinkForm.ContainsImage = true; hyperlinkForm.EditStyle = !String.IsNullOrEmpty(ImagePropertiesInfo.LinkTargetUrl); hyperlinkForm.NewWindow = ImagePropertiesInfo.LinkOptions.ShowInNewWindow; if (ImagePropertiesInfo.LinkTitle != String.Empty) { hyperlinkForm.LinkTitle = ImagePropertiesInfo.LinkTitle; } if (ImagePropertiesInfo.LinkRel != String.Empty) { hyperlinkForm.Rel = ImagePropertiesInfo.LinkRel; } if (ImagePropertiesInfo.LinkTargetUrl != null && ImagePropertiesInfo.LinkTarget != LinkTargetType.IMAGE) { hyperlinkForm.Hyperlink = ImagePropertiesInfo.LinkTargetUrl; } DialogResult result = hyperlinkForm.ShowDialog(_editorContext.MainFrameWindow); if (result == DialogResult.OK) { ImagePropertiesInfo.LinkTargetUrl = hyperlinkForm.Hyperlink; ImagePropertiesInfo.UpdateImageLinkOptions(hyperlinkForm.LinkTitle, hyperlinkForm.Rel, hyperlinkForm.NewWindow); ImagePropertiesInfo.LinkOptions = new LinkOptions(hyperlinkForm.NewWindow, false, null); } return(result); } } return(DialogResult.Abort); } }
private void comboBoxLinkTargets_SelectedIndexChanged(object sender, EventArgs e) { if (suppressComboBoxLinkTargetsSelectionChanged) { return; } if (EditorState == ControlState.Loaded) { using (new WaitCursor()) { using (IImageDecoratorUndoUnit undo = EditorContext.CreateUndoUnit()) { bool commitChanges = true; LinkTargetType target = SelectedLinkTarget; if (target == LinkTargetType.URL && !comboBoxLinkTargets.DroppedDown) { ClearTargetSummaryLabel(); commitChanges = EditTargetOptions() == DialogResult.OK; } if (commitChanges) { HtmlImageTargetSettings.LinkTarget = target; SaveSettingsAndApplyDecorator(); //note: this is optionally committed because the EditTargetOptions() method //makes changes to the settings that persist in the DOM. This is bad and we should //stop doing that, and save in the OnSaveSettings() method instead. Then we won't //need this stupid optional commit. undo.Commit(); } else { //rollback to the previous selected item suppressComboBoxLinkTargetsSelectionChanged = true; try { comboBoxLinkTargets.SelectedItem = new OptionItem("", HtmlImageTargetSettings.LinkTarget); } finally { suppressComboBoxLinkTargetsSelectionChanged = false; } } } } } LoadTargetSummaryLabel(); buttonTargetOptions.Enabled = !SelectedLinkTarget.Equals(LinkTargetType.NONE); }
/// <summary> /// Returns a <see cref="string" /> that represents this instance. /// </summary> /// <param name="target">The target.</param> /// <returns> /// A <see cref="string" /> that represents this instance. /// </returns> public static string ToHtmlString(this LinkTargetType target) { switch (target) { case LinkTargetType.Blank: return("_blank"); case LinkTargetType.Self: return("_self"); default: return("_self"); } }
private void LoadLinkTargetsCombo() { LinkTargetType targetType = HtmlImageTargetSettings.LinkTarget; this.comboBoxLinkTargets.Items.Clear(); if (LinkToSourceImageEnabled) { comboBoxLinkTargets.Items.Add(new OptionItem(Res.Get(StringId.LinkToSource), LinkTargetType.IMAGE)); } comboBoxLinkTargets.Items.Add(new OptionItem(Res.Get(StringId.LinkToURL), LinkTargetType.URL)); comboBoxLinkTargets.Items.Add(new OptionItem(Res.Get(StringId.LinkToNone), LinkTargetType.NONE)); comboBoxLinkTargets.SelectedItem = new OptionItem("", targetType); //comboBoxLinkTargets.Visible = comboBoxLinkTargets.Items.Count > 1; }
void imageTargetSelectGalleryCommand_Execute(object sender, EventArgs args) { // By the time this is called we've already changed the dropdown // If user cancels then we need to restore previous dropdown selection. Command selectedCommand = (Command)sender; LinkTargetType newLinkTargetType = (LinkTargetType)selectedCommand.Tag; using (new WaitCursor()) using (IUndoUnit undo = _editorContext.CreateUndoUnit()) { if (newLinkTargetType == LinkTargetType.URL && EditTargetOptions(newLinkTargetType) != DialogResult.OK) { newLinkTargetType = ImagePropertiesInfo.LinkTarget; _imageLinkTargetDropdown.SelectTag(newLinkTargetType); } ImagePropertiesInfo.LinkTarget = newLinkTargetType; ApplyImageDecorations(); undo.Commit(); } }
private DialogResult EditTargetOptions(LinkTargetType linkTargetType) { using (LinkToOptionsForm linkOptionsForm = new LinkToOptionsForm()) { if (linkTargetType == LinkTargetType.IMAGE) { using (ImageTargetEditorControl editor = new ImageTargetEditorControl()) { editor.LoadImageSize(ImagePropertiesInfo.LinkTargetImageSize, ImagePropertiesInfo.ImageSourceSize, ImagePropertiesInfo.ImageRotation); editor.LinkOptions = ImagePropertiesInfo.LinkOptions; editor.EditorOptions = _imageEditingContext.EditorOptions; linkOptionsForm.EditorControl = editor; ImagePropertiesInfo.DhtmlImageViewer = _imageEditingContext.EditorOptions.DhtmlImageViewer; DialogResult result = linkOptionsForm.ShowDialog(_editorContext.MainFrameWindow); if (result == DialogResult.OK) { ImagePropertiesInfo.LinkTargetImageSize = editor.ImageSize; ImagePropertiesInfo.DhtmlImageViewer = _imageEditingContext.EditorOptions.DhtmlImageViewer; ImagePropertiesInfo.LinkOptions = editor.LinkOptions; ImagePropertiesInfo.LinkTargetImageSizeName = editor.ImageBoundsSize; } return result; } } else if (linkTargetType == LinkTargetType.URL) { using (HyperlinkForm hyperlinkForm = new HyperlinkForm(_editorContext.CommandManager, GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ShowAllLinkOptions))) { hyperlinkForm.ContainsImage = true; hyperlinkForm.EditStyle = !String.IsNullOrEmpty(ImagePropertiesInfo.LinkTargetUrl); hyperlinkForm.NewWindow = ImagePropertiesInfo.LinkOptions.ShowInNewWindow; if (ImagePropertiesInfo.LinkTitle != String.Empty) hyperlinkForm.LinkTitle = ImagePropertiesInfo.LinkTitle; if (ImagePropertiesInfo.LinkRel != String.Empty) hyperlinkForm.Rel = ImagePropertiesInfo.LinkRel; if (ImagePropertiesInfo.LinkTargetUrl != null && ImagePropertiesInfo.LinkTarget != LinkTargetType.IMAGE) { hyperlinkForm.Hyperlink = ImagePropertiesInfo.LinkTargetUrl; } DialogResult result = hyperlinkForm.ShowDialog(_editorContext.MainFrameWindow); if (result == DialogResult.OK) { ImagePropertiesInfo.LinkTargetUrl = hyperlinkForm.Hyperlink; ImagePropertiesInfo.UpdateImageLinkOptions(hyperlinkForm.LinkTitle, hyperlinkForm.Rel, hyperlinkForm.NewWindow); ImagePropertiesInfo.LinkOptions = new LinkOptions(hyperlinkForm.NewWindow, false, null); } return result; } } return DialogResult.Abort; } }
/// <summary> /// Initializes a new instance of the <see cref="Link"/> class. /// </summary> /// <param name="caption">The caption.</param> /// <param name="href">The url</param> public Link(string caption, string href) { Caption = caption; Href = href; Target = LinkTargetType.Self; }