[prev in list] [next in list] [prev in thread] [next in thread]
List: mapguide-commits
Subject: [mapguide-commits] r6599 - in trunk/MgDev/Desktop: MapViewer MapViewerTest
From: svn_mapguide () osgeo ! org
Date: 2012-04-28 10:40:05
Message-ID: 20120428104005.EF7B43903D9 () trac ! osgeo ! org
[Download RAW message or body]
Author: jng
Date: 2012-04-28 03:40:05 -0700 (Sat, 28 Apr 2012)
New Revision: 6599
Added:
trunk/MgDev/Desktop/MapViewer/MgQueryControl.Designer.cs
trunk/MgDev/Desktop/MapViewer/MgQueryControl.cs
trunk/MgDev/Desktop/MapViewer/MgQueryControl.resx
trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.Designer.cs
trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.cs
trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.resx
Modified:
trunk/MgDev/Desktop/MapViewer/IMapViewer.cs
trunk/MgDev/Desktop/MapViewer/MapViewer.Net40.csproj
trunk/MgDev/Desktop/MapViewer/MgMapViewer.cs
trunk/MgDev/Desktop/MapViewerTest/Form1.Designer.cs
trunk/MgDev/Desktop/MapViewerTest/Form1.cs
trunk/MgDev/Desktop/MapViewerTest/Form1.resx
Log:
More mg-desktop updates:
- Add a new generic query control with support for spatial and/or single property \
filtering
- Add a new overload of IMapViewer.UpdateSelection() allowing to indicate whether \
the viewer should raise SelectionChanged event.
Modified: trunk/MgDev/Desktop/MapViewer/IMapViewer.cs
===================================================================
--- trunk/MgDev/Desktop/MapViewer/IMapViewer.cs 2012-04-27 16:59:42 UTC (rev 6598)
+++ trunk/MgDev/Desktop/MapViewer/IMapViewer.cs 2012-04-28 10:40:05 UTC (rev 6599)
@@ -211,6 +211,13 @@
void UpdateSelection();
/// <summary>
+ /// Updates the rendered selection. Call this method if you have manipulated \
the selection + /// set outside of the viewer
+ /// </summary>
+ /// <param name="raise">Indicates if the <see cref="SelectionChanged"/> \
event should be raised as well</param> + void UpdateSelection(bool raise);
+
+ /// <summary>
/// Selects features from all selectable layers that intersects the given \
geometry /// </summary>
/// <param name="geom"></param>
Modified: trunk/MgDev/Desktop/MapViewer/MapViewer.Net40.csproj
===================================================================
--- trunk/MgDev/Desktop/MapViewer/MapViewer.Net40.csproj 2012-04-27 16:59:42 UTC (rev \
6598)
+++ trunk/MgDev/Desktop/MapViewer/MapViewer.Net40.csproj 2012-04-28 10:40:05 UTC (rev \
6599) @@ -122,6 +122,18 @@
<Compile Include="MgPropertyPane.Designer.cs">
<DependentUpon>MgPropertyPane.cs</DependentUpon>
</Compile>
+ <Compile Include="MgQueryControl.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
+ <Compile Include="MgQueryControl.Designer.cs">
+ <DependentUpon>MgQueryControl.cs</DependentUpon>
+ </Compile>
+ <Compile Include="MgQueryResultsDialog.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="MgQueryResultsDialog.Designer.cs">
+ <DependentUpon>MgQueryResultsDialog.cs</DependentUpon>
+ </Compile>
<Compile Include="MgReadOnlyStream.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
@@ -148,6 +160,12 @@
<EmbeddedResource Include="MgPropertyPane.resx">
<DependentUpon>MgPropertyPane.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="MgQueryControl.resx">
+ <DependentUpon>MgQueryControl.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="MgQueryResultsDialog.resx">
+ <DependentUpon>MgQueryResultsDialog.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Modified: trunk/MgDev/Desktop/MapViewer/MgMapViewer.cs
===================================================================
--- trunk/MgDev/Desktop/MapViewer/MgMapViewer.cs 2012-04-27 16:59:42 UTC (rev 6598)
+++ trunk/MgDev/Desktop/MapViewer/MgMapViewer.cs 2012-04-28 10:40:05 UTC (rev 6599)
@@ -1253,11 +1253,27 @@
/// <summary>
/// Updates the rendered selection. Call this method if you have manipulated \
the selection
- /// set outside of the viewer
+ /// set outside of the viewer. This does not raise the <see \
cref="SelectionChanged"/> event /// </summary>
public void UpdateSelection()
{
+ UpdateSelection(false);
+ }
+
+ /// <summary>
+ /// Updates the rendered selection. Call this method if you have manipulated \
the selection + /// set outside of the viewer
+ /// </summary>
+ /// <param name="raise">Indicates if the <see cref="SelectionChanged"/> \
event should be raised as well</param> + public void UpdateSelection(bool \
raise) + {
RenderSelection();
+ if (raise)
+ {
+ var handler = this.SelectionChanged;
+ if (handler != null)
+ handler(this, EventArgs.Empty);
+ }
}
internal void RenderSelection()
Added: trunk/MgDev/Desktop/MapViewer/MgQueryControl.Designer.cs
===================================================================
--- trunk/MgDev/Desktop/MapViewer/MgQueryControl.Designer.cs \
(rev 0)
+++ trunk/MgDev/Desktop/MapViewer/MgQueryControl.Designer.cs 2012-04-28 10:40:05 UTC \
(rev 6599) @@ -0,0 +1,329 @@
+namespace OSGeo.MapGuide.Viewer
+{
+ partial class MgQueryControl
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; \
otherwise, false.</param> + protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.cmbLayer = new System.Windows.Forms.ComboBox();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.txtValue = new System.Windows.Forms.TextBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.cmbOperator = new System.Windows.Forms.ComboBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.cmbProperty = new System.Windows.Forms.ComboBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.chkPropFilterEnabled = new System.Windows.Forms.CheckBox();
+ this.groupBox3 = new System.Windows.Forms.GroupBox();
+ this.spatialFilterButtonPanel = new \
System.Windows.Forms.FlowLayoutPanel(); + this.btnRectangle = new \
System.Windows.Forms.Button(); + this.btnPolygon = new \
System.Windows.Forms.Button(); + this.btnClear = new \
System.Windows.Forms.Button(); + this.chkSpatialFilter = new \
System.Windows.Forms.CheckBox(); + this.btnExecute = new \
System.Windows.Forms.Button(); + this.label5 = new \
System.Windows.Forms.Label(); + this.numResults = new \
System.Windows.Forms.NumericUpDown(); + this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.groupBox3.SuspendLayout();
+ this.spatialFilterButtonPanel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.numResults)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.label1);
+ this.groupBox1.Controls.Add(this.cmbLayer);
+ this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
+ this.groupBox1.Location = new System.Drawing.Point(0, 0);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(266, 82);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Layer";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(16, 20);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(75, 13);
+ this.label1.TabIndex = 1;
+ this.label1.Text = "Select a Layer";
+ //
+ // cmbLayer
+ //
+ this.cmbLayer.Anchor = \
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | \
System.Windows.Forms.AnchorStyles.Left) + | \
System.Windows.Forms.AnchorStyles.Right))); + this.cmbLayer.DisplayMember \
= "Name"; + this.cmbLayer.DropDownStyle = \
System.Windows.Forms.ComboBoxStyle.DropDownList; + \
this.cmbLayer.FormattingEnabled = true; + this.cmbLayer.Location = new \
System.Drawing.Point(16, 45); + this.cmbLayer.Name = "cmbLayer";
+ this.cmbLayer.Size = new System.Drawing.Size(231, 21);
+ this.cmbLayer.TabIndex = 0;
+ this.cmbLayer.SelectedIndexChanged += new \
System.EventHandler(this.cmbLayer_SelectedIndexChanged); + //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.txtValue);
+ this.groupBox2.Controls.Add(this.label4);
+ this.groupBox2.Controls.Add(this.cmbOperator);
+ this.groupBox2.Controls.Add(this.label3);
+ this.groupBox2.Controls.Add(this.cmbProperty);
+ this.groupBox2.Controls.Add(this.label2);
+ this.groupBox2.Controls.Add(this.chkPropFilterEnabled);
+ this.groupBox2.Dock = System.Windows.Forms.DockStyle.Top;
+ this.groupBox2.Location = new System.Drawing.Point(0, 82);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(266, 187);
+ this.groupBox2.TabIndex = 1;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Property Filter";
+ //
+ // txtValue
+ //
+ this.txtValue.Anchor = \
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | \
System.Windows.Forms.AnchorStyles.Left) + | \
System.Windows.Forms.AnchorStyles.Right))); + this.txtValue.Location = new \
System.Drawing.Point(16, 145); + this.txtValue.Name = "txtValue";
+ this.txtValue.Size = new System.Drawing.Size(231, 20);
+ this.txtValue.TabIndex = 6;
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(16, 129);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(34, 13);
+ this.label4.TabIndex = 5;
+ this.label4.Text = "Value";
+ //
+ // cmbOperator
+ //
+ this.cmbOperator.Anchor = \
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | \
System.Windows.Forms.AnchorStyles.Left) + | \
System.Windows.Forms.AnchorStyles.Right))); + \
this.cmbOperator.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + \
this.cmbOperator.FormattingEnabled = true; + this.cmbOperator.Location = \
new System.Drawing.Point(16, 101); + this.cmbOperator.Name = \
"cmbOperator"; + this.cmbOperator.Size = new System.Drawing.Size(231, 21);
+ this.cmbOperator.TabIndex = 4;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(16, 85);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(48, 13);
+ this.label3.TabIndex = 3;
+ this.label3.Text = "Operator";
+ //
+ // cmbProperty
+ //
+ this.cmbProperty.Anchor = \
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | \
System.Windows.Forms.AnchorStyles.Left) + | \
System.Windows.Forms.AnchorStyles.Right))); + \
this.cmbProperty.DisplayMember = "Name"; + this.cmbProperty.DropDownStyle \
= System.Windows.Forms.ComboBoxStyle.DropDownList; + \
this.cmbProperty.FormattingEnabled = true; + this.cmbProperty.Location = \
new System.Drawing.Point(16, 60); + this.cmbProperty.Name = "cmbProperty";
+ this.cmbProperty.Size = new System.Drawing.Size(231, 21);
+ this.cmbProperty.TabIndex = 2;
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(16, 44);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(46, 13);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Property";
+ //
+ // chkPropFilterEnabled
+ //
+ this.chkPropFilterEnabled.AutoSize = true;
+ this.chkPropFilterEnabled.Location = new System.Drawing.Point(19, 20);
+ this.chkPropFilterEnabled.Name = "chkPropFilterEnabled";
+ this.chkPropFilterEnabled.Size = new System.Drawing.Size(65, 17);
+ this.chkPropFilterEnabled.TabIndex = 0;
+ this.chkPropFilterEnabled.Text = "Enabled";
+ this.chkPropFilterEnabled.UseVisualStyleBackColor = true;
+ //
+ // groupBox3
+ //
+ this.groupBox3.Controls.Add(this.spatialFilterButtonPanel);
+ this.groupBox3.Controls.Add(this.chkSpatialFilter);
+ this.groupBox3.Dock = System.Windows.Forms.DockStyle.Top;
+ this.groupBox3.Location = new System.Drawing.Point(0, 269);
+ this.groupBox3.Name = "groupBox3";
+ this.groupBox3.Size = new System.Drawing.Size(266, 119);
+ this.groupBox3.TabIndex = 2;
+ this.groupBox3.TabStop = false;
+ this.groupBox3.Text = "Spatial Filter";
+ //
+ // spatialFilterButtonPanel
+ //
+ this.spatialFilterButtonPanel.Anchor = \
((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | \
System.Windows.Forms.AnchorStyles.Bottom) + | \
System.Windows.Forms.AnchorStyles.Left) + | \
System.Windows.Forms.AnchorStyles.Right))); + \
this.spatialFilterButtonPanel.Controls.Add(this.btnRectangle); + \
this.spatialFilterButtonPanel.Controls.Add(this.btnPolygon); + \
this.spatialFilterButtonPanel.Controls.Add(this.btnClear); + \
this.spatialFilterButtonPanel.Location = new System.Drawing.Point(19, 43); + \
this.spatialFilterButtonPanel.Name = "spatialFilterButtonPanel"; + \
this.spatialFilterButtonPanel.Size = new System.Drawing.Size(228, 60); + \
this.spatialFilterButtonPanel.TabIndex = 2; + //
+ // btnRectangle
+ //
+ this.btnRectangle.Location = new System.Drawing.Point(3, 3);
+ this.btnRectangle.Name = "btnRectangle";
+ this.btnRectangle.Size = new System.Drawing.Size(75, 23);
+ this.btnRectangle.TabIndex = 2;
+ this.btnRectangle.Text = "Rectangle";
+ this.btnRectangle.UseVisualStyleBackColor = true;
+ this.btnRectangle.Click += new \
System.EventHandler(this.btnRectangle_Click); + //
+ // btnPolygon
+ //
+ this.btnPolygon.Location = new System.Drawing.Point(84, 3);
+ this.btnPolygon.Name = "btnPolygon";
+ this.btnPolygon.Size = new System.Drawing.Size(75, 23);
+ this.btnPolygon.TabIndex = 3;
+ this.btnPolygon.Text = "Polygon";
+ this.btnPolygon.UseVisualStyleBackColor = true;
+ this.btnPolygon.Click += new System.EventHandler(this.btnPolygon_Click);
+ //
+ // btnClear
+ //
+ this.btnClear.Location = new System.Drawing.Point(3, 32);
+ this.btnClear.Name = "btnClear";
+ this.btnClear.Size = new System.Drawing.Size(75, 23);
+ this.btnClear.TabIndex = 4;
+ this.btnClear.Text = "Clear";
+ this.btnClear.UseVisualStyleBackColor = true;
+ this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
+ //
+ // chkSpatialFilter
+ //
+ this.chkSpatialFilter.AutoSize = true;
+ this.chkSpatialFilter.Location = new System.Drawing.Point(19, 19);
+ this.chkSpatialFilter.Name = "chkSpatialFilter";
+ this.chkSpatialFilter.Size = new System.Drawing.Size(65, 17);
+ this.chkSpatialFilter.TabIndex = 1;
+ this.chkSpatialFilter.Text = "Enabled";
+ this.chkSpatialFilter.UseVisualStyleBackColor = true;
+ //
+ // btnExecute
+ //
+ this.btnExecute.Location = new System.Drawing.Point(16, 395);
+ this.btnExecute.Name = "btnExecute";
+ this.btnExecute.Size = new System.Drawing.Size(75, 23);
+ this.btnExecute.TabIndex = 3;
+ this.btnExecute.Text = "Execute";
+ this.btnExecute.UseVisualStyleBackColor = true;
+ this.btnExecute.Click += new System.EventHandler(this.btnExecute_Click);
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(97, 400);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(42, 13);
+ this.label5.TabIndex = 4;
+ this.label5.Text = "Results";
+ //
+ // numResults
+ //
+ this.numResults.Anchor = \
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | \
System.Windows.Forms.AnchorStyles.Left) + | \
System.Windows.Forms.AnchorStyles.Right))); + this.numResults.Location = \
new System.Drawing.Point(143, 398); + this.numResults.Maximum = new \
decimal(new int[] { + 10000,
+ 0,
+ 0,
+ 0});
+ this.numResults.Name = "numResults";
+ this.numResults.Size = new System.Drawing.Size(104, 20);
+ this.numResults.TabIndex = 5;
+ this.numResults.Value = new decimal(new int[] {
+ 100,
+ 0,
+ 0,
+ 0});
+ //
+ // MgQueryControl
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.numResults);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.btnExecute);
+ this.Controls.Add(this.groupBox3);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.groupBox1);
+ this.Name = "MgQueryControl";
+ this.Size = new System.Drawing.Size(266, 431);
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.groupBox3.ResumeLayout(false);
+ this.groupBox3.PerformLayout();
+ this.spatialFilterButtonPanel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.numResults)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.ComboBox cmbLayer;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.CheckBox chkPropFilterEnabled;
+ private System.Windows.Forms.GroupBox groupBox3;
+ private System.Windows.Forms.CheckBox chkSpatialFilter;
+ private System.Windows.Forms.TextBox txtValue;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.ComboBox cmbOperator;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.ComboBox cmbProperty;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.FlowLayoutPanel spatialFilterButtonPanel;
+ private System.Windows.Forms.Button btnRectangle;
+ private System.Windows.Forms.Button btnPolygon;
+ private System.Windows.Forms.Button btnClear;
+ private System.Windows.Forms.Button btnExecute;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.NumericUpDown numResults;
+ }
+}
Added: trunk/MgDev/Desktop/MapViewer/MgQueryControl.cs
===================================================================
--- trunk/MgDev/Desktop/MapViewer/MgQueryControl.cs (rev 0)
+++ trunk/MgDev/Desktop/MapViewer/MgQueryControl.cs 2012-04-28 10:40:05 UTC (rev \
6599) @@ -0,0 +1,205 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace OSGeo.MapGuide.Viewer
+{
+ public partial class MgQueryControl : UserControl
+ {
+ private IMapViewer _viewer;
+ private MgWktReaderWriter _wktRw;
+ private MgGeometryFactory _geomFact;
+
+ private BindingList<MgDataPropertyDefinition> _properties;
+ private BindingList<MgLayerBase> _layers;
+
+ public MgQueryControl(IMapViewer viewer)
+ {
+ InitializeComponent();
+ this.Disposed += new EventHandler(OnDisposed);
+ _viewer = viewer;
+ _properties = new BindingList<MgDataPropertyDefinition>();
+ _layers = new BindingList<MgLayerBase>();
+ _wktRw = new MgWktReaderWriter();
+ _geomFact = new MgGeometryFactory();
+
+ cmbOperator.DataSource = Enum.GetValues(typeof(QueryOperator));
+ cmbLayer.DataSource = _layers;
+ cmbProperty.DataSource = _properties;
+
+ cmbOperator.SelectedIndex = 0;
+
+ var map = viewer.GetMap();
+ var layers = map.GetLayers();
+ for (var i = 0; i < layers.GetCount(); i++)
+ {
+ _layers.Add(layers.GetItem(i));
+ }
+ cmbLayer.SelectedIndex = 0;
+ }
+
+ void OnDisposed(object sender, EventArgs e)
+ {
+ _properties.Clear();
+ _layers.Clear();
+ _wktRw.Dispose();
+ _wktRw = null;
+ _geomFact.Dispose();
+ _geomFact = null;
+ }
+
+ private void cmbLayer_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ var layer = cmbLayer.SelectedItem as MgLayerBase;
+ if (layer != null)
+ {
+ var cls = layer.GetClassDefinition();
+ var clsProps = cls.GetProperties();
+ _properties.Clear();
+ for (var i = 0; i < clsProps.GetCount(); i++)
+ {
+ var prop = clsProps.GetItem(i);
+ if (prop.GetPropertyType() == \
MgFeaturePropertyType.DataProperty) + {
+ _properties.Add((MgDataPropertyDefinition)prop);
+ }
+ }
+ cmbProperty.SelectedIndex = 0;
+ }
+ }
+
+ static string MakeWktPolygon(double x1, double y1, double x2, double y2)
+ {
+ return "POLYGON((" + x1 + " " + y1 + ", " + x2 + " " + y1 + ", " + x2 + \
" " + y2 + ", " + x1 + " " + y2 + ", " + x1 + " " + y1 + "))"; + }
+
+ private MgGeometry _filterGeometry;
+
+ private void btnRectangle_Click(object sender, EventArgs e)
+ {
+ _viewer.DigitizeRectangle((llx, lly, urx, ury) =>
+ {
+ ClearFilterGeometry();
+ _filterGeometry = _wktRw.Read(MakeWktPolygon(llx, lly, urx, ury));
+ });
+ }
+
+ private void btnPolygon_Click(object sender, EventArgs e)
+ {
+ _viewer.DigitizePolygon((coordinates) =>
+ {
+ ClearFilterGeometry();
+ MgCoordinateCollection coords = new MgCoordinateCollection();
+ for (int i = 0; i < coordinates.GetLength(0); i++)
+ {
+ coords.Add(_geomFact.CreateCoordinateXY(coordinates[i, 0], \
coordinates[i, 1])); + }
+ coords.Add(_geomFact.CreateCoordinateXY(coordinates[0, 0], \
coordinates[0, 1])); + MgLinearRing ring = \
_geomFact.CreateLinearRing(coords); + _filterGeometry = \
_geomFact.CreatePolygon(ring, null); + });
+ }
+
+ private void ClearFilterGeometry()
+ {
+ if (_filterGeometry != null)
+ _filterGeometry.Dispose();
+ }
+
+ private void btnClear_Click(object sender, EventArgs e)
+ {
+ ClearFilterGeometry();
+ }
+
+ private void btnExecute_Click(object sender, EventArgs e)
+ {
+ var query = new MgFeatureQueryOptions();
+ var provider = _viewer.GetProvider();
+ var layer = (MgLayerBase)cmbLayer.SelectedItem;
+ var prop = (MgDataPropertyDefinition)cmbProperty.SelectedItem;
+ var op = (QueryOperator)cmbOperator.SelectedItem;
+
+ if (chkPropFilterEnabled.Checked)
+ query.SetFilter(FilterToString(prop, op, txtValue.Text));
+ if (chkSpatialFilter.Checked)
+ query.SetSpatialFilter(layer.GetFeatureGeometryName(), \
_filterGeometry, MgFeatureSpatialOperations.Intersects); +
+ var reader = layer.SelectFeatures(query);
+ new MgQueryResultsDialog(_viewer, layer, reader, \
Convert.ToInt32(numResults.Value)).Show(); + }
+
+ static string FilterToString(MgDataPropertyDefinition prop, QueryOperator \
op, string value) + {
+ var sb = new StringBuilder();
+
+ sb.Append(prop.Name + " ");
+
+ switch (op)
+ {
+ case QueryOperator.EqualTo:
+ sb.Append(" = ");
+ break;
+ case QueryOperator.GreaterThan:
+ sb.Append(" > ");
+ break;
+ case QueryOperator.GreaterThanOrEqualTo:
+ sb.Append(" >= ");
+ break;
+ case QueryOperator.In:
+ sb.Append(" IN ");
+ break;
+ case QueryOperator.LessThan:
+ sb.Append(" < ");
+ break;
+ case QueryOperator.LessThanOrEqualTo:
+ sb.Append(" <= ");
+ break;
+ case QueryOperator.Like:
+ sb.Append(" LIKE ");
+ break;
+ case QueryOperator.NotEqualTo:
+ sb.Append(" <> ");
+ break;
+ }
+
+ if (op == QueryOperator.In)
+ {
+ sb.Append("(");
+ sb.Append(value);
+ sb.Append(")");
+ }
+ else
+ {
+ if (prop.DataType == MgPropertyType.String)
+ {
+ sb.Append("'");
+ sb.Append(value);
+ sb.Append("'");
+ }
+ else
+ {
+ sb.Append(value);
+ }
+ }
+
+ return sb.ToString();
+ }
+ }
+
+ public enum QueryOperator
+ {
+ EqualTo,
+ NotEqualTo,
+ GreaterThan,
+ GreaterThanOrEqualTo,
+ LessThan,
+ LessThanOrEqualTo,
+ Like,
+ In
+ }
+}
Added: trunk/MgDev/Desktop/MapViewer/MgQueryControl.resx
===================================================================
--- trunk/MgDev/Desktop/MapViewer/MgQueryControl.resx (rev 0)
+++ trunk/MgDev/Desktop/MapViewer/MgQueryControl.resx 2012-04-28 10:40:05 UTC (rev \
6599) @@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, \
System.Windows.Forms, ...</resheader> + <resheader \
name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, \
...</resheader> + <data name="Name1"><value>this is my long \
string</value><comment>this is a comment</comment></data> + <data name="Color1" \
type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" \
mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 \
mime encoded serialized .NET Framework object]</value> + </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" \
mimetype="application/x-microsoft.net.object.bytearray.base64"> + \
<value>[base64 mime encoded string representing a byte array form of the .NET \
Framework object]</value> + <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import \
namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" \
msdata:IsDataSet="true"> + <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" \
msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" \
minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" \
msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" \
msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" \
msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" \
msdata:Ordinal="1" /> + </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, \
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + \
</resheader> + <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, \
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + \
</resheader> +</root>
\ No newline at end of file
Added: trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.Designer.cs
===================================================================
--- trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.Designer.cs \
(rev 0)
+++ trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.Designer.cs 2012-04-28 \
10:40:05 UTC (rev 6599) @@ -0,0 +1,141 @@
+namespace OSGeo.MapGuide.Viewer
+{
+ partial class MgQueryResultsDialog
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; \
otherwise, false.</param> + protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.toolStrip1 = new System.Windows.Forms.ToolStrip();
+ this.btnSelect = new System.Windows.Forms.ToolStripButton();
+ this.btnZoom = new System.Windows.Forms.ToolStripButton();
+ this.statusStrip1 = new System.Windows.Forms.StatusStrip();
+ this.lblResults = new System.Windows.Forms.ToolStripStatusLabel();
+ this.grdResults = new System.Windows.Forms.DataGridView();
+ this.bgGridLoader = new System.ComponentModel.BackgroundWorker();
+ this.toolStrip1.SuspendLayout();
+ this.statusStrip1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.grdResults)).BeginInit();
+ this.SuspendLayout();
+ //
+ // toolStrip1
+ //
+ this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] \
{ + this.btnSelect,
+ this.btnZoom});
+ this.toolStrip1.Location = new System.Drawing.Point(0, 0);
+ this.toolStrip1.Name = "toolStrip1";
+ this.toolStrip1.Size = new System.Drawing.Size(904, 25);
+ this.toolStrip1.TabIndex = 0;
+ this.toolStrip1.Text = "toolStrip1";
+ //
+ // btnSelect
+ //
+ this.btnSelect.Enabled = false;
+ this.btnSelect.Image = \
global::OSGeo.MapGuide.Viewer.Properties.Resources.select_features; + \
this.btnSelect.ImageTransparentColor = System.Drawing.Color.Magenta; + \
this.btnSelect.Name = "btnSelect"; + this.btnSelect.Size = new \
System.Drawing.Size(58, 22); + this.btnSelect.Text = "Select";
+ this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
+ //
+ // btnZoom
+ //
+ this.btnZoom.Enabled = false;
+ this.btnZoom.Image = \
global::OSGeo.MapGuide.Viewer.Properties.Resources.search; + \
this.btnZoom.ImageTransparentColor = System.Drawing.Color.Magenta; + \
this.btnZoom.Name = "btnZoom"; + this.btnZoom.Size = new \
System.Drawing.Size(59, 22); + this.btnZoom.Text = "Zoom";
+ this.btnZoom.Click += new System.EventHandler(this.btnZoom_Click);
+ //
+ // statusStrip1
+ //
+ this.statusStrip1.Items.AddRange(new \
System.Windows.Forms.ToolStripItem[] { + this.lblResults});
+ this.statusStrip1.Location = new System.Drawing.Point(0, 302);
+ this.statusStrip1.Name = "statusStrip1";
+ this.statusStrip1.Size = new System.Drawing.Size(904, 22);
+ this.statusStrip1.TabIndex = 1;
+ this.statusStrip1.Text = "statusStrip1";
+ //
+ // lblResults
+ //
+ this.lblResults.Name = "lblResults";
+ this.lblResults.Size = new System.Drawing.Size(0, 17);
+ //
+ // grdResults
+ //
+ this.grdResults.AllowUserToAddRows = false;
+ this.grdResults.AllowUserToDeleteRows = false;
+ this.grdResults.ColumnHeadersHeightSizeMode = \
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + \
this.grdResults.Dock = System.Windows.Forms.DockStyle.Fill; + \
this.grdResults.Location = new System.Drawing.Point(0, 25); + \
this.grdResults.Name = "grdResults"; + this.grdResults.ReadOnly = true;
+ this.grdResults.Size = new System.Drawing.Size(904, 277);
+ this.grdResults.TabIndex = 2;
+ this.grdResults.SelectionChanged += new \
System.EventHandler(this.grdResults_SelectionChanged); + //
+ // bgGridLoader
+ //
+ this.bgGridLoader.WorkerReportsProgress = true;
+ this.bgGridLoader.DoWork += new \
System.ComponentModel.DoWorkEventHandler(this.bgGridLoader_DoWork); + \
this.bgGridLoader.ProgressChanged += new \
System.ComponentModel.ProgressChangedEventHandler(this.bgGridLoader_ProgressChanged); \
+ this.bgGridLoader.RunWorkerCompleted += new \
System.ComponentModel.RunWorkerCompletedEventHandler(this.bgGridLoader_RunWorkerCompleted);
+ //
+ // MgQueryResultsDialog
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(904, 324);
+ this.Controls.Add(this.grdResults);
+ this.Controls.Add(this.statusStrip1);
+ this.Controls.Add(this.toolStrip1);
+ this.Name = "MgQueryResultsDialog";
+ this.ShowIcon = false;
+ this.StartPosition = \
System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Query \
Results"; + this.toolStrip1.ResumeLayout(false);
+ this.toolStrip1.PerformLayout();
+ this.statusStrip1.ResumeLayout(false);
+ this.statusStrip1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.grdResults)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ToolStrip toolStrip1;
+ private System.Windows.Forms.StatusStrip statusStrip1;
+ private System.Windows.Forms.DataGridView grdResults;
+ private System.Windows.Forms.ToolStripButton btnSelect;
+ private System.Windows.Forms.ToolStripButton btnZoom;
+ private System.Windows.Forms.ToolStripStatusLabel lblResults;
+ private System.ComponentModel.BackgroundWorker bgGridLoader;
+ }
+}
\ No newline at end of file
Added: trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.cs
===================================================================
--- trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.cs \
(rev 0)
+++ trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.cs 2012-04-28 10:40:05 UTC \
(rev 6599) @@ -0,0 +1,345 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace OSGeo.MapGuide.Viewer
+{
+ public partial class MgQueryResultsDialog : Form
+ {
+ private string _geomProp;
+ private string[] _identityProps;
+ private MgReader _reader;
+ private IMapViewer _viewer;
+ private Dictionary<string, int> _propMap;
+ private MgLayerBase _layer;
+ private int _limit;
+
+ private string[] _columns;
+
+ public MgQueryResultsDialog(IMapViewer viewer, MgLayerBase layer, MgReader \
reader, int limit) + {
+ InitializeComponent();
+ _viewer = viewer;
+ _reader = reader;
+ _geomProp = layer.GetFeatureGeometryName();
+ _layer = layer;
+ _limit = limit;
+ _propMap = new Dictionary<string, int>();
+ }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+ bgGridLoader.RunWorkerAsync(_reader);
+ }
+
+ private void bgGridLoader_DoWork(object sender, DoWorkEventArgs e)
+ {
+ var reader = (MgReader)e.Argument;
+ var wktRw = new MgWktReaderWriter();
+ var agfRw = new MgAgfReaderWriter();
+
+ var cls = _layer.GetClassDefinition();
+ var idProps = cls.GetIdentityProperties();
+ var idNames = new List<string>();
+ for (int i = 0; i < idProps.Count; i++)
+ {
+ var prop = idProps.GetItem(i);
+ idNames.Add(prop.Name);
+ }
+ _identityProps = idNames.ToArray();
+
+ var propNames = new List<string>();
+ int propCount = reader.GetPropertyCount();
+ HashSet<int> skipProps = new HashSet<int>();
+ for (int i = 0; i < propCount; i++)
+ {
+ var pt = reader.GetPropertyType(i);
+ if (pt == MgPropertyType.Blob ||
+ pt == MgPropertyType.Clob ||
+ pt == MgPropertyType.Feature ||
+ pt == MgPropertyType.Null ||
+ pt == MgPropertyType.Raster)
+ {
+ skipProps.Add(i);
+ }
+ else
+ {
+ var name = reader.GetPropertyName(i);
+ _propMap.Add(name, pt);
+ propNames.Add(name);
+ }
+ }
+ try
+ {
+ bgGridLoader.ReportProgress(-1, new InitGridAction() { ColumnNames = \
propNames.ToArray() }); + int read = 0;
+ while (reader.ReadNext() && read < _limit)
+ {
+ object[] values = new object[propCount];
+ for (int i = 0; i < propCount; i++)
+ {
+ if (skipProps.Contains(i))
+ continue;
+
+ if (reader.IsNull(i))
+ {
+ values[i] = null;
+ }
+ else
+ {
+ switch (reader.GetPropertyType(i))
+ {
+ case MgPropertyType.Boolean:
+ values[i] = reader.GetBoolean(i);
+ break;
+ case MgPropertyType.Byte:
+ values[i] = reader.GetByte(i);
+ break;
+ case MgPropertyType.DateTime:
+ values[i] = \
ToClrDateTime(reader.GetDateTime(i)); + break;
+ case MgPropertyType.Decimal:
+ case MgPropertyType.Double:
+ values[i] = reader.GetDouble(i);
+ break;
+ case MgPropertyType.Geometry:
+ {
+ try
+ {
+ var agf = reader.GetGeometry(i);
+ var geom = agfRw.Read(agf);
+ var env = geom.Envelope();
+ var envLL = env.LowerLeftCoordinate;
+ var envUR = env.UpperRightCoordinate;
+ var wkt = wktRw.Write(geom);
+
+ values[i] = new BoxedGeometry()
+ {
+ Text = wkt,
+ GeomBounds = new Bounds()
+ {
+ LowerX = envLL.X,
+ LowerY = envLL.Y,
+ UpperX = envUR.X,
+ UpperY = envUR.Y
+ }
+ };
+ }
+ catch
+ {
+ values[i] = null;
+ }
+ }
+ break;
+ case MgPropertyType.Int16:
+ values[i] = reader.GetInt16(i);
+ break;
+ case MgPropertyType.Int32:
+ values[i] = reader.GetInt32(i);
+ break;
+ case MgPropertyType.Int64:
+ values[i] = reader.GetInt64(i);
+ break;
+ case MgPropertyType.Single:
+ values[i] = reader.GetSingle(i);
+ break;
+ case MgPropertyType.String :
+ values[i] = reader.GetString(i);
+ break;
+ }
+ }
+ }
+ bgGridLoader.ReportProgress(-1, new AddRow() { Values = values \
}); + read++;
+ }
+ }
+ finally
+ {
+ reader.Close();
+ wktRw.Dispose();
+ agfRw.Dispose();
+ wktRw = null;
+ agfRw = null;
+ }
+ }
+
+ private void bgGridLoader_ProgressChanged(object sender, \
ProgressChangedEventArgs e) + {
+ var action = (Progress)e.UserState;
+ if (action.Action == ProgressAction.InitGrid)
+ {
+ var columns = ((InitGridAction)action).ColumnNames;
+ for (int i = 0; i < columns.Length; i++)
+ {
+ grdResults.Columns.Add(columns[i], columns[i]);
+ }
+ _columns = columns;
+ }
+ else
+ {
+ grdResults.Rows.Add(((AddRow)action).Values);
+ }
+ }
+
+ private void bgGridLoader_RunWorkerCompleted(object sender, \
RunWorkerCompletedEventArgs e) + {
+ lblResults.Text = grdResults.Rows.Count + " results";
+ }
+
+ static DateTime ToClrDateTime(MgDateTime dt)
+ {
+ return new DateTime(dt.Year, dt.Day, dt.Month, dt.Hour, dt.Minute, \
dt.Second, dt.Microsecond / 1000); + }
+
+ abstract class Progress
+ {
+ public abstract ProgressAction Action { get; }
+ }
+
+ class InitGridAction : Progress
+ {
+ public override ProgressAction Action
+ {
+ get { return ProgressAction.InitGrid; }
+ }
+
+ public string[] ColumnNames { get; set; }
+ }
+
+ class AddRow : Progress
+ {
+ public override ProgressAction Action
+ {
+ get { return ProgressAction.AddRow; }
+ }
+
+ public object[] Values { get; set; }
+ }
+
+ enum ProgressAction
+ {
+ InitGrid,
+ AddRow
+ }
+
+ private void grdResults_SelectionChanged(object sender, EventArgs e)
+ {
+ btnZoom.Enabled = btnSelect.Enabled = (grdResults.SelectedRows.Count > \
0); + }
+
+ private void btnSelect_Click(object sender, EventArgs e)
+ {
+ _viewer.ClearSelection();
+ var sel = _viewer.GetSelection();
+
+ foreach (DataGridViewRow row in grdResults.SelectedRows)
+ {
+ MgPropertyCollection idProps = new MgPropertyCollection();
+ foreach (string name in _identityProps)
+ {
+ int idx = Array.IndexOf(_columns, name);
+ if (idx >= 0)
+ {
+ int type = _propMap[name];
+ switch (type)
+ {
+ case MgPropertyType.Boolean:
+ idProps.Add(new MgBooleanProperty(name, \
Convert.ToBoolean(row.Cells[idx].Value))); + break;
+ case MgPropertyType.Byte:
+ idProps.Add(new MgByteProperty(name, \
Convert.ToByte(row.Cells[idx].Value))); + break;
+ case MgPropertyType.DateTime:
+ idProps.Add(new MgDateTimeProperty(name, \
FromClrDateTime((DateTime)row.Cells[idx].Value))); + \
break; + case MgPropertyType.Decimal:
+ case MgPropertyType.Double:
+ idProps.Add(new MgDoubleProperty(name, \
Convert.ToDouble(row.Cells[idx].Value))); + break;
+ case MgPropertyType.Int16:
+ idProps.Add(new MgInt16Property(name, \
Convert.ToInt16(row.Cells[idx].Value))); + break;
+ case MgPropertyType.Int32:
+ idProps.Add(new MgInt32Property(name, \
Convert.ToInt32(row.Cells[idx].Value))); + break;
+ case MgPropertyType.Int64:
+ idProps.Add(new MgInt64Property(name, \
Convert.ToInt64(row.Cells[idx].Value))); + break;
+ case MgPropertyType.Single:
+ idProps.Add(new MgSingleProperty(name, \
Convert.ToSingle(row.Cells[idx].Value))); + break;
+ case MgPropertyType.String:
+ idProps.Add(new MgStringProperty(name, \
Convert.ToString(row.Cells[idx].Value))); + break;
+ }
+ }
+ }
+ if (idProps.Count == _identityProps.Length)
+ {
+ sel.AddFeatureIds(_layer, _layer.FeatureClassName, idProps);
+ }
+ else
+ {
+ idProps.Dispose();
+ idProps = null;
+ }
+ }
+ _viewer.UpdateSelection(true);
+ }
+
+ static MgDateTime FromClrDateTime(DateTime dt)
+ {
+ return new MgDateTime((short)dt.Year, (short)dt.Month, (short)dt.Day, \
(short)dt.Hour, (short)dt.Minute, (short)dt.Second, dt.Millisecond * 1000); + \
} +
+ private void btnZoom_Click(object sender, EventArgs e)
+ {
+ //Collect the bounding boxes of all geometries and zoom to that
+ MgEnvelope env = new MgEnvelope();
+ int idx = Array.IndexOf(_columns, _geomProp);
+ if (idx < 0)
+ {
+ MessageBox.Show("Could not find the geoemtry property: " + \
_geomProp); + return;
+ }
+
+ foreach (DataGridViewRow row in grdResults.SelectedRows)
+ {
+ var geom = row.Cells[idx].Value as BoxedGeometry;
+ MgEnvelope tmp = new MgEnvelope(geom.GeomBounds.LowerX, \
geom.GeomBounds.LowerY, geom.GeomBounds.UpperX, geom.GeomBounds.UpperY); + \
env.ExpandToInclude(tmp); + }
+
+ var ll = env.LowerLeftCoordinate;
+ var ur = env.UpperRightCoordinate;
+
+ _viewer.ZoomToExtents(ll.X, ll.Y, ur.X, ur.Y);
+ }
+ }
+
+ public struct Bounds
+ {
+ public double LowerX;
+ public double LowerY;
+ public double UpperX;
+ public double UpperY;
+ }
+
+ public class BoxedGeometry
+ {
+ public override string ToString()
+ {
+ return this.Text;
+ }
+
+ public string Text { get; set; }
+
+ public Bounds GeomBounds { get; set; }
+ }
+}
Added: trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.resx
===================================================================
--- trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.resx \
(rev 0)
+++ trunk/MgDev/Desktop/MapViewer/MgQueryResultsDialog.resx 2012-04-28 10:40:05 UTC \
(rev 6599) @@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, \
System.Windows.Forms, ...</resheader> + <resheader \
name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, \
...</resheader> + <data name="Name1"><value>this is my long \
string</value><comment>this is a comment</comment></data> + <data name="Color1" \
type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" \
mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 \
mime encoded serialized .NET Framework object]</value> + </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" \
mimetype="application/x-microsoft.net.object.bytearray.base64"> + \
<value>[base64 mime encoded string representing a byte array form of the .NET \
Framework object]</value> + <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import \
namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" \
msdata:IsDataSet="true"> + <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" \
msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" \
minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" \
msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" \
msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" \
msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" \
msdata:Ordinal="1" /> + </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, \
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + \
</resheader> + <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, \
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + \
</resheader> + <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, \
System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + \
<value>17, 17</value> + </metadata>
+ <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, \
System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + \
<value>122, 17</value> + </metadata>
+ <metadata name="bgGridLoader.TrayLocation" type="System.Drawing.Point, \
System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + \
<value>238, 17</value> + </metadata>
+</root>
\ No newline at end of file
Modified: trunk/MgDev/Desktop/MapViewerTest/Form1.Designer.cs
===================================================================
--- trunk/MgDev/Desktop/MapViewerTest/Form1.Designer.cs 2012-04-27 16:59:42 UTC (rev \
6598)
+++ trunk/MgDev/Desktop/MapViewerTest/Form1.Designer.cs 2012-04-28 10:40:05 UTC (rev \
6599) @@ -71,6 +71,7 @@
this.initialViewToolStripMenuItem = new \
System.Windows.Forms.ToolStripMenuItem();
this.toolStripContainer1 = new \
System.Windows.Forms.ToolStripContainer(); this.toolbar = new \
OSGeo.MapGuide.Viewer.MgDefaultToolbar(); + this.toolStripButton3 = new \
System.Windows.Forms.ToolStripButton(); this.statusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
@@ -227,7 +228,8 @@
this.toolStripSeparator1,
this.btnPlotToDwf,
this.toolStripButton1,
- this.toolStripButton2});
+ this.toolStripButton2,
+ this.toolStripButton3});
this.toolStrip1.LayoutStyle = \
System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow; \
this.toolStrip1.Location = new System.Drawing.Point(0, 25); this.toolStrip1.Name = \
"toolStrip1"; @@ -481,6 +483,15 @@
this.toolbar.Viewer = null;
this.toolbar.ZoomOutMode = OSGeo.MapGuide.Viewer.ZoomOutMode.AutoZoom;
//
+ // toolStripButton3
+ //
+ this.toolStripButton3.Image = \
((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); + \
this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; + \
this.toolStripButton3.Name = "toolStripButton3"; + \
this.toolStripButton3.Size = new System.Drawing.Size(59, 22); + \
this.toolStripButton3.Text = "Query"; + this.toolStripButton3.Click += new \
System.EventHandler(this.toolStripButton3_Click); + //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -562,6 +573,7 @@
private System.Windows.Forms.ToolStripMenuItem initialViewToolStripMenuItem;
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.ToolStripButton toolStripButton2;
+ private System.Windows.Forms.ToolStripButton toolStripButton3;
}
}
Modified: trunk/MgDev/Desktop/MapViewerTest/Form1.cs
===================================================================
--- trunk/MgDev/Desktop/MapViewerTest/Form1.cs 2012-04-27 16:59:42 UTC (rev 6598)
+++ trunk/MgDev/Desktop/MapViewerTest/Form1.cs 2012-04-28 10:40:05 UTC (rev 6599)
@@ -459,10 +459,21 @@
var ctrl = new MgBufferControl(viewer);
var frm = new Form();
frm.Text = "Buffer";
- frm.Size = ctrl.PreferredSize;
+ frm.Size = new System.Drawing.Size(250, 601);
ctrl.Dock = DockStyle.Fill;
frm.Controls.Add(ctrl);
frm.Show();
}
+
+ private void toolStripButton3_Click(object sender, EventArgs e)
+ {
+ var ctrl = new MgQueryControl(viewer);
+ var frm = new Form();
+ frm.Text = "Query";
+ frm.Size = new System.Drawing.Size(266, 460);
+ ctrl.Dock = DockStyle.Fill;
+ frm.Controls.Add(ctrl);
+ frm.Show();
+ }
}
}
Modified: trunk/MgDev/Desktop/MapViewerTest/Form1.resx
===================================================================
--- trunk/MgDev/Desktop/MapViewerTest/Form1.resx 2012-04-27 16:59:42 UTC (rev 6598)
+++ trunk/MgDev/Desktop/MapViewerTest/Form1.resx 2012-04-28 10:40:05 UTC (rev 6599)
@@ -157,6 +157,21 @@
KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC
</value>
</data>
+ <data name="toolStripButton3.Image" type="System.Drawing.Bitmap, System.Drawing" \
mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+ YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI
+ ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9
+ HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN
+ rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K
+ TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx
+ oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8
+ 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI
+ xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX
+ LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd
+ KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC
+</value>
+ </data>
<metadata name="ctxGroup.TrayLocation" type="System.Drawing.Point, System.Drawing, \
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>444, \
17</value> </metadata>
_______________________________________________
mapguide-commits mailing list
mapguide-commits@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic