コード例 #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 Manifold.Interop.Map loadManifoldMap(AxManifold.Interop.AxComponentControl p_axManifoldMap, string p_sMapPath, string p_sMapName)
        {
            Manifold.Interop.Map objReturn = null;
            bool bMapExists = false;

            try
            {
                p_axManifoldMap.set_Document(p_sMapPath);
                Manifold.Interop.ComponentSet m_ComponentSet = p_axManifoldMap.get_Document().ComponentSet;

                //Disaply _Map_Inspection if exists
                foreach (Manifold.Interop.Component objComponent in m_ComponentSet)
                {
                    switch (objComponent.Type)
                    {
                        case Manifold.Interop.ComponentType.ComponentMap:
                            if (p_sMapName.Equals(objComponent.Name))
                            {
                                //Get Map Name
                                objReturn = (Manifold.Interop.Map)objComponent;
                                p_axManifoldMap.ComponentName = objComponent.Name;
                                bMapExists = true;
                                break;
                            }
                            break;
                        default:
                            break;
                    }
                }

                //Create new Map if required
                if (bMapExists == false)
                {
                    Manifold.Interop.ComponentSet objNewComponentSet = p_axManifoldMap.get_Document().NewComponentSet();
                    foreach (Manifold.Interop.Component objComponent in m_ComponentSet)
                    {
                        switch (objComponent.Type)
                        {
                            case Manifold.Interop.ComponentType.ComponentDrawing:
                                objNewComponentSet.Add(objComponent);
                                break;
                            case Manifold.Interop.ComponentType.ComponentTable:
                                break;
                            default:
                                break;
                        }
                    }

                    //objReturn = p_axManifoldMap.get_Document().NewMap(p_sMapName, objNewComponentSet, p_axManifoldMap.Application.DefaultCoordinateSystem, true);
                    objReturn = p_axManifoldMap.get_Document().NewMap(p_sMapName, objNewComponentSet, p_axManifoldMap.Application.Application.NewCoordinateSystem("Irish Grid"), true);
                    p_axManifoldMap.ComponentName = p_sMapName;
                    p_axManifoldMap.ZoomToFit();
                }
            }
            catch (Exception objEx)
            {
                throw;
            }

            return objReturn;
        }