示例#1
0
        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 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;
            }
        }