[mapguide-commits] r7994 - in trunk/Tools/Maestro: Maestro.Base/Events Maestro.Base/UI/Preferences Maestro.Editors Maestro.Editors/Preview Maestro.Editors/Properties Maestro.Editors/Resources
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Mar 21 06:36:59 PDT 2014
Author: jng
Date: 2014-03-21 06:36:59 -0700 (Fri, 21 Mar 2014)
New Revision: 7994
Added:
trunk/Tools/Maestro/Maestro.Editors/Resources/TextWatermark.txt
Modified:
trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs
trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs
trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs
trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs
trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
trunk/Tools/Maestro/Maestro.Editors/Preview/PreviewSettings.cs
trunk/Tools/Maestro/Maestro.Editors/Preview/ResourcePreviewEngine.cs
trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs
trunk/Tools/Maestro/Maestro.Editors/Strings.resx
Log:
#2413: Add debug watermark for Map Definitions generated for resource previews. The debug watermark contains extent and CS information about the map, something that's very useful when previewing layers to ascertain it has the right CS and bounds (as they would've been used to generate the preview Map Definition)
Modified: trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs 2014-03-21 13:36:59 UTC (rev 7994)
@@ -61,6 +61,10 @@
PreviewSettings.UseLocalPreview = Convert.ToBoolean(e.NewValue);
LoggingService.Info("Use Local Preview setting is now: " + PreviewSettings.UseLocalPreview); //NOXLATE
break;
+ case ConfigProperties.AddDebugWatermark:
+ PreviewSettings.AddDebugWatermark = Convert.ToBoolean(e.NewValue);
+ LoggingService.Info("Add Debug Watermark setting is now: " + PreviewSettings.AddDebugWatermark); //NOXLATE
+ break;
case ConfigProperties.PreviewViewerType:
PreviewSettings.UseAjaxViewer = (e.NewValue.ToString() == "AJAX"); //NOXLATE
LoggingService.Info("Use AJAX Viewer setting is now: " + PreviewSettings.UseAjaxViewer);
Modified: trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs 2014-03-21 13:36:59 UTC (rev 7994)
@@ -98,6 +98,11 @@
public const string UseLocalPreview = "Editor.UseLocalPreview"; //NOXLATE
/// <summary>
+ /// Add a debug watermark for any Map Definition generated for a resource preview
+ /// </summary>
+ public const string AddDebugWatermark = "Editor.AddDebugWatermark"; //NOXLATE
+
+ /// <summary>
/// Show the tip of the day on startup
/// </summary>
public const string ShowTipOfTheDay = "General.ShowTipOfTheDay"; //NOXLATE
@@ -170,6 +175,11 @@
/// Default setting for using local previews
/// </summary>
public static bool DefaultUseLocalPreview { get { return true; } }
+
+ /// <summary>
+ /// Default setting for adding debug watermarks
+ /// </summary>
+ public static bool DefaultAddDebugWatermark { get { return true; } }
/// <summary>
/// Default color for open resources in the Site Explorer
Modified: trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs 2014-03-21 13:36:59 UTC (rev 7994)
@@ -29,6 +29,7 @@
private void InitializeComponent()
{
this.groupBox4 = new System.Windows.Forms.GroupBox();
+ this.chkUseLocalPreview = new System.Windows.Forms.CheckBox();
this.chkValidateOnSave = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnBrowseXsdPath = new System.Windows.Forms.Button();
@@ -37,7 +38,7 @@
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.txtPreviewLocale = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
- this.chkUseLocalPreview = new System.Windows.Forms.CheckBox();
+ this.chkAddDebugWatermark = new System.Windows.Forms.CheckBox();
this.groupBox4.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
@@ -47,15 +48,26 @@
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
+ this.groupBox4.Controls.Add(this.chkAddDebugWatermark);
this.groupBox4.Controls.Add(this.chkUseLocalPreview);
this.groupBox4.Controls.Add(this.chkValidateOnSave);
this.groupBox4.Location = new System.Drawing.Point(3, 3);
this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(399, 50);
+ this.groupBox4.Size = new System.Drawing.Size(399, 78);
this.groupBox4.TabIndex = 10;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "General";
//
+ // chkUseLocalPreview
+ //
+ this.chkUseLocalPreview.AutoSize = true;
+ this.chkUseLocalPreview.Location = new System.Drawing.Point(134, 19);
+ this.chkUseLocalPreview.Name = "chkUseLocalPreview";
+ this.chkUseLocalPreview.Size = new System.Drawing.Size(257, 17);
+ this.chkUseLocalPreview.TabIndex = 3;
+ this.chkUseLocalPreview.Text = "Preview with local map viewer (where applicable)";
+ this.chkUseLocalPreview.UseVisualStyleBackColor = true;
+ //
// chkValidateOnSave
//
this.chkValidateOnSave.AutoSize = true;
@@ -74,7 +86,7 @@
this.groupBox1.Controls.Add(this.btnBrowseXsdPath);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.txtXsdPath);
- this.groupBox1.Location = new System.Drawing.Point(4, 60);
+ this.groupBox1.Location = new System.Drawing.Point(3, 87);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(398, 66);
this.groupBox1.TabIndex = 11;
@@ -119,7 +131,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.txtPreviewLocale);
this.groupBox2.Controls.Add(this.label1);
- this.groupBox2.Location = new System.Drawing.Point(4, 132);
+ this.groupBox2.Location = new System.Drawing.Point(3, 159);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(398, 60);
this.groupBox2.TabIndex = 12;
@@ -142,15 +154,16 @@
this.label1.TabIndex = 0;
this.label1.Text = "Preview using the following locale";
//
- // chkUseLocalPreview
+ // chkAddDebugWatermark
//
- this.chkUseLocalPreview.AutoSize = true;
- this.chkUseLocalPreview.Location = new System.Drawing.Point(134, 19);
- this.chkUseLocalPreview.Name = "chkUseLocalPreview";
- this.chkUseLocalPreview.Size = new System.Drawing.Size(257, 17);
- this.chkUseLocalPreview.TabIndex = 3;
- this.chkUseLocalPreview.Text = "Preview with local map viewer (where applicable)";
- this.chkUseLocalPreview.UseVisualStyleBackColor = true;
+ this.chkAddDebugWatermark.AutoSize = true;
+ this.chkAddDebugWatermark.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+ this.chkAddDebugWatermark.Location = new System.Drawing.Point(19, 42);
+ this.chkAddDebugWatermark.Name = "chkAddDebugWatermark";
+ this.chkAddDebugWatermark.Size = new System.Drawing.Size(290, 17);
+ this.chkAddDebugWatermark.TabIndex = 4;
+ this.chkAddDebugWatermark.Text = "Add Debug Watermark for generated resource previews";
+ this.chkAddDebugWatermark.UseVisualStyleBackColor = true;
//
// EditorPreferencesCtrl
//
@@ -183,5 +196,6 @@
private System.Windows.Forms.TextBox txtPreviewLocale;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox chkUseLocalPreview;
+ private System.Windows.Forms.CheckBox chkAddDebugWatermark;
}
}
Modified: trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs 2014-03-21 13:36:59 UTC (rev 7994)
@@ -38,6 +38,9 @@
var useLocal = Props.Get(ConfigProperties.UseLocalPreview, ConfigProperties.DefaultUseLocalPreview);
chkUseLocalPreview.Checked = useLocal;
+ var addWmd = Props.Get(ConfigProperties.AddDebugWatermark, ConfigProperties.DefaultAddDebugWatermark);
+ chkAddDebugWatermark.Checked = addWmd;
+
var path = Props.Get(ConfigProperties.XsdSchemaPath, ConfigProperties.DefaultXsdSchemaPath);
txtXsdPath.Text = path;
@@ -60,6 +63,7 @@
Apply(ConfigProperties.ValidateOnSave, chkValidateOnSave.Checked);
Apply(ConfigProperties.UseLocalPreview, chkUseLocalPreview.Checked);
+ Apply(ConfigProperties.AddDebugWatermark, chkAddDebugWatermark.Checked);
Apply(ConfigProperties.PreviewLocale, txtPreviewLocale.Text);
//These changes require restart
Modified: trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj 2014-03-21 13:36:59 UTC (rev 7994)
@@ -2324,6 +2324,7 @@
<Content Include="OdbcDriverMap.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
+ <None Include="Resources\TextWatermark.txt" />
<None Include="Resources\document-code.png" />
<None Include="Resources\document-search-result.png" />
<None Include="Resources\arrow-split.png" />
Modified: trunk/Tools/Maestro/Maestro.Editors/Preview/PreviewSettings.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Preview/PreviewSettings.cs 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Editors/Preview/PreviewSettings.cs 2014-03-21 13:36:59 UTC (rev 7994)
@@ -33,9 +33,16 @@
{
UseAjaxViewer = true;
UseLocalPreview = true;
+ AddDebugWatermark = true;
}
/// <summary>
+ /// Determines if a watermark will be added to the generated Map Definition which
+ /// displays additional debugging information
+ /// </summary>
+ public static bool AddDebugWatermark { get; set; }
+
+ /// <summary>
/// Determines if a local map viewer should be used over launching a viewer URL
/// </summary>
public static bool UseLocalPreview { get; set; }
Modified: trunk/Tools/Maestro/Maestro.Editors/Preview/ResourcePreviewEngine.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Preview/ResourcePreviewEngine.cs 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Editors/Preview/ResourcePreviewEngine.cs 2014-03-21 13:36:59 UTC (rev 7994)
@@ -27,6 +27,7 @@
using OSGeo.MapGuide.ObjectModels.WebLayout;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
@@ -116,6 +117,33 @@
return url;
}
+ static string CreateDebugWatermark(IMapDefinition2 mdf, IServerConnection conn)
+ {
+ //Tidy up the CS WKT so that it can display nicely in a watermark
+ StringBuilder cleanCs = new StringBuilder(mdf.CoordinateSystem);
+ cleanCs.Replace("[", "[\n");
+ cleanCs.Replace("],", "],\n");
+
+ string message = string.Format(Strings.DebugWatermarkMessage,
+ mdf.Extents.MinX,
+ mdf.Extents.MinY,
+ mdf.Extents.MaxX,
+ mdf.Extents.MaxY,
+ cleanCs.ToString());
+ string watermarkXml = string.Format(Properties.Resources.TextWatermark, message);
+ string resId = "Session:" + conn.SessionID + "//Debug.WatermarkDefinition";
+ using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(watermarkXml)))
+ {
+ conn.ResourceService.SetResourceXmlData(resId, ms);
+ }
+
+ //Add watermark to Map Definition
+ var wmd = (IWatermarkDefinition)conn.ResourceService.GetResource(resId);
+ mdf.AddWatermark(wmd);
+
+ return resId;
+ }
+
internal static IMapDefinition CreateLayerPreviewMapDefinition(ILayerDefinition ldf, string sessionId, string layerName, IServerConnection conn)
{
//Create temp map definition to house our current layer
@@ -127,7 +155,10 @@
//TODO: Based on the visible scales in this layer, size this extents accordingly
var mdf = ObjectFactory.CreateMapDefinition(conn, Strings.PreviewMap, csWkt, extent);
-
+ IMapDefinition2 mdf2 = mdf as IMapDefinition2;
+ if (mdf2 != null && PreviewSettings.AddDebugWatermark)
+ CreateDebugWatermark(mdf2, conn);
+
var layer = mdf.AddLayer(null, layerName, ldf.ResourceID);
conn.ResourceService.SaveResourceAs(mdf, mdfId);
mdf.ResourceID = mdfId;
@@ -224,6 +255,9 @@
var mdf = (IMapDefinition)res;
var conn = mdf.CurrentConnection;
+ IMapDefinition2 mdf2 = mdf as IMapDefinition2;
+ if (mdf2 != null && PreviewSettings.AddDebugWatermark)
+ CreateDebugWatermark(mdf2, conn);
conn.ResourceService.SaveResourceAs(mdf, mdfId);
//if (PropertyService.Get(ConfigProperties.PreviewViewerType, "AJAX").Equals("AJAX")) //NOXLATE
Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs 2014-03-21 13:36:59 UTC (rev 7994)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18052
+// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -1815,6 +1815,27 @@
}
/// <summary>
+ /// Looks up a localized string similar to <?xml version="1.0"?>
+ ///<WatermarkDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.4.0" xsi:noNamespaceSchemaLocation="WatermarkDefinition-2.4.0.xsd">
+ /// <Content>
+ /// <SimpleSymbolDefinition>
+ /// <Name />
+ /// <Description />
+ /// <Graphics>
+ /// <Text>
+ /// <Content>'{0}'</Content>
+ /// <FontName>'Arial'</FontName>
+ /// <Height>3</Height>
+ /// <Justification>'Left'</Justification>
+ /// <TextCol [rest of string was truncated]";.
+ /// </summary>
+ internal static string TextWatermark {
+ get {
+ return ResourceManager.GetString("TextWatermark", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap tick {
Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx 2014-03-21 13:36:59 UTC (rev 7994)
@@ -2043,7 +2043,7 @@
<data name="MgCooker" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
- YQUAAAAJcEhZcwAADsAAAA7AAWrWiQkAAAHrSURBVDhPjZHvS1phFMf9T3qxl4MaxDKSoiKKIqEaBAlC
+ YQUAAAAJcEhZcwAADr8AAA6/ATgFUyQAAAHrSURBVDhPjZHvS1phFMf9T3qxl4MaxDKSoiKKIqEaBAlC
Rg2KfBWhL9peOCiK2F0abSs2xFWk3n4JdhVMS2tdhv246CazreiHa4OCeit4v/N5vA5He2oHvpyH+5zz
Od/zXBUrZha/on/SS2Wbl6B8/r+omhiBIbCImuVx1PMVKJ9rQq/zFB/cyftBmld9aPZYUfS6Ba2CExqX
EVWBQzwMyjCsXd0N6OR4OrHGWZudWok27zsYJRlaUUapx49Hbhv0wy42pGx0QLFcCWPQjunDNEyxDHRR
@@ -4427,4 +4427,7 @@
<data name="document_code" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\document-code.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
+ <data name="TextWatermark" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\TextWatermark.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+ </data>
</root>
\ No newline at end of file
Added: trunk/Tools/Maestro/Maestro.Editors/Resources/TextWatermark.txt
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Resources/TextWatermark.txt (rev 0)
+++ trunk/Tools/Maestro/Maestro.Editors/Resources/TextWatermark.txt 2014-03-21 13:36:59 UTC (rev 7994)
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<WatermarkDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.4.0" xsi:noNamespaceSchemaLocation="WatermarkDefinition-2.4.0.xsd">
+ <Content>
+ <SimpleSymbolDefinition>
+ <Name />
+ <Description />
+ <Graphics>
+ <Text>
+ <Content>'{0}'</Content>
+ <FontName>'Arial'</FontName>
+ <Height>3</Height>
+ <Justification>'Left'</Justification>
+ <TextColor>FF000000</TextColor>
+ <Frame>
+ <FillColor>CCFFFFFF</FillColor>
+ </Frame>
+ </Text>
+ </Graphics>
+ <PointUsage />
+ <ParameterDefinition />
+ </SimpleSymbolDefinition>
+ </Content>
+ <Appearance />
+ <Position>
+ <XYPosition>
+ <XPosition>
+ <Offset>10</Offset>
+ <Unit>Points</Unit>
+ <Alignment>Left</Alignment>
+ </XPosition>
+ <YPosition>
+ <Offset>10</Offset>
+ <Unit>Points</Unit>
+ <Alignment>Top</Alignment>
+ </YPosition>
+ </XYPosition>
+ </Position>
+</WatermarkDefinition>
\ No newline at end of file
Modified: trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs 2014-03-21 13:36:59 UTC (rev 7994)
@@ -439,6 +439,15 @@
}
/// <summary>
+ /// Looks up a localized string similar to MapGuide Debugging Information\n==============================\n\nMap Extents Min: ({0}, {1})\nMap Extents Max: ({2}, {3})\nMap Coordinate System: \n{4}.
+ /// </summary>
+ internal static string DebugWatermarkMessage {
+ get {
+ return ResourceManager.GetString("DebugWatermarkMessage", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Delete Command.
/// </summary>
internal static string DeleteCommand {
Modified: trunk/Tools/Maestro/Maestro.Editors/Strings.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Strings.resx 2014-03-21 12:51:24 UTC (rev 7993)
+++ trunk/Tools/Maestro/Maestro.Editors/Strings.resx 2014-03-21 13:36:59 UTC (rev 7994)
@@ -1554,4 +1554,7 @@
<data name="ThemePrimaryKeyPropertyNotSelected" xml:space="preserve">
<value>Property not selected. Please select the Property which connects to the selected Key Property in the external class</value>
</data>
+ <data name="DebugWatermarkMessage" xml:space="preserve">
+ <value>MapGuide Debugging Information\n==============================\n\nMap Extents Min: ({0}, {1})\nMap Extents Max: ({2}, {3})\nMap Coordinate System: \n{4}</value>
+ </data>
</root>
\ No newline at end of file
More information about the mapguide-commits
mailing list