[mapguide-commits] r6265 - in trunk/Tools/Maestro:
Maestro.Base/Commands Maestro.Base/UI/Preferences
Maestro.Editors/LayerDefinition/Vector/Scales
Maestro.Editors/LayerDefinition/Vector/StyleEditors
Maestro.Editors/LayerDefinition/Vector/Thematics
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Nov 30 03:07:17 EST 2011
Author: jng
Date: 2011-11-30 00:07:17 -0800 (Wed, 30 Nov 2011)
New Revision: 6265
Modified:
trunk/Tools/Maestro/Maestro.Base/Commands/StartupCommand.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/LayerDefinition/Vector/Scales/Condition.cs
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionListButtons.cs
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ItemStyle.cs
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/AreaFeatureStyleEditor.cs
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/LineFeatureStyleEditor.cs
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs
trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
Log:
#1875: Add support for using GetLegendImage API for layer style previews. A new boolean preference determines whether this mode will be used or the existing client-side style preview renderer will be used (which performs better, but is not fully accurate, and can't render certain things like composite styles). The GetLegendImage API produces accurate previews at the expense of performance (which will only be apparent on style-heavy layer definitions). The default mode will still be the existing client-side style preview renderer.
Modified: trunk/Tools/Maestro/Maestro.Base/Commands/StartupCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/StartupCommand.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/StartupCommand.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -40,6 +40,8 @@
ResourceService.RegisterNeutralImages(Properties.Resources.ResourceManager);
ResourceService.RegisterNeutralStrings(Properties.Resources.ResourceManager);
+ Maestro.Editors.LayerDefinition.Vector.Scales.StylePreview.UseClientSideStylePreview = PropertyService.Get(ConfigProperties.UseClientSideStylePreview, ConfigProperties.DefaultUseClientSideStylePreview);
+
ServiceRegistry.Initialize();
EventWatcher.Initialize();
Modified: trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -40,6 +40,7 @@
public const string ValidateOnSave = "General.ValidateResourceOnSave";
public const string XsdSchemaPath = "Editor.XsdSchemaPath";
public const string ShowTipOfTheDay = "General.ShowTipOfTheDay";
+ public const string UseClientSideStylePreview = "Editor.UseClientSideStylePreview";
internal static void ApplyDefaults()
{
@@ -51,6 +52,7 @@
{
Props.Set(ConfigProperties.ValidateOnSave, DefaultValidateOnSave);
Props.Set(ConfigProperties.XsdSchemaPath, DefaultXsdSchemaPath);
+ Props.Set(ConfigProperties.UseClientSideStylePreview, DefaultUseClientSideStylePreview);
}
internal static void ApplyGeneralDefaults()
@@ -87,5 +89,7 @@
public static string DefaultPreviewViewerType { get { return "AJAX"; } }
public static string DefaultUserTemplatesDirectory { get { return Path.Combine(FileUtility.ApplicationRootPath, "UserTemplates"); } }
+
+ public static bool DefaultUseClientSideStylePreview { get { return true; } }
}
}
Modified: trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -32,10 +32,14 @@
this.chkValidateOnSave = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnBrowseXsdPath = new System.Windows.Forms.Button();
+ this.label4 = new System.Windows.Forms.Label();
this.txtXsdPath = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.chkUseClientSidePreviews = new System.Windows.Forms.CheckBox();
+ this.label1 = new System.Windows.Forms.Label();
this.groupBox4.SuspendLayout();
this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox4
@@ -87,6 +91,16 @@
this.btnBrowseXsdPath.UseVisualStyleBackColor = true;
this.btnBrowseXsdPath.Click += new System.EventHandler(this.btnBrowseXsdPath_Click);
//
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+ this.label4.Location = new System.Drawing.Point(15, 27);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(91, 13);
+ this.label4.TabIndex = 12;
+ this.label4.Text = "Xml Schema Path";
+ //
// txtXsdPath
//
this.txtXsdPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -97,20 +111,46 @@
this.txtXsdPath.Size = new System.Drawing.Size(249, 20);
this.txtXsdPath.TabIndex = 13;
//
- // label4
+ // groupBox2
//
- this.label4.AutoSize = true;
- this.label4.ImeMode = System.Windows.Forms.ImeMode.NoControl;
- this.label4.Location = new System.Drawing.Point(15, 27);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(91, 13);
- this.label4.TabIndex = 12;
- this.label4.Text = "Xml Schema Path";
+ this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.groupBox2.Controls.Add(this.label1);
+ this.groupBox2.Controls.Add(this.chkUseClientSidePreviews);
+ this.groupBox2.Location = new System.Drawing.Point(4, 133);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(398, 116);
+ this.groupBox2.TabIndex = 12;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Style Previews";
//
+ // chkUseClientSidePreviews
+ //
+ this.chkUseClientSidePreviews.AutoSize = true;
+ this.chkUseClientSidePreviews.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+ this.chkUseClientSidePreviews.Location = new System.Drawing.Point(18, 29);
+ this.chkUseClientSidePreviews.Name = "chkUseClientSidePreviews";
+ this.chkUseClientSidePreviews.Size = new System.Drawing.Size(156, 17);
+ this.chkUseClientSidePreviews.TabIndex = 3;
+ this.chkUseClientSidePreviews.Text = "Render previews client-side\r\n";
+ this.chkUseClientSidePreviews.UseVisualStyleBackColor = true;
+ //
+ // label1
+ //
+ this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.label1.Location = new System.Drawing.Point(15, 61);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(366, 36);
+ this.label1.TabIndex = 4;
+ this.label1.Text = "un-checking the above item will use GetLegendImage API, which produces accurate p" +
+ "reviews at the expense of performance for style heavy layers";
+ //
// EditorPreferencesCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox4);
this.Name = "EditorPreferencesCtrl";
@@ -119,6 +159,8 @@
this.groupBox4.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
this.ResumeLayout(false);
}
@@ -131,5 +173,8 @@
private System.Windows.Forms.Button btnBrowseXsdPath;
private System.Windows.Forms.TextBox txtXsdPath;
private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.CheckBox chkUseClientSidePreviews;
+ private System.Windows.Forms.Label label1;
}
}
Modified: trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -37,6 +37,9 @@
var path = Props.Get(ConfigProperties.XsdSchemaPath, ConfigProperties.DefaultXsdSchemaPath);
txtXsdPath.Text = path;
+
+ var clientStyle = Props.Get(ConfigProperties.UseClientSideStylePreview, ConfigProperties.DefaultUseClientSideStylePreview);
+ chkUseClientSidePreviews.Checked = clientStyle;
}
public string Title
@@ -54,6 +57,8 @@
bool restart = false;
Apply(ConfigProperties.ValidateOnSave, chkValidateOnSave.Checked);
+ Apply(ConfigProperties.UseClientSideStylePreview, chkUseClientSidePreviews.Checked);
+ Maestro.Editors.LayerDefinition.Vector.Scales.StylePreview.UseClientSideStylePreview = chkUseClientSidePreviews.Checked;
//These changes require restart
if (Apply(ConfigProperties.XsdSchemaPath, txtXsdPath.Text))
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/Condition.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/Condition.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/Condition.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -68,27 +68,27 @@
_conn = conn;
}
- public void SetItem(IPointRule prt)
+ public void SetItem(IVectorScaleRange parentRange, IPointRule prt, int themeCategory)
{
- SetItemInternal(prt);
+ SetItemInternal(parentRange, prt, themeCategory);
}
- public void SetItem(ILineRule lrt)
+ public void SetItem(IVectorScaleRange parentRange, ILineRule lrt, int themeCategory)
{
- SetItemInternal(lrt);
+ SetItemInternal(parentRange, lrt, themeCategory);
}
- public void SetItem(IAreaRule art)
+ public void SetItem(IVectorScaleRange parentRange, IAreaRule art, int themeCategory)
{
- SetItemInternal(art);
+ SetItemInternal(parentRange, art, themeCategory);
}
- public void SetItem(ICompositeRule comp)
+ public void SetItem(IVectorScaleRange parentRange, ICompositeRule comp, int themeCategory)
{
- SetItemInternal(comp);
+ SetItemInternal(parentRange, comp, themeCategory);
}
- private void SetItemInternal(object item)
+ private void SetItemInternal(IVectorScaleRange parentRange, object item, int themeCategory)
{
m_prt = item as IPointRule;
m_lrt = item as ILineRule;
@@ -112,31 +112,31 @@
w2d = SymbolPicker.GetSymbol(_conn, sym.W2DSymbol.ResourceId, sym.W2DSymbol.LibraryItemName);
}
}
- FeatureStyle.SetItem(m_prt, m_prt.PointSymbolization2D, w2d);
- LabelStyle.SetItem(m_prt, m_prt.Label);
+ FeatureStyle.SetItem(parentRange, m_prt, m_prt.PointSymbolization2D, w2d, themeCategory);
+ LabelStyle.SetItem(parentRange, m_prt, m_prt.Label, themeCategory);
LabelStyle.Visible = true;
}
else if (m_lrt != null)
{
RuleCondition.Text = m_lrt.Filter;
LegendLabel.Text = m_lrt.LegendLabel;
- FeatureStyle.SetItem(m_lrt, m_lrt.Strokes);
- LabelStyle.SetItem(m_lrt, m_lrt.Label);
+ FeatureStyle.SetItem(parentRange, m_lrt, m_lrt.Strokes, themeCategory);
+ LabelStyle.SetItem(parentRange, m_lrt, m_lrt.Label, themeCategory);
LabelStyle.Visible = true;
}
else if (m_art != null)
{
RuleCondition.Text = m_art.Filter;
LegendLabel.Text = m_art.LegendLabel;
- FeatureStyle.SetItem(m_art, m_art.AreaSymbolization2D);
- LabelStyle.SetItem(m_art, m_art.Label);
+ FeatureStyle.SetItem(parentRange, m_art, m_art.AreaSymbolization2D, themeCategory);
+ LabelStyle.SetItem(parentRange, m_art, m_art.Label, themeCategory);
LabelStyle.Visible = true;
}
else if (m_comp != null)
{
RuleCondition.Text = m_comp.Filter;
LegendLabel.Text = m_comp.LegendLabel;
- FeatureStyle.SetItem(m_comp, m_comp.CompositeSymbolization);
+ FeatureStyle.SetItem(parentRange, m_comp, m_comp.CompositeSymbolization, themeCategory);
LabelStyle.Visible = false;
}
}
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -110,7 +110,7 @@
m_comp = item as ICompositeTypeStyle;
this.Controls.Clear();
-
+ int themeCategory = 0;
try
{
this.Visible = false;
@@ -119,22 +119,34 @@
if (m_point != null)
{
foreach (IPointRule prt in m_point.Rules)
- AddRuleControl(prt);
+ {
+ AddRuleControl(prt, themeCategory);
+ themeCategory++;
+ }
}
else if (m_line != null)
{
foreach (ILineRule lrt in m_line.Rules)
- AddRuleControl(lrt);
+ {
+ AddRuleControl(lrt, themeCategory);
+ themeCategory++;
+ }
}
else if (m_area != null)
{
foreach (IAreaRule art in m_area.Rules)
- AddRuleControl(art);
+ {
+ AddRuleControl(art, themeCategory);
+ themeCategory++;
+ }
}
else if (m_comp != null)
{
foreach (ICompositeRule comp in m_comp.CompositeRule)
- AddRuleControl(comp);
+ {
+ AddRuleControl(comp, themeCategory);
+ themeCategory++;
+ }
}
}
finally
@@ -144,7 +156,7 @@
}
}
- public Condition AddRuleControl(object rule)
+ public Condition AddRuleControl(object rule, int themeCategory)
{
if (rule == null)
return null;
@@ -153,13 +165,13 @@
Condition c = new Condition(m_owner.EditorService.GetEditedResource().CurrentConnection);
if (rule as IPointRule != null)
- c.SetItem(rule as IPointRule);
+ c.SetItem(m_parent, rule as IPointRule, themeCategory);
else if (rule as ILineRule != null)
- c.SetItem(rule as ILineRule);
+ c.SetItem(m_parent, rule as ILineRule, themeCategory);
else if (rule as IAreaRule != null)
- c.SetItem(rule as IAreaRule);
+ c.SetItem(m_parent, rule as IAreaRule, themeCategory);
else if (rule as ICompositeRule != null)
- c.SetItem(rule as ICompositeRule);
+ c.SetItem(m_parent, rule as ICompositeRule, themeCategory);
c.Owner = m_owner;
c.Dock = DockStyle.Top;
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionListButtons.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionListButtons.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionListButtons.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -133,26 +133,26 @@
if (m_point != null)
{
IPointRule prt = _factory.CreateDefaultPointRule();
- conditionList.AddRuleControl(prt).Focus();
m_point.AddRule(prt);
+ conditionList.AddRuleControl(prt, m_point.RuleCount - 1).Focus();
}
else if (m_line != null)
{
ILineRule lrt = _factory.CreateDefaultLineRule();
- conditionList.AddRuleControl(lrt).Focus();
m_line.AddRule(lrt);
+ conditionList.AddRuleControl(lrt, m_line.RuleCount - 1).Focus();
}
else if (m_area != null)
{
IAreaRule art = _factory.CreateDefaultAreaRule();
- conditionList.AddRuleControl(art).Focus();
m_area.AddRule(art);
+ conditionList.AddRuleControl(art, m_area.RuleCount - 1).Focus();
}
else if (m_comp != null)
{
ICompositeRule cr = _factory.CreateDefaultCompositeRule();
- conditionList.AddRuleControl(cr).Focus();
m_comp.AddCompositeRule(cr);
+ conditionList.AddRuleControl(cr, m_comp.RuleCount - 1).Focus();
}
if (ItemChanged != null)
@@ -215,23 +215,26 @@
object rule = Utility.XmlDeepCopy(conditionList.SelectedItem);
-
+ int themeCategory = -1;
if (m_point != null)
{
m_point.AddRule((IPointRule)rule);
+ themeCategory = m_point.RuleCount - 1;
}
else if (m_line != null)
{
m_line.AddRule((ILineRule)rule);
+ themeCategory = m_line.RuleCount - 1;
}
else if (m_area != null)
{
m_area.AddRule((IAreaRule)rule);
+ themeCategory = m_area.RuleCount - 1;
}
else
return;
- conditionList.AddRuleControl(rule).Focus();
+ conditionList.AddRuleControl(rule, themeCategory).Focus();
if (ItemChanged != null)
ItemChanged(this, null);
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ItemStyle.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ItemStyle.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Scales/ItemStyle.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -27,6 +27,7 @@
using OSGeo.MapGuide.MaestroAPI;
using OSGeo.MapGuide.ObjectModels.LayerDefinition;
using Maestro.Editors.LayerDefinition.Vector.StyleEditors;
+using OSGeo.MapGuide.MaestroAPI.Services;
namespace Maestro.Editors.LayerDefinition.Vector.Scales
{
@@ -65,19 +66,20 @@
}
private ILayerElementFactory _factory;
+ private IVectorScaleRange _parentRange;
public ItemStyle(ILayerElementFactory factory)
{
_factory = factory;
}
- public void SetItem(object parent, ITextSymbol label)
+ public void SetItem(IVectorScaleRange parentRange, object parent, ITextSymbol label, int themeCategory)
{
isLabel = true;
- SetItemInternal(parent, label);
+ SetItemInternal(parentRange, parent, label, themeCategory);
}
- public void SetItem(IPointRule parent, IPointSymbolization2D point, Image img)
+ public void SetItem(IVectorScaleRange parentRange, IPointRule parent, IPointSymbolization2D point, Image img, int themeCategory)
{
if (point == null)
{
@@ -89,30 +91,34 @@
isPoint = (point.Symbol.Type != PointSymbolType.W2D);
isW2dSymbol = (point.Symbol.Type == PointSymbolType.W2D);
}
- SetItemInternal(parent, point);
+ SetItemInternal(parentRange, parent, point, themeCategory);
m_w2dsymbol = img;
}
- public void SetItem(ILineRule parent, IEnumerable<IStroke> line)
+ public void SetItem(IVectorScaleRange parentRange, ILineRule parent, IEnumerable<IStroke> line, int themeCategory)
{
isLine = true;
- SetItemInternal(parent, line);
+ SetItemInternal(parentRange, parent, line, themeCategory);
}
- public void SetItem(IAreaRule parent, IAreaSymbolizationFill area)
+ public void SetItem(IVectorScaleRange parentRange, IAreaRule parent, IAreaSymbolizationFill area, int themeCategory)
{
isArea = true;
- SetItemInternal(parent, area);
+ SetItemInternal(parentRange, parent, area, themeCategory);
}
- public void SetItem(ICompositeRule parent, ICompositeSymbolization comp)
+ public void SetItem(IVectorScaleRange parentRange, ICompositeRule parent, ICompositeSymbolization comp, int themeCategory)
{
isComp = true;
- SetItemInternal(parent, comp);
+ SetItemInternal(parentRange, parent, comp, themeCategory);
}
- private void SetItemInternal(object parent, object item)
+ private int _themeCategory;
+
+ private void SetItemInternal(IVectorScaleRange parentRange, object parent, object item, int themeCategory)
{
+ _parentRange = parentRange;
+ _themeCategory = themeCategory;
m_parent = parent;
m_label = item as ITextSymbol;
m_point = item as IPointSymbolization2D;
@@ -126,66 +132,112 @@
m_line = null;
}
- private void previewPicture_Paint(object sender, PaintEventArgs e)
+ private IMappingService _mapSvc = null;
+
+ IMappingService GetMappingService()
{
- e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- Rectangle rect = new Rectangle(0, 0, previewPicture.Width, previewPicture.Height);
- if (m_label != null)
+ if (null == _mapSvc)
{
- FeaturePreviewRender.RenderPreviewFont(e.Graphics, rect, m_label);
+ var conn = Owner.EditorService.GetEditedResource().CurrentConnection;
+ if (Array.IndexOf<int>(conn.Capabilities.SupportedServices, (int)ServiceType.Mapping) >= 0)
+ _mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
}
- else if (m_point != null)
+ return _mapSvc;
+ }
+
+ int GetGeomType()
+ {
+ int gt = -1;
+ if (isPoint || isLabel || isW2dSymbol)
+ return 1;
+ else if (isLine)
+ return 2;
+ else if (isArea)
+ return 3;
+ else if (isComp)
+ return 4;
+ return gt;
+ }
+
+ private void previewPicture_Paint(object sender, PaintEventArgs e)
+ {
+ var mapSvc = GetMappingService();
+ if (mapSvc != null && !StylePreview.UseClientSideStylePreview)
{
- if (m_point.Symbol.Type == PointSymbolType.Mark)
- FeaturePreviewRender.RenderPreviewPoint(e.Graphics, rect, m_point.Symbol as IMarkSymbol);
- else if (m_point.Symbol.Type == PointSymbolType.Font)
- FeaturePreviewRender.RenderPreviewFontSymbol(e.Graphics, rect, m_point.Symbol as IFontSymbol);
- else if (m_point.Symbol.Type == PointSymbolType.W2D)
- FeaturePreviewRender.RenderW2DImage(e.Graphics, rect, m_point.Symbol as IW2DSymbol, m_w2dsymbol);
- }
- else if (m_line != null)
- {
- FeaturePreviewRender.RenderPreviewLine(e.Graphics, rect, m_line);
+ double scale = 10000.0;
+ if (_parentRange.MaxScale.HasValue)
+ scale = _parentRange.MaxScale.Value - 1.0;
+ else if (_parentRange.MinScale.HasValue)
+ scale = _parentRange.MinScale.Value + 1.0;
+
+ //Ensure the layer def we're rendering from is latest
+ Owner.EditorService.SyncSessionCopy();
+ using (var img = mapSvc.GetLegendImage(scale, Owner.EditorService.GetEditedResource().ResourceID, _themeCategory, GetGeomType(), previewPicture.Width, previewPicture.Height, "PNG"))
+ {
+ e.Graphics.DrawImage(img, new Point(0, 0));
+ }
}
- else if (m_area != null)
+ else
{
- FeaturePreviewRender.RenderPreviewArea(e.Graphics, rect, m_area);
+ e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ Rectangle rect = new Rectangle(0, 0, previewPicture.Width, previewPicture.Height);
+ if (m_label != null)
+ {
+ FeaturePreviewRender.RenderPreviewFont(e.Graphics, rect, m_label);
+ }
+ else if (m_point != null)
+ {
+ if (m_point.Symbol.Type == PointSymbolType.Mark)
+ FeaturePreviewRender.RenderPreviewPoint(e.Graphics, rect, m_point.Symbol as IMarkSymbol);
+ else if (m_point.Symbol.Type == PointSymbolType.Font)
+ FeaturePreviewRender.RenderPreviewFontSymbol(e.Graphics, rect, m_point.Symbol as IFontSymbol);
+ else if (m_point.Symbol.Type == PointSymbolType.W2D)
+ FeaturePreviewRender.RenderW2DImage(e.Graphics, rect, m_point.Symbol as IW2DSymbol, m_w2dsymbol);
+ }
+ else if (m_line != null)
+ {
+ FeaturePreviewRender.RenderPreviewLine(e.Graphics, rect, m_line);
+ }
+ else if (m_area != null)
+ {
+ FeaturePreviewRender.RenderPreviewArea(e.Graphics, rect, m_area);
+ }
+ else if (m_comp != null)
+ {
+ FeaturePreviewRender.RenderNoPreview(e.Graphics, rect);
+ }
+ else
+ FeaturePreviewRender.RenderPreviewFont(e.Graphics, rect, null);
}
- else if (m_comp != null)
- {
- FeaturePreviewRender.RenderNoPreview(e.Graphics, rect);
- }
- else
- FeaturePreviewRender.RenderPreviewFont(e.Graphics, rect, null);
}
private void EditButton_Click(object sender, EventArgs e)
{
- UserControl uc = null;
+ IFeatureStyleEditor uc = null;
if (isLabel)
{
- uc = new FontStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId);
- ((FontStyleEditor)uc).Item = m_label == null ? null : (ITextSymbol)m_label.Clone(); //(ITextSymbol)Utility.DeepCopy(m_label);
+ uc = new FontStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, m_label);
+ //((FontStyleEditor)uc).Item = m_label == null ? null : (ITextSymbol)m_label.Clone(); //(ITextSymbol)Utility.DeepCopy(m_label);
}
else if (isW2dSymbol)
{
- uc = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, m_w2dsymbol);
- ((PointFeatureStyleEditor)uc).Item = m_point == null ? null : (IPointSymbolization2D)m_point.Clone(); //(IPointSymbolization2D)Utility.XmlDeepCopy(m_point);
+ uc = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, m_w2dsymbol, _parentRange, _themeCategory, m_point);
+ //((PointFeatureStyleEditor)uc).Item = m_point == null ? null : (IPointSymbolization2D)m_point.Clone(); //(IPointSymbolization2D)Utility.XmlDeepCopy(m_point);
}
else if (isPoint)
{
- uc = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId);
- ((PointFeatureStyleEditor)uc).Item = m_point == null ? null : (IPointSymbolization2D)m_point.Clone(); //(IPointSymbolization2D)Utility.XmlDeepCopy(m_point);
+ uc = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, _parentRange, _themeCategory, m_point);
+ //((PointFeatureStyleEditor)uc).Item = m_point == null ? null : (IPointSymbolization2D)m_point.Clone(); //(IPointSymbolization2D)Utility.XmlDeepCopy(m_point);
}
else if (isLine)
{
- uc = new LineFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, _factory);
- ((LineFeatureStyleEditor)uc).Item = m_line == null ? null : LayerElementCloningUtil.CloneStrokes(m_line);//(IList<IStroke>)Utility.XmlDeepCopy(m_line);
+ uc = new LineFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, _factory, _parentRange, _themeCategory, m_line);
+ //((LineFeatureStyleEditor)uc).Item = m_line == null ? null : LayerElementCloningUtil.CloneStrokes(m_line);//(IList<IStroke>)Utility.XmlDeepCopy(m_line);
}
else if (isArea)
{
- uc = new AreaFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId);
- ((AreaFeatureStyleEditor)uc).Item = m_area == null ? null : (IAreaSymbolizationFill)m_area.Clone(); //(IAreaSymbolizationFill)Utility.XmlDeepCopy(m_area);
+ uc = new AreaFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, _parentRange, _themeCategory, m_area);
+ //((AreaFeatureStyleEditor)uc).Item = m_area == null ? null : (IAreaSymbolizationFill)m_area.Clone(); //(IAreaSymbolizationFill)Utility.XmlDeepCopy(m_area);
}
else if (isComp)
{
@@ -198,12 +250,15 @@
if (uc != null)
{
+ uc.CreateSnapshot();
+
EditorTemplateForm dlg = new EditorTemplateForm();
- dlg.ItemPanel.Controls.Add(uc);
- uc.Dock = DockStyle.Fill;
+ dlg.ItemPanel.Controls.Add(uc.Content);
+ uc.Content.Dock = DockStyle.Fill;
dlg.RefreshSize();
if (dlg.ShowDialog(this) == DialogResult.OK)
{
+ /*
if (isLabel)
{
m_label = ((FontStyleEditor)uc).Item;
@@ -246,10 +301,14 @@
if (ItemChanged != null)
ItemChanged(m_area, null);
}
-
+ */
this.Refresh();
-
+ Owner.FlagDirty();
}
+ else
+ {
+ uc.RejectChanges();
+ }
}
}
@@ -268,4 +327,33 @@
EditButton_Click(sender, e);
}
}
+
+ internal interface IFeatureStyleEditor
+ {
+ void RejectChanges();
+ void CreateSnapshot();
+ Control Content { get; }
+ void Detach();
+ void Attach();
+ bool IsAttached { get; }
+ event EventHandler StyleDetached;
+ event EventHandler StyleAttached;
+ }
+
+ public class StylePreview
+ {
+ /// <summary>
+ /// Indicates whether to use client-side rendering to generate style previews. Client-side rendering is more efficient, but does
+ /// not produce fully accurate preview styles. Setting it to false will use the GETLEGENDIMAGE API to produce the style preview which
+ /// will produce the exact preview style.
+ ///
+ /// For style-intensive layers, the GETLEGENDIMAGE approach can momentarily grind the MapGuide Server
+ /// </summary>
+ public static bool UseClientSideStylePreview;
+
+ static StylePreview()
+ {
+ UseClientSideStylePreview = true;
+ }
+ }
}
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/AreaFeatureStyleEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/AreaFeatureStyleEditor.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/AreaFeatureStyleEditor.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -27,6 +27,9 @@
using OSGeo.MapGuide.ObjectModels.FeatureSource;
using OSGeo.MapGuide.ObjectModels;
using OSGeo.MapGuide.MaestroAPI.Schema;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using Maestro.Editors.LayerDefinition.Vector.Scales;
+using System.Diagnostics;
namespace Maestro.Editors.LayerDefinition.Vector.StyleEditors
{
@@ -34,7 +37,7 @@
/// Summary description for AreaFeatureStyleEditor.
/// </summary>
[ToolboxItem(false)]
- internal class AreaFeatureStyleEditor : System.Windows.Forms.UserControl
+ internal class AreaFeatureStyleEditor : System.Windows.Forms.UserControl, IFeatureStyleEditor
{
private System.Windows.Forms.ComboBox sizeContextCombo;
private System.Windows.Forms.Label label4;
@@ -71,18 +74,23 @@
private string m_featureSource;
private string m_providername;
private ILayerElementFactory _factory;
+ private IVectorScaleRange _parentRange;
+ private int _themeCategory;
- public AreaFeatureStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource)
+ public AreaFeatureStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource, IVectorScaleRange parentRange, int themeCategory, IAreaSymbolizationFill originalItem)
: this()
{
m_editor = editor;
m_schema = schema;
+ _parentRange = parentRange;
+ _themeCategory = themeCategory;
_factory = (ILayerElementFactory)editor.GetEditedResource();
var fs = (IFeatureSource)m_editor.ResourceService.GetResource(featureSource);
m_providername = fs.Provider;
m_featureSource = featureSource;
+ m_item = originalItem;
}
private AreaFeatureStyleEditor()
@@ -353,19 +361,46 @@
}
}
+ private IMappingService _mapSvc;
+
+ IMappingService GetMappingService()
+ {
+ if (null == _mapSvc)
+ {
+ var conn = m_editor.GetEditedResource().CurrentConnection;
+ if (Array.IndexOf<int>(conn.Capabilities.SupportedServices, (int)ServiceType.Mapping) >= 0)
+ _mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+ }
+ return _mapSvc;
+ }
+
+ int GetGeomType()
+ {
+ return 3;
+ }
+
private void previewPicture_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
- FeaturePreviewRender.RenderPreviewArea(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 4, previewPicture.Height - 4), m_item);
- }
+ IMappingService mapSvc = GetMappingService();
+ if (mapSvc != null && _parentRange != null && !StylePreview.UseClientSideStylePreview)
+ {
+ double scale = 10000.0;
+ if (_parentRange.MaxScale.HasValue)
+ scale = _parentRange.MaxScale.Value - 1.0;
+ else if (_parentRange.MinScale.HasValue)
+ scale = _parentRange.MinScale.Value + 1.0;
- public IAreaSymbolizationFill Item
- {
- get { return m_item; }
- set
- {
- m_item = value;
- UpdateDisplay();
- }
+ //Ensure the layer def we're rendering from is latest
+ m_editor.SyncSessionCopy();
+ using (var img = mapSvc.GetLegendImage(scale, m_editor.GetEditedResource().ResourceID, _themeCategory, GetGeomType(), previewPicture.Width, previewPicture.Height, "PNG"))
+ {
+ e.Graphics.DrawImage(img, new Point(0, 0));
+ }
+ }
+ else
+ {
+ FeaturePreviewRender.RenderPreviewArea(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 4, previewPicture.Height - 4), m_item);
+ }
}
private void fillCombo_SelectedIndexChanged(object sender, EventArgs e)
@@ -554,5 +589,54 @@
if (expr != null)
fillStyleEditor.foregroundColor.ColorExpression = expr;
}
+
+ public void RejectChanges()
+ {
+ if (m_snapshot != null)
+ {
+ m_item.Fill = m_snapshot.Fill;
+ m_item.Stroke = m_snapshot.Stroke;
+ Trace.TraceInformation("AreaFeatureStyleEditor: Changes rejected");
+ }
+ }
+
+ private IAreaSymbolizationFill m_snapshot;
+
+ public void CreateSnapshot()
+ {
+ if (m_item != null)
+ {
+ m_snapshot = m_item.Clone();
+ Trace.TraceInformation("AreaFeatureStyleEditor: Style snapshot created");
+ }
+ UpdateDisplay();
+ }
+
+ public Control Content
+ {
+ get { return this; }
+ }
+
+ public void Detach()
+ {
+ this.IsAttached = false;
+ var handler = this.StyleDetached;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+
+ public void Attach()
+ {
+ this.IsAttached = true;
+ var handler = this.StyleAttached;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+
+ public bool IsAttached { get; private set; }
+
+ public event EventHandler StyleDetached;
+
+ public event EventHandler StyleAttached;
}
}
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -28,6 +28,8 @@
using OSGeo.MapGuide.ObjectModels.FeatureSource;
using OSGeo.MapGuide.ObjectModels;
using OSGeo.MapGuide.MaestroAPI.Schema;
+using Maestro.Editors.LayerDefinition.Vector.Scales;
+using System.Diagnostics;
namespace Maestro.Editors.LayerDefinition.Vector.StyleEditors
{
@@ -35,7 +37,7 @@
/// Summary description for FontStyleEditor.
/// </summary>
[ToolboxItem(false)]
- internal class FontStyleEditor : System.Windows.Forms.UserControl
+ internal class FontStyleEditor : System.Windows.Forms.UserControl, IFeatureStyleEditor
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
@@ -109,7 +111,7 @@
private ILayerElementFactory _factory;
- public FontStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource)
+ public FontStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource, ITextSymbol originalItem)
: this()
{
m_editor = editor;
@@ -134,6 +136,7 @@
foreach (FontFamily f in new System.Drawing.Text.InstalledFontCollection().Families)
fontCombo.Items.Add(f.Name);
+ m_item = originalItem;
}
private FontStyleEditor()
@@ -926,16 +929,6 @@
Changed(this, new EventArgs());
}
- public ITextSymbol Item
- {
- get { return m_item; }
- set
- {
- m_item = value;
- UpdateDisplay();
- }
- }
-
private void DisplayLabel_CheckedChanged(object sender, EventArgs e)
{
foreach (Control c in this.Controls)
@@ -945,6 +938,11 @@
return;
if (DisplayLabel.Checked)
+ Attach();
+ else
+ Detach();
+ /*
+ if (DisplayLabel.Checked)
{
if (DisplayLabel.Tag as ITextSymbol != null)
this.Item = DisplayLabel.Tag as ITextSymbol;
@@ -955,8 +953,7 @@
{
DisplayLabel.Tag = m_item;
this.Item = null;
- }
-
+ }*/
}
private void sizeCombo_TextChanged(object sender, EventArgs e)
@@ -1038,5 +1035,73 @@
Changed(this, new EventArgs());
}
- }
+
+ public void RejectChanges()
+ {
+ if (m_snapshot != null)
+ {
+ m_item.AdvancedPlacement = m_snapshot.AdvancedPlacement;
+ m_item.BackgroundColor = m_snapshot.BackgroundColor;
+ m_item.BackgroundStyle = m_snapshot.BackgroundStyle;
+ m_item.Bold = m_snapshot.Bold;
+ m_item.FontName = m_snapshot.FontName;
+ m_item.ForegroundColor = m_snapshot.ForegroundColor;
+ m_item.HorizontalAlignment = m_snapshot.HorizontalAlignment;
+ m_item.InsertionPointX = m_snapshot.InsertionPointX;
+ m_item.InsertionPointY = m_snapshot.InsertionPointY;
+ m_item.Italic = m_snapshot.Italic;
+ m_item.MaintainAspect = m_snapshot.MaintainAspect;
+ m_item.Rotation = m_snapshot.Rotation;
+ m_item.SizeContext = m_snapshot.SizeContext;
+ m_item.SizeX = m_snapshot.SizeX;
+ m_item.SizeY = m_snapshot.SizeY;
+ m_item.Text = m_snapshot.Text;
+ //m_item.Type = m_snapshot.Type;
+ m_item.Underlined = m_snapshot.Underlined;
+ m_item.Unit = m_snapshot.Unit;
+ m_item.VerticalAlignment = m_snapshot.VerticalAlignment;
+
+ Trace.TraceInformation("FontStyleEditor: Changes rejected");
+ }
+ }
+
+ private ITextSymbol m_snapshot;
+
+ public void CreateSnapshot()
+ {
+ if (m_item != null)
+ {
+ m_snapshot = m_item.Clone();
+ Trace.TraceInformation("FontStyleEditor: Style snapshot created");
+ }
+ UpdateDisplay();
+ }
+
+ public Control Content
+ {
+ get { return this; }
+ }
+
+ public void Detach()
+ {
+ this.IsAttached = false;
+ var handler = this.StyleDetached;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+
+ public void Attach()
+ {
+ this.IsAttached = true;
+ var handler = this.StyleAttached;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+
+ public bool IsAttached { get; private set; }
+
+ public event EventHandler StyleDetached;
+
+ public event EventHandler StyleAttached;
+ }
}
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/LineFeatureStyleEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/LineFeatureStyleEditor.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/LineFeatureStyleEditor.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -29,6 +29,9 @@
using Maestro.Editors.Common;
using OSGeo.MapGuide.ObjectModels;
using OSGeo.MapGuide.MaestroAPI.Schema;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using Maestro.Editors.LayerDefinition.Vector.Scales;
+using System.Diagnostics;
namespace Maestro.Editors.LayerDefinition.Vector.StyleEditors
{
@@ -36,7 +39,7 @@
/// Summary description for LineFeatureStyleEditor.
/// </summary>
[ToolboxItem(false)]
- internal class LineFeatureStyleEditor : System.Windows.Forms.UserControl
+ internal class LineFeatureStyleEditor : System.Windows.Forms.UserControl, IFeatureStyleEditor
{
/// <summary>
/// Required designer variable.
@@ -79,12 +82,16 @@
private string m_featureSource;
private string m_providername;
private ILayerElementFactory _factory;
+ private IVectorScaleRange _parentRange;
+ private int _themeCategory;
- public LineFeatureStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource, ILayerElementFactory factory)
+ public LineFeatureStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource, ILayerElementFactory factory, IVectorScaleRange parentRange, int themeCategory, IList<IStroke> originalItem)
: this()
{
m_editor = editor;
m_schema = schema;
+ _parentRange = parentRange;
+ _themeCategory = themeCategory;
_factory = (ILayerElementFactory)editor.GetEditedResource();
@@ -92,6 +99,7 @@
m_providername = fs.Provider;
m_featureSource = featureSource;
+ m_item = originalItem;
}
private LineFeatureStyleEditor()
@@ -512,16 +520,6 @@
Changed(this, new EventArgs());
}
- public IList<IStroke> Item
- {
- get { return m_item; }
- set
- {
- m_item = value;
- UpdateDisplay();
- }
- }
-
private void thicknessCombo_TextChanged(object sender, EventArgs e)
{
if (m_inUpdate || lineStyleEditor.thicknessCombo.SelectedIndex != -1)
@@ -586,6 +584,7 @@
if (!applyLineStyle.Checked)
{
applyLineStyle.Tag = m_item;
+ //TODO: Need to review this given the accept/reject pattern changes
m_item = new BindingList<IStroke>();
}
else
@@ -618,9 +617,46 @@
Changed(this, new EventArgs());
}
+ private IMappingService _mapSvc;
+
+ IMappingService GetMappingService()
+ {
+ if (null == _mapSvc)
+ {
+ var conn = m_editor.GetEditedResource().CurrentConnection;
+ if (Array.IndexOf<int>(conn.Capabilities.SupportedServices, (int)ServiceType.Mapping) >= 0)
+ _mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+ }
+ return _mapSvc;
+ }
+
+ int GetGeomType()
+ {
+ return 1;
+ }
+
private void previewPicture_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
- FeaturePreviewRender.RenderPreviewLine(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), m_item);
+ var mapSvc = GetMappingService();
+ if (mapSvc != null && _parentRange != null && !StylePreview.UseClientSideStylePreview)
+ {
+ double scale = 10000.0;
+ if (_parentRange.MaxScale.HasValue)
+ scale = _parentRange.MaxScale.Value - 1.0;
+ else if (_parentRange.MinScale.HasValue)
+ scale = _parentRange.MinScale.Value + 1.0;
+
+ //Ensure the layer def we're rendering from is latest
+ m_editor.SyncSessionCopy();
+ using (var img = mapSvc.GetLegendImage(scale, m_editor.GetEditedResource().ResourceID, _themeCategory, GetGeomType(), previewPicture.Width, previewPicture.Height, "PNG"))
+ {
+ e.Graphics.DrawImage(img, new Point(0, 0));
+ }
+ }
+ else
+ {
+ FeaturePreviewRender.RenderPreviewLine(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), m_item);
+ }
}
private void lineStyles_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
@@ -693,5 +729,56 @@
if (expr != null)
lineStyleEditor.ColorExpression = expr;
}
+
+ public void RejectChanges()
+ {
+ if (m_snapshot != null)
+ {
+ m_item.Clear();
+ foreach (IStroke st in m_snapshot)
+ m_item.Add(st);
+
+ Trace.TraceInformation("LineFeatureStyleEditor: Changes rejected");
+ }
+ }
+
+ private IList<IStroke> m_snapshot;
+
+ public void CreateSnapshot()
+ {
+ if (m_item != null)
+ {
+ m_snapshot = LayerElementCloningUtil.CloneStrokes(m_item);
+ Trace.TraceInformation("LineFeatureStyleEditor: Style snapshot created");
+ }
+ UpdateDisplay();
+ }
+
+ public Control Content
+ {
+ get { return this; }
+ }
+
+ public void Detach()
+ {
+ this.IsAttached = false;
+ var handler = this.StyleDetached;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+
+ public void Attach()
+ {
+ this.IsAttached = true;
+ var handler = this.StyleAttached;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+
+ public bool IsAttached { get; private set; }
+
+ public event EventHandler StyleDetached;
+
+ public event EventHandler StyleAttached;
}
}
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -31,6 +31,9 @@
using OSGeo.MapGuide.ObjectModels;
using OSGeo.MapGuide.ObjectModels.FeatureSource;
using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using Maestro.Editors.LayerDefinition.Vector.Scales;
+using System.Diagnostics;
namespace Maestro.Editors.LayerDefinition.Vector.StyleEditors
{
@@ -38,7 +41,7 @@
/// Summary description for PointFeatureStyleEditor.
/// </summary>
[ToolboxItem(false)]
- internal class PointFeatureStyleEditor : System.Windows.Forms.UserControl
+ internal class PointFeatureStyleEditor : System.Windows.Forms.UserControl, IFeatureStyleEditor
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
@@ -121,12 +124,16 @@
private CheckBox chkW2DFillColor;
private ColorComboWithTransparency cmbW2DFillColor;
private ILayerElementFactory _factory;
+ private IVectorScaleRange _parentRange;
+ private int _themeCategory;
- public PointFeatureStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource)
+ public PointFeatureStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource, IVectorScaleRange parentRange, int themeCategory, IPointSymbolization2D originalItem)
: this()
{
m_editor = editor;
m_schema = schema;
+ _parentRange = parentRange;
+ _themeCategory = themeCategory;
_factory = (ILayerElementFactory)editor.GetEditedResource();
var fs = (IFeatureSource)editor.ResourceService.GetResource(featureSource);
@@ -134,11 +141,11 @@
m_providername = fs.Provider;
m_featureSource = featureSource;
- m_item = _factory.CreateDefaultPointSymbolization2D();
+ m_item = originalItem;
}
- public PointFeatureStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource, Image currentW2D)
- : this(editor, schema, featureSource)
+ public PointFeatureStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource, Image currentW2D, IVectorScaleRange parentRange, int themeCategory, IPointSymbolization2D originalItem)
+ : this(editor, schema, featureSource, parentRange, themeCategory, originalItem)
{
grpW2DStyle.Tag = currentW2D;
}
@@ -889,17 +896,54 @@
UpdateDisplay();
}
+ private IMappingService _mapSvc;
+
+ IMappingService GetMappingService()
+ {
+ if (null == _mapSvc)
+ {
+ var conn = m_editor.GetEditedResource().CurrentConnection;
+ if (Array.IndexOf<int>(conn.Capabilities.SupportedServices, (int)ServiceType.Mapping) >= 0)
+ _mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+ }
+ return _mapSvc;
+ }
+
+ int GetGeomType()
+ {
+ return 1;
+ }
+
private void previewPicture_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
- e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- if (m_item != null && m_item.Symbol.Type == PointSymbolType.Mark)
- FeaturePreviewRender.RenderPreviewPoint(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (IMarkSymbol)m_item.Symbol);
- else if (m_item != null && m_item.Symbol.Type == PointSymbolType.Font)
- FeaturePreviewRender.RenderPreviewFontSymbol(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (IFontSymbol)m_item.Symbol);
- else if (m_item != null && m_item.Symbol.Type == PointSymbolType.W2D)
- FeaturePreviewRender.RenderW2DImage(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (IW2DSymbol)m_item.Symbol, grpW2DStyle.Tag as Image);
+ IMappingService mapSvc = GetMappingService();
+ if (mapSvc != null && _parentRange != null && !StylePreview.UseClientSideStylePreview)
+ {
+ double scale = 10000.0;
+ if (_parentRange.MaxScale.HasValue)
+ scale = _parentRange.MaxScale.Value - 1.0;
+ else if (_parentRange.MinScale.HasValue)
+ scale = _parentRange.MinScale.Value + 1.0;
+
+ //Ensure the layer def we're rendering from is latest
+ m_editor.SyncSessionCopy();
+ using (var img = mapSvc.GetLegendImage(scale, m_editor.GetEditedResource().ResourceID, _themeCategory, GetGeomType(), previewPicture.Width, previewPicture.Height, "PNG"))
+ {
+ e.Graphics.DrawImage(img, new Point(0, 0));
+ }
+ }
else
- FeaturePreviewRender.RenderPreviewPoint(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), null);
+ {
+ e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ if (m_item != null && m_item.Symbol.Type == PointSymbolType.Mark)
+ FeaturePreviewRender.RenderPreviewPoint(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (IMarkSymbol)m_item.Symbol);
+ else if (m_item != null && m_item.Symbol.Type == PointSymbolType.Font)
+ FeaturePreviewRender.RenderPreviewFontSymbol(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (IFontSymbol)m_item.Symbol);
+ else if (m_item != null && m_item.Symbol.Type == PointSymbolType.W2D)
+ FeaturePreviewRender.RenderW2DImage(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (IW2DSymbol)m_item.Symbol, grpW2DStyle.Tag as Image);
+ else
+ FeaturePreviewRender.RenderPreviewPoint(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), null);
+ }
}
private IW2DSymbol m_lastSymbol;
@@ -1376,17 +1420,6 @@
comboBoxCharacter_SelectedIndexChanged(sender, e);
}
-
- public IPointSymbolization2D Item
- {
- get { return m_item; }
- set
- {
- m_item = value;
- UpdateDisplay();
- }
- }
-
private void DisplayPoints_CheckedChanged(object sender, EventArgs e)
{
foreach (Control c in this.Controls)
@@ -1396,6 +1429,11 @@
return;
if (DisplayPoints.Checked)
+ Attach();
+ else
+ Detach();
+ /*
+ if (DisplayPoints.Checked)
{
if (DisplayPoints.Tag as IPointSymbolization2D != null)
this.Item = DisplayPoints.Tag as IPointSymbolization2D;
@@ -1406,7 +1444,7 @@
{
DisplayPoints.Tag = m_item;
this.Item = null;
- }
+ }*/
}
static string DoubleToString(double? value)
@@ -1657,5 +1695,53 @@
if (Changed != null)
Changed(this, new EventArgs());
}
+
+ public void RejectChanges()
+ {
+ if (m_snapshot != null)
+ {
+ m_item.Symbol = m_snapshot.Symbol;
+ Trace.TraceInformation("PointFeatureStyleEditor: Changes rejected");
+ }
+ }
+
+ private IPointSymbolization2D m_snapshot;
+
+ public void CreateSnapshot()
+ {
+ if (m_item != null)
+ {
+ m_snapshot = m_item.Clone();
+ Trace.TraceInformation("PointFeatureStyleEditor: Style snapshot created");
+ }
+ UpdateDisplay();
+ }
+
+ public Control Content
+ {
+ get { return this; }
+ }
+
+ public void Detach()
+ {
+ this.IsAttached = false;
+ var handler = this.StyleDetached;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+
+ public void Attach()
+ {
+ this.IsAttached = true;
+ var handler = this.StyleAttached;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
+
+ public bool IsAttached { get; private set; }
+
+ public event EventHandler StyleDetached;
+
+ public event EventHandler StyleAttached;
}
}
Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs 2011-11-29 16:25:17 UTC (rev 6264)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs 2011-11-30 08:07:17 UTC (rev 6265)
@@ -820,42 +820,45 @@
private void ChangeBaseStyleBtn_Click(object sender, EventArgs e)
{
IVectorLayerDefinition vl = (IVectorLayerDefinition)m_layer.SubLayer;
- UserControl uc = null;
+ IFeatureStyleEditor uc = null;
if (m_ruleCollection is IPointVectorStyle)
{
- uc = new PointFeatureStyleEditor(m_editor, m_schema, vl.ResourceId);
- ((PointFeatureStyleEditor)uc).Item = (IPointSymbolization2D)Utility.XmlDeepCopy(m_defaultItem);
+ uc = new PointFeatureStyleEditor(m_editor, m_schema, vl.ResourceId, null, -1, (IPointSymbolization2D)m_defaultItem);
+ //((PointFeatureStyleEditor)uc).Item = (IPointSymbolization2D)Utility.XmlDeepCopy(m_defaultItem);
((PointFeatureStyleEditor)uc).SetupForTheming();
}
else if (m_ruleCollection is ILineVectorStyle)
{
- uc = new LineFeatureStyleEditor(m_editor, m_schema, vl.ResourceId, _factory);
var rule = _factory.CreateDefaultLineRule();
- ((LineFeatureStyleEditor)uc).Item = new List<IStroke>(rule.Strokes);
+ uc = new LineFeatureStyleEditor(m_editor, m_schema, vl.ResourceId, _factory, null, -1, new List<IStroke>(rule.Strokes));
+ //((LineFeatureStyleEditor)uc).Item = new List<IStroke>(rule.Strokes);
((LineFeatureStyleEditor)uc).SetupForTheming();
}
else if (m_ruleCollection is IAreaVectorStyle)
{
- uc = new AreaFeatureStyleEditor(m_editor, m_schema, vl.ResourceId);
- ((AreaFeatureStyleEditor)uc).Item = (IAreaSymbolizationFill)Utility.XmlDeepCopy(m_defaultItem);
+ uc = new AreaFeatureStyleEditor(m_editor, m_schema, vl.ResourceId, null, -1, (IAreaSymbolizationFill)m_defaultItem);
+ //((AreaFeatureStyleEditor)uc).Item = (IAreaSymbolizationFill)Utility.XmlDeepCopy(m_defaultItem);
((AreaFeatureStyleEditor)uc).SetupForTheming();
}
if (uc != null)
{
EditorTemplateForm dlg = new EditorTemplateForm();
- dlg.ItemPanel.Controls.Add(uc);
- uc.Dock = DockStyle.Fill;
+ dlg.ItemPanel.Controls.Add(uc.Content);
+ uc.Content.Dock = DockStyle.Fill;
dlg.RefreshSize();
- if (dlg.ShowDialog(this) == DialogResult.OK)
+ if (dlg.ShowDialog(this) != DialogResult.OK)
{
+ uc.RejectChanges();
+ /*
if (m_ruleCollection is IPointVectorStyle)
m_defaultItem = ((PointFeatureStyleEditor)uc).Item;
else if (m_ruleCollection is ILineVectorStyle)
m_defaultItem = ((LineFeatureStyleEditor)uc).Item;
else if (m_ruleCollection is IAreaVectorStyle)
m_defaultItem = ((AreaFeatureStyleEditor)uc).Item;
+ */
}
}
More information about the mapguide-commits
mailing list