Opened 13 years ago

Closed 13 years ago

#1811 closed defect (fixed)

Maestro UI Does Not Respect Field/Property Use for Colours

Reported by: crispinatime Owned by: jng
Priority: low Milestone: Maestro-4.0
Component: Maestro Version:
Severity: minor Keywords:
Cc: External ID:

Description

MapGuide supports field properties for <ForegroundColor> and <BackgroundColor> but Maestro 4b1 throws an error when opening this XML in the UI - by trying an HTML colour conversion.

  • Full fix: update the colour selection UI to support fields
  • Partial fix: prevent exception (shown below)

Current workaround is to use XML editor.

<?xml version="1.0" encoding="utf-8"?>
<LayerDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.3.0" xsi:noNamespaceSchemaLocation="LayerDefinition-1.3.0.xsd">
  <VectorLayerDefinition>
    <ResourceId>Library://ABC/Data/SQLite_Redline.FeatureSource</ResourceId>
    <FeatureName>Default:Redline_Polygon</FeatureName>
    <FeatureNameType>FeatureClass</FeatureNameType>
    <Filter />
    <PropertyMapping>
      <Name>ID</Name>
      <Value>ID</Value>
    </PropertyMapping>
    <PropertyMapping>
      <Name>SessionID</Name>
      <Value>SessionID</Value>
    </PropertyMapping>
    <PropertyMapping>
      <Name>Style_Colour</Name>
      <Value>Style_Colour</Value>
    </PropertyMapping>
    <PropertyMapping>
      <Name>Style_Linetype</Name>
      <Value>Style_Linetype</Value>
    </PropertyMapping>
    <PropertyMapping>
      <Name>Style_Weight</Name>
      <Value>Style_Weight</Value>
    </PropertyMapping>
    <PropertyMapping>
      <Name>Style_Colour_Background</Name>
      <Value>Style_Colour_Background</Value>
    </PropertyMapping>
    <PropertyMapping>
      <Name>Style_Fill</Name>
      <Value>Style_Fill</Value>
    </PropertyMapping>
    <Geometry>Geometry</Geometry>
    <Url />
    <ToolTip />
    <VectorScaleRange>
      <AreaTypeStyle>
        <AreaRule>
          <LegendLabel />
          <Filter>Style_Fill = 'LINE'</Filter>
          <AreaSymbolization2D>
            <Fill>
              <FillPattern>LINE</FillPattern>
              <ForegroundColor>Style_Colour</ForegroundColor>
              <BackgroundColor>Style_Colour_Background</BackgroundColor>
            </Fill>
            <Stroke>
              <LineStyle>Solid</LineStyle>
              <Thickness>1</Thickness>
              <Color>Style_Colour</Color>
              <Unit>Points</Unit>
              <SizeContext>DeviceUnits</SizeContext>
            </Stroke>
          </AreaSymbolization2D>
        </AreaRule>
        <AreaRule>
          <LegendLabel />
          <Filter>Style_Fill = 'LINE_90'</Filter>
          <AreaSymbolization2D>
            <Fill>
              <FillPattern>LINE_90</FillPattern>
              <ForegroundColor>Style_Colour</ForegroundColor>
              <BackgroundColor>Style_Colour_Background</BackgroundColor>
            </Fill>
            <Stroke>
              <LineStyle>Solid</LineStyle>
              <Thickness>1</Thickness>
              <Color>Style_Colour</Color>
              <Unit>Points</Unit>
              <SizeContext>DeviceUnits</SizeContext>
            </Stroke>
          </AreaSymbolization2D>
        </AreaRule>
      </AreaTypeStyle>
    </VectorScaleRange>
  </VectorLayerDefinition>
</LayerDefinition>
System.Exception: Bad HTML color: "Style_Colour_Background"
   at OSGeo.MapGuide.MaestroAPI.Utility.ParseHTMLColor(String color) in e:\Projects\Maestro\OSGeo.MapGuide.MaestroAPI\Utility.cs:line 107
   at Maestro.Editors.LayerDefinition.Vector.FeaturePreviewRender.RenderPreviewArea(Graphics g, Rectangle size, IAreaSymbolizationFill item) in e:\Projects\Maestro\Maestro.Editors\LayerDefinition\Vector\FeaturePreviewRender.cs:line 99
   at Maestro.Editors.LayerDefinition.Vector.Scales.ItemStyle.previewPicture_Paint(Object sender, PaintEventArgs e) in e:\Projects\Maestro\Maestro.Editors\LayerDefinition\Vector\Scales\ItemStyle.cs:line 152
   at System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Change History (7)

comment:1 by crispinatime, 13 years ago

Summary: Maestro UI Does Not Respect Fields forMaestro UI Does Not Respect Field/Property Use for Colours

comment:2 by jng, 13 years ago

Resolution: fixed
Status: newclosed

Fixed r6137. Re-open if you find any problems with this change.

comment:3 by crispinatime, 13 years ago

Resolution: fixed
Status: closedreopened

I am now getting a different exception (see below). But, I think the new colour control is really great and exposes some non-obvious functionality.

Is there a way to find out which layer elements support expressions? I am having to use thematic filters to display different linestyles and fills because of they way they are enumerated. Same for text background style, italic and bold. Would learning composite symbols help me here?

In addition: Obviously if you just save the XML above without the referenced .FeatureSource you will not be able to load the .LayerDefinition... but I think it would be nice to catch the exception "MgResourceNotFoundException" separately and give a nice message like "The underlying data featuresource {0} is missing - please ensure you blah, blah" rather than having a scary stack trace.

System.ArgumentNullException: Value cannot be null.
Parameter name: image
   at System.Drawing.TextureBrush..ctor(Image image, WrapMode wrapMode)
   at System.Drawing.TextureBrush..ctor(Image bitmap)
   at Maestro.Editors.LayerDefinition.Vector.FeaturePreviewRender.RenderPreviewArea(Graphics g, Rectangle size, IAreaSymbolizationFill item) in e:\Projects\Maestro\Maestro.Editors\LayerDefinition\Vector\FeaturePreviewRender.cs:line 116
   at Maestro.Editors.LayerDefinition.Vector.Scales.ItemStyle.previewPicture_Paint(Object sender, PaintEventArgs e) in e:\Projects\Maestro\Maestro.Editors\LayerDefinition\Vector\Scales\ItemStyle.cs:line 152
   at System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

comment:4 by jng, 13 years ago

Give r6141 a try

comment:5 by crispinatime, 13 years ago

Resolution: fixed
Status: reopenedclosed

Hi - almost perfect - all my layers now load, the broken FeatureSource re-link is a nice implementation... only minor niggle is the colour-coding on the resource tree does not go back to 'red' when you have fixed a broken FeatureSource. But I can live with that and this particular ticket issue can be closed, thank you.

comment:6 by crispinatime, 13 years ago

Resolution: fixed
Status: closedreopened

Hmmm,

OK - the issue now is that Maestro is great for advanced users but has maybe lost too much for the casual user.

Now, if you have a specified colour it shows as the ARGB code - not so bad BUT importantly you have lost the UI for transparency and have to edit the first two characters in hex. The old slider was obviously a better UI.

I don't have the solution but want to raise the effect of this change on regular layers.

comment:7 by jng, 13 years ago

Resolution: fixed
Status: reopenedclosed

Fixed r6147

Note: See TracTickets for help on using tickets.