コード例 #1
0
        public static void setSelection(AxManifold.Interop.AxComponentControl p_MapControl, Manifold.Interop.Drawing p_Drawing, Manifold.Interop.Point p_ptClickedLocation, double p_dblSelectionTolerance)
        {
            Manifold.Interop.Query tempQuery = p_MapControl.get_Document().NewQuery("TempQuery", false);
            try
            {
                //Clear any Previous selection
                unsetSelection(p_MapControl, p_Drawing);

                StringBuilder sbSQL = new StringBuilder();
                #region Method1
                //Set current selection
                //sbSQL.AppendLine(@"UPDATE [" + p_Drawing.Name + "] SET [Selection (I)] = True WHERE [ID] IN (");
                //sbSQL.AppendLine(@" SELECT tblDistance.[ID] FROM [" + p_Drawing.Name + "] tblDistance WHERE ");
                //sbSQL.AppendLine(@" DISTANCE(GEOM([ID]),AssignCoordSys(CGeom(CGeomWKB(""POINT (" + p_ptClickedLocation.X.ToString() + " " + p_ptClickedLocation.Y.ToString() + @")"")), CoordSys(""" + p_Drawing.Name + @""" AS COMPONENT))) = ");
                //sbSQL.AppendLine(@" (");
                //sbSQL.AppendLine(@"     SELECT min (DISTANCE(GEOM([ID]),AssignCoordSys(CGeom(CGeomWKB(""POINT (" + p_ptClickedLocation.X.ToString() + " " + p_ptClickedLocation.Y.ToString() + @")"")), CoordSys(""" + p_Drawing.Name + @""" AS COMPONENT))))");
                //sbSQL.AppendLine(@"     FROM [" + p_Drawing.Name + "] tblDistance");
                //sbSQL.AppendLine(@"     WHERE DISTANCE(GEOM([ID]),AssignCoordSys(CGeom(CGeomWKB(""POINT (" + p_ptClickedLocation.X.ToString() + " " + p_ptClickedLocation.Y.ToString() + @")"")), CoordSys(""" + p_Drawing.Name + @""" AS COMPONENT))) < " + p_dblSelectionTolerance);
                //sbSQL.AppendLine(@" ))");
                #endregion

                #region Method2
                //string wkt = String.Format("POINT ({0} {1})", p_ptClickedLocation.X.ToString(), p_ptClickedLocation.Y.ToString());
                //string sql = String.Format(@"UPDATE [{0}] SET [Selection (I)] = True " +
                //                           @"WHERE TOUCHES([ID],BUFFER(AssignCoordSys(CGeom(CGeomWKB(""{1}"")), CoordSys(""{0}"" AS COMPONENT)),{2}))",
                //                           p_Drawing.Name, wkt, p_dblSelectionTolerance);
                #endregion

                //Create selection Rectangle around clicked Point
                Manifold.Interop.PointSet points = p_MapControl.Application.NewPointSet();
                points.Add(p_MapControl.Application.NewPoint(p_ptClickedLocation.X - p_dblSelectionTolerance, p_ptClickedLocation.Y - p_dblSelectionTolerance));
                points.Add(p_MapControl.Application.NewPoint(p_ptClickedLocation.X + p_dblSelectionTolerance, p_ptClickedLocation.Y - p_dblSelectionTolerance));
                points.Add(p_MapControl.Application.NewPoint(p_ptClickedLocation.X + p_dblSelectionTolerance, p_ptClickedLocation.Y + p_dblSelectionTolerance));
                points.Add(p_MapControl.Application.NewPoint(p_ptClickedLocation.X - p_dblSelectionTolerance, p_ptClickedLocation.Y + p_dblSelectionTolerance));
                points.Add(VBManifoldWrapper.ManifoldObjectWrapper.getPointFromPointSet(points, 0));

                //Create the geom to get WKT string to use in search
                Manifold.Interop.Geom geom = p_MapControl.Application.NewGeom(Manifold.Interop.GeomType.GeomArea, null);
                Manifold.Interop.BranchSet geomBranchSet = geom.get_BranchSet();
                VBManifoldWrapper.ManifoldObjectWrapper.setPointSetInBranchSet(points, geomBranchSet);
                string wkt = geom.ToTextWKT();

                sbSQL.Length = 0;
                sbSQL.AppendLine(@"UPDATE [" + p_Drawing.Name + "] SET [Selection (I)] = True ");
                sbSQL.AppendLine("WHERE Touches(AssignCoordSys(CGeom(CGeomWKB(\"" + wkt + "\")), CoordSys(\"" + p_Drawing.Name + "\" AS COMPONENT)), [ID])");

                tempQuery.Text = sbSQL.ToString();
                tempQuery.Run();
                p_MapControl.Refresh();
            }
            catch (Exception objEx)
            {
                throw;
            }
            finally
            {
                p_MapControl.get_Document().ComponentSet.Remove(tempQuery);
            }
        }
コード例 #2
0
 public static void unsetSelection(AxManifold.Interop.AxComponentControl p_MapControl, Manifold.Interop.Drawing p_Drawing)
 {
     try
     {
         string sSQL = string.Format(@"UPDATE [{0}] SET [Selection (I)] = False ", p_Drawing.Name);
         executeSQL(sSQL);
         p_MapControl.Refresh();
     }
     catch (Exception objEx)
     {
         throw;
     }
 }
コード例 #3
0
        public static void setSelection(AxManifold.Interop.AxComponentControl p_MapControl, Manifold.Interop.Drawing p_Drawing, Int32 p_iManifoldObjectID)
        {
            try
            {
                //Clear any Previous selection
                unsetSelection(p_MapControl, p_Drawing);

                //Set selection
                string sSQL = String.Format(@"UPDATE [{0}] SET [Selection (I)] = True WHERE [ID]= {1}", p_Drawing.Name, p_iManifoldObjectID.ToString());
                //Manifold.Interop.Query tempQuery = p_MapControl.get_Document().NewQuery("TempQuery", false);

                //p_MapControl.get_Document().ComponentSet.Remove(tempQuery);
                executeSQL(sSQL);
                p_MapControl.Refresh();
            }
            catch (Exception objEx)
            {
                throw;
            }
        }