コード例 #1
0
        public override void OnResizeStart(ISmartContent content, ResizeOptions options)
        {
            //force the resize operation to scale based on the size of the map image.
            MapSettings settings = new MapSettings(content.Properties);

            options.ResizeableElementId = settings.MapId;
        }
コード例 #2
0
        public override DialogResult CreateContent(IWin32Window dialogOwner, ISmartContent content)
        {
            using (new WaitCursor())
            {
                if (!MapForm.ValidateLiveLocalConnection(true))
                {
                    return(DialogResult.Cancel);
                }

                using (MapForm mapForm = new MapForm(true, _pluginOptions, ((ICommandManagerHost)dialogOwner).CommandManager))
                {
                    mapForm.LoadMap(-0.3515603f, 0.3515625f, null, "r", 1, null);
                    if (mapForm.ShowDialog(dialogOwner) == DialogResult.OK)
                    {
                        MapSettings settings = new MapSettings(content.Properties);
                        settings.MapId = "map-" + Guid.NewGuid().ToString();
                        settings.UpdateSettings(mapForm.Latitude, mapForm.Longitude, mapForm.Reserved, mapForm.ZoomLevel, mapForm.MapStyle, mapForm.Pushpins, mapForm.BirdseyeScene);
                        _pluginOptions.DefaultDialogSize = mapForm.Size;

                        return(DialogResult.OK);
                    }
                    else
                    {
                        return(DialogResult.Cancel);
                    }
                }
            }
        }
コード例 #3
0
        public override DialogResult CreateContent(IWin32Window dialogOwner, ISmartContent content)
        {
            using (new WaitCursor())
            {
                if (!MapForm.ValidateLiveLocalConnection(true))
                    return DialogResult.Cancel;

                using (MapForm mapForm = new MapForm(true, _pluginOptions, ((ICommandManagerHost)dialogOwner).CommandManager))
                {
                    mapForm.LoadMap(-0.3515603f, 0.3515625f, null, "r", 1, null);
                    if (mapForm.ShowDialog(dialogOwner) == DialogResult.OK)
                    {
                        MapSettings settings = new MapSettings(content.Properties);
                        settings.MapId = "map-" + Guid.NewGuid().ToString();
                        settings.UpdateSettings(mapForm.Latitude, mapForm.Longitude, mapForm.Reserved, mapForm.ZoomLevel, mapForm.MapStyle, mapForm.Pushpins, mapForm.BirdseyeScene);
                        _pluginOptions.DefaultDialogSize = mapForm.Size;

                        return DialogResult.OK;
                    }
                    else
                    {
                        return DialogResult.Cancel;
                    }
                }
            }
        }
コード例 #4
0
        public Size GetDefaultMapSize(string blogId)
        {
            IProperties blogProps     = GetBlogSettings(blogId);
            int         defaultWidth  = blogProps.GetInt(DEFAULT_MAP_WIDTH, DefaultMapSize.Width);
            int         defaultHeight = blogProps.GetInt(DEFAULT_MAP_HEIGHT, DefaultMapSize.Height);

            return(MapSettings.EnsurePositiveSize(new Size(defaultWidth, defaultHeight), DefaultMapSize));
        }
コード例 #5
0
        private string GenerateHtml(ISmartContent content, bool editor, string blogId)
        {
            MapSettings settings = new MapSettings(content.Properties);

            settings.PublishTargetId = blogId;

            Uri imageUri = content.Files.GetUri(settings.ImageFileId);

            if (imageUri == null)
            {
                //try to regenerate the image using the default size for blog
                Size mapSize = _pluginOptions.GetDefaultMapSize(blogId);
                UpdateMapImage(content, settings, mapSize);
                settings.Size = mapSize;

                imageUri = content.Files.GetUri(settings.ImageFileId);
            }

            string imgAltText = Res.Get(StringId.MapImageAltText);

            if (settings.Caption != String.Empty)
            {
                imgAltText = settings.Caption;
            }

            string imageHtml = settings.Caption;

            if (imageUri != null)
            {
                Size   mapSize   = settings.Size;
                string sizeAttrs = mapSize != Size.Empty
                                                        ? String.Format(CultureInfo.InvariantCulture, " width=\"{0}\" height=\"{1}\"", mapSize.Width, mapSize.Height) : "";
                imageHtml = String.Format(CultureInfo.InvariantCulture, "<img src=\"{0}\"{1} alt=\"{2}\">", HtmlServices.HtmlEncode(imageUri.ToString()), sizeAttrs, HtmlServices.HtmlEncode(imgAltText));
            }
            else
            {
                if (imageHtml.Equals(String.Empty))
                {
                    imageHtml = Res.Get(StringId.ViewMap);
                }
            }

            string clickToViewAttr = editor ? "" : String.Format(CultureInfo.InvariantCulture, " alt=\"{0}\" title=\"{0}\"", clickToViewText);
            string mapHtml         = String.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\" id=\"{2}\"{3}>{1}</a>",
                                                   HtmlServices.HtmlEncode(settings.LiveMapUrl), imageHtml, settings.MapId, clickToViewAttr);

            if (imageUri != null && settings.Caption != String.Empty)
            {
                //append the caption HTML
                mapHtml += String.Format(CultureInfo.InvariantCulture, _pluginOptions.CaptionHtmlFormat, HtmlServices.HtmlEncode(settings.Caption), settings.MapId);
            }
            return(mapHtml);
        }
コード例 #6
0
        public override void OnResizeComplete(ISmartContent content, Size newSize)
        {
            //don't allow the size to be smaller than the min size (fixes bug 398580)
            newSize.Width = Math.Max(newSize.Width, MIN_MAP_SIZE.Width);
            newSize.Height = Math.Max(newSize.Height, MIN_MAP_SIZE.Height);

            MapSettings settings = new MapSettings(content.Properties);
            UpdateMapImage(content, settings, newSize);
            settings.Size = newSize;

            if (settings.PublishTargetId != null)
                _pluginOptions.SetDefaultMapSize(settings.PublishTargetId, newSize);
        }
コード例 #7
0
        protected override void OnSelectedContentChanged()
        {
            base.OnSelectedContentChanged();

            _mapSettings = new MapSettings(SelectedContent.Properties);
            sidebarHeaderControl1.LinkUrl = _mapSettings.LiveMapUrl;

            // update the settings UI
            InitializeOptionsUI();

            // force a layout for dynamic control flow
            PerformLayout();
            RefreshLayout();
        }
コード例 #8
0
        private string GenerateHtml(ISmartContent content, bool editor, string blogId)
        {
            MapSettings settings = new MapSettings(content.Properties);
            settings.PublishTargetId = blogId;

            Uri imageUri = content.Files.GetUri(settings.ImageFileId);

            if (imageUri == null)
            {
                //try to regenerate the image using the default size for blog
                Size mapSize = _pluginOptions.GetDefaultMapSize(blogId);
                UpdateMapImage(content, settings, mapSize);
                settings.Size = mapSize;

                imageUri = content.Files.GetUri(settings.ImageFileId);
            }

            string imgAltText = Res.Get(StringId.MapImageAltText);
            if (settings.Caption != String.Empty)
                imgAltText = settings.Caption;

            string imageHtml = settings.Caption;
            if (imageUri != null)
            {
                Size mapSize = settings.Size;
                string sizeAttrs = mapSize != Size.Empty
                                       ? String.Format(CultureInfo.InvariantCulture, " width=\"{0}\" height=\"{1}\"", mapSize.Width, mapSize.Height) : "";
                imageHtml = String.Format(CultureInfo.InvariantCulture, "<img src=\"{0}\"{1} alt=\"{2}\">", HtmlServices.HtmlEncode(imageUri.ToString()), sizeAttrs, HtmlServices.HtmlEncode(imgAltText));
            }
            else
            {
                if (imageHtml.Equals(String.Empty))
                {
                    imageHtml = Res.Get(StringId.ViewMap);
                }
            }

            string clickToViewAttr = editor ? "" : String.Format(CultureInfo.InvariantCulture, " alt=\"{0}\" title=\"{0}\"", clickToViewText);
            string mapHtml = String.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\" id=\"{2}\"{3}>{1}</a>",
                HtmlServices.HtmlEncode(settings.LiveMapUrl), imageHtml, settings.MapId, clickToViewAttr);
            if (imageUri != null && settings.Caption != String.Empty)
            {
                //append the caption HTML
                mapHtml += String.Format(CultureInfo.InvariantCulture, _pluginOptions.CaptionHtmlFormat, HtmlServices.HtmlEncode(settings.Caption), settings.MapId);
            }
            return mapHtml;
        }
コード例 #9
0
        internal static void UpdateMapImage(ISmartContent content, MapSettings settings, Size newSize)
        {
            if (settings.MapImageInvalidated)
            {
                settings.MapImageInvalidated = false;
                float           latitude   = settings.Latitude;
                float           longitude  = settings.Longitude;
                string          reserved   = settings.Reserved;
                int             zoomLevel  = settings.ZoomLevel;
                string          style      = settings.MapStyle;
                string          sceneId    = settings.BirdseyeSceneId;
                VEBirdseyeScene scene      = sceneId != null ? new VEBirdseyeScene(sceneId, settings.BirdseyeOrientation) : null;
                string          previewUrl = MapUrlHelper.CreateMapUrl(LocalMapPreviewUrl, latitude, longitude, reserved, style, zoomLevel, settings.Pushpins, scene);

#pragma warning disable 612,618
                HtmlScreenCapture screenCapture = new HtmlScreenCapture(new Uri(previewUrl, true), newSize.Width);
#pragma warning restore 612,618

                screenCapture.HtmlDocumentAvailable += new OpenLiveWriter.Api.HtmlDocumentAvailableHandler(screenCapture_HtmlDocumentAvailable);
                screenCapture.MaximumHeight          = newSize.Height;
                Bitmap bitmap = screenCapture.CaptureHtml(45000);
                if (bitmap != null)
                {
                    try
                    {
                        if (content.Files.Contains(settings.ImageFileId))
                        {
                            content.Files.Remove(settings.ImageFileId);
                        }
                    }
                    catch (Exception e) { Debug.Fail(e.ToString()); }

                    //add the new map image (note that we use a new name to a bug in IE7 that prevents the editor
                    //from refreshing the image displayed in the browser (bug 287563)
                    string newGuid        = Guid.NewGuid().ToString();
                    string newImageFileId = "map-" + newGuid.Substring(newGuid.LastIndexOf("-", StringComparison.OrdinalIgnoreCase) + 1) + ".jpg";
                    settings.ImageFileId = newImageFileId;
                    content.Files.AddImage(settings.ImageFileId, bitmap, ImageFormat.Jpeg);
                }
                else
                {
                    Debug.WriteLine("Map image could not be regenerated.");
                }
            }
        }
コード例 #10
0
        public override void OnResizing(ISmartContent content, Size newSize)
        {
            MapSettings settings = new MapSettings(content.Properties);

            settings.Size = newSize;
        }
コード例 #11
0
        internal static void UpdateMapImage(ISmartContent content, MapSettings settings, Size newSize)
        {
            if (settings.MapImageInvalidated)
            {
                settings.MapImageInvalidated = false;
                float latitude = settings.Latitude;
                float longitude = settings.Longitude;
                string reserved = settings.Reserved;
                int zoomLevel = settings.ZoomLevel;
                string style = settings.MapStyle;
                string sceneId = settings.BirdseyeSceneId;
                VEBirdseyeScene scene = sceneId != null ? new VEBirdseyeScene(sceneId, settings.BirdseyeOrientation) : null;
                string previewUrl = MapUrlHelper.CreateMapUrl(LocalMapPreviewUrl, latitude, longitude, reserved, style, zoomLevel, settings.Pushpins, scene);

#pragma warning disable 612, 618
                HtmlScreenCapture screenCapture = new HtmlScreenCapture(new Uri(previewUrl, true), newSize.Width);
#pragma warning restore 612, 618

                screenCapture.HtmlDocumentAvailable += new OpenLiveWriter.Api.HtmlDocumentAvailableHandler(screenCapture_HtmlDocumentAvailable);
                screenCapture.MaximumHeight = newSize.Height;
                Bitmap bitmap = screenCapture.CaptureHtml(45000);
                if (bitmap != null)
                {
                    try
                    {
                        if (content.Files.Contains(settings.ImageFileId))
                            content.Files.Remove(settings.ImageFileId);
                    }
                    catch (Exception e) { Debug.Fail(e.ToString()); }

                    //add the new map image (note that we use a new name to a bug in IE7 that prevents the editor
                    //from refreshing the image displayed in the browser (bug 287563)
                    string newGuid = Guid.NewGuid().ToString();
                    string newImageFileId = "map-" + newGuid.Substring(newGuid.LastIndexOf("-", StringComparison.OrdinalIgnoreCase) + 1) + ".jpg";
                    settings.ImageFileId = newImageFileId;
                    content.Files.AddImage(settings.ImageFileId, bitmap, ImageFormat.Jpeg);
                }
                else
                {
                    Debug.WriteLine("Map image could not be regenerated.");
                }
            }
        }
コード例 #12
0
 public override void OnResizing(ISmartContent content, Size newSize)
 {
     MapSettings settings = new MapSettings(content.Properties);
     settings.Size = newSize;
 }
コード例 #13
0
 public override void OnResizeStart(ISmartContent content, ResizeOptions options)
 {
     //force the resize operation to scale based on the size of the map image.
     MapSettings settings = new MapSettings(content.Properties);
     options.ResizeableElementId = settings.MapId;
 }
コード例 #14
0
        protected override void OnSelectedContentChanged()
        {
            base.OnSelectedContentChanged();

            _mapSettings = new MapSettings(SelectedContent.Properties);
            sidebarHeaderControl1.LinkUrl = _mapSettings.LiveMapUrl;

            // update the settings UI
            InitializeOptionsUI();

            // force a layout for dynamic control flow
            PerformLayout();
            RefreshLayout();
        }